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
jlowdermilk/test-infra
gubernator/secrets.py
22
1724
#!/usr/bin/env python # Copyright 2018 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os from google.appengine.ext import ndb from google.appengine.api import modules from google.appengine.api import app_identity def get_hostname(): hostname = app_identity.get_default_version_hostname() if 'testbed' not in os.environ.get('SERVER_SOFTWARE', 'testbed'): current_version = modules.modules.get_current_version_name() if current_version and modules.modules.get_default_version() != current_version: hostname = '%s-dot-%s' % (current_version, hostname) return hostname class Secret(ndb.Model): value = ndb.JsonProperty() @staticmethod def make_key(key, per_host): if per_host: return ndb.Key(Secret, '%s\t%s' % (get_hostname(), key)) return ndb.Key(Secret, key) @staticmethod def make(key, value, per_host): return Secret(key=Secret.make_key(key, per_host), value=value) def get(key, per_host=True): data = Secret.make_key(key, per_host).get() if not data: raise KeyError return data.value def put(key, value, per_host=True): Secret.make(key, value, per_host).put()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 14894, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4621, 199, 504, 6233, 14, 15358, 14, 1246, 492, 1145, 63, 5582, 199, 199, 318, 664, 63, 4269, 837, 272, 6246, 275, 1145, 63, 5582, 14, 362, 63, 885, 63, 1023, 63, 4269, 342, 272, 340, 283, 396, 6123, 7, 440, 315, 747, 14, 2314, 14, 362, 360, 6613, 63, 26734, 297, 283, 396, 6123, 735, 267, 1453, 63, 1023, 275, 4621, 14, 3112, 14, 362, 63, 1818, 63, 1023, 63, 354, 342, 267, 340, 1453, 63, 1023, 436, 4621, 14, 3112, 14, 362, 63, 885, 63, 1023, 342, 1137, 1453, 63, 1023, 26, 288, 6246, 275, 1543, 83, 13, 3287, 3295, 83, 7, 450, 334, 1818, 63, 1023, 12, 6246, 9, 272, 372, 6246, 199, 199, 533, 23580, 8, 78, 697, 14, 1685, 304, 272, 574, 275, 23788, 14, 9653, 3697, 342, 339, 768, 4639, 272, 347, 1852, 63, 498, 8, 498, 12, 1126, 63, 1102, 304, 267, 340, 1126, 63, 1102, 26, 288, 372, 23788, 14, 1197, 8, 13790, 12, 1543, 83, 60, 84, 5, 83, 7, 450, 334, 362, 63, 4269, 1062, 790, 430, 267, 372, 23788, 14, 1197, 8, 13790, 12, 790, 9, 339, 768, 4639, 272, 347, 1852, 8, 498, 12, 574, 12, 1126, 63, 1102, 304, 267, 372, 23580, 8, 498, 29, 13790, 14, 1875, 63, 498, 8, 498, 12, 1126, 63, 1102, 395, 574, 29, 585, 9, 421, 199, 318, 664, 8, 498, 12, 1126, 63, 1102, 29, 549, 304, 272, 666, 275, 23580, 14, 1875, 63, 498, 8, 498, 12, 1126, 63, 1102, 680, 362, 342, 272, 340, 440, 666, 26, 267, 746, 4067, 272, 372, 666, 14, 585, 421, 199, 318, 5324, 8, 498, 12, 574, 12, 1126, 63, 1102, 29, 549, 304, 272, 23580, 14, 1875, 8, 498, 12, 574, 12, 1126, 63, 1102, 680, 524, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 14894, 710, 28723, 6642, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 747, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4621, 199, 504, 6233, 14, 15358, 14, 1246, 492, 1145, 63, 5582, 199, 199, 318, 664, 63, 4269, 837, 272, 6246, 275, 1145, 63, 5582, 14, 362, 63, 885, 63, 1023, 63, 4269, 342, 272, 340, 283, 396, 6123, 7, 440, 315, 747, 14, 2314, 14, 362, 360, 6613, 63, 26734, 297, 283, 396, 6123, 735, 267, 1453, 63, 1023, 275, 4621, 14, 3112, 14, 362, 63, 1818, 63, 1023, 63, 354, 342, 267, 340, 1453, 63, 1023, 436, 4621, 14, 3112, 14, 362, 63, 885, 63, 1023, 342, 1137, 1453, 63, 1023, 26, 288, 6246, 275, 1543, 83, 13, 3287, 3295, 83, 7, 450, 334, 1818, 63, 1023, 12, 6246, 9, 272, 372, 6246, 199, 199, 533, 23580, 8, 78, 697, 14, 1685, 304, 272, 574, 275, 23788, 14, 9653, 3697, 342, 339, 768, 4639, 272, 347, 1852, 63, 498, 8, 498, 12, 1126, 63, 1102, 304, 267, 340, 1126, 63, 1102, 26, 288, 372, 23788, 14, 1197, 8, 13790, 12, 1543, 83, 60, 84, 5, 83, 7, 450, 334, 362, 63, 4269, 1062, 790, 430, 267, 372, 23788, 14, 1197, 8, 13790, 12, 790, 9, 339, 768, 4639, 272, 347, 1852, 8, 498, 12, 574, 12, 1126, 63, 1102, 304, 267, 372, 23580, 8, 498, 29, 13790, 14, 1875, 63, 498, 8, 498, 12, 1126, 63, 1102, 395, 574, 29, 585, 9, 421, 199, 318, 664, 8, 498, 12, 1126, 63, 1102, 29, 549, 304, 272, 666, 275, 23580, 14, 1875, 63, 498, 8, 498, 12, 1126, 63, 1102, 680, 362, 342, 272, 340, 440, 666, 26, 267, 746, 4067, 272, 372, 666, 14, 585, 421, 199, 318, 5324, 8, 498, 12, 574, 12, 1126, 63, 1102, 29, 549, 304, 272, 23580, 14, 1875, 8, 498, 12, 574, 12, 1126, 63, 1102, 680, 524, 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,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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 ]
codepython/sockjs-tornado
examples/chat/chat.py
7
1466
# -*- coding: utf-8 -*- """ Simple sockjs-tornado chat application. By default will listen on port 8080. """ import tornado.ioloop import tornado.web import sockjs.tornado class IndexHandler(tornado.web.RequestHandler): """Regular HTTP handler to serve the chatroom page""" def get(self): self.render('index.html') class ChatConnection(sockjs.tornado.SockJSConnection): """Chat connection implementation""" # Class level variable participants = set() def on_open(self, info): # Send that someone joined self.broadcast(self.participants, "Someone joined.") # Add client to the clients list self.participants.add(self) def on_message(self, message): # Broadcast message self.broadcast(self.participants, message) def on_close(self): # Remove client from the clients list and broadcast leave message self.participants.remove(self) self.broadcast(self.participants, "Someone left.") if __name__ == "__main__": import logging logging.getLogger().setLevel(logging.DEBUG) # 1. Create chat router ChatRouter = sockjs.tornado.SockJSRouter(ChatConnection, '/chat') # 2. Create Tornado application app = tornado.web.Application( [(r"/", IndexHandler)] + ChatRouter.urls ) # 3. Make Tornado app listen on port 8080 app.listen(8080) # 4. Start IOLoop tornado.ioloop.IOLoop.instance().start()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 5870, 6771, 3596, 13, 18443, 21472, 4223, 14, 4885, 849, 911, 6938, 641, 1844, 30220, 14, 199, 624, 199, 646, 12148, 14, 27212, 199, 646, 12148, 14, 2520, 199, 199, 646, 6771, 3596, 14, 18443, 421, 199, 533, 5499, 2461, 8, 18443, 14, 2520, 14, 11149, 304, 272, 408, 16038, 3101, 3016, 370, 14062, 314, 21472, 11245, 2034, 624, 272, 347, 664, 8, 277, 304, 267, 291, 14, 3352, 360, 1080, 14, 1360, 358, 421, 199, 533, 2799, 292, 3225, 8, 5096, 3596, 14, 18443, 14, 51, 766, 11378, 3225, 304, 272, 408, 21954, 1950, 4514, 624, 272, 327, 8089, 2166, 1750, 272, 623, 20989, 275, 663, 342, 339, 347, 641, 63, 1490, 8, 277, 12, 2256, 304, 267, 327, 10217, 626, 17122, 16538, 267, 291, 14, 10786, 8, 277, 14, 31790, 12, 298, 7700, 368, 16538, 2685, 398, 327, 2654, 1890, 370, 314, 13431, 769, 267, 291, 14, 31790, 14, 525, 8, 277, 9, 339, 347, 641, 63, 1188, 8, 277, 12, 1245, 304, 267, 327, 699, 5659, 1245, 267, 291, 14, 10786, 8, 277, 14, 31790, 12, 1245, 9, 339, 347, 641, 63, 1600, 8, 277, 304, 267, 327, 5852, 1890, 687, 314, 13431, 769, 436, 11180, 10137, 1245, 267, 291, 14, 31790, 14, 2168, 8, 277, 9, 398, 291, 14, 10786, 8, 277, 14, 31790, 12, 298, 7700, 368, 3602, 2685, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2050, 272, 2050, 14, 5572, 1252, 13548, 8, 4806, 14, 5287, 9, 339, 327, 413, 14, 2790, 21472, 6197, 272, 2799, 292, 11691, 275, 6771, 3596, 14, 18443, 14, 51, 766, 11378, 11691, 8, 21954, 3225, 12, 1994, 10289, 358, 339, 327, 499, 14, 2790, 377, 8622, 4223, 272, 1145, 275, 12148, 14, 2520, 14, 5039, 8, 288, 3842, 82, 2, 10665, 5499, 2461, 1874, 435, 2799, 292, 11691, 14, 3603, 272, 776, 339, 327, 650, 14, 4155, 377, 8622, 1145, 6938, 641, 1844, 30220, 272, 1145, 14, 5859, 8, 15844, 9, 339, 327, 841, 14, 7707, 25584, 272, 12148, 14, 27212, 14, 23152, 14, 842, 1252, 928, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 5870, 6771, 3596, 13, 18443, 21472, 4223, 14, 4885, 849, 911, 6938, 641, 1844, 30220, 14, 199, 624, 199, 646, 12148, 14, 27212, 199, 646, 12148, 14, 2520, 199, 199, 646, 6771, 3596, 14, 18443, 421, 199, 533, 5499, 2461, 8, 18443, 14, 2520, 14, 11149, 304, 272, 408, 16038, 3101, 3016, 370, 14062, 314, 21472, 11245, 2034, 624, 272, 347, 664, 8, 277, 304, 267, 291, 14, 3352, 360, 1080, 14, 1360, 358, 421, 199, 533, 2799, 292, 3225, 8, 5096, 3596, 14, 18443, 14, 51, 766, 11378, 3225, 304, 272, 408, 21954, 1950, 4514, 624, 272, 327, 8089, 2166, 1750, 272, 623, 20989, 275, 663, 342, 339, 347, 641, 63, 1490, 8, 277, 12, 2256, 304, 267, 327, 10217, 626, 17122, 16538, 267, 291, 14, 10786, 8, 277, 14, 31790, 12, 298, 7700, 368, 16538, 2685, 398, 327, 2654, 1890, 370, 314, 13431, 769, 267, 291, 14, 31790, 14, 525, 8, 277, 9, 339, 347, 641, 63, 1188, 8, 277, 12, 1245, 304, 267, 327, 699, 5659, 1245, 267, 291, 14, 10786, 8, 277, 14, 31790, 12, 1245, 9, 339, 347, 641, 63, 1600, 8, 277, 304, 267, 327, 5852, 1890, 687, 314, 13431, 769, 436, 11180, 10137, 1245, 267, 291, 14, 31790, 14, 2168, 8, 277, 9, 398, 291, 14, 10786, 8, 277, 14, 31790, 12, 298, 7700, 368, 3602, 2685, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2050, 272, 2050, 14, 5572, 1252, 13548, 8, 4806, 14, 5287, 9, 339, 327, 413, 14, 2790, 21472, 6197, 272, 2799, 292, 11691, 275, 6771, 3596, 14, 18443, 14, 51, 766, 11378, 11691, 8, 21954, 3225, 12, 1994, 10289, 358, 339, 327, 499, 14, 2790, 377, 8622, 4223, 272, 1145, 275, 12148, 14, 2520, 14, 5039, 8, 288, 3842, 82, 2, 10665, 5499, 2461, 1874, 435, 2799, 292, 11691, 14, 3603, 272, 776, 339, 327, 650, 14, 4155, 377, 8622, 1145, 6938, 641, 1844, 30220, 272, 1145, 14, 5859, 8, 15844, 9, 339, 327, 841, 14, 7707, 25584, 272, 12148, 14, 27212, 14, 23152, 14, 842, 1252, 928, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
visi0nary/P8000-Kernel
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py
4653
3596
# EventClass.py # # This is a library defining some events types classes, which could # be used by other scripts to analyzing the perf samples. # # Currently there are just a few classes defined for examples, # PerfEvent is the base class for all perf event sample, PebsEvent # is a HW base Intel x86 PEBS event, and user could add more SW/HW # event classes based on requirements. import struct # Event types, user could add more here EVTYPE_GENERIC = 0 EVTYPE_PEBS = 1 # Basic PEBS event EVTYPE_PEBS_LL = 2 # PEBS event with load latency info EVTYPE_IBS = 3 # # Currently we don't have good way to tell the event type, but by # the size of raw buffer, raw PEBS event with load latency data's # size is 176 bytes, while the pure PEBS event's size is 144 bytes. # def create_event(name, comm, dso, symbol, raw_buf): if (len(raw_buf) == 144): event = PebsEvent(name, comm, dso, symbol, raw_buf) elif (len(raw_buf) == 176): event = PebsNHM(name, comm, dso, symbol, raw_buf) else: event = PerfEvent(name, comm, dso, symbol, raw_buf) return event class PerfEvent(object): event_num = 0 def __init__(self, name, comm, dso, symbol, raw_buf, ev_type=EVTYPE_GENERIC): self.name = name self.comm = comm self.dso = dso self.symbol = symbol self.raw_buf = raw_buf self.ev_type = ev_type PerfEvent.event_num += 1 def show(self): print "PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" % (self.name, self.symbol, self.comm, self.dso) # # Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer # contains the context info when that event happened: the EFLAGS and # linear IP info, as well as all the registers. # class PebsEvent(PerfEvent): pebs_num = 0 def __init__(self, name, comm, dso, symbol, raw_buf, ev_type=EVTYPE_PEBS): tmp_buf=raw_buf[0:80] flags, ip, ax, bx, cx, dx, si, di, bp, sp = struct.unpack('QQQQQQQQQQ', tmp_buf) self.flags = flags self.ip = ip self.ax = ax self.bx = bx self.cx = cx self.dx = dx self.si = si self.di = di self.bp = bp self.sp = sp PerfEvent.__init__(self, name, comm, dso, symbol, raw_buf, ev_type) PebsEvent.pebs_num += 1 del tmp_buf # # Intel Nehalem and Westmere support PEBS plus Load Latency info which lie # in the four 64 bit words write after the PEBS data: # Status: records the IA32_PERF_GLOBAL_STATUS register value # DLA: Data Linear Address (EIP) # DSE: Data Source Encoding, where the latency happens, hit or miss # in L1/L2/L3 or IO operations # LAT: the actual latency in cycles # class PebsNHM(PebsEvent): pebs_nhm_num = 0 def __init__(self, name, comm, dso, symbol, raw_buf, ev_type=EVTYPE_PEBS_LL): tmp_buf=raw_buf[144:176] status, dla, dse, lat = struct.unpack('QQQQ', tmp_buf) self.status = status self.dla = dla self.dse = dse self.lat = lat PebsEvent.__init__(self, name, comm, dso, symbol, raw_buf, ev_type) PebsNHM.pebs_nhm_num += 1 del tmp_buf
gpl-2.0
[ 3, 6763, 2543, 14, 647, 199, 3, 199, 3, 961, 365, 282, 3555, 12669, 2005, 4474, 2943, 3992, 12, 1314, 4293, 199, 3, 506, 1202, 701, 1163, 10554, 370, 5909, 20135, 314, 8582, 5845, 14, 199, 3, 199, 3, 13550, 2337, 787, 2951, 282, 9284, 3992, 3247, 367, 7251, 12, 199, 3, 31778, 2390, 365, 314, 1300, 1021, 367, 1006, 8582, 1566, 2690, 12, 11379, 1533, 2390, 199, 3, 365, 282, 869, 55, 1300, 20619, 671, 1184, 19599, 11087, 1566, 12, 436, 922, 4293, 1050, 1655, 17548, 15, 15487, 199, 3, 1566, 3992, 4079, 641, 9760, 14, 199, 199, 646, 2702, 199, 199, 3, 6763, 2943, 12, 922, 4293, 1050, 1655, 2348, 199, 18015, 2711, 63, 29395, 221, 275, 378, 199, 18015, 2711, 63, 1510, 11087, 258, 275, 413, 258, 327, 10082, 19599, 11087, 1566, 199, 18015, 2711, 63, 1510, 11087, 63, 4464, 221, 275, 499, 258, 327, 19599, 11087, 1566, 543, 2248, 23967, 2256, 199, 18015, 2711, 63, 2100, 51, 420, 275, 650, 199, 199, 3, 199, 3, 13550, 781, 2793, 1133, 1172, 6954, 4340, 370, 11480, 314, 1566, 730, 12, 1325, 701, 199, 3, 314, 1568, 402, 3066, 3335, 12, 3066, 19599, 11087, 1566, 543, 2248, 23967, 666, 1159, 199, 3, 1568, 365, 27827, 2783, 12, 1830, 314, 15111, 19599, 11087, 1566, 1159, 1568, 365, 21771, 2783, 14, 199, 3, 199, 318, 1218, 63, 1430, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 304, 267, 340, 334, 552, 8, 1773, 63, 1436, 9, 508, 21771, 304, 355, 1566, 275, 11379, 1533, 2390, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 916, 334, 552, 8, 1773, 63, 1436, 9, 508, 27827, 304, 355, 1566, 275, 11379, 1533, 46, 27699, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 587, 26, 355, 1566, 275, 31778, 2390, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 398, 372, 1566, 199, 199, 533, 31778, 2390, 8, 785, 304, 267, 1566, 63, 1507, 275, 378, 267, 347, 636, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 29, 18015, 2711, 63, 29395, 304, 355, 291, 14, 354, 755, 275, 536, 355, 291, 14, 1404, 755, 275, 1923, 355, 291, 14, 32211, 263, 275, 25547, 355, 291, 14, 5155, 258, 275, 5272, 355, 291, 14, 1773, 63, 1436, 259, 275, 3066, 63, 1436, 355, 291, 14, 6857, 63, 466, 259, 275, 8145, 63, 466, 355, 31778, 2390, 14, 1430, 63, 1507, 847, 413, 398, 347, 2498, 8, 277, 304, 355, 870, 298, 10793, 53, 1566, 26, 536, 2458, 713, 83, 12, 5272, 2458, 1194, 83, 12, 1923, 2458, 24, 83, 12, 25547, 2458, 713, 83, 2, 450, 334, 277, 14, 354, 12, 291, 14, 5155, 12, 291, 14, 1404, 12, 291, 14, 32211, 9, 199, 199, 3, 199, 3, 10082, 20619, 19599, 11087, 334, 2398, 11900, 6763, 13, 6788, 428, 23144, 9, 1566, 12, 7447, 3066, 3335, 199, 3, 3509, 314, 1067, 2256, 1380, 626, 1566, 21056, 26, 314, 662, 4831, 436, 199, 3, 7798, 3531, 2256, 12, 465, 5521, 465, 1006, 314, 24493, 14, 199, 3, 199, 533, 11379, 1533, 2390, 8, 12387, 2390, 304, 267, 4837, 1533, 63, 1507, 275, 378, 267, 347, 636, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 29, 18015, 2711, 63, 1510, 11087, 304, 355, 3529, 63, 1436, 29, 1773, 63, 1436, 59, 16, 26, 1257, 61, 355, 3285, 12, 3384, 12, 2185, 12, 330, 88, 12, 17280, 12, 11868, 12, 13877, 12, 487, 12, 13292, 12, 2249, 275, 2702, 14, 5301, 360, 12917, 12917, 12917, 12917, 12917, 297, 3529, 63, 1436, 9, 355, 291, 14, 2469, 275, 3285, 355, 291, 14, 711, 259, 275, 3384, 355, 291, 14, 1219, 259, 275, 2185, 355, 291, 14, 13691, 259, 275, 330, 88, 355, 291, 14, 11859, 259, 275, 17280, 355, 291, 14, 8373, 259, 275, 11868, 355, 291, 14, 338, 259, 275, 13877, 355, 291, 14, 328, 259, 275, 487, 355, 291, 14, 10913, 259, 275, 13292, 355, 291, 14, 681, 259, 275, 2249, 2234, 31778, 2390, 855, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 9, 355, 11379, 1533, 2390, 14, 321, 1533, 63, 1507, 847, 413, 355, 2150, 3529, 63, 1436, 199, 199, 3, 199, 3, 20619, 5612, 72, 1895, 77, 436, 644, 597, 278, 264, 2291, 19599, 11087, 12254, 7190, 491, 323, 12501, 2256, 1314, 1212, 69, 199, 3, 315, 314, 11648, 5049, 4546, 5932, 2218, 2410, 314, 19599, 11087, 666, 26, 199, 3, 755, 9795, 26, 5767, 314, 473, 33, 708, 63, 17038, 63, 13808, 63, 6305, 2274, 574, 199, 3, 755, 577, 5837, 26, 259, 3918, 12489, 9906, 334, 37, 1772, 9, 199, 3, 755, 577, 899, 26, 259, 3918, 5800, 19694, 12, 2382, 314, 23967, 10986, 12, 9793, 503, 26747, 199, 3, 5185, 315, 491, 17, 15, 44, 18, 15, 44, 19, 503, 5004, 5331, 199, 3, 755, 491, 619, 26, 259, 314, 3503, 23967, 315, 19001, 199, 3, 199, 533, 11379, 1533, 46, 27699, 8, 8070, 1533, 2390, 304, 267, 4837, 1533, 63, 78, 14038, 63, 1507, 275, 378, 267, 347, 636, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 29, 18015, 2711, 63, 1510, 11087, 63, 4464, 304, 355, 3529, 63, 1436, 29, 1773, 63, 1436, 59, 9862, 26, 10216, 61, 355, 2004, 12, 366, 416, 12, 366, 261, 12, 8396, 275, 2702, 14, 5301, 360, 12917, 12917, 297, 3529, 63, 1436, 9, 355, 291, 14, 1205, 275, 2004, 355, 291, 14, 68, 416, 275, 366, 416, 355, 291, 14, 68, 261, 275, 366, 261, 355, 291, 14, 4452, 275, 8396, 2234, 11379, 1533, 2390, 855, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 9, 355, 11379, 1533, 46, 27699, 14, 321, 1533, 63, 78, 14038, 63, 1507, 847, 413, 355, 2150, 3529, 63, 1436, 199, 32768, 32768, 32768, 32768, 32768 ]
[ 6763, 2543, 14, 647, 199, 3, 199, 3, 961, 365, 282, 3555, 12669, 2005, 4474, 2943, 3992, 12, 1314, 4293, 199, 3, 506, 1202, 701, 1163, 10554, 370, 5909, 20135, 314, 8582, 5845, 14, 199, 3, 199, 3, 13550, 2337, 787, 2951, 282, 9284, 3992, 3247, 367, 7251, 12, 199, 3, 31778, 2390, 365, 314, 1300, 1021, 367, 1006, 8582, 1566, 2690, 12, 11379, 1533, 2390, 199, 3, 365, 282, 869, 55, 1300, 20619, 671, 1184, 19599, 11087, 1566, 12, 436, 922, 4293, 1050, 1655, 17548, 15, 15487, 199, 3, 1566, 3992, 4079, 641, 9760, 14, 199, 199, 646, 2702, 199, 199, 3, 6763, 2943, 12, 922, 4293, 1050, 1655, 2348, 199, 18015, 2711, 63, 29395, 221, 275, 378, 199, 18015, 2711, 63, 1510, 11087, 258, 275, 413, 258, 327, 10082, 19599, 11087, 1566, 199, 18015, 2711, 63, 1510, 11087, 63, 4464, 221, 275, 499, 258, 327, 19599, 11087, 1566, 543, 2248, 23967, 2256, 199, 18015, 2711, 63, 2100, 51, 420, 275, 650, 199, 199, 3, 199, 3, 13550, 781, 2793, 1133, 1172, 6954, 4340, 370, 11480, 314, 1566, 730, 12, 1325, 701, 199, 3, 314, 1568, 402, 3066, 3335, 12, 3066, 19599, 11087, 1566, 543, 2248, 23967, 666, 1159, 199, 3, 1568, 365, 27827, 2783, 12, 1830, 314, 15111, 19599, 11087, 1566, 1159, 1568, 365, 21771, 2783, 14, 199, 3, 199, 318, 1218, 63, 1430, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 304, 267, 340, 334, 552, 8, 1773, 63, 1436, 9, 508, 21771, 304, 355, 1566, 275, 11379, 1533, 2390, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 916, 334, 552, 8, 1773, 63, 1436, 9, 508, 27827, 304, 355, 1566, 275, 11379, 1533, 46, 27699, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 267, 587, 26, 355, 1566, 275, 31778, 2390, 8, 354, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 9, 398, 372, 1566, 199, 199, 533, 31778, 2390, 8, 785, 304, 267, 1566, 63, 1507, 275, 378, 267, 347, 636, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 29, 18015, 2711, 63, 29395, 304, 355, 291, 14, 354, 755, 275, 536, 355, 291, 14, 1404, 755, 275, 1923, 355, 291, 14, 32211, 263, 275, 25547, 355, 291, 14, 5155, 258, 275, 5272, 355, 291, 14, 1773, 63, 1436, 259, 275, 3066, 63, 1436, 355, 291, 14, 6857, 63, 466, 259, 275, 8145, 63, 466, 355, 31778, 2390, 14, 1430, 63, 1507, 847, 413, 398, 347, 2498, 8, 277, 304, 355, 870, 298, 10793, 53, 1566, 26, 536, 2458, 713, 83, 12, 5272, 2458, 1194, 83, 12, 1923, 2458, 24, 83, 12, 25547, 2458, 713, 83, 2, 450, 334, 277, 14, 354, 12, 291, 14, 5155, 12, 291, 14, 1404, 12, 291, 14, 32211, 9, 199, 199, 3, 199, 3, 10082, 20619, 19599, 11087, 334, 2398, 11900, 6763, 13, 6788, 428, 23144, 9, 1566, 12, 7447, 3066, 3335, 199, 3, 3509, 314, 1067, 2256, 1380, 626, 1566, 21056, 26, 314, 662, 4831, 436, 199, 3, 7798, 3531, 2256, 12, 465, 5521, 465, 1006, 314, 24493, 14, 199, 3, 199, 533, 11379, 1533, 2390, 8, 12387, 2390, 304, 267, 4837, 1533, 63, 1507, 275, 378, 267, 347, 636, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 29, 18015, 2711, 63, 1510, 11087, 304, 355, 3529, 63, 1436, 29, 1773, 63, 1436, 59, 16, 26, 1257, 61, 355, 3285, 12, 3384, 12, 2185, 12, 330, 88, 12, 17280, 12, 11868, 12, 13877, 12, 487, 12, 13292, 12, 2249, 275, 2702, 14, 5301, 360, 12917, 12917, 12917, 12917, 12917, 297, 3529, 63, 1436, 9, 355, 291, 14, 2469, 275, 3285, 355, 291, 14, 711, 259, 275, 3384, 355, 291, 14, 1219, 259, 275, 2185, 355, 291, 14, 13691, 259, 275, 330, 88, 355, 291, 14, 11859, 259, 275, 17280, 355, 291, 14, 8373, 259, 275, 11868, 355, 291, 14, 338, 259, 275, 13877, 355, 291, 14, 328, 259, 275, 487, 355, 291, 14, 10913, 259, 275, 13292, 355, 291, 14, 681, 259, 275, 2249, 2234, 31778, 2390, 855, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 9, 355, 11379, 1533, 2390, 14, 321, 1533, 63, 1507, 847, 413, 355, 2150, 3529, 63, 1436, 199, 199, 3, 199, 3, 20619, 5612, 72, 1895, 77, 436, 644, 597, 278, 264, 2291, 19599, 11087, 12254, 7190, 491, 323, 12501, 2256, 1314, 1212, 69, 199, 3, 315, 314, 11648, 5049, 4546, 5932, 2218, 2410, 314, 19599, 11087, 666, 26, 199, 3, 755, 9795, 26, 5767, 314, 473, 33, 708, 63, 17038, 63, 13808, 63, 6305, 2274, 574, 199, 3, 755, 577, 5837, 26, 259, 3918, 12489, 9906, 334, 37, 1772, 9, 199, 3, 755, 577, 899, 26, 259, 3918, 5800, 19694, 12, 2382, 314, 23967, 10986, 12, 9793, 503, 26747, 199, 3, 5185, 315, 491, 17, 15, 44, 18, 15, 44, 19, 503, 5004, 5331, 199, 3, 755, 491, 619, 26, 259, 314, 3503, 23967, 315, 19001, 199, 3, 199, 533, 11379, 1533, 46, 27699, 8, 8070, 1533, 2390, 304, 267, 4837, 1533, 63, 78, 14038, 63, 1507, 275, 378, 267, 347, 636, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 29, 18015, 2711, 63, 1510, 11087, 63, 4464, 304, 355, 3529, 63, 1436, 29, 1773, 63, 1436, 59, 9862, 26, 10216, 61, 355, 2004, 12, 366, 416, 12, 366, 261, 12, 8396, 275, 2702, 14, 5301, 360, 12917, 12917, 297, 3529, 63, 1436, 9, 355, 291, 14, 1205, 275, 2004, 355, 291, 14, 68, 416, 275, 366, 416, 355, 291, 14, 68, 261, 275, 366, 261, 355, 291, 14, 4452, 275, 8396, 2234, 11379, 1533, 2390, 855, 826, 721, 277, 12, 536, 12, 1923, 12, 25547, 12, 5272, 12, 3066, 63, 1436, 12, 8145, 63, 466, 9, 355, 11379, 1533, 46, 27699, 14, 321, 1533, 63, 78, 14038, 63, 1507, 847, 413, 355, 2150, 3529, 63, 1436, 199, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
quantopian/toolz
toolz/sandbox/tests/test_core.py
9
3878
from toolz import curry, unique, first, take from toolz.sandbox.core import EqualityHashKey, unzip from itertools import count, repeat from toolz.compatibility import map, zip def test_EqualityHashKey_default_key(): EqualityHashDefault = curry(EqualityHashKey, None) L1 = [1] L2 = [2] data1 = [L1, L1, L2, [], [], [1], [2], {}, ()] set1 = set(map(EqualityHashDefault, data1)) set2 = set(map(EqualityHashDefault, [[], [1], [2], {}, ()])) assert set1 == set2 assert len(set1) == 5 # Test that ``EqualityHashDefault(item)`` is distinct from ``item`` T0 = () T1 = (1,) data2 = list(map(EqualityHashDefault, [T0, T0, T1, T1, (), (1,)])) data2.extend([T0, T1, (), (1,)]) set3 = set(data2) assert set3 == set([(), (1,), EqualityHashDefault(()), EqualityHashDefault((1,))]) assert len(set3) == 4 assert EqualityHashDefault(()) in set3 assert EqualityHashDefault((1,)) in set3 # Miscellaneous E1 = EqualityHashDefault(L1) E2 = EqualityHashDefault(L2) assert str(E1) == '=[1]=' assert repr(E1) == '=[1]=' assert E1 != E2 assert not (E1 == E2) assert E1 == EqualityHashDefault(L1) assert not (E1 != EqualityHashDefault(L1)) assert E1 != L1 assert not (E1 == L1) def test_EqualityHashKey_callable_key(): # Common simple hash key functions. EqualityHashLen = curry(EqualityHashKey, len) EqualityHashType = curry(EqualityHashKey, type) EqualityHashId = curry(EqualityHashKey, id) EqualityHashFirst = curry(EqualityHashKey, first) data1 = [[], [1], (), (1,), {}, {1: 2}] data2 = [[1, 2], (1, 2), (1, 3), [1, 3], [2, 1], {1: 2}] assert list(unique(data1*3, key=EqualityHashLen)) == data1 assert list(unique(data2*3, key=EqualityHashLen)) == data2 assert list(unique(data1*3, key=EqualityHashType)) == data1 assert list(unique(data2*3, key=EqualityHashType)) == data2 assert list(unique(data1*3, key=EqualityHashId)) == data1 assert list(unique(data2*3, key=EqualityHashId)) == data2 assert list(unique(data2*3, key=EqualityHashFirst)) == data2 def test_EqualityHashKey_index_key(): d1 = {'firstname': 'Alice', 'age': 21, 'data': {}} d2 = {'firstname': 'Alice', 'age': 34, 'data': {}} d3a = {'firstname': 'Bob', 'age': 56, 'data': {}} d3b = {'firstname': 'Bob', 'age': 56, 'data': {}} EqualityHashFirstname = curry(EqualityHashKey, 'firstname') assert list(unique(3*[d1, d2, d3a, d3b], key=EqualityHashFirstname)) == [d1, d2, d3a] EqualityHashFirstnameAge = curry(EqualityHashKey, ['firstname', 'age']) assert list(unique(3*[d1, d2, d3a, d3b], key=EqualityHashFirstnameAge)) == [d1, d2, d3a] list1 = [0] * 10 list2 = [0] * 100 list3a = [1] * 10 list3b = [1] * 10 EqualityHash0 = curry(EqualityHashKey, 0) assert list(unique(3*[list1, list2, list3a, list3b], key=EqualityHash0)) == [list1, list2, list3a] def test_unzip(): def _to_lists(seq, n=10): """iter of iters -> finite list of finite lists """ def initial(s): return list(take(n, s)) return initial(map(initial, seq)) def _assert_initial_matches(a, b, n=10): assert list(take(n, a)) == list(take(n, b)) # Unzips a simple list correctly assert _to_lists(unzip([('a', 1), ('b', 2), ('c', 3)])) \ == [['a', 'b', 'c'], [1, 2, 3]] # Can handle a finite number of infinite iterators (the naive unzip # implementation `zip(*args)` impelementation fails on this example). a, b, c = unzip(zip(count(1), repeat(0), repeat(1))) _assert_initial_matches(a, count(1)) _assert_initial_matches(b, repeat(0)) _assert_initial_matches(c, repeat(1)) # Sensibly handles empty input assert list(unzip(zip([]))) == []
bsd-3-clause
[ 504, 4744, 90, 492, 1094, 651, 12, 3747, 12, 1642, 12, 5452, 199, 504, 4744, 90, 14, 16647, 14, 1018, 492, 221, 22977, 3476, 1197, 12, 29379, 199, 504, 7975, 492, 2338, 12, 11982, 199, 504, 4744, 90, 14, 15390, 492, 2341, 12, 3482, 421, 199, 318, 511, 63, 22977, 3476, 1197, 63, 885, 63, 498, 837, 272, 221, 22977, 3476, 2698, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 488, 9, 272, 491, 17, 275, 359, 17, 61, 272, 491, 18, 275, 359, 18, 61, 272, 666, 17, 275, 359, 44, 17, 12, 491, 17, 12, 491, 18, 12, 990, 990, 359, 17, 467, 359, 18, 467, 5479, 334, 1874, 272, 663, 17, 275, 663, 8, 1130, 8, 22977, 3476, 2698, 12, 666, 17, 430, 272, 663, 18, 275, 663, 8, 1130, 8, 22977, 3476, 2698, 12, 3474, 467, 359, 17, 467, 359, 18, 467, 5479, 334, 19563, 272, 702, 663, 17, 508, 663, 18, 272, 702, 822, 8, 409, 17, 9, 508, 959, 339, 327, 1379, 626, 1124, 22977, 3476, 2698, 8, 1053, 9719, 365, 15392, 687, 1124, 1053, 1040, 272, 377, 16, 275, 6248, 272, 377, 17, 275, 334, 17, 4258, 272, 666, 18, 275, 769, 8, 1130, 8, 22977, 3476, 2698, 12, 359, 52, 16, 12, 377, 16, 12, 377, 17, 12, 377, 17, 12, 11969, 334, 17, 12, 19563, 272, 666, 18, 14, 2880, 779, 52, 16, 12, 377, 17, 12, 11969, 334, 17, 12, 3948, 272, 663, 19, 275, 663, 8, 576, 18, 9, 272, 702, 663, 19, 508, 663, 779, 1062, 334, 17, 4706, 221, 22977, 3476, 2698, 8, 4000, 717, 221, 22977, 3476, 2698, 1332, 17, 4641, 566, 272, 702, 822, 8, 409, 19, 9, 508, 841, 272, 702, 221, 22977, 3476, 2698, 30812, 315, 663, 19, 272, 702, 221, 22977, 3476, 2698, 1332, 17, 4641, 315, 663, 19, 339, 327, 12481, 19549, 272, 662, 17, 275, 221, 22977, 3476, 2698, 8, 44, 17, 9, 272, 662, 18, 275, 221, 22977, 3476, 2698, 8, 44, 18, 9, 272, 702, 620, 8, 37, 17, 9, 508, 283, 1524, 17, 61, 534, 272, 702, 4700, 8, 37, 17, 9, 508, 283, 1524, 17, 61, 534, 272, 702, 662, 17, 1137, 662, 18, 272, 702, 440, 334, 37, 17, 508, 662, 18, 9, 272, 702, 662, 17, 508, 221, 22977, 3476, 2698, 8, 44, 17, 9, 272, 702, 440, 334, 37, 17, 1137, 221, 22977, 3476, 2698, 8, 44, 17, 430, 272, 702, 662, 17, 1137, 491, 17, 272, 702, 440, 334, 37, 17, 508, 491, 17, 9, 421, 199, 318, 511, 63, 22977, 3476, 1197, 63, 8296, 63, 498, 837, 272, 327, 13964, 3486, 2631, 790, 3423, 14, 272, 221, 22977, 3476, 3166, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 822, 9, 272, 221, 22977, 3476, 804, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 730, 9, 272, 221, 22977, 3476, 1304, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 1305, 9, 272, 221, 22977, 3476, 7147, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 1642, 9, 272, 666, 17, 275, 3474, 467, 359, 17, 467, 11969, 334, 17, 4706, 5479, 469, 17, 26, 499, 11049, 272, 666, 18, 275, 3474, 17, 12, 499, 467, 334, 17, 12, 499, 395, 334, 17, 12, 650, 395, 359, 17, 12, 650, 467, 359, 18, 12, 413, 467, 469, 17, 26, 499, 11049, 272, 702, 769, 8, 3235, 8, 576, 17, 10, 19, 12, 790, 29, 22977, 3476, 3166, 430, 508, 666, 17, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 3166, 430, 508, 666, 18, 272, 702, 769, 8, 3235, 8, 576, 17, 10, 19, 12, 790, 29, 22977, 3476, 804, 430, 508, 666, 17, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 804, 430, 508, 666, 18, 272, 702, 769, 8, 3235, 8, 576, 17, 10, 19, 12, 790, 29, 22977, 3476, 1304, 430, 508, 666, 17, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 1304, 430, 508, 666, 18, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 7147, 430, 508, 666, 18, 421, 199, 318, 511, 63, 22977, 3476, 1197, 63, 1080, 63, 498, 837, 272, 366, 17, 275, 791, 25603, 356, 283, 28001, 297, 283, 474, 356, 7829, 12, 283, 576, 356, 24312, 272, 366, 18, 275, 791, 25603, 356, 283, 28001, 297, 283, 474, 356, 8177, 12, 283, 576, 356, 24312, 272, 366, 19, 65, 275, 791, 25603, 356, 283, 22593, 297, 283, 474, 356, 12001, 12, 283, 576, 356, 24312, 272, 366, 19, 66, 275, 791, 25603, 356, 283, 22593, 297, 283, 474, 356, 12001, 12, 283, 576, 356, 24312, 272, 221, 22977, 3476, 7147, 354, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 283, 25603, 358, 272, 702, 769, 8, 3235, 8, 19, 23033, 68, 17, 12, 366, 18, 12, 366, 19, 65, 12, 366, 19, 66, 467, 2432, 790, 29, 22977, 3476, 7147, 354, 430, 508, 359, 68, 17, 12, 366, 18, 12, 366, 19, 65, 61, 272, 221, 22977, 3476, 7147, 354, 20480, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 788, 25603, 297, 283, 474, 1105, 272, 702, 769, 8, 3235, 8, 19, 23033, 68, 17, 12, 366, 18, 12, 366, 19, 65, 12, 366, 19, 66, 467, 2432, 790, 29, 22977, 3476, 7147, 354, 20480, 430, 508, 359, 68, 17, 12, 366, 18, 12, 366, 19, 65, 61, 272, 769, 17, 275, 359, 16, 61, 627, 1616, 272, 769, 18, 275, 359, 16, 61, 627, 2948, 272, 769, 19, 65, 275, 359, 17, 61, 627, 1616, 272, 769, 19, 66, 275, 359, 17, 61, 627, 1616, 272, 221, 22977, 3476, 16, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 378, 9, 272, 702, 769, 8, 3235, 8, 19, 23033, 513, 17, 12, 769, 18, 12, 769, 19, 65, 12, 769, 19, 66, 467, 2432, 790, 29, 22977, 3476, 16, 430, 508, 359, 513, 17, 12, 769, 18, 12, 769, 19, 65, 61, 421, 199, 318, 511, 63, 26700, 837, 272, 347, 485, 475, 63, 6717, 8, 3610, 12, 302, 29, 709 ]
[ 4744, 90, 492, 1094, 651, 12, 3747, 12, 1642, 12, 5452, 199, 504, 4744, 90, 14, 16647, 14, 1018, 492, 221, 22977, 3476, 1197, 12, 29379, 199, 504, 7975, 492, 2338, 12, 11982, 199, 504, 4744, 90, 14, 15390, 492, 2341, 12, 3482, 421, 199, 318, 511, 63, 22977, 3476, 1197, 63, 885, 63, 498, 837, 272, 221, 22977, 3476, 2698, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 488, 9, 272, 491, 17, 275, 359, 17, 61, 272, 491, 18, 275, 359, 18, 61, 272, 666, 17, 275, 359, 44, 17, 12, 491, 17, 12, 491, 18, 12, 990, 990, 359, 17, 467, 359, 18, 467, 5479, 334, 1874, 272, 663, 17, 275, 663, 8, 1130, 8, 22977, 3476, 2698, 12, 666, 17, 430, 272, 663, 18, 275, 663, 8, 1130, 8, 22977, 3476, 2698, 12, 3474, 467, 359, 17, 467, 359, 18, 467, 5479, 334, 19563, 272, 702, 663, 17, 508, 663, 18, 272, 702, 822, 8, 409, 17, 9, 508, 959, 339, 327, 1379, 626, 1124, 22977, 3476, 2698, 8, 1053, 9719, 365, 15392, 687, 1124, 1053, 1040, 272, 377, 16, 275, 6248, 272, 377, 17, 275, 334, 17, 4258, 272, 666, 18, 275, 769, 8, 1130, 8, 22977, 3476, 2698, 12, 359, 52, 16, 12, 377, 16, 12, 377, 17, 12, 377, 17, 12, 11969, 334, 17, 12, 19563, 272, 666, 18, 14, 2880, 779, 52, 16, 12, 377, 17, 12, 11969, 334, 17, 12, 3948, 272, 663, 19, 275, 663, 8, 576, 18, 9, 272, 702, 663, 19, 508, 663, 779, 1062, 334, 17, 4706, 221, 22977, 3476, 2698, 8, 4000, 717, 221, 22977, 3476, 2698, 1332, 17, 4641, 566, 272, 702, 822, 8, 409, 19, 9, 508, 841, 272, 702, 221, 22977, 3476, 2698, 30812, 315, 663, 19, 272, 702, 221, 22977, 3476, 2698, 1332, 17, 4641, 315, 663, 19, 339, 327, 12481, 19549, 272, 662, 17, 275, 221, 22977, 3476, 2698, 8, 44, 17, 9, 272, 662, 18, 275, 221, 22977, 3476, 2698, 8, 44, 18, 9, 272, 702, 620, 8, 37, 17, 9, 508, 283, 1524, 17, 61, 534, 272, 702, 4700, 8, 37, 17, 9, 508, 283, 1524, 17, 61, 534, 272, 702, 662, 17, 1137, 662, 18, 272, 702, 440, 334, 37, 17, 508, 662, 18, 9, 272, 702, 662, 17, 508, 221, 22977, 3476, 2698, 8, 44, 17, 9, 272, 702, 440, 334, 37, 17, 1137, 221, 22977, 3476, 2698, 8, 44, 17, 430, 272, 702, 662, 17, 1137, 491, 17, 272, 702, 440, 334, 37, 17, 508, 491, 17, 9, 421, 199, 318, 511, 63, 22977, 3476, 1197, 63, 8296, 63, 498, 837, 272, 327, 13964, 3486, 2631, 790, 3423, 14, 272, 221, 22977, 3476, 3166, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 822, 9, 272, 221, 22977, 3476, 804, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 730, 9, 272, 221, 22977, 3476, 1304, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 1305, 9, 272, 221, 22977, 3476, 7147, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 1642, 9, 272, 666, 17, 275, 3474, 467, 359, 17, 467, 11969, 334, 17, 4706, 5479, 469, 17, 26, 499, 11049, 272, 666, 18, 275, 3474, 17, 12, 499, 467, 334, 17, 12, 499, 395, 334, 17, 12, 650, 395, 359, 17, 12, 650, 467, 359, 18, 12, 413, 467, 469, 17, 26, 499, 11049, 272, 702, 769, 8, 3235, 8, 576, 17, 10, 19, 12, 790, 29, 22977, 3476, 3166, 430, 508, 666, 17, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 3166, 430, 508, 666, 18, 272, 702, 769, 8, 3235, 8, 576, 17, 10, 19, 12, 790, 29, 22977, 3476, 804, 430, 508, 666, 17, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 804, 430, 508, 666, 18, 272, 702, 769, 8, 3235, 8, 576, 17, 10, 19, 12, 790, 29, 22977, 3476, 1304, 430, 508, 666, 17, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 1304, 430, 508, 666, 18, 272, 702, 769, 8, 3235, 8, 576, 18, 10, 19, 12, 790, 29, 22977, 3476, 7147, 430, 508, 666, 18, 421, 199, 318, 511, 63, 22977, 3476, 1197, 63, 1080, 63, 498, 837, 272, 366, 17, 275, 791, 25603, 356, 283, 28001, 297, 283, 474, 356, 7829, 12, 283, 576, 356, 24312, 272, 366, 18, 275, 791, 25603, 356, 283, 28001, 297, 283, 474, 356, 8177, 12, 283, 576, 356, 24312, 272, 366, 19, 65, 275, 791, 25603, 356, 283, 22593, 297, 283, 474, 356, 12001, 12, 283, 576, 356, 24312, 272, 366, 19, 66, 275, 791, 25603, 356, 283, 22593, 297, 283, 474, 356, 12001, 12, 283, 576, 356, 24312, 272, 221, 22977, 3476, 7147, 354, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 283, 25603, 358, 272, 702, 769, 8, 3235, 8, 19, 23033, 68, 17, 12, 366, 18, 12, 366, 19, 65, 12, 366, 19, 66, 467, 2432, 790, 29, 22977, 3476, 7147, 354, 430, 508, 359, 68, 17, 12, 366, 18, 12, 366, 19, 65, 61, 272, 221, 22977, 3476, 7147, 354, 20480, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 788, 25603, 297, 283, 474, 1105, 272, 702, 769, 8, 3235, 8, 19, 23033, 68, 17, 12, 366, 18, 12, 366, 19, 65, 12, 366, 19, 66, 467, 2432, 790, 29, 22977, 3476, 7147, 354, 20480, 430, 508, 359, 68, 17, 12, 366, 18, 12, 366, 19, 65, 61, 272, 769, 17, 275, 359, 16, 61, 627, 1616, 272, 769, 18, 275, 359, 16, 61, 627, 2948, 272, 769, 19, 65, 275, 359, 17, 61, 627, 1616, 272, 769, 19, 66, 275, 359, 17, 61, 627, 1616, 272, 221, 22977, 3476, 16, 275, 1094, 651, 8, 22977, 3476, 1197, 12, 378, 9, 272, 702, 769, 8, 3235, 8, 19, 23033, 513, 17, 12, 769, 18, 12, 769, 19, 65, 12, 769, 19, 66, 467, 2432, 790, 29, 22977, 3476, 16, 430, 508, 359, 513, 17, 12, 769, 18, 12, 769, 19, 65, 61, 421, 199, 318, 511, 63, 26700, 837, 272, 347, 485, 475, 63, 6717, 8, 3610, 12, 302, 29, 709, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alex/pip
pip/_vendor/html5lib/inputstream.py
435
31665
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type from pip._vendor.six.moves import http_client import codecs import re from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase from .constants import encodings, ReparseException from . import utils from io import StringIO try: from io import BytesIO except ImportError: BytesIO = StringIO try: from io import BufferedIOBase except ImportError: class BufferedIOBase(object): pass # Non-unicode versions of constants for use in the pre-parser spaceCharactersBytes = frozenset([item.encode("ascii") for item in spaceCharacters]) asciiLettersBytes = frozenset([item.encode("ascii") for item in asciiLetters]) asciiUppercaseBytes = frozenset([item.encode("ascii") for item in asciiUppercase]) spacesAngleBrackets = spaceCharactersBytes | frozenset([b">", b"<"]) invalid_unicode_no_surrogate = "[\u0001-\u0008\u000B\u000E-\u001F\u007F-\u009F\uFDD0-\uFDEF\uFFFE\uFFFF\U0001FFFE\U0001FFFF\U0002FFFE\U0002FFFF\U0003FFFE\U0003FFFF\U0004FFFE\U0004FFFF\U0005FFFE\U0005FFFF\U0006FFFE\U0006FFFF\U0007FFFE\U0007FFFF\U0008FFFE\U0008FFFF\U0009FFFE\U0009FFFF\U000AFFFE\U000AFFFF\U000BFFFE\U000BFFFF\U000CFFFE\U000CFFFF\U000DFFFE\U000DFFFF\U000EFFFE\U000EFFFF\U000FFFFE\U000FFFFF\U0010FFFE\U0010FFFF]" if utils.supports_lone_surrogates: # Use one extra step of indirection and create surrogates with # unichr. Not using this indirection would introduce an illegal # unicode literal on platforms not supporting such lone # surrogates. invalid_unicode_re = re.compile(invalid_unicode_no_surrogate + eval('"\\uD800-\\uDFFF"')) else: invalid_unicode_re = re.compile(invalid_unicode_no_surrogate) non_bmp_invalid_codepoints = set([0x1FFFE, 0x1FFFF, 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE, 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF]) ascii_punctuation_re = re.compile("[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]") # Cache for charsUntil() charsUntilRegEx = {} class BufferedStream(object): """Buffering for streams that do not have buffering of their own The buffer is implemented as a list of chunks on the assumption that joining many strings will be slow since it is O(n**2) """ def __init__(self, stream): self.stream = stream self.buffer = [] self.position = [-1, 0] # chunk number, offset def tell(self): pos = 0 for chunk in self.buffer[:self.position[0]]: pos += len(chunk) pos += self.position[1] return pos def seek(self, pos): assert pos <= self._bufferedBytes() offset = pos i = 0 while len(self.buffer[i]) < offset: offset -= len(self.buffer[i]) i += 1 self.position = [i, offset] def read(self, bytes): if not self.buffer: return self._readStream(bytes) elif (self.position[0] == len(self.buffer) and self.position[1] == len(self.buffer[-1])): return self._readStream(bytes) else: return self._readFromBuffer(bytes) def _bufferedBytes(self): return sum([len(item) for item in self.buffer]) def _readStream(self, bytes): data = self.stream.read(bytes) self.buffer.append(data) self.position[0] += 1 self.position[1] = len(data) return data def _readFromBuffer(self, bytes): remainingBytes = bytes rv = [] bufferIndex = self.position[0] bufferOffset = self.position[1] while bufferIndex < len(self.buffer) and remainingBytes != 0: assert remainingBytes > 0 bufferedData = self.buffer[bufferIndex] if remainingBytes <= len(bufferedData) - bufferOffset: bytesToRead = remainingBytes self.position = [bufferIndex, bufferOffset + bytesToRead] else: bytesToRead = len(bufferedData) - bufferOffset self.position = [bufferIndex, len(bufferedData)] bufferIndex += 1 rv.append(bufferedData[bufferOffset:bufferOffset + bytesToRead]) remainingBytes -= bytesToRead bufferOffset = 0 if remainingBytes: rv.append(self._readStream(remainingBytes)) return b"".join(rv) def HTMLInputStream(source, encoding=None, parseMeta=True, chardet=True): if isinstance(source, http_client.HTTPResponse): # Work around Python bug #20007: read(0) closes the connection. # http://bugs.python.org/issue20007 isUnicode = False elif hasattr(source, "read"): isUnicode = isinstance(source.read(0), text_type) else: isUnicode = isinstance(source, text_type) if isUnicode: if encoding is not None: raise TypeError("Cannot explicitly set an encoding with a unicode string") return HTMLUnicodeInputStream(source) else: return HTMLBinaryInputStream(source, encoding, parseMeta, chardet) class HTMLUnicodeInputStream(object): """Provides a unicode stream of characters to the HTMLTokenizer. This class takes care of character encoding and removing or replacing incorrect byte-sequences and also provides column and line tracking. """ _defaultChunkSize = 10240 def __init__(self, source): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specified, that encoding will be used, regardless of any BOM or later declaration (such as in a meta element) parseMeta - Look for a <meta> element containing encoding information """ if not utils.supports_lone_surrogates: # Such platforms will have already checked for such # surrogate errors, so no need to do this checking. self.reportCharacterErrors = None self.replaceCharactersRegexp = None elif len("\U0010FFFF") == 1: self.reportCharacterErrors = self.characterErrorsUCS4 self.replaceCharactersRegexp = re.compile(eval('"[\\uD800-\\uDFFF]"')) else: self.reportCharacterErrors = self.characterErrorsUCS2 self.replaceCharactersRegexp = re.compile( eval('"([\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF])"')) # List of where new lines occur self.newLines = [0] self.charEncoding = ("utf-8", "certain") self.dataStream = self.openStream(source) self.reset() def reset(self): self.chunk = "" self.chunkSize = 0 self.chunkOffset = 0 self.errors = [] # number of (complete) lines in previous chunks self.prevNumLines = 0 # number of columns in the last line of the previous chunk self.prevNumCols = 0 # Deal with CR LF and surrogates split over chunk boundaries self._bufferedCharacter = None def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) return stream def _position(self, offset): chunk = self.chunk nLines = chunk.count('\n', 0, offset) positionLine = self.prevNumLines + nLines lastLinePos = chunk.rfind('\n', 0, offset) if lastLinePos == -1: positionColumn = self.prevNumCols + offset else: positionColumn = offset - (lastLinePos + 1) return (positionLine, positionColumn) def position(self): """Returns (line, col) of the current position in the stream.""" line, col = self._position(self.chunkOffset) return (line + 1, col) def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF chunkOffset = self.chunkOffset char = self.chunk[chunkOffset] self.chunkOffset = chunkOffset + 1 return char def readChunk(self, chunkSize=None): if chunkSize is None: chunkSize = self._defaultChunkSize self.prevNumLines, self.prevNumCols = self._position(self.chunkSize) self.chunk = "" self.chunkSize = 0 self.chunkOffset = 0 data = self.dataStream.read(chunkSize) # Deal with CR LF and surrogates broken across chunks if self._bufferedCharacter: data = self._bufferedCharacter + data self._bufferedCharacter = None elif not data: # We have no more data, bye-bye stream return False if len(data) > 1: lastv = ord(data[-1]) if lastv == 0x0D or 0xD800 <= lastv <= 0xDBFF: self._bufferedCharacter = data[-1] data = data[:-1] if self.reportCharacterErrors: self.reportCharacterErrors(data) # Replace invalid characters # Note U+0000 is dealt with in the tokenizer data = self.replaceCharactersRegexp.sub("\ufffd", data) data = data.replace("\r\n", "\n") data = data.replace("\r", "\n") self.chunk = data self.chunkSize = len(data) return True def characterErrorsUCS4(self, data): for i in range(len(invalid_unicode_re.findall(data))): self.errors.append("invalid-codepoint") def characterErrorsUCS2(self, data): # Someone picked the wrong compile option # You lose skip = False for match in invalid_unicode_re.finditer(data): if skip: continue codepoint = ord(match.group()) pos = match.start() # Pretty sure there should be endianness issues here if utils.isSurrogatePair(data[pos:pos + 2]): # We have a surrogate pair! char_val = utils.surrogatePairToCodepoint(data[pos:pos + 2]) if char_val in non_bmp_invalid_codepoints: self.errors.append("invalid-codepoint") skip = True elif (codepoint >= 0xD800 and codepoint <= 0xDFFF and pos == len(data) - 1): self.errors.append("invalid-codepoint") else: skip = False self.errors.append("invalid-codepoint") def charsUntil(self, characters, opposite=False): """ Returns a string of characters from the stream up to but not including any character in 'characters' or EOF. 'characters' must be a container that supports the 'in' method and iteration over its characters. """ # Use a cache of regexps to find the required characters try: chars = charsUntilRegEx[(characters, opposite)] except KeyError: if __debug__: for c in characters: assert(ord(c) < 128) regex = "".join(["\\x%02x" % ord(c) for c in characters]) if not opposite: regex = "^%s" % regex chars = charsUntilRegEx[(characters, opposite)] = re.compile("[%s]+" % regex) rv = [] while True: # Find the longest matching prefix m = chars.match(self.chunk, self.chunkOffset) if m is None: # If nothing matched, and it wasn't because we ran out of chunk, # then stop if self.chunkOffset != self.chunkSize: break else: end = m.end() # If not the whole chunk matched, return everything # up to the part that didn't match if end != self.chunkSize: rv.append(self.chunk[self.chunkOffset:end]) self.chunkOffset = end break # If the whole remainder of the chunk matched, # use it all and read the next chunk rv.append(self.chunk[self.chunkOffset:]) if not self.readChunk(): # Reached EOF break r = "".join(rv) return r def unget(self, char): # Only one character is allowed to be ungotten at once - it must # be consumed again before any further call to unget if char is not None: if self.chunkOffset == 0: # unget is called quite rarely, so it's a good idea to do # more work here if it saves a bit of work in the frequently # called char and charsUntil. # So, just prepend the ungotten character onto the current # chunk: self.chunk = char + self.chunk self.chunkSize += 1 else: self.chunkOffset -= 1 assert self.chunk[self.chunkOffset] == char class HTMLBinaryInputStream(HTMLUnicodeInputStream): """Provides a unicode stream of characters to the HTMLTokenizer. This class takes care of character encoding and removing or replacing incorrect byte-sequences and also provides column and line tracking. """ def __init__(self, source, encoding=None, parseMeta=True, chardet=True): """Initialises the HTMLInputStream. HTMLInputStream(source, [encoding]) -> Normalized stream from source for use by html5lib. source can be either a file-object, local filename or a string. The optional encoding parameter must be a string that indicates the encoding. If specified, that encoding will be used, regardless of any BOM or later declaration (such as in a meta element) parseMeta - Look for a <meta> element containing encoding information """ # Raw Stream - for unicode objects this will encode to utf-8 and set # self.charEncoding as appropriate self.rawStream = self.openStream(source) HTMLUnicodeInputStream.__init__(self, self.rawStream) self.charEncoding = (codecName(encoding), "certain") # Encoding Information # Number of bytes to use when looking for a meta element with # encoding information self.numBytesMeta = 512 # Number of bytes to use when using detecting encoding using chardet self.numBytesChardet = 100 # Encoding to use if no other information can be found self.defaultEncoding = "windows-1252" # Detect encoding iff no explicit "transport level" encoding is supplied if (self.charEncoding[0] is None): self.charEncoding = self.detectEncoding(parseMeta, chardet) # Call superclass self.reset() def reset(self): self.dataStream = codecs.getreader(self.charEncoding[0])(self.rawStream, 'replace') HTMLUnicodeInputStream.reset(self) def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) try: stream.seek(stream.tell()) except: stream = BufferedStream(stream) return stream def detectEncoding(self, parseMeta=True, chardet=True): # First look for a BOM # This will also read past the BOM if present encoding = self.detectBOM() confidence = "certain" # If there is no BOM need to look for meta elements with encoding # information if encoding is None and parseMeta: encoding = self.detectEncodingMeta() confidence = "tentative" # Guess with chardet, if avaliable if encoding is None and chardet: confidence = "tentative" try: try: from charade.universaldetector import UniversalDetector except ImportError: from chardet.universaldetector import UniversalDetector buffers = [] detector = UniversalDetector() while not detector.done: buffer = self.rawStream.read(self.numBytesChardet) assert isinstance(buffer, bytes) if not buffer: break buffers.append(buffer) detector.feed(buffer) detector.close() encoding = detector.result['encoding'] self.rawStream.seek(0) except ImportError: pass # If all else fails use the default encoding if encoding is None: confidence = "tentative" encoding = self.defaultEncoding # Substitute for equivalent encodings: encodingSub = {"iso-8859-1": "windows-1252"} if encoding.lower() in encodingSub: encoding = encodingSub[encoding.lower()] return encoding, confidence def changeEncoding(self, newEncoding): assert self.charEncoding[1] != "certain" newEncoding = codecName(newEncoding) if newEncoding in ("utf-16", "utf-16-be", "utf-16-le"): newEncoding = "utf-8" if newEncoding is None: return elif newEncoding == self.charEncoding[0]: self.charEncoding = (self.charEncoding[0], "certain") else: self.rawStream.seek(0) self.reset() self.charEncoding = (newEncoding, "certain") raise ReparseException("Encoding changed from %s to %s" % (self.charEncoding[0], newEncoding)) def detectBOM(self): """Attempts to detect at BOM at the start of the stream. If an encoding can be determined from the BOM return the name of the encoding otherwise return None""" bomDict = { codecs.BOM_UTF8: 'utf-8', codecs.BOM_UTF16_LE: 'utf-16-le', codecs.BOM_UTF16_BE: 'utf-16-be', codecs.BOM_UTF32_LE: 'utf-32-le', codecs.BOM_UTF32_BE: 'utf-32-be' } # Go to beginning of file and read in 4 bytes string = self.rawStream.read(4) assert isinstance(string, bytes) # Try detecting the BOM using bytes from the string encoding = bomDict.get(string[:3]) # UTF-8 seek = 3 if not encoding: # Need to detect UTF-32 before UTF-16 encoding = bomDict.get(string) # UTF-32 seek = 4 if not encoding: encoding = bomDict.get(string[:2]) # UTF-16 seek = 2 # Set the read position past the BOM if one was found, otherwise # set it to the start of the stream self.rawStream.seek(encoding and seek or 0) return encoding def detectEncodingMeta(self): """Report the encoding declared by the meta element """ buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() if encoding in ("utf-16", "utf-16-be", "utf-16-le"): encoding = "utf-8" return encoding class EncodingBytes(bytes): """String-like object with an associated position and various extra methods If the position is ever greater than the string length then an exception is raised""" def __new__(self, value): assert isinstance(value, bytes) return bytes.__new__(self, value.lower()) def __init__(self, value): self._position = -1 def __iter__(self): return self def __next__(self): p = self._position = self._position + 1 if p >= len(self): raise StopIteration elif p < 0: raise TypeError return self[p:p + 1] def next(self): # Py2 compat return self.__next__() def previous(self): p = self._position if p >= len(self): raise StopIteration elif p < 0: raise TypeError self._position = p = p - 1 return self[p:p + 1] def setPosition(self, position): if self._position >= len(self): raise StopIteration self._position = position def getPosition(self): if self._position >= len(self): raise StopIteration if self._position >= 0: return self._position else: return None position = property(getPosition, setPosition) def getCurrentByte(self): return self[self.position:self.position + 1] currentByte = property(getCurrentByte) def skip(self, chars=spaceCharactersBytes): """Skip past a list of characters""" p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p return c p += 1 self._position = p return None def skipUntil(self, chars): p = self.position while p < len(self): c = self[p:p + 1] if c in chars: self._position = p return c p += 1 self._position = p return None def matchBytes(self, bytes): """Look for a sequence of bytes at the start of a string. If the bytes are found return True and advance the position to the byte after the match. Otherwise return False and leave the position alone""" p = self.position data = self[p:p + len(bytes)] rv = data.startswith(bytes) if rv: self.position += len(bytes) return rv def jumpTo(self, bytes): """Look for the next sequence of bytes matching a given sequence. If a match is found advance the position to the last byte of the match""" newPosition = self[self.position:].find(bytes) if newPosition > -1: # XXX: This is ugly, but I can't see a nicer way to fix this. if self._position == -1: self._position = 0 self._position += (newPosition + len(bytes) - 1) return True else: raise StopIteration class EncodingParser(object): """Mini parser for detecting character encoding from meta elements""" def __init__(self, data): """string - the data to work on for encoding detection""" self.data = EncodingBytes(data) self.encoding = None def getEncoding(self): methodDispatch = ( (b"<!--", self.handleComment), (b"<meta", self.handleMeta), (b"</", self.handlePossibleEndTag), (b"<!", self.handleOther), (b"<?", self.handleOther), (b"<", self.handlePossibleStartTag)) for byte in self.data: keepParsing = True for key, method in methodDispatch: if self.data.matchBytes(key): try: keepParsing = method() break except StopIteration: keepParsing = False break if not keepParsing: break return self.encoding def handleComment(self): """Skip over comments""" return self.data.jumpTo(b"-->") def handleMeta(self): if self.data.currentByte not in spaceCharactersBytes: # if we have <meta not followed by a space so just keep going return True # We have a valid meta element we want to search for attributes hasPragma = False pendingEncoding = None while True: # Try to find the next attribute after the current position attr = self.getAttribute() if attr is None: return True else: if attr[0] == b"http-equiv": hasPragma = attr[1] == b"content-type" if hasPragma and pendingEncoding is not None: self.encoding = pendingEncoding return False elif attr[0] == b"charset": tentativeEncoding = attr[1] codec = codecName(tentativeEncoding) if codec is not None: self.encoding = codec return False elif attr[0] == b"content": contentParser = ContentAttrParser(EncodingBytes(attr[1])) tentativeEncoding = contentParser.parse() if tentativeEncoding is not None: codec = codecName(tentativeEncoding) if codec is not None: if hasPragma: self.encoding = codec return False else: pendingEncoding = codec def handlePossibleStartTag(self): return self.handlePossibleTag(False) def handlePossibleEndTag(self): next(self.data) return self.handlePossibleTag(True) def handlePossibleTag(self, endTag): data = self.data if data.currentByte not in asciiLettersBytes: # If the next byte is not an ascii letter either ignore this # fragment (possible start tag case) or treat it according to # handleOther if endTag: data.previous() self.handleOther() return True c = data.skipUntil(spacesAngleBrackets) if c == b"<": # return to the first step in the overall "two step" algorithm # reprocessing the < byte data.previous() else: # Read all attributes attr = self.getAttribute() while attr is not None: attr = self.getAttribute() return True def handleOther(self): return self.data.jumpTo(b">") def getAttribute(self): """Return a name,value pair for the next attribute in the stream, if one is found, or None""" data = self.data # Step 1 (skip chars) c = data.skip(spaceCharactersBytes | frozenset([b"/"])) assert c is None or len(c) == 1 # Step 2 if c in (b">", None): return None # Step 3 attrName = [] attrValue = [] # Step 4 attribute name while True: if c == b"=" and attrName: break elif c in spaceCharactersBytes: # Step 6! c = data.skip() break elif c in (b"/", b">"): return b"".join(attrName), b"" elif c in asciiUppercaseBytes: attrName.append(c.lower()) elif c is None: return None else: attrName.append(c) # Step 5 c = next(data) # Step 7 if c != b"=": data.previous() return b"".join(attrName), b"" # Step 8 next(data) # Step 9 c = data.skip() # Step 10 if c in (b"'", b'"'): # 10.1 quoteChar = c while True: # 10.2 c = next(data) # 10.3 if c == quoteChar: next(data) return b"".join(attrName), b"".join(attrValue) # 10.4 elif c in asciiUppercaseBytes: attrValue.append(c.lower()) # 10.5 else: attrValue.append(c) elif c == b">": return b"".join(attrName), b"" elif c in asciiUppercaseBytes: attrValue.append(c.lower()) elif c is None: return None else: attrValue.append(c) # Step 11 while True: c = next(data) if c in spacesAngleBrackets: return b"".join(attrName), b"".join(attrValue) elif c in asciiUppercaseBytes: attrValue.append(c.lower()) elif c is None: return None else: attrValue.append(c) class ContentAttrParser(object): def __init__(self, data): assert isinstance(data, bytes) self.data = data def parse(self): try: # Check if the attr name is charset # otherwise return self.data.jumpTo(b"charset") self.data.position += 1 self.data.skip() if not self.data.currentByte == b"=": # If there is no = sign keep looking for attrs return None self.data.position += 1 self.data.skip() # Look for an encoding between matching quote marks if self.data.currentByte in (b'"', b"'"): quoteMark = self.data.currentByte self.data.position += 1 oldPosition = self.data.position if self.data.jumpTo(quoteMark): return self.data[oldPosition:self.data.position] else: return None else: # Unquoted value oldPosition = self.data.position try: self.data.skipUntil(spaceCharactersBytes) return self.data[oldPosition:self.data.position] except StopIteration: # Return the whole remaining value return self.data[oldPosition:] except StopIteration: return None def codecName(encoding): """Return the python codec name corresponding to an encoding or None if the string doesn't correspond to a valid encoding.""" if isinstance(encoding, bytes): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return None if encoding: canonicalName = ascii_punctuation_re.sub("", encoding).lower() return encodings.get(canonicalName, None) else: return None
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 504, 7305, 423, 9884, 14, 4174, 492, 1318, 63, 466, 199, 504, 7305, 423, 9884, 14, 4174, 14, 4912, 492, 1455, 63, 1258, 199, 199, 646, 6010, 199, 646, 295, 199, 199, 504, 1275, 5559, 492, 9027, 12, 25431, 12, 13294, 28760, 12, 13294, 19316, 2546, 199, 504, 1275, 5559, 492, 14134, 12, 799, 1122, 1726, 199, 504, 1275, 492, 3778, 199, 199, 504, 5890, 492, 5228, 199, 199, 893, 26, 272, 687, 5890, 492, 11808, 199, 2590, 3545, 26, 272, 11808, 275, 5228, 199, 199, 893, 26, 272, 687, 5890, 492, 26832, 23413, 199, 2590, 3545, 26, 272, 1021, 26832, 23413, 8, 785, 304, 267, 986, 199, 199, 3, 10172, 13, 2975, 5459, 402, 5262, 367, 675, 315, 314, 876, 13, 2087, 199, 2638, 9272, 5571, 275, 9522, 779, 1053, 14, 2143, 480, 4371, 531, 367, 1242, 315, 25431, 566, 199, 4371, 28760, 5571, 275, 9522, 779, 1053, 14, 2143, 480, 4371, 531, 367, 1242, 315, 13294, 28760, 566, 199, 4371, 19316, 2546, 5571, 275, 9522, 779, 1053, 14, 2143, 480, 4371, 531, 367, 1242, 315, 13294, 19316, 2546, 566, 199, 10749, 16943, 29418, 83, 275, 25431, 5571, 1204, 9522, 779, 66, 1743, 401, 330, 17030, 3135, 421, 199, 3197, 63, 2975, 63, 889, 63, 16380, 275, 298, 7023, 85, 4183, 2696, 85, 19141, 60, 85, 1493, 34, 60, 85, 1493, 37, 2696, 85, 4587, 38, 60, 85, 8255, 38, 2696, 85, 8581, 38, 60, 19872, 5745, 16, 2696, 19872, 5638, 60, 15347, 5100, 60, 85, 6968, 60, 53, 4183, 27897, 60, 53, 4183, 6968, 60, 53, 9425, 27897, 60, 53, 9425, 6968, 60, 53, 16861, 27897, 60, 53, 16861, 6968, 60, 53, 16643, 27897, 60, 53, 16643, 6968, 60, 53, 15646, 27897, 60, 53, 15646, 6968, 60, 53, 20965, 27897, 60, 53, 20965, 6968, 60, 53, 22530, 27897, 60, 53, 22530, 6968, 60, 53, 19141, 27897, 60, 53, 19141, 6968, 60, 53, 21144, 27897, 60, 53, 21144, 6968, 60, 53, 1493, 25900, 5100, 60, 53, 1493, 33, 6968, 60, 53, 1493, 34, 27897, 60, 53, 1493, 34, 6968, 60, 53, 1493, 35, 27897, 60, 53, 1493, 35, 6968, 60, 53, 1493, 36, 27897, 60, 53, 1493, 36, 6968, 60, 53, 1493, 37, 27897, 60, 53, 1493, 37, 6968, 60, 53, 1493, 6968, 37, 60, 53, 1493, 6968, 38, 60, 53, 17657, 27897, 60, 53, 17657, 6968, 8480, 199, 199, 692, 3778, 14, 9823, 63, 76, 368, 63, 5105, 19029, 2335, 26, 272, 327, 3645, 1373, 2402, 3650, 402, 2539, 4017, 436, 1218, 6296, 19029, 2335, 543, 272, 327, 17742, 14, 2832, 1808, 642, 2539, 4017, 3955, 13318, 3402, 376, 20282, 272, 327, 2649, 8785, 641, 10677, 440, 21038, 4066, 634, 368, 272, 327, 6296, 19029, 2335, 14, 272, 3866, 63, 2975, 63, 264, 275, 295, 14, 2014, 8, 3197, 63, 2975, 63, 889, 63, 16380, 435, 2511, 3468, 14088, 1103, 18867, 6718, 31206, 18867, 24254, 2, 1333, 199, 2836, 26, 272, 3866, 63, 2975, 63, 264, 275, 295, 14, 2014, 8, 3197, 63, 2975, 63, 889, 63, 16380, 9, 199, 199, 2865, 63, 22308, 63, 3197, 63, 600, 3438, 275, 663, 779, 16, 88, 17, 27897, 12, 378, 88, 17, 6968, 12, 378, 88, 18, 27897, 12, 378, 88, 18, 6968, 12, 378, 88, 19, 27897, 12, 3303, 378, 88, 19, 6968, 12, 378, 88, 20, 27897, 12, 378, 88, 20, 6968, 12, 378, 88, 21, 27897, 12, 378, 88, 21, 6968, 12, 3303, 378, 88, 22, 27897, 12, 378, 88, 22, 6968, 12, 378, 88, 23, 27897, 12, 378, 88, 23, 6968, 12, 378, 88, 24, 27897, 12, 3303, 378, 88, 24, 6968, 12, 378, 88, 25, 27897, 12, 378, 88, 25, 6968, 12, 378, 7471, 27897, 12, 378, 7471, 6968, 12, 3303, 378, 8094, 27897, 12, 378, 8094, 6968, 12, 378, 8163, 27897, 12, 378, 8163, 6968, 12, 378, 8313, 27897, 12, 3303, 378, 8313, 6968, 12, 378, 6991, 27897, 12, 378, 6991, 6968, 12, 378, 23973, 37, 12, 378, 23973, 38, 12, 3303, 378, 88, 709, 27897, 12, 378, 88, 709, 6968, 566, 199, 199, 4371, 63, 25181, 63, 264, 275, 295, 14, 2014, 480, 7023, 85, 21144, 2696, 85, 1493, 36, 60, 85, 20734, 2696, 85, 7432, 38, 60, 85, 8262, 33, 2696, 85, 25665, 60, 85, 7972, 34, 2696, 85, 29120, 60, 85, 8255, 34, 2696, 85, 8255, 37, 12523, 199, 199, 3, 11977, 367, 8365, 18667, 342, 199, 6574, 18667, 2872, 920, 275, 1052, 421, 199, 533, 26832, 3296, 8, 785, 304, 272, 408, 3299, 316, 367, 13788, 626, 886, 440, 1172, 21033, 402, 3932, 5705, 339, 710, 3335, 365, 6366, 465, 282, 769, 402, 8291, 641, 314, 30075, 626, 272, 4263, 316, 5002, 3326, 911, 506, 11999, 3967, 652, 365, 593, 8, 78, 538, 18, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2547, 304, 267, 291, 14, 1745, 275, 2547, 267, 291, 14, 2738, 275, 942, 267, 291, 14, 3124, 275, 5243, 17, 12, 378, 61, 221, 327, 3728, 1329, 12, 3268, 339, 347, 11480, 8, 277, 304, 267, 2086, 275, 378, 267, 367, 3728, 315, 291, 14, 2738, 1491, 277, 14, 3124, 59, 16, 27589, 288, 2086, 847, 822, 8, 4604, 9, 267, 2086, 847, 291, 14, 3124, 59, 17, 61, 267, 372, 2086, 339, 347, 12005, 8, 277, 12, 2086, 304, 267, 702, 2086, 2695, 291, 423, 17605, 5571, 342, 267, 3268, 275, 2086, 267, 284, 275, 378, 267, 1830, 822, 8, 277, 14, 2738, 59, 73, 566, 665, 3268, 26, 288, 3268, 4862, 822, 8, 277, 14, 2738, 59, 73, 566, 288, 284, 847, 413, 267, 291, 14, 3124, 275, 359, 73, 12, 3268, 61, 339, 347, 1586, 8, 277, 12, 2783, 304, 267, 340, 440, 291, 14, 2738, 26, 288, 372, 291, 423, 739, 3296, 8, 2394, 9, 267, 916, 334, 277, 14, 3124, 59, 16, 61, 508, 822, 8, 277, 14, 2738, 9, 436, 1598, 291, 14, 3124, 59, 17, 61, 508, 822, 8, 277, 14, 2738, 1988, 17, 18710, 288, 372, 291, 423, 739, 3296, 8, 2394, 9, 267, 587, 26, 288, 372, 291, 423, 739, 2532, 3299, 8, 2394, 9 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 504, 7305, 423, 9884, 14, 4174, 492, 1318, 63, 466, 199, 504, 7305, 423, 9884, 14, 4174, 14, 4912, 492, 1455, 63, 1258, 199, 199, 646, 6010, 199, 646, 295, 199, 199, 504, 1275, 5559, 492, 9027, 12, 25431, 12, 13294, 28760, 12, 13294, 19316, 2546, 199, 504, 1275, 5559, 492, 14134, 12, 799, 1122, 1726, 199, 504, 1275, 492, 3778, 199, 199, 504, 5890, 492, 5228, 199, 199, 893, 26, 272, 687, 5890, 492, 11808, 199, 2590, 3545, 26, 272, 11808, 275, 5228, 199, 199, 893, 26, 272, 687, 5890, 492, 26832, 23413, 199, 2590, 3545, 26, 272, 1021, 26832, 23413, 8, 785, 304, 267, 986, 199, 199, 3, 10172, 13, 2975, 5459, 402, 5262, 367, 675, 315, 314, 876, 13, 2087, 199, 2638, 9272, 5571, 275, 9522, 779, 1053, 14, 2143, 480, 4371, 531, 367, 1242, 315, 25431, 566, 199, 4371, 28760, 5571, 275, 9522, 779, 1053, 14, 2143, 480, 4371, 531, 367, 1242, 315, 13294, 28760, 566, 199, 4371, 19316, 2546, 5571, 275, 9522, 779, 1053, 14, 2143, 480, 4371, 531, 367, 1242, 315, 13294, 19316, 2546, 566, 199, 10749, 16943, 29418, 83, 275, 25431, 5571, 1204, 9522, 779, 66, 1743, 401, 330, 17030, 3135, 421, 199, 3197, 63, 2975, 63, 889, 63, 16380, 275, 298, 7023, 85, 4183, 2696, 85, 19141, 60, 85, 1493, 34, 60, 85, 1493, 37, 2696, 85, 4587, 38, 60, 85, 8255, 38, 2696, 85, 8581, 38, 60, 19872, 5745, 16, 2696, 19872, 5638, 60, 15347, 5100, 60, 85, 6968, 60, 53, 4183, 27897, 60, 53, 4183, 6968, 60, 53, 9425, 27897, 60, 53, 9425, 6968, 60, 53, 16861, 27897, 60, 53, 16861, 6968, 60, 53, 16643, 27897, 60, 53, 16643, 6968, 60, 53, 15646, 27897, 60, 53, 15646, 6968, 60, 53, 20965, 27897, 60, 53, 20965, 6968, 60, 53, 22530, 27897, 60, 53, 22530, 6968, 60, 53, 19141, 27897, 60, 53, 19141, 6968, 60, 53, 21144, 27897, 60, 53, 21144, 6968, 60, 53, 1493, 25900, 5100, 60, 53, 1493, 33, 6968, 60, 53, 1493, 34, 27897, 60, 53, 1493, 34, 6968, 60, 53, 1493, 35, 27897, 60, 53, 1493, 35, 6968, 60, 53, 1493, 36, 27897, 60, 53, 1493, 36, 6968, 60, 53, 1493, 37, 27897, 60, 53, 1493, 37, 6968, 60, 53, 1493, 6968, 37, 60, 53, 1493, 6968, 38, 60, 53, 17657, 27897, 60, 53, 17657, 6968, 8480, 199, 199, 692, 3778, 14, 9823, 63, 76, 368, 63, 5105, 19029, 2335, 26, 272, 327, 3645, 1373, 2402, 3650, 402, 2539, 4017, 436, 1218, 6296, 19029, 2335, 543, 272, 327, 17742, 14, 2832, 1808, 642, 2539, 4017, 3955, 13318, 3402, 376, 20282, 272, 327, 2649, 8785, 641, 10677, 440, 21038, 4066, 634, 368, 272, 327, 6296, 19029, 2335, 14, 272, 3866, 63, 2975, 63, 264, 275, 295, 14, 2014, 8, 3197, 63, 2975, 63, 889, 63, 16380, 435, 2511, 3468, 14088, 1103, 18867, 6718, 31206, 18867, 24254, 2, 1333, 199, 2836, 26, 272, 3866, 63, 2975, 63, 264, 275, 295, 14, 2014, 8, 3197, 63, 2975, 63, 889, 63, 16380, 9, 199, 199, 2865, 63, 22308, 63, 3197, 63, 600, 3438, 275, 663, 779, 16, 88, 17, 27897, 12, 378, 88, 17, 6968, 12, 378, 88, 18, 27897, 12, 378, 88, 18, 6968, 12, 378, 88, 19, 27897, 12, 3303, 378, 88, 19, 6968, 12, 378, 88, 20, 27897, 12, 378, 88, 20, 6968, 12, 378, 88, 21, 27897, 12, 378, 88, 21, 6968, 12, 3303, 378, 88, 22, 27897, 12, 378, 88, 22, 6968, 12, 378, 88, 23, 27897, 12, 378, 88, 23, 6968, 12, 378, 88, 24, 27897, 12, 3303, 378, 88, 24, 6968, 12, 378, 88, 25, 27897, 12, 378, 88, 25, 6968, 12, 378, 7471, 27897, 12, 378, 7471, 6968, 12, 3303, 378, 8094, 27897, 12, 378, 8094, 6968, 12, 378, 8163, 27897, 12, 378, 8163, 6968, 12, 378, 8313, 27897, 12, 3303, 378, 8313, 6968, 12, 378, 6991, 27897, 12, 378, 6991, 6968, 12, 378, 23973, 37, 12, 378, 23973, 38, 12, 3303, 378, 88, 709, 27897, 12, 378, 88, 709, 6968, 566, 199, 199, 4371, 63, 25181, 63, 264, 275, 295, 14, 2014, 480, 7023, 85, 21144, 2696, 85, 1493, 36, 60, 85, 20734, 2696, 85, 7432, 38, 60, 85, 8262, 33, 2696, 85, 25665, 60, 85, 7972, 34, 2696, 85, 29120, 60, 85, 8255, 34, 2696, 85, 8255, 37, 12523, 199, 199, 3, 11977, 367, 8365, 18667, 342, 199, 6574, 18667, 2872, 920, 275, 1052, 421, 199, 533, 26832, 3296, 8, 785, 304, 272, 408, 3299, 316, 367, 13788, 626, 886, 440, 1172, 21033, 402, 3932, 5705, 339, 710, 3335, 365, 6366, 465, 282, 769, 402, 8291, 641, 314, 30075, 626, 272, 4263, 316, 5002, 3326, 911, 506, 11999, 3967, 652, 365, 593, 8, 78, 538, 18, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 2547, 304, 267, 291, 14, 1745, 275, 2547, 267, 291, 14, 2738, 275, 942, 267, 291, 14, 3124, 275, 5243, 17, 12, 378, 61, 221, 327, 3728, 1329, 12, 3268, 339, 347, 11480, 8, 277, 304, 267, 2086, 275, 378, 267, 367, 3728, 315, 291, 14, 2738, 1491, 277, 14, 3124, 59, 16, 27589, 288, 2086, 847, 822, 8, 4604, 9, 267, 2086, 847, 291, 14, 3124, 59, 17, 61, 267, 372, 2086, 339, 347, 12005, 8, 277, 12, 2086, 304, 267, 702, 2086, 2695, 291, 423, 17605, 5571, 342, 267, 3268, 275, 2086, 267, 284, 275, 378, 267, 1830, 822, 8, 277, 14, 2738, 59, 73, 566, 665, 3268, 26, 288, 3268, 4862, 822, 8, 277, 14, 2738, 59, 73, 566, 288, 284, 847, 413, 267, 291, 14, 3124, 275, 359, 73, 12, 3268, 61, 339, 347, 1586, 8, 277, 12, 2783, 304, 267, 340, 440, 291, 14, 2738, 26, 288, 372, 291, 423, 739, 3296, 8, 2394, 9, 267, 916, 334, 277, 14, 3124, 59, 16, 61, 508, 822, 8, 277, 14, 2738, 9, 436, 1598, 291, 14, 3124, 59, 17, 61, 508, 822, 8, 277, 14, 2738, 1988, 17, 18710, 288, 372, 291, 423, 739, 3296, 8, 2394, 9, 267, 587, 26, 288, 372, 291, 423, 739, 2532, 3299, 8, 2394, 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, 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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 ]
sim0629/irc
setup.py
1
1516
import sys import setuptools def read_long_description(): with open('README.rst') as f: data = f.read() with open('CHANGES.rst') as f: data += '\n\n' + f.read() return data importlib_req = ['importlib'] if sys.version_info < (2,7) else [] argparse_req = ['argparse'] if sys.version_info < (2,7) else [] setup_params = dict( name="irc", description="IRC (Internet Relay Chat) protocol client library for Python", long_description=read_long_description(), use_hg_version=True, packages=setuptools.find_packages(), author="Joel Rosdahl", author_email="joel@rosdahl.net", maintainer="Jason R. Coombs", maintainer_email="jaraco@jaraco.com", url="http://python-irclib.sourceforge.net", license="MIT", classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", ], install_requires=[ ] + importlib_req + argparse_req, setup_requires=[ 'hgtools', 'pytest-runner', ], tests_require=[ 'pytest', 'mock', ], use_2to3=True, use_2to3_exclude_fixers=[ 'lib2to3.fixes.fix_import', 'lib2to3.fixes.fix_next', 'lib2to3.fixes.fix_print', ], ) if __name__ == '__main__': setuptools.setup(**setup_params)
lgpl-2.1
[ 646, 984, 2999, 199, 646, 9116, 2999, 199, 318, 1586, 63, 2809, 63, 1802, 837, 1128, 543, 1551, 360, 18195, 14, 8332, 358, 465, 289, 26, 1039, 666, 275, 289, 14, 739, 342, 1128, 543, 1551, 360, 17858, 654, 14, 8332, 358, 465, 289, 26, 1039, 666, 847, 1557, 78, 60, 78, 7, 435, 289, 14, 739, 342, 1128, 372, 666, 2999, 199, 25893, 63, 2103, 275, 788, 25893, 418, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 23, 9, 587, 942, 202, 199, 18978, 63, 2103, 275, 788, 18978, 418, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 23, 9, 587, 942, 2999, 199, 2758, 63, 1162, 275, 1211, 8, 1128, 536, 628, 5958, 401, 1128, 1369, 628, 3927, 35, 334, 29820, 9781, 1187, 2799, 292, 9, 4113, 1890, 3555, 367, 2018, 401, 1128, 1846, 63, 1802, 29, 739, 63, 2809, 63, 1802, 1062, 1128, 675, 63, 9208, 63, 1023, 29, 549, 12, 1128, 6117, 29, 13623, 14, 1623, 63, 5154, 1062, 1128, 4132, 628, 5691, 352, 820, 736, 983, 15544, 401, 1128, 4132, 63, 2123, 628, 743, 352, 32, 4796, 983, 15544, 14, 846, 401, 1128, 11075, 281, 628, 42, 2660, 820, 14, 1849, 676, 1533, 401, 1128, 11075, 281, 63, 2123, 628, 7338, 13286, 32, 7338, 13286, 14, 957, 401, 1128, 1166, 628, 1014, 921, 1548, 13, 5958, 773, 14, 22943, 14, 846, 401, 1128, 4190, 628, 13965, 401, 1128, 19137, 275, 359, 1039, 298, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 401, 1039, 298, 23910, 23975, 3800, 23493, 401, 1039, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 401, 1039, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 1039, 298, 11411, 8466, 3800, 2018, 3800, 650, 401, 1128, 2156, 1128, 3907, 63, 6537, 1524, 1128, 1622, 435, 14802, 63, 2103, 435, 7534, 63, 2103, 12, 1128, 3272, 63, 6537, 1524, 1039, 283, 9208, 2537, 297, 1039, 283, 4462, 13, 5933, 297, 1128, 2156, 1128, 2295, 63, 4365, 1524, 1039, 283, 4462, 297, 1039, 283, 1805, 297, 1128, 2156, 1128, 675, 63, 18, 475, 19, 29, 549, 12, 1128, 675, 63, 18, 475, 19, 63, 5473, 63, 970, 1192, 1524, 1039, 283, 773, 18, 475, 19, 14, 26205, 14, 970, 63, 646, 297, 1039, 283, 773, 18, 475, 19, 14, 26205, 14, 970, 63, 2184, 297, 1039, 283, 773, 18, 475, 19, 14, 26205, 14, 970, 63, 1361, 297, 1128, 2156, 202, 199, 9, 2999, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 9116, 14, 2758, 3682, 2758, 63, 1162, 9, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 2999, 199, 646, 9116, 2999, 199, 318, 1586, 63, 2809, 63, 1802, 837, 1128, 543, 1551, 360, 18195, 14, 8332, 358, 465, 289, 26, 1039, 666, 275, 289, 14, 739, 342, 1128, 543, 1551, 360, 17858, 654, 14, 8332, 358, 465, 289, 26, 1039, 666, 847, 1557, 78, 60, 78, 7, 435, 289, 14, 739, 342, 1128, 372, 666, 2999, 199, 25893, 63, 2103, 275, 788, 25893, 418, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 23, 9, 587, 942, 202, 199, 18978, 63, 2103, 275, 788, 18978, 418, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 23, 9, 587, 942, 2999, 199, 2758, 63, 1162, 275, 1211, 8, 1128, 536, 628, 5958, 401, 1128, 1369, 628, 3927, 35, 334, 29820, 9781, 1187, 2799, 292, 9, 4113, 1890, 3555, 367, 2018, 401, 1128, 1846, 63, 1802, 29, 739, 63, 2809, 63, 1802, 1062, 1128, 675, 63, 9208, 63, 1023, 29, 549, 12, 1128, 6117, 29, 13623, 14, 1623, 63, 5154, 1062, 1128, 4132, 628, 5691, 352, 820, 736, 983, 15544, 401, 1128, 4132, 63, 2123, 628, 743, 352, 32, 4796, 983, 15544, 14, 846, 401, 1128, 11075, 281, 628, 42, 2660, 820, 14, 1849, 676, 1533, 401, 1128, 11075, 281, 63, 2123, 628, 7338, 13286, 32, 7338, 13286, 14, 957, 401, 1128, 1166, 628, 1014, 921, 1548, 13, 5958, 773, 14, 22943, 14, 846, 401, 1128, 4190, 628, 13965, 401, 1128, 19137, 275, 359, 1039, 298, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 401, 1039, 298, 23910, 23975, 3800, 23493, 401, 1039, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 401, 1039, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 1039, 298, 11411, 8466, 3800, 2018, 3800, 650, 401, 1128, 2156, 1128, 3907, 63, 6537, 1524, 1128, 1622, 435, 14802, 63, 2103, 435, 7534, 63, 2103, 12, 1128, 3272, 63, 6537, 1524, 1039, 283, 9208, 2537, 297, 1039, 283, 4462, 13, 5933, 297, 1128, 2156, 1128, 2295, 63, 4365, 1524, 1039, 283, 4462, 297, 1039, 283, 1805, 297, 1128, 2156, 1128, 675, 63, 18, 475, 19, 29, 549, 12, 1128, 675, 63, 18, 475, 19, 63, 5473, 63, 970, 1192, 1524, 1039, 283, 773, 18, 475, 19, 14, 26205, 14, 970, 63, 646, 297, 1039, 283, 773, 18, 475, 19, 14, 26205, 14, 970, 63, 2184, 297, 1039, 283, 773, 18, 475, 19, 14, 26205, 14, 970, 63, 1361, 297, 1128, 2156, 202, 199, 9, 2999, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 1128, 9116, 14, 2758, 3682, 2758, 63, 1162, 9, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
CoDEmanX/ArangoDB
3rdParty/V8-4.3.61/third_party/python_26/Lib/encodings/cp775.py
593
34732
""" Python Character Mapping Codec cp775 generated from 'VENDORS/MICSFT/PC/CP775.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_map) 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_map)[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='cp775', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamreader=StreamReader, streamwriter=StreamWriter, ) ### Decoding Map decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x0080: 0x0106, # LATIN CAPITAL LETTER C WITH ACUTE 0x0081: 0x00fc, # LATIN SMALL LETTER U WITH DIAERESIS 0x0082: 0x00e9, # LATIN SMALL LETTER E WITH ACUTE 0x0083: 0x0101, # LATIN SMALL LETTER A WITH MACRON 0x0084: 0x00e4, # LATIN SMALL LETTER A WITH DIAERESIS 0x0085: 0x0123, # LATIN SMALL LETTER G WITH CEDILLA 0x0086: 0x00e5, # LATIN SMALL LETTER A WITH RING ABOVE 0x0087: 0x0107, # LATIN SMALL LETTER C WITH ACUTE 0x0088: 0x0142, # LATIN SMALL LETTER L WITH STROKE 0x0089: 0x0113, # LATIN SMALL LETTER E WITH MACRON 0x008a: 0x0156, # LATIN CAPITAL LETTER R WITH CEDILLA 0x008b: 0x0157, # LATIN SMALL LETTER R WITH CEDILLA 0x008c: 0x012b, # LATIN SMALL LETTER I WITH MACRON 0x008d: 0x0179, # LATIN CAPITAL LETTER Z WITH ACUTE 0x008e: 0x00c4, # LATIN CAPITAL LETTER A WITH DIAERESIS 0x008f: 0x00c5, # LATIN CAPITAL LETTER A WITH RING ABOVE 0x0090: 0x00c9, # LATIN CAPITAL LETTER E WITH ACUTE 0x0091: 0x00e6, # LATIN SMALL LIGATURE AE 0x0092: 0x00c6, # LATIN CAPITAL LIGATURE AE 0x0093: 0x014d, # LATIN SMALL LETTER O WITH MACRON 0x0094: 0x00f6, # LATIN SMALL LETTER O WITH DIAERESIS 0x0095: 0x0122, # LATIN CAPITAL LETTER G WITH CEDILLA 0x0096: 0x00a2, # CENT SIGN 0x0097: 0x015a, # LATIN CAPITAL LETTER S WITH ACUTE 0x0098: 0x015b, # LATIN SMALL LETTER S WITH ACUTE 0x0099: 0x00d6, # LATIN CAPITAL LETTER O WITH DIAERESIS 0x009a: 0x00dc, # LATIN CAPITAL LETTER U WITH DIAERESIS 0x009b: 0x00f8, # LATIN SMALL LETTER O WITH STROKE 0x009c: 0x00a3, # POUND SIGN 0x009d: 0x00d8, # LATIN CAPITAL LETTER O WITH STROKE 0x009e: 0x00d7, # MULTIPLICATION SIGN 0x009f: 0x00a4, # CURRENCY SIGN 0x00a0: 0x0100, # LATIN CAPITAL LETTER A WITH MACRON 0x00a1: 0x012a, # LATIN CAPITAL LETTER I WITH MACRON 0x00a2: 0x00f3, # LATIN SMALL LETTER O WITH ACUTE 0x00a3: 0x017b, # LATIN CAPITAL LETTER Z WITH DOT ABOVE 0x00a4: 0x017c, # LATIN SMALL LETTER Z WITH DOT ABOVE 0x00a5: 0x017a, # LATIN SMALL LETTER Z WITH ACUTE 0x00a6: 0x201d, # RIGHT DOUBLE QUOTATION MARK 0x00a7: 0x00a6, # BROKEN BAR 0x00a8: 0x00a9, # COPYRIGHT SIGN 0x00a9: 0x00ae, # REGISTERED SIGN 0x00aa: 0x00ac, # NOT SIGN 0x00ab: 0x00bd, # VULGAR FRACTION ONE HALF 0x00ac: 0x00bc, # VULGAR FRACTION ONE QUARTER 0x00ad: 0x0141, # LATIN CAPITAL LETTER L WITH STROKE 0x00ae: 0x00ab, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00af: 0x00bb, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00b0: 0x2591, # LIGHT SHADE 0x00b1: 0x2592, # MEDIUM SHADE 0x00b2: 0x2593, # DARK SHADE 0x00b3: 0x2502, # BOX DRAWINGS LIGHT VERTICAL 0x00b4: 0x2524, # BOX DRAWINGS LIGHT VERTICAL AND LEFT 0x00b5: 0x0104, # LATIN CAPITAL LETTER A WITH OGONEK 0x00b6: 0x010c, # LATIN CAPITAL LETTER C WITH CARON 0x00b7: 0x0118, # LATIN CAPITAL LETTER E WITH OGONEK 0x00b8: 0x0116, # LATIN CAPITAL LETTER E WITH DOT ABOVE 0x00b9: 0x2563, # BOX DRAWINGS DOUBLE VERTICAL AND LEFT 0x00ba: 0x2551, # BOX DRAWINGS DOUBLE VERTICAL 0x00bb: 0x2557, # BOX DRAWINGS DOUBLE DOWN AND LEFT 0x00bc: 0x255d, # BOX DRAWINGS DOUBLE UP AND LEFT 0x00bd: 0x012e, # LATIN CAPITAL LETTER I WITH OGONEK 0x00be: 0x0160, # LATIN CAPITAL LETTER S WITH CARON 0x00bf: 0x2510, # BOX DRAWINGS LIGHT DOWN AND LEFT 0x00c0: 0x2514, # BOX DRAWINGS LIGHT UP AND RIGHT 0x00c1: 0x2534, # BOX DRAWINGS LIGHT UP AND HORIZONTAL 0x00c2: 0x252c, # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL 0x00c3: 0x251c, # BOX DRAWINGS LIGHT VERTICAL AND RIGHT 0x00c4: 0x2500, # BOX DRAWINGS LIGHT HORIZONTAL 0x00c5: 0x253c, # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL 0x00c6: 0x0172, # LATIN CAPITAL LETTER U WITH OGONEK 0x00c7: 0x016a, # LATIN CAPITAL LETTER U WITH MACRON 0x00c8: 0x255a, # BOX DRAWINGS DOUBLE UP AND RIGHT 0x00c9: 0x2554, # BOX DRAWINGS DOUBLE DOWN AND RIGHT 0x00ca: 0x2569, # BOX DRAWINGS DOUBLE UP AND HORIZONTAL 0x00cb: 0x2566, # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL 0x00cc: 0x2560, # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT 0x00cd: 0x2550, # BOX DRAWINGS DOUBLE HORIZONTAL 0x00ce: 0x256c, # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL 0x00cf: 0x017d, # LATIN CAPITAL LETTER Z WITH CARON 0x00d0: 0x0105, # LATIN SMALL LETTER A WITH OGONEK 0x00d1: 0x010d, # LATIN SMALL LETTER C WITH CARON 0x00d2: 0x0119, # LATIN SMALL LETTER E WITH OGONEK 0x00d3: 0x0117, # LATIN SMALL LETTER E WITH DOT ABOVE 0x00d4: 0x012f, # LATIN SMALL LETTER I WITH OGONEK 0x00d5: 0x0161, # LATIN SMALL LETTER S WITH CARON 0x00d6: 0x0173, # LATIN SMALL LETTER U WITH OGONEK 0x00d7: 0x016b, # LATIN SMALL LETTER U WITH MACRON 0x00d8: 0x017e, # LATIN SMALL LETTER Z WITH CARON 0x00d9: 0x2518, # BOX DRAWINGS LIGHT UP AND LEFT 0x00da: 0x250c, # BOX DRAWINGS LIGHT DOWN AND RIGHT 0x00db: 0x2588, # FULL BLOCK 0x00dc: 0x2584, # LOWER HALF BLOCK 0x00dd: 0x258c, # LEFT HALF BLOCK 0x00de: 0x2590, # RIGHT HALF BLOCK 0x00df: 0x2580, # UPPER HALF BLOCK 0x00e0: 0x00d3, # LATIN CAPITAL LETTER O WITH ACUTE 0x00e1: 0x00df, # LATIN SMALL LETTER SHARP S (GERMAN) 0x00e2: 0x014c, # LATIN CAPITAL LETTER O WITH MACRON 0x00e3: 0x0143, # LATIN CAPITAL LETTER N WITH ACUTE 0x00e4: 0x00f5, # LATIN SMALL LETTER O WITH TILDE 0x00e5: 0x00d5, # LATIN CAPITAL LETTER O WITH TILDE 0x00e6: 0x00b5, # MICRO SIGN 0x00e7: 0x0144, # LATIN SMALL LETTER N WITH ACUTE 0x00e8: 0x0136, # LATIN CAPITAL LETTER K WITH CEDILLA 0x00e9: 0x0137, # LATIN SMALL LETTER K WITH CEDILLA 0x00ea: 0x013b, # LATIN CAPITAL LETTER L WITH CEDILLA 0x00eb: 0x013c, # LATIN SMALL LETTER L WITH CEDILLA 0x00ec: 0x0146, # LATIN SMALL LETTER N WITH CEDILLA 0x00ed: 0x0112, # LATIN CAPITAL LETTER E WITH MACRON 0x00ee: 0x0145, # LATIN CAPITAL LETTER N WITH CEDILLA 0x00ef: 0x2019, # RIGHT SINGLE QUOTATION MARK 0x00f0: 0x00ad, # SOFT HYPHEN 0x00f1: 0x00b1, # PLUS-MINUS SIGN 0x00f2: 0x201c, # LEFT DOUBLE QUOTATION MARK 0x00f3: 0x00be, # VULGAR FRACTION THREE QUARTERS 0x00f4: 0x00b6, # PILCROW SIGN 0x00f5: 0x00a7, # SECTION SIGN 0x00f6: 0x00f7, # DIVISION SIGN 0x00f7: 0x201e, # DOUBLE LOW-9 QUOTATION MARK 0x00f8: 0x00b0, # DEGREE SIGN 0x00f9: 0x2219, # BULLET OPERATOR 0x00fa: 0x00b7, # MIDDLE DOT 0x00fb: 0x00b9, # SUPERSCRIPT ONE 0x00fc: 0x00b3, # SUPERSCRIPT THREE 0x00fd: 0x00b2, # SUPERSCRIPT TWO 0x00fe: 0x25a0, # BLACK SQUARE 0x00ff: 0x00a0, # NO-BREAK SPACE }) ### Decoding Table decoding_table = ( u'\x00' # 0x0000 -> NULL u'\x01' # 0x0001 -> START OF HEADING u'\x02' # 0x0002 -> START OF TEXT u'\x03' # 0x0003 -> END OF TEXT u'\x04' # 0x0004 -> END OF TRANSMISSION u'\x05' # 0x0005 -> ENQUIRY u'\x06' # 0x0006 -> ACKNOWLEDGE u'\x07' # 0x0007 -> BELL u'\x08' # 0x0008 -> BACKSPACE u'\t' # 0x0009 -> HORIZONTAL TABULATION u'\n' # 0x000a -> LINE FEED u'\x0b' # 0x000b -> VERTICAL TABULATION u'\x0c' # 0x000c -> FORM FEED u'\r' # 0x000d -> CARRIAGE RETURN u'\x0e' # 0x000e -> SHIFT OUT u'\x0f' # 0x000f -> SHIFT IN u'\x10' # 0x0010 -> DATA LINK ESCAPE u'\x11' # 0x0011 -> DEVICE CONTROL ONE u'\x12' # 0x0012 -> DEVICE CONTROL TWO u'\x13' # 0x0013 -> DEVICE CONTROL THREE u'\x14' # 0x0014 -> DEVICE CONTROL FOUR u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE u'\x16' # 0x0016 -> SYNCHRONOUS IDLE u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK u'\x18' # 0x0018 -> CANCEL u'\x19' # 0x0019 -> END OF MEDIUM u'\x1a' # 0x001a -> SUBSTITUTE u'\x1b' # 0x001b -> ESCAPE u'\x1c' # 0x001c -> FILE SEPARATOR u'\x1d' # 0x001d -> GROUP SEPARATOR u'\x1e' # 0x001e -> RECORD SEPARATOR u'\x1f' # 0x001f -> UNIT SEPARATOR u' ' # 0x0020 -> SPACE u'!' # 0x0021 -> EXCLAMATION MARK u'"' # 0x0022 -> QUOTATION MARK u'#' # 0x0023 -> NUMBER SIGN u'$' # 0x0024 -> DOLLAR SIGN u'%' # 0x0025 -> PERCENT SIGN u'&' # 0x0026 -> AMPERSAND u"'" # 0x0027 -> APOSTROPHE u'(' # 0x0028 -> LEFT PARENTHESIS u')' # 0x0029 -> RIGHT PARENTHESIS u'*' # 0x002a -> ASTERISK u'+' # 0x002b -> PLUS SIGN u',' # 0x002c -> COMMA u'-' # 0x002d -> HYPHEN-MINUS u'.' # 0x002e -> FULL STOP u'/' # 0x002f -> SOLIDUS u'0' # 0x0030 -> DIGIT ZERO u'1' # 0x0031 -> DIGIT ONE u'2' # 0x0032 -> DIGIT TWO u'3' # 0x0033 -> DIGIT THREE u'4' # 0x0034 -> DIGIT FOUR u'5' # 0x0035 -> DIGIT FIVE u'6' # 0x0036 -> DIGIT SIX u'7' # 0x0037 -> DIGIT SEVEN u'8' # 0x0038 -> DIGIT EIGHT u'9' # 0x0039 -> DIGIT NINE u':' # 0x003a -> COLON u';' # 0x003b -> SEMICOLON u'<' # 0x003c -> LESS-THAN SIGN u'=' # 0x003d -> EQUALS SIGN u'>' # 0x003e -> GREATER-THAN SIGN u'?' # 0x003f -> QUESTION MARK u'@' # 0x0040 -> COMMERCIAL AT u'A' # 0x0041 -> LATIN CAPITAL LETTER A u'B' # 0x0042 -> LATIN CAPITAL LETTER B u'C' # 0x0043 -> LATIN CAPITAL LETTER C u'D' # 0x0044 -> LATIN CAPITAL LETTER D u'E' # 0x0045 -> LATIN CAPITAL LETTER E u'F' # 0x0046 -> LATIN CAPITAL LETTER F u'G' # 0x0047 -> LATIN CAPITAL LETTER G u'H' # 0x0048 -> LATIN CAPITAL LETTER H u'I' # 0x0049 -> LATIN CAPITAL LETTER I u'J' # 0x004a -> LATIN CAPITAL LETTER J u'K' # 0x004b -> LATIN CAPITAL LETTER K u'L' # 0x004c -> LATIN CAPITAL LETTER L u'M' # 0x004d -> LATIN CAPITAL LETTER M u'N' # 0x004e -> LATIN CAPITAL LETTER N u'O' # 0x004f -> LATIN CAPITAL LETTER O u'P' # 0x0050 -> LATIN CAPITAL LETTER P u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q u'R' # 0x0052 -> LATIN CAPITAL LETTER R u'S' # 0x0053 -> LATIN CAPITAL LETTER S u'T' # 0x0054 -> LATIN CAPITAL LETTER T u'U' # 0x0055 -> LATIN CAPITAL LETTER U u'V' # 0x0056 -> LATIN CAPITAL LETTER V u'W' # 0x0057 -> LATIN CAPITAL LETTER W u'X' # 0x0058 -> LATIN CAPITAL LETTER X u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y u'Z' # 0x005a -> LATIN CAPITAL LETTER Z u'[' # 0x005b -> LEFT SQUARE BRACKET u'\\' # 0x005c -> REVERSE SOLIDUS u']' # 0x005d -> RIGHT SQUARE BRACKET u'^' # 0x005e -> CIRCUMFLEX ACCENT u'_' # 0x005f -> LOW LINE u'`' # 0x0060 -> GRAVE ACCENT u'a' # 0x0061 -> LATIN SMALL LETTER A u'b' # 0x0062 -> LATIN SMALL LETTER B u'c' # 0x0063 -> LATIN SMALL LETTER C u'd' # 0x0064 -> LATIN SMALL LETTER D u'e' # 0x0065 -> LATIN SMALL LETTER E u'f' # 0x0066 -> LATIN SMALL LETTER F u'g' # 0x0067 -> LATIN SMALL LETTER G u'h' # 0x0068 -> LATIN SMALL LETTER H u'i' # 0x0069 -> LATIN SMALL LETTER I u'j' # 0x006a -> LATIN SMALL LETTER J u'k' # 0x006b -> LATIN SMALL LETTER K u'l' # 0x006c -> LATIN SMALL LETTER L u'm' # 0x006d -> LATIN SMALL LETTER M u'n' # 0x006e -> LATIN SMALL LETTER N u'o' # 0x006f -> LATIN SMALL LETTER O u'p' # 0x0070 -> LATIN SMALL LETTER P u'q' # 0x0071 -> LATIN SMALL LETTER Q u'r' # 0x0072 -> LATIN SMALL LETTER R u's' # 0x0073 -> LATIN SMALL LETTER S u't' # 0x0074 -> LATIN SMALL LETTER T u'u' # 0x0075 -> LATIN SMALL LETTER U u'v' # 0x0076 -> LATIN SMALL LETTER V u'w' # 0x0077 -> LATIN SMALL LETTER W u'x' # 0x0078 -> LATIN SMALL LETTER X u'y' # 0x0079 -> LATIN SMALL LETTER Y u'z' # 0x007a -> LATIN SMALL LETTER Z u'{' # 0x007b -> LEFT CURLY BRACKET u'|' # 0x007c -> VERTICAL LINE u'}' # 0x007d -> RIGHT CURLY BRACKET u'~' # 0x007e -> TILDE u'\x7f' # 0x007f -> DELETE u'\u0106' # 0x0080 -> LATIN CAPITAL LETTER C WITH ACUTE u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE u'\u0101' # 0x0083 -> LATIN SMALL LETTER A WITH MACRON u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS u'\u0123' # 0x0085 -> LATIN SMALL LETTER G WITH CEDILLA u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE u'\u0107' # 0x0087 -> LATIN SMALL LETTER C WITH ACUTE u'\u0142' # 0x0088 -> LATIN SMALL LETTER L WITH STROKE u'\u0113' # 0x0089 -> LATIN SMALL LETTER E WITH MACRON u'\u0156' # 0x008a -> LATIN CAPITAL LETTER R WITH CEDILLA u'\u0157' # 0x008b -> LATIN SMALL LETTER R WITH CEDILLA u'\u012b' # 0x008c -> LATIN SMALL LETTER I WITH MACRON u'\u0179' # 0x008d -> LATIN CAPITAL LETTER Z WITH ACUTE u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE u'\u014d' # 0x0093 -> LATIN SMALL LETTER O WITH MACRON u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS u'\u0122' # 0x0095 -> LATIN CAPITAL LETTER G WITH CEDILLA u'\xa2' # 0x0096 -> CENT SIGN u'\u015a' # 0x0097 -> LATIN CAPITAL LETTER S WITH ACUTE u'\u015b' # 0x0098 -> LATIN SMALL LETTER S WITH ACUTE u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE u'\xa3' # 0x009c -> POUND SIGN u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE u'\xd7' # 0x009e -> MULTIPLICATION SIGN u'\xa4' # 0x009f -> CURRENCY SIGN u'\u0100' # 0x00a0 -> LATIN CAPITAL LETTER A WITH MACRON u'\u012a' # 0x00a1 -> LATIN CAPITAL LETTER I WITH MACRON u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE u'\u017b' # 0x00a3 -> LATIN CAPITAL LETTER Z WITH DOT ABOVE u'\u017c' # 0x00a4 -> LATIN SMALL LETTER Z WITH DOT ABOVE u'\u017a' # 0x00a5 -> LATIN SMALL LETTER Z WITH ACUTE u'\u201d' # 0x00a6 -> RIGHT DOUBLE QUOTATION MARK u'\xa6' # 0x00a7 -> BROKEN BAR u'\xa9' # 0x00a8 -> COPYRIGHT SIGN u'\xae' # 0x00a9 -> REGISTERED SIGN u'\xac' # 0x00aa -> NOT SIGN u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER u'\u0141' # 0x00ad -> LATIN CAPITAL LETTER L WITH STROKE u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\u2591' # 0x00b0 -> LIGHT SHADE u'\u2592' # 0x00b1 -> MEDIUM SHADE u'\u2593' # 0x00b2 -> DARK SHADE u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT u'\u0104' # 0x00b5 -> LATIN CAPITAL LETTER A WITH OGONEK u'\u010c' # 0x00b6 -> LATIN CAPITAL LETTER C WITH CARON u'\u0118' # 0x00b7 -> LATIN CAPITAL LETTER E WITH OGONEK u'\u0116' # 0x00b8 -> LATIN CAPITAL LETTER E WITH DOT ABOVE u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT u'\u012e' # 0x00bd -> LATIN CAPITAL LETTER I WITH OGONEK u'\u0160' # 0x00be -> LATIN CAPITAL LETTER S WITH CARON u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL u'\u0172' # 0x00c6 -> LATIN CAPITAL LETTER U WITH OGONEK u'\u016a' # 0x00c7 -> LATIN CAPITAL LETTER U WITH MACRON u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL u'\u017d' # 0x00cf -> LATIN CAPITAL LETTER Z WITH CARON u'\u0105' # 0x00d0 -> LATIN SMALL LETTER A WITH OGONEK u'\u010d' # 0x00d1 -> LATIN SMALL LETTER C WITH CARON u'\u0119' # 0x00d2 -> LATIN SMALL LETTER E WITH OGONEK u'\u0117' # 0x00d3 -> LATIN SMALL LETTER E WITH DOT ABOVE u'\u012f' # 0x00d4 -> LATIN SMALL LETTER I WITH OGONEK u'\u0161' # 0x00d5 -> LATIN SMALL LETTER S WITH CARON u'\u0173' # 0x00d6 -> LATIN SMALL LETTER U WITH OGONEK u'\u016b' # 0x00d7 -> LATIN SMALL LETTER U WITH MACRON u'\u017e' # 0x00d8 -> LATIN SMALL LETTER Z WITH CARON u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT u'\u2588' # 0x00db -> FULL BLOCK u'\u2584' # 0x00dc -> LOWER HALF BLOCK u'\u258c' # 0x00dd -> LEFT HALF BLOCK u'\u2590' # 0x00de -> RIGHT HALF BLOCK u'\u2580' # 0x00df -> UPPER HALF BLOCK u'\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S (GERMAN) u'\u014c' # 0x00e2 -> LATIN CAPITAL LETTER O WITH MACRON u'\u0143' # 0x00e3 -> LATIN CAPITAL LETTER N WITH ACUTE u'\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE u'\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE u'\xb5' # 0x00e6 -> MICRO SIGN u'\u0144' # 0x00e7 -> LATIN SMALL LETTER N WITH ACUTE u'\u0136' # 0x00e8 -> LATIN CAPITAL LETTER K WITH CEDILLA u'\u0137' # 0x00e9 -> LATIN SMALL LETTER K WITH CEDILLA u'\u013b' # 0x00ea -> LATIN CAPITAL LETTER L WITH CEDILLA u'\u013c' # 0x00eb -> LATIN SMALL LETTER L WITH CEDILLA u'\u0146' # 0x00ec -> LATIN SMALL LETTER N WITH CEDILLA u'\u0112' # 0x00ed -> LATIN CAPITAL LETTER E WITH MACRON u'\u0145' # 0x00ee -> LATIN CAPITAL LETTER N WITH CEDILLA u'\u2019' # 0x00ef -> RIGHT SINGLE QUOTATION MARK u'\xad' # 0x00f0 -> SOFT HYPHEN u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN u'\u201c' # 0x00f2 -> LEFT DOUBLE QUOTATION MARK u'\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS u'\xb6' # 0x00f4 -> PILCROW SIGN u'\xa7' # 0x00f5 -> SECTION SIGN u'\xf7' # 0x00f6 -> DIVISION SIGN u'\u201e' # 0x00f7 -> DOUBLE LOW-9 QUOTATION MARK u'\xb0' # 0x00f8 -> DEGREE SIGN u'\u2219' # 0x00f9 -> BULLET OPERATOR u'\xb7' # 0x00fa -> MIDDLE DOT u'\xb9' # 0x00fb -> SUPERSCRIPT ONE u'\xb3' # 0x00fc -> SUPERSCRIPT THREE u'\xb2' # 0x00fd -> SUPERSCRIPT TWO u'\u25a0' # 0x00fe -> BLACK SQUARE u'\xa0' # 0x00ff -> NO-BREAK SPACE ) ### Encoding Map encoding_map = { 0x0000: 0x0000, # NULL 0x0001: 0x0001, # START OF HEADING 0x0002: 0x0002, # START OF TEXT 0x0003: 0x0003, # END OF TEXT 0x0004: 0x0004, # END OF TRANSMISSION 0x0005: 0x0005, # ENQUIRY 0x0006: 0x0006, # ACKNOWLEDGE 0x0007: 0x0007, # BELL 0x0008: 0x0008, # BACKSPACE 0x0009: 0x0009, # HORIZONTAL TABULATION 0x000a: 0x000a, # LINE FEED 0x000b: 0x000b, # VERTICAL TABULATION 0x000c: 0x000c, # FORM FEED 0x000d: 0x000d, # CARRIAGE RETURN 0x000e: 0x000e, # SHIFT OUT 0x000f: 0x000f, # SHIFT IN 0x0010: 0x0010, # DATA LINK ESCAPE 0x0011: 0x0011, # DEVICE CONTROL ONE 0x0012: 0x0012, # DEVICE CONTROL TWO 0x0013: 0x0013, # DEVICE CONTROL THREE 0x0014: 0x0014, # DEVICE CONTROL FOUR 0x0015: 0x0015, # NEGATIVE ACKNOWLEDGE 0x0016: 0x0016, # SYNCHRONOUS IDLE 0x0017: 0x0017, # END OF TRANSMISSION BLOCK 0x0018: 0x0018, # CANCEL 0x0019: 0x0019, # END OF MEDIUM 0x001a: 0x001a, # SUBSTITUTE 0x001b: 0x001b, # ESCAPE 0x001c: 0x001c, # FILE SEPARATOR 0x001d: 0x001d, # GROUP SEPARATOR 0x001e: 0x001e, # RECORD SEPARATOR 0x001f: 0x001f, # UNIT SEPARATOR 0x0020: 0x0020, # SPACE 0x0021: 0x0021, # EXCLAMATION MARK 0x0022: 0x0022, # QUOTATION MARK 0x0023: 0x0023, # NUMBER SIGN 0x0024: 0x0024, # DOLLAR SIGN 0x0025: 0x0025, # PERCENT SIGN 0x0026: 0x0026, # AMPERSAND 0x0027: 0x0027, # APOSTROPHE 0x0028: 0x0028, # LEFT PARENTHESIS 0x0029: 0x0029, # RIGHT PARENTHESIS 0x002a: 0x002a, # ASTERISK 0x002b: 0x002b, # PLUS SIGN 0x002c: 0x002c, # COMMA 0x002d: 0x002d, # HYPHEN-MINUS 0x002e: 0x002e, # FULL STOP 0x002f: 0x002f, # SOLIDUS 0x0030: 0x0030, # DIGIT ZERO 0x0031: 0x0031, # DIGIT ONE 0x0032: 0x0032, # DIGIT TWO 0x0033: 0x0033, # DIGIT THREE 0x0034: 0x0034, # DIGIT FOUR 0x0035: 0x0035, # DIGIT FIVE 0x0036: 0x0036, # DIGIT SIX 0x0037: 0x0037, # DIGIT SEVEN 0x0038: 0x0038, # DIGIT EIGHT 0x0039: 0x0039, # DIGIT NINE 0x003a: 0x003a, # COLON 0x003b: 0x003b, # SEMICOLON 0x003c: 0x003c, # LESS-THAN SIGN 0x003d: 0x003d, # EQUALS SIGN 0x003e: 0x003e, # GREATER-THAN SIGN 0x003f: 0x003f, # QUESTION MARK 0x0040: 0x0040, # COMMERCIAL AT 0x0041: 0x0041, # LATIN CAPITAL LETTER A 0x0042: 0x0042, # LATIN CAPITAL LETTER B 0x0043: 0x0043, # LATIN CAPITAL LETTER C 0x0044: 0x0044, # LATIN CAPITAL LETTER D 0x0045: 0x0045, # LATIN CAPITAL LETTER E 0x0046: 0x0046, # LATIN CAPITAL LETTER F 0x0047: 0x0047, # LATIN CAPITAL LETTER G 0x0048: 0x0048, # LATIN CAPITAL LETTER H 0x0049: 0x0049, # LATIN CAPITAL LETTER I 0x004a: 0x004a, # LATIN CAPITAL LETTER J 0x004b: 0x004b, # LATIN CAPITAL LETTER K 0x004c: 0x004c, # LATIN CAPITAL LETTER L 0x004d: 0x004d, # LATIN CAPITAL LETTER M 0x004e: 0x004e, # LATIN CAPITAL LETTER N 0x004f: 0x004f, # LATIN CAPITAL LETTER O 0x0050: 0x0050, # LATIN CAPITAL LETTER P 0x0051: 0x0051, # LATIN CAPITAL LETTER Q 0x0052: 0x0052, # LATIN CAPITAL LETTER R 0x0053: 0x0053, # LATIN CAPITAL LETTER S 0x0054: 0x0054, # LATIN CAPITAL LETTER T 0x0055: 0x0055, # LATIN CAPITAL LETTER U 0x0056: 0x0056, # LATIN CAPITAL LETTER V 0x0057: 0x0057, # LATIN CAPITAL LETTER W 0x0058: 0x0058, # LATIN CAPITAL LETTER X 0x0059: 0x0059, # LATIN CAPITAL LETTER Y 0x005a: 0x005a, # LATIN CAPITAL LETTER Z 0x005b: 0x005b, # LEFT SQUARE BRACKET 0x005c: 0x005c, # REVERSE SOLIDUS 0x005d: 0x005d, # RIGHT SQUARE BRACKET 0x005e: 0x005e, # CIRCUMFLEX ACCENT 0x005f: 0x005f, # LOW LINE 0x0060: 0x0060, # GRAVE ACCENT 0x0061: 0x0061, # LATIN SMALL LETTER A 0x0062: 0x0062, # LATIN SMALL LETTER B 0x0063: 0x0063, # LATIN SMALL LETTER C 0x0064: 0x0064, # LATIN SMALL LETTER D 0x0065: 0x0065, # LATIN SMALL LETTER E 0x0066: 0x0066, # LATIN SMALL LETTER F 0x0067: 0x0067, # LATIN SMALL LETTER G 0x0068: 0x0068, # LATIN SMALL LETTER H 0x0069: 0x0069, # LATIN SMALL LETTER I 0x006a: 0x006a, # LATIN SMALL LETTER J 0x006b: 0x006b, # LATIN SMALL LETTER K 0x006c: 0x006c, # LATIN SMALL LETTER L 0x006d: 0x006d, # LATIN SMALL LETTER M 0x006e: 0x006e, # LATIN SMALL LETTER N 0x006f: 0x006f, # LATIN SMALL LETTER O 0x0070: 0x0070, # LATIN SMALL LETTER P 0x0071: 0x0071, # LATIN SMALL LETTER Q 0x0072: 0x0072, # LATIN SMALL LETTER R 0x0073: 0x0073, # LATIN SMALL LETTER S 0x0074: 0x0074, # LATIN SMALL LETTER T 0x0075: 0x0075, # LATIN SMALL LETTER U 0x0076: 0x0076, # LATIN SMALL LETTER V 0x0077: 0x0077, # LATIN SMALL LETTER W 0x0078: 0x0078, # LATIN SMALL LETTER X 0x0079: 0x0079, # LATIN SMALL LETTER Y 0x007a: 0x007a, # LATIN SMALL LETTER Z 0x007b: 0x007b, # LEFT CURLY BRACKET 0x007c: 0x007c, # VERTICAL LINE 0x007d: 0x007d, # RIGHT CURLY BRACKET 0x007e: 0x007e, # TILDE 0x007f: 0x007f, # DELETE 0x00a0: 0x00ff, # NO-BREAK SPACE 0x00a2: 0x0096, # CENT SIGN 0x00a3: 0x009c, # POUND SIGN 0x00a4: 0x009f, # CURRENCY SIGN 0x00a6: 0x00a7, # BROKEN BAR 0x00a7: 0x00f5, # SECTION SIGN 0x00a9: 0x00a8, # COPYRIGHT SIGN 0x00ab: 0x00ae, # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00ac: 0x00aa, # NOT SIGN 0x00ad: 0x00f0, # SOFT HYPHEN 0x00ae: 0x00a9, # REGISTERED SIGN 0x00b0: 0x00f8, # DEGREE SIGN 0x00b1: 0x00f1, # PLUS-MINUS SIGN 0x00b2: 0x00fd, # SUPERSCRIPT TWO 0x00b3: 0x00fc, # SUPERSCRIPT THREE 0x00b5: 0x00e6, # MICRO SIGN 0x00b6: 0x00f4, # PILCROW SIGN 0x00b7: 0x00fa, # MIDDLE DOT 0x00b9: 0x00fb, # SUPERSCRIPT ONE 0x00bb: 0x00af, # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 0x00bc: 0x00ac, # VULGAR FRACTION ONE QUARTER 0x00bd: 0x00ab, # VULGAR FRACTION ONE HALF 0x00be: 0x00f3, # VULGAR FRACTION THREE QUARTERS 0x00c4: 0x008e, # LATIN CAPITAL LETTER A WITH DIAERESIS 0x00c5: 0x008f, # LATIN CAPITAL LETTER A WITH RING ABOVE 0x00c6: 0x0092, # LATIN CAPITAL LIGATURE AE 0x00c9: 0x0090, # LATIN CAPITAL LETTER E WITH ACUTE 0x00d3: 0x00e0, # LATIN CAPITAL LETTER O WITH ACUTE 0x00d5: 0x00e5, # LATIN CAPITAL LETTER O WITH TILDE 0x00d6: 0x0099, # LATIN CAPITAL LETTER O WITH DIAERESIS 0x00d7: 0x009e, # MULTIPLICATION SIGN 0x00d8: 0x009d, # LATIN CAPITAL LETTER O WITH STROKE 0x00dc: 0x009a, # LATIN CAPITAL LETTER U WITH DIAERESIS 0x00df: 0x00e1, # LATIN SMALL LETTER SHARP S (GERMAN) 0x00e4: 0x0084, # LATIN SMALL LETTER A WITH DIAERESIS 0x00e5: 0x0086, # LATIN SMALL LETTER A WITH RING ABOVE 0x00e6: 0x0091, # LATIN SMALL LIGATURE AE 0x00e9: 0x0082, # LATIN SMALL LETTER E WITH ACUTE 0x00f3: 0x00a2, # LATIN SMALL LETTER O WITH ACUTE 0x00f5: 0x00e4, # LATIN SMALL LETTER O WITH TILDE 0x00f6: 0x0094, # LATIN SMALL LETTER O WITH DIAERESIS 0x00f7: 0x00f6, # DIVISION SIGN 0x00f8: 0x009b, # LATIN SMALL LETTER O WITH STROKE 0x00fc: 0x0081, # LATIN SMALL LETTER U WITH DIAERESIS 0x0100: 0x00a0, # LATIN CAPITAL LETTER A WITH MACRON 0x0101: 0x0083, # LATIN SMALL LETTER A WITH MACRON 0x0104: 0x00b5, # LATIN CAPITAL LETTER A WITH OGONEK 0x0105: 0x00d0, # LATIN SMALL LETTER A WITH OGONEK 0x0106: 0x0080, # LATIN CAPITAL LETTER C WITH ACUTE 0x0107: 0x0087, # LATIN SMALL LETTER C WITH ACUTE 0x010c: 0x00b6, # LATIN CAPITAL LETTER C WITH CARON 0x010d: 0x00d1, # LATIN SMALL LETTER C WITH CARON 0x0112: 0x00ed, # LATIN CAPITAL LETTER E WITH MACRON 0x0113: 0x0089, # LATIN SMALL LETTER E WITH MACRON 0x0116: 0x00b8, # LATIN CAPITAL LETTER E WITH DOT ABOVE 0x0117: 0x00d3, # LATIN SMALL LETTER E WITH DOT ABOVE 0x0118: 0x00b7, # LATIN CAPITAL LETTER E WITH OGONEK 0x0119: 0x00d2, # LATIN SMALL LETTER E WITH OGONEK 0x0122: 0x0095, # LATIN CAPITAL LETTER G WITH CEDILLA 0x0123: 0x0085, # LATIN SMALL LETTER G WITH CEDILLA 0x012a: 0x00a1, # LATIN CAPITAL LETTER I WITH MACRON 0x012b: 0x008c, # LATIN SMALL LETTER I WITH MACRON 0x012e: 0x00bd, # LATIN CAPITAL LETTER I WITH OGONEK 0x012f: 0x00d4, # LATIN SMALL LETTER I WITH OGONEK 0x0136: 0x00e8, # LATIN CAPITAL LETTER K WITH CEDILLA 0x0137: 0x00e9, # LATIN SMALL LETTER K WITH CEDILLA 0x013b: 0x00ea, # LATIN CAPITAL LETTER L WITH CEDILLA 0x013c: 0x00eb, # LATIN SMALL LETTER L WITH CEDILLA 0x0141: 0x00ad, # LATIN CAPITAL LETTER L WITH STROKE 0x0142: 0x0088, # LATIN SMALL LETTER L WITH STROKE 0x0143: 0x00e3, # LATIN CAPITAL LETTER N WITH ACUTE 0x0144: 0x00e7, # LATIN SMALL LETTER N WITH ACUTE 0x0145: 0x00ee, # LATIN CAPITAL LETTER N WITH CEDILLA 0x0146: 0x00ec, # LATIN SMALL LETTER N WITH CEDILLA 0x014c: 0x00e2, # LATIN CAPITAL LETTER O WITH MACRON 0x014d: 0x0093, # LATIN SMALL LETTER O WITH MACRON 0x0156: 0x008a, # LATIN CAPITAL LETTER R WITH CEDILLA 0x0157: 0x008b, # LATIN SMALL LETTER R WITH CEDILLA 0x015a: 0x0097, # LATIN CAPITAL LETTER S WITH ACUTE 0x015b: 0x0098, # LATIN SMALL LETTER S WITH ACUTE 0x0160: 0x00be, # LATIN CAPITAL LETTER S WITH CARON 0x0161: 0x00d5, # LATIN SMALL LETTER S WITH CARON 0x016a: 0x00c7, # LATIN CAPITAL LETTER U WITH MACRON 0x016b: 0x00d7, # LATIN SMALL LETTER U WITH MACRON 0x0172: 0x00c6, # LATIN CAPITAL LETTER U WITH OGONEK 0x0173: 0x00d6, # LATIN SMALL LETTER U WITH OGONEK 0x0179: 0x008d, # LATIN CAPITAL LETTER Z WITH ACUTE 0x017a: 0x00a5, # LATIN SMALL LETTER Z WITH ACUTE 0x017b: 0x00a3, # LATIN CAPITAL LETTER Z WITH DOT ABOVE 0x017c: 0x00a4, # LATIN SMALL LETTER Z WITH DOT ABOVE 0x017d: 0x00cf, # LATIN CAPITAL LETTER Z WITH CARON 0x017e: 0x00d8, # LATIN SMALL LETTER Z WITH CARON 0x2019: 0x00ef, # RIGHT SINGLE QUOTATION MARK 0x201c: 0x00f2, # LEFT DOUBLE QUOTATION MARK 0x201d: 0x00a6, # RIGHT DOUBLE QUOTATION MARK 0x201e: 0x00f7, # DOUBLE LOW-9 QUOTATION MARK 0x2219: 0x00f9, # BULLET OPERATOR 0x2500: 0x00c4, # BOX DRAWINGS LIGHT HORIZONTAL 0x2502: 0x00b3, # BOX DRAWINGS LIGHT VERTICAL 0x250c: 0x00da, # BOX DRAWINGS LIGHT DOWN AND RIGHT 0x2510: 0x00bf, # BOX DRAWINGS LIGHT DOWN AND LEFT 0x2514: 0x00c0, # BOX DRAWINGS LIGHT UP AND RIGHT 0x2518: 0x00d9, # BOX DRAWINGS LIGHT UP AND LEFT 0x251c: 0x00c3, # BOX DRAWINGS LIGHT VERTICAL AND RIGHT 0x2524: 0x00b4, # BOX DRAWINGS LIGHT VERTICAL AND LEFT 0x252c: 0x00c2, # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL 0x2534: 0x00c1, # BOX DRAWINGS LIGHT UP AND HORIZONTAL 0x253c: 0x00c5, # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL 0x2550: 0x00cd, # BOX DRAWINGS DOUBLE HORIZONTAL 0x2551: 0x00ba, # BOX DRAWINGS DOUBLE VERTICAL 0x2554: 0x00c9, # BOX DRAWINGS DOUBLE DOWN AND RIGHT 0x2557: 0x00bb, # BOX DRAWINGS DOUBLE DOWN AND LEFT 0x255a: 0x00c8, # BOX DRAWINGS DOUBLE UP AND RIGHT 0x255d: 0x00bc, # BOX DRAWINGS DOUBLE UP AND LEFT 0x2560: 0x00cc, # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT 0x2563: 0x00b9, # BOX DRAWINGS DOUBLE VERTICAL AND LEFT 0x2566: 0x00cb, # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL 0x2569: 0x00ca, # BOX DRAWINGS DOUBLE UP AND HORIZONTAL 0x256c: 0x00ce, # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL 0x2580: 0x00df, # UPPER HALF BLOCK 0x2584: 0x00dc, # LOWER HALF BLOCK 0x2588: 0x00db, # FULL BLOCK 0x258c: 0x00dd, # LEFT HALF BLOCK 0x2590: 0x00de, # RIGHT HALF BLOCK 0x2591: 0x00b0, # LIGHT SHADE 0x2592: 0x00b1, # MEDIUM SHADE 0x2593: 0x00b2, # DARK SHADE 0x25a0: 0x00fe, # BLACK SQUARE }
apache-2.0
[ 624, 2018, 17660, 12340, 13732, 7667, 12710, 4046, 687, 283, 27839, 4149, 15, 17233, 51, 2161, 15, 4222, 15, 2890, 12710, 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, 1130, 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, 1130, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 1850, 12710, 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, 199, 5680, 27368, 9672, 199, 199, 12796, 63, 1130, 275, 6010, 14, 1875, 63, 5582, 63, 807, 8, 1842, 8, 3912, 430, 199, 12796, 63, 1130, 14, 873, 2561, 272, 378, 88, 23686, 26, 378, 88, 614, 1690, 12, 258, 327, 221, 1948, 2678, 1578, 445, 1663, 8123, 272, 378, 88, 383, 2835, 26, 378, 88, 383, 3003, 12, 258, 327, 221, 1948, 2516, 1578, 738, 1663, 9680, 272, 378, 88, 383, 2564, 26, 378, 88, 383, 69, 25, 12, 258, 327, 221, 1948, 2516, 1578, 662, 1663, 8123, 272, 378, 88, 383, 2658, 26, 378, 88, 11502, 12, 258, 327, 221, 1948, 2516, 1578, 437, 1663, 22847, 272, 378, 88, 30935, 26, 378, 88, 383, 69, 20, 12, 258, 327, 221, 1948, 2516, 1578, 437, 1663, 9680, 272, 378, 88, 383, 2426, 26, 378, 88, 29555, 12, 258, 327, 221, 1948, 2516, 1578, 598, 1663, 15609, 272, 378, 88, 31743, 26, 378, 88, 383, 69, 21, 12, 258, 327, 221, 1948, 2516, 1578, 437, 1663, 24809, 16054, 272, 378, 88, 383, 1555, 26, 378, 88, 32586, 12, 258, 327, 221, 1948, 2516, 1578, 445, 1663, 8123, 272, 378, 88, 31419, 26, 378, 88, 29556, 12, 258, 327, 221, 1948, 2516, 1578, 491, 1663, 22755, 272, 378, 88, 383, 1407, 26, 378, 88, 614, 969, 12, 258, 327, 221, 1948, 2516, 1578, 662, 1663, 22847, 272, 378, 88, 8662, 65, 26, 378, 88, 614, 1367, 12, 258, 327, 221, 1948, 2678, 1578, 820, 1663, 15609, 272, 378, 88, 8662, 66, 26, 378, 88, 614, 1641, 12, 258, 327, 221, 1948, 2516, 1578, 820, 1663, 15609, 272, 378, 88, 8662, 67, 26, 378, 88, 11533, 66, 12, 258, 327, 221, 1948, 2516, 1578, 473, 1663, 22847, 272, 378, 88, 8662, 68, 26, 378, 88, 614, 1965, 12, 258, 327, 221, 1948, 2678, 1578, 3107, 1663, 8123, 272, 378, 88, 8662, 69, 26, 378, 88, 383, 67, 20, 12, 258, 327, 221, 1948, 2678, 1578, 437, 1663, 9680, 272, 378, 88, 8662, 70, 26, 378, 88, 383, 67, 21, 12, 258, 327, 221, 1948, 2678, 1578, 437, 1663, 24809, 16054, 272, 378, 88, 28875, 26, 378, 88, 383, 67, 25, 12, 258, 327, 221, 1948, 2678, 1578, 662, 1663, 8123, 272, 378, 88, 383, 3328, 26, 378, 88, 383, 69, 22, 12, 258, 327, 221, 1948, 2516, 27427, 24475, 272, 378, 88, 383, 2942, 26, 378, 88, 383, 67, 22, 12, 258, 327, 221, 1948, 2678, 27427, 24475, 272, 378, 88, 383, 3129, 26, 378, 88, 10752, 68, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 22847, 272, 378, 88, 383, 2635, 26, 378, 88, 383, 70, 22, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 9680, 272, 378, 88, 383, 2720, 26, 378, 88, 614, 1081, 12, 258, 327, 221, 1948, 2678, 1578, 598, 1663, 15609, 272, 378, 88, 383, 2534, 26, 378, 88, 383, 65, 18, 12, 258, 327, 221, 445, 1309, 5056, 272, 378, 88, 383, 2576, 26, 378, 88, 11164, 65, 12, 258, 327, 221, 1948, 2678, 1578, 428, 1663, 8123, 272, 378, 88, 383, 2905, 26, 378, 88, 11164, 66, 12, 258, 327, 221, 1948, 2516, 1578, 428, 1663, 8123, 272, 378, 88, 29660, 26, 378, 88, 383, 68, 22, 12, 258, 327, 221, 1948, 2678, 1578, 593, 1663, 9680, 272, 378, 88, 8581, 65, 26, 378, 88, 383, 3833, 12, 258, 327, 221, 1948, 2678, 1578, 738, 1663, 9680, 272, 378, 88, 8581, 66, 26, 378, 88, 383, 70, 24, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 22755, 272, 378, 88, 8581, 67, 26, 378, 88, 383, 65, 19, 12, 258, 327, 221, 3625, 6131, 5056, 272, 378, 88, 8581, 68, 26, 378, 88, 383, 68, 24, 12, 258, 327, 221, 1948, 2678, 1578, 593, 1663, 22755, 272, 378, 88, 8581, 69, 26, 378, 88, 383, 68, 23, 12, 258, 327, 221, 24895, 1772, 17939, 5056, 272, 378, 88, 8581, 70, 26, 378, 88, 383, 65, 20, 12, 258, 327, 221, 18715, 24861, 5056, 272, 378, 88, 383, 65, 16, 26, 378, 88, 16569, 12, 258, 327, 221, 1948, 2678, 1578, 437, 1663, 22847, 272, 378, 88, 383, 65, 17, 26, 378, 88, 11533, 65, 12, 258, 327, 221, 1948, 2678, 1578, 473, 1663, 22847, 272, 378, 88, 383, 65, 18, 26, 378, 88, 383, 70, 19, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 8123, 272, 378, 88, 383, 65, 19, 26, 378, 88, 9570, 66, 12, 258, 327, 221, 1948, 2678, 1578, 3107, 1663, 15854, 16054, 272 ]
[ 2018, 17660, 12340, 13732, 7667, 12710, 4046, 687, 283, 27839, 4149, 15, 17233, 51, 2161, 15, 4222, 15, 2890, 12710, 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, 1130, 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, 1130, 2788, 16, 61, 199, 199, 533, 24385, 8, 8933, 14, 16703, 304, 272, 347, 4849, 8, 277, 12, 1324, 12, 4242, 29, 797, 304, 267, 372, 6010, 14, 13391, 63, 2708, 8, 1210, 12, 277, 14, 2550, 12, 12796, 63, 1224, 2788, 16, 61, 199, 199, 533, 24163, 8, 8818, 12, 8933, 14, 16551, 304, 272, 986, 199, 199, 533, 22970, 8, 8818, 12, 8933, 14, 16132, 304, 272, 986, 199, 199, 5680, 14134, 859, 3261, 199, 199, 318, 26116, 837, 272, 372, 6010, 14, 26375, 8, 267, 536, 534, 1850, 12710, 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, 199, 5680, 27368, 9672, 199, 199, 12796, 63, 1130, 275, 6010, 14, 1875, 63, 5582, 63, 807, 8, 1842, 8, 3912, 430, 199, 12796, 63, 1130, 14, 873, 2561, 272, 378, 88, 23686, 26, 378, 88, 614, 1690, 12, 258, 327, 221, 1948, 2678, 1578, 445, 1663, 8123, 272, 378, 88, 383, 2835, 26, 378, 88, 383, 3003, 12, 258, 327, 221, 1948, 2516, 1578, 738, 1663, 9680, 272, 378, 88, 383, 2564, 26, 378, 88, 383, 69, 25, 12, 258, 327, 221, 1948, 2516, 1578, 662, 1663, 8123, 272, 378, 88, 383, 2658, 26, 378, 88, 11502, 12, 258, 327, 221, 1948, 2516, 1578, 437, 1663, 22847, 272, 378, 88, 30935, 26, 378, 88, 383, 69, 20, 12, 258, 327, 221, 1948, 2516, 1578, 437, 1663, 9680, 272, 378, 88, 383, 2426, 26, 378, 88, 29555, 12, 258, 327, 221, 1948, 2516, 1578, 598, 1663, 15609, 272, 378, 88, 31743, 26, 378, 88, 383, 69, 21, 12, 258, 327, 221, 1948, 2516, 1578, 437, 1663, 24809, 16054, 272, 378, 88, 383, 1555, 26, 378, 88, 32586, 12, 258, 327, 221, 1948, 2516, 1578, 445, 1663, 8123, 272, 378, 88, 31419, 26, 378, 88, 29556, 12, 258, 327, 221, 1948, 2516, 1578, 491, 1663, 22755, 272, 378, 88, 383, 1407, 26, 378, 88, 614, 969, 12, 258, 327, 221, 1948, 2516, 1578, 662, 1663, 22847, 272, 378, 88, 8662, 65, 26, 378, 88, 614, 1367, 12, 258, 327, 221, 1948, 2678, 1578, 820, 1663, 15609, 272, 378, 88, 8662, 66, 26, 378, 88, 614, 1641, 12, 258, 327, 221, 1948, 2516, 1578, 820, 1663, 15609, 272, 378, 88, 8662, 67, 26, 378, 88, 11533, 66, 12, 258, 327, 221, 1948, 2516, 1578, 473, 1663, 22847, 272, 378, 88, 8662, 68, 26, 378, 88, 614, 1965, 12, 258, 327, 221, 1948, 2678, 1578, 3107, 1663, 8123, 272, 378, 88, 8662, 69, 26, 378, 88, 383, 67, 20, 12, 258, 327, 221, 1948, 2678, 1578, 437, 1663, 9680, 272, 378, 88, 8662, 70, 26, 378, 88, 383, 67, 21, 12, 258, 327, 221, 1948, 2678, 1578, 437, 1663, 24809, 16054, 272, 378, 88, 28875, 26, 378, 88, 383, 67, 25, 12, 258, 327, 221, 1948, 2678, 1578, 662, 1663, 8123, 272, 378, 88, 383, 3328, 26, 378, 88, 383, 69, 22, 12, 258, 327, 221, 1948, 2516, 27427, 24475, 272, 378, 88, 383, 2942, 26, 378, 88, 383, 67, 22, 12, 258, 327, 221, 1948, 2678, 27427, 24475, 272, 378, 88, 383, 3129, 26, 378, 88, 10752, 68, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 22847, 272, 378, 88, 383, 2635, 26, 378, 88, 383, 70, 22, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 9680, 272, 378, 88, 383, 2720, 26, 378, 88, 614, 1081, 12, 258, 327, 221, 1948, 2678, 1578, 598, 1663, 15609, 272, 378, 88, 383, 2534, 26, 378, 88, 383, 65, 18, 12, 258, 327, 221, 445, 1309, 5056, 272, 378, 88, 383, 2576, 26, 378, 88, 11164, 65, 12, 258, 327, 221, 1948, 2678, 1578, 428, 1663, 8123, 272, 378, 88, 383, 2905, 26, 378, 88, 11164, 66, 12, 258, 327, 221, 1948, 2516, 1578, 428, 1663, 8123, 272, 378, 88, 29660, 26, 378, 88, 383, 68, 22, 12, 258, 327, 221, 1948, 2678, 1578, 593, 1663, 9680, 272, 378, 88, 8581, 65, 26, 378, 88, 383, 3833, 12, 258, 327, 221, 1948, 2678, 1578, 738, 1663, 9680, 272, 378, 88, 8581, 66, 26, 378, 88, 383, 70, 24, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 22755, 272, 378, 88, 8581, 67, 26, 378, 88, 383, 65, 19, 12, 258, 327, 221, 3625, 6131, 5056, 272, 378, 88, 8581, 68, 26, 378, 88, 383, 68, 24, 12, 258, 327, 221, 1948, 2678, 1578, 593, 1663, 22755, 272, 378, 88, 8581, 69, 26, 378, 88, 383, 68, 23, 12, 258, 327, 221, 24895, 1772, 17939, 5056, 272, 378, 88, 8581, 70, 26, 378, 88, 383, 65, 20, 12, 258, 327, 221, 18715, 24861, 5056, 272, 378, 88, 383, 65, 16, 26, 378, 88, 16569, 12, 258, 327, 221, 1948, 2678, 1578, 437, 1663, 22847, 272, 378, 88, 383, 65, 17, 26, 378, 88, 11533, 65, 12, 258, 327, 221, 1948, 2678, 1578, 473, 1663, 22847, 272, 378, 88, 383, 65, 18, 26, 378, 88, 383, 70, 19, 12, 258, 327, 221, 1948, 2516, 1578, 593, 1663, 8123, 272, 378, 88, 383, 65, 19, 26, 378, 88, 9570, 66, 12, 258, 327, 221, 1948, 2678, 1578, 3107, 1663, 15854, 16054, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tinker20/tinker-society
venv/lib/python2.7/site-packages/pip/wheel.py
184
20618
""" Support for installing and building the "wheel" binary package format. """ from __future__ import with_statement import compileall import csv import functools import hashlib import os import re import shutil import sys from base64 import urlsafe_b64encode from email.parser import Parser from pip.backwardcompat import ConfigParser, StringIO from pip.exceptions import InvalidWheelFilename, UnsupportedWheel from pip.locations import distutils_scheme from pip.log import logger from pip import pep425tags from pip.util import call_subprocess, normalize_path, make_path_relative from pip._vendor import pkg_resources from pip._vendor.distlib.scripts import ScriptMaker from pip._vendor import pkg_resources wheel_ext = '.whl' VERSION_COMPATIBLE = (1, 0) def rehash(path, algo='sha256', blocksize=1<<20): """Return (hash, length) for path using hashlib.new(algo)""" h = hashlib.new(algo) length = 0 with open(path, 'rb') as f: block = f.read(blocksize) while block: length += len(block) h.update(block) block = f.read(blocksize) digest = 'sha256='+urlsafe_b64encode(h.digest()).decode('latin1').rstrip('=') return (digest, length) try: unicode def binary(s): if isinstance(s, unicode): return s.encode('ascii') return s except NameError: def binary(s): if isinstance(s, str): return s.encode('ascii') def open_for_csv(name, mode): if sys.version_info[0] < 3: nl = {} bin = 'b' else: nl = { 'newline': '' } bin = '' return open(name, mode + bin, **nl) def fix_script(path): """Replace #!python with #!/path/to/python Return True if file was changed.""" # XXX RECORD hashes will need to be updated if os.path.isfile(path): script = open(path, 'rb') try: firstline = script.readline() if not firstline.startswith(binary('#!python')): return False exename = sys.executable.encode(sys.getfilesystemencoding()) firstline = binary('#!') + exename + binary(os.linesep) rest = script.read() finally: script.close() script = open(path, 'wb') try: script.write(firstline) script.write(rest) finally: script.close() return True dist_info_re = re.compile(r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?) \.dist-info$""", re.VERBOSE) def root_is_purelib(name, wheeldir): """ Return True if the extracted wheel in wheeldir should go into purelib. """ name_folded = name.replace("-", "_") for item in os.listdir(wheeldir): match = dist_info_re.match(item) if match and match.group('name') == name_folded: with open(os.path.join(wheeldir, item, 'WHEEL')) as wheel: for line in wheel: line = line.lower().rstrip() if line == "root-is-purelib: true": return True return False def get_entrypoints(filename): if not os.path.exists(filename): return {}, {} # This is done because you can pass a string to entry_points wrappers which # means that they may or may not be valid INI files. The attempt here is to # strip leading and trailing whitespace in order to make them valid INI # files. with open(filename) as fp: data = StringIO() for line in fp: data.write(line.strip()) data.write("\n") data.seek(0) cp = ConfigParser.RawConfigParser() cp.readfp(data) console = {} gui = {} if cp.has_section('console_scripts'): console = dict(cp.items('console_scripts')) if cp.has_section('gui_scripts'): gui = dict(cp.items('gui_scripts')) return console, gui def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None, pycompile=True, scheme=None): """Install a wheel""" if not scheme: scheme = distutils_scheme(name, user=user, home=home, root=root) if root_is_purelib(name, wheeldir): lib_dir = scheme['purelib'] else: lib_dir = scheme['platlib'] info_dir = [] data_dirs = [] source = wheeldir.rstrip(os.path.sep) + os.path.sep # Record details of the files moved # installed = files copied from the wheel to the destination # changed = files changed while installing (scripts #! line typically) # generated = files newly generated during the install (script wrappers) installed = {} changed = set() generated = [] # Compile all of the pyc files that we're going to be installing if pycompile: compileall.compile_dir(source, force=True, quiet=True) def normpath(src, p): return make_path_relative(src, p).replace(os.path.sep, '/') def record_installed(srcfile, destfile, modified=False): """Map archive RECORD paths to installation RECORD paths.""" oldpath = normpath(srcfile, wheeldir) newpath = normpath(destfile, lib_dir) installed[oldpath] = newpath if modified: changed.add(destfile) def clobber(source, dest, is_base, fixer=None, filter=None): if not os.path.exists(dest): # common for the 'include' path os.makedirs(dest) for dir, subdirs, files in os.walk(source): basedir = dir[len(source):].lstrip(os.path.sep) destdir = os.path.join(dest, basedir) if is_base and basedir.split(os.path.sep, 1)[0].endswith('.data'): continue for s in subdirs: destsubdir = os.path.join(dest, basedir, s) if is_base and basedir == '' and destsubdir.endswith('.data'): data_dirs.append(s) continue elif (is_base and s.endswith('.dist-info') # is self.req.project_name case preserving? and s.lower().startswith(req.project_name.replace('-', '_').lower())): assert not info_dir, 'Multiple .dist-info directories' info_dir.append(destsubdir) for f in files: # Skip unwanted files if filter and filter(f): continue srcfile = os.path.join(dir, f) destfile = os.path.join(dest, basedir, f) # directory creation is lazy and after the file filtering above # to ensure we don't install empty dirs; empty dirs can't be # uninstalled. if not os.path.exists(destdir): os.makedirs(destdir) # use copy2 (not move) to be extra sure we're not moving # directories over; copy2 fails for directories. this would # fail tests (not during released/user execution) shutil.copy2(srcfile, destfile) changed = False if fixer: changed = fixer(destfile) record_installed(srcfile, destfile, changed) clobber(source, lib_dir, True) assert info_dir, "%s .dist-info directory not found" % req # Get the defined entry points ep_file = os.path.join(info_dir[0], 'entry_points.txt') console, gui = get_entrypoints(ep_file) def is_entrypoint_wrapper(name): # EP, EP.exe and EP-script.py are scripts generated for # entry point EP by setuptools if name.lower().endswith('.exe'): matchname = name[:-4] elif name.lower().endswith('-script.py'): matchname = name[:-10] elif name.lower().endswith(".pya"): matchname = name[:-4] else: matchname = name # Ignore setuptools-generated scripts return (matchname in console or matchname in gui) for datadir in data_dirs: fixer = None filter = None for subdir in os.listdir(os.path.join(wheeldir, datadir)): fixer = None if subdir == 'scripts': fixer = fix_script filter = is_entrypoint_wrapper source = os.path.join(wheeldir, datadir, subdir) dest = scheme[subdir] clobber(source, dest, False, fixer=fixer, filter=filter) maker = ScriptMaker(None, scheme['scripts']) # Ensure we don't generate any variants for scripts because this is almost # never what somebody wants. # See https://bitbucket.org/pypa/distlib/issue/35/ maker.variants = set(('', )) # This is required because otherwise distlib creates scripts that are not # executable. # See https://bitbucket.org/pypa/distlib/issue/32/ maker.set_mode = True # Simplify the script and fix the fact that the default script swallows # every single stack trace. # See https://bitbucket.org/pypa/distlib/issue/34/ # See https://bitbucket.org/pypa/distlib/issue/33/ def _get_script_text(entry): return maker.script_template % { "module": entry.prefix, "import_name": entry.suffix.split(".")[0], "func": entry.suffix, } maker._get_script_text = _get_script_text maker.script_template = """# -*- coding: utf-8 -*- import re import sys from %(module)s import %(import_name)s if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(%(func)s()) """ # Special case pip and setuptools to generate versioned wrappers # # The issue is that some projects (specifically, pip and setuptools) use # code in setup.py to create "versioned" entry points - pip2.7 on Python # 2.7, pip3.3 on Python 3.3, etc. But these entry points are baked into # the wheel metadata at build time, and so if the wheel is installed with # a *different* version of Python the entry points will be wrong. The # correct fix for this is to enhance the metadata to be able to describe # such versioned entry points, but that won't happen till Metadata 2.0 is # available. # In the meantime, projects using versioned entry points will either have # incorrect versioned entry points, or they will not be able to distribute # "universal" wheels (i.e., they will need a wheel per Python version). # # Because setuptools and pip are bundled with _ensurepip and virtualenv, # we need to use universal wheels. So, as a stopgap until Metadata 2.0, we # override the versioned entry points in the wheel and generate the # correct ones. This code is purely a short-term measure until Metadat 2.0 # is available. # # To add the level of hack in this section of code, in order to support # ensurepip this code will look for an ``ENSUREPIP_OPTIONS`` environment # variable which will control which version scripts get installed. # # ENSUREPIP_OPTIONS=altinstall # - Only pipX.Y and easy_install-X.Y will be generated and installed # ENSUREPIP_OPTIONS=install # - pipX.Y, pipX, easy_install-X.Y will be generated and installed. Note # that this option is technically if ENSUREPIP_OPTIONS is set and is # not altinstall # DEFAULT # - The default behavior is to install pip, pipX, pipX.Y, easy_install # and easy_install-X.Y. pip_script = console.pop('pip', None) if pip_script: if "ENSUREPIP_OPTIONS" not in os.environ: spec = 'pip = ' + pip_script generated.extend(maker.make(spec)) if os.environ.get("ENSUREPIP_OPTIONS", "") != "altinstall": spec = 'pip%s = %s' % (sys.version[:1], pip_script) generated.extend(maker.make(spec)) spec = 'pip%s = %s' % (sys.version[:3], pip_script) generated.extend(maker.make(spec)) # Delete any other versioned pip entry points pip_ep = [k for k in console if re.match(r'pip(\d(\.\d)?)?$', k)] for k in pip_ep: del console[k] easy_install_script = console.pop('easy_install', None) if easy_install_script: if "ENSUREPIP_OPTIONS" not in os.environ: spec = 'easy_install = ' + easy_install_script generated.extend(maker.make(spec)) spec = 'easy_install-%s = %s' % (sys.version[:3], easy_install_script) generated.extend(maker.make(spec)) # Delete any other versioned easy_install entry points easy_install_ep = [k for k in console if re.match(r'easy_install(-\d\.\d)?$', k)] for k in easy_install_ep: del console[k] # Generate the console and GUI entry points specified in the wheel if len(console) > 0: generated.extend(maker.make_multiple(['%s = %s' % kv for kv in console.items()])) if len(gui) > 0: generated.extend(maker.make_multiple(['%s = %s' % kv for kv in gui.items()], {'gui': True})) record = os.path.join(info_dir[0], 'RECORD') temp_record = os.path.join(info_dir[0], 'RECORD.pip') with open_for_csv(record, 'r') as record_in: with open_for_csv(temp_record, 'w+') as record_out: reader = csv.reader(record_in) writer = csv.writer(record_out) for row in reader: row[0] = installed.pop(row[0], row[0]) if row[0] in changed: row[1], row[2] = rehash(row[0]) writer.writerow(row) for f in generated: h, l = rehash(f) writer.writerow((f, h, l)) for f in installed: writer.writerow((installed[f], '', '')) shutil.move(temp_record, record) def _unique(fn): @functools.wraps(fn) def unique(*args, **kw): seen = set() for item in fn(*args, **kw): if item not in seen: seen.add(item) yield item return unique # TODO: this goes somewhere besides the wheel module @_unique def uninstallation_paths(dist): """ Yield all the uninstallation paths for dist based on RECORD-without-.pyc Yield paths to all the files in RECORD. For each .py file in RECORD, add the .pyc in the same directory. UninstallPathSet.add() takes care of the __pycache__ .pyc. """ from pip.req import FakeFile # circular import r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD'))) for row in r: path = os.path.join(dist.location, row[0]) yield path if path.endswith('.py'): dn, fn = os.path.split(path) base = fn[:-3] path = os.path.join(dn, base+'.pyc') yield path def wheel_version(source_dir): """ Return the Wheel-Version of an extracted wheel, if possible. Otherwise, return False if we couldn't parse / extract it. """ try: dist = [d for d in pkg_resources.find_on_path(None, source_dir)][0] wheel_data = dist.get_metadata('WHEEL') wheel_data = Parser().parsestr(wheel_data) version = wheel_data['Wheel-Version'].strip() version = tuple(map(int, version.split('.'))) return version except: return False def check_compatibility(version, name): """ Raises errors or warns if called with an incompatible Wheel-Version. Pip should refuse to install a Wheel-Version that's a major series ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when installing a version only minor version ahead (e.g 1.2 > 1.1). version: a 2-tuple representing a Wheel-Version (Major, Minor) name: name of wheel or package to raise exception about :raises UnsupportedWheel: when an incompatible Wheel-Version is given """ if not version: raise UnsupportedWheel( "%s is in an unsupported or invalid wheel" % name ) if version[0] > VERSION_COMPATIBLE[0]: raise UnsupportedWheel( "%s's Wheel-Version (%s) is not compatible with this version " "of pip" % (name, '.'.join(map(str, version))) ) elif version > VERSION_COMPATIBLE: logger.warn('Installing from a newer Wheel-Version (%s)' % '.'.join(map(str, version))) class Wheel(object): """A wheel file""" # TODO: maybe move the install code into this class wheel_file_re = re.compile( r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?)) ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?) \.whl|\.dist-info)$""", re.VERBOSE) def __init__(self, filename): """ :raises InvalidWheelFilename: when the filename is invalid for a wheel """ wheel_info = self.wheel_file_re.match(filename) if not wheel_info: raise InvalidWheelFilename("%s is not a valid wheel filename." % filename) self.filename = filename self.name = wheel_info.group('name').replace('_', '-') # we'll assume "_" means "-" due to wheel naming scheme # (https://github.com/pypa/pip/issues/1150) self.version = wheel_info.group('ver').replace('_', '-') self.pyversions = wheel_info.group('pyver').split('.') self.abis = wheel_info.group('abi').split('.') self.plats = wheel_info.group('plat').split('.') # All the tag combinations from this file self.file_tags = set((x, y, z) for x in self.pyversions for y in self.abis for z in self.plats) def support_index_min(self, tags=None): """ Return the lowest index that one of the wheel's file_tag combinations achieves in the supported_tags list e.g. if there are 8 supported tags, and one of the file tags is first in the list, then return 0. Returns None is the wheel is not supported. """ if tags is None: # for mock tags = pep425tags.supported_tags indexes = [tags.index(c) for c in self.file_tags if c in tags] return min(indexes) if indexes else None def supported(self, tags=None): """Is this wheel supported on this system?""" if tags is None: # for mock tags = pep425tags.supported_tags return bool(set(tags).intersection(self.file_tags)) class WheelBuilder(object): """Build wheels from a RequirementSet.""" def __init__(self, requirement_set, finder, wheel_dir, build_options=[], global_options=[]): self.requirement_set = requirement_set self.finder = finder self.wheel_dir = normalize_path(wheel_dir) self.build_options = build_options self.global_options = global_options def _build_one(self, req): """Build one wheel.""" base_args = [ sys.executable, '-c', "import setuptools;__file__=%r;"\ "exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))" % req.setup_py] + \ list(self.global_options) logger.notify('Running setup.py bdist_wheel for %s' % req.name) logger.notify('Destination directory: %s' % self.wheel_dir) wheel_args = base_args + ['bdist_wheel', '-d', self.wheel_dir] + self.build_options try: call_subprocess(wheel_args, cwd=req.source_dir, show_stdout=False) return True except: logger.error('Failed building wheel for %s' % req.name) return False def build(self): """Build wheels.""" #unpack and constructs req set self.requirement_set.prepare_files(self.finder) reqset = self.requirement_set.requirements.values() buildset = [req for req in reqset if not req.is_wheel] if not buildset: return #build the wheels logger.notify( 'Building wheels for collected packages: %s' % ','.join([req.name for req in buildset]) ) logger.indent += 2 build_success, build_failure = [], [] for req in buildset: if self._build_one(req): build_success.append(req) else: build_failure.append(req) logger.indent -= 2 #notify sucess/failure if build_success: logger.notify('Successfully built %s' % ' '.join([req.name for req in build_success])) if build_failure: logger.notify('Failed to build %s' % ' '.join([req.name for req in build_failure]))
cc0-1.0
[ 624, 199, 11532, 367, 22200, 436, 10015, 314, 298, 11798, 2, 3366, 2559, 1475, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 6555, 452, 199, 646, 7392, 199, 646, 9143, 199, 646, 8337, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 984, 199, 199, 504, 1300, 772, 492, 8187, 6504, 63, 66, 772, 2143, 199, 504, 3031, 14, 2087, 492, 10191, 199, 199, 504, 7305, 14, 15457, 5819, 492, 14196, 12, 5228, 199, 504, 7305, 14, 3924, 492, 6378, 25663, 8117, 12, 19022, 25663, 199, 504, 7305, 14, 8022, 492, 7065, 63, 5512, 199, 504, 7305, 14, 793, 492, 2512, 199, 504, 7305, 492, 22602, 24398, 2969, 199, 504, 7305, 14, 1974, 492, 1240, 63, 5781, 12, 7666, 63, 515, 12, 1852, 63, 515, 63, 6188, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 199, 504, 7305, 423, 9884, 14, 2686, 773, 14, 6429, 492, 14914, 23560, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 421, 199, 11798, 63, 832, 275, 1987, 2191, 76, 7, 199, 199, 4612, 63, 29720, 7187, 275, 334, 17, 12, 378, 9, 421, 199, 318, 295, 2227, 8, 515, 12, 24633, 534, 4835, 3912, 297, 27461, 29, 17, 8999, 1165, 304, 272, 408, 1767, 334, 2227, 12, 2582, 9, 367, 931, 1808, 8337, 14, 1222, 8, 21734, 9471, 272, 394, 275, 8337, 14, 1222, 8, 21734, 9, 272, 2582, 275, 378, 272, 543, 1551, 8, 515, 12, 283, 4848, 358, 465, 289, 26, 267, 1853, 275, 289, 14, 739, 8, 25959, 9, 267, 1830, 1853, 26, 288, 2582, 847, 822, 8, 1457, 9, 288, 394, 14, 873, 8, 1457, 9, 288, 1853, 275, 289, 14, 739, 8, 25959, 9, 272, 10017, 275, 283, 4835, 3912, 22078, 28201, 63, 66, 772, 2143, 8, 72, 14, 5671, 8801, 2708, 360, 10378, 17, 1959, 6735, 23917, 272, 372, 334, 5671, 12, 2582, 9, 199, 199, 893, 26, 272, 2649, 272, 347, 3366, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2649, 304, 288, 372, 308, 14, 2143, 360, 4371, 358, 267, 372, 308, 199, 2590, 12746, 26, 272, 347, 3366, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 620, 304, 288, 372, 308, 14, 2143, 360, 4371, 358, 199, 199, 318, 1551, 63, 509, 63, 4737, 8, 354, 12, 818, 304, 272, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 267, 12992, 275, 1052, 267, 2517, 275, 283, 66, 7, 272, 587, 26, 267, 12992, 275, 469, 283, 12210, 356, 2125, 789, 267, 2517, 275, 2125, 272, 372, 1551, 8, 354, 12, 818, 435, 2517, 12, 1011, 7530, 9, 199, 199, 318, 5325, 63, 1579, 8, 515, 304, 272, 408, 11328, 327, 1, 1548, 543, 327, 1, 15, 515, 15, 475, 15, 1548, 272, 1432, 715, 340, 570, 1990, 2896, 1041, 272, 327, 5787, 24973, 14647, 911, 1929, 370, 506, 4588, 272, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 267, 2884, 275, 1551, 8, 515, 12, 283, 4848, 358, 267, 862, 26, 288, 1642, 604, 275, 2884, 14, 6407, 342, 288, 340, 440, 1642, 604, 14, 2460, 8, 3008, 360, 3168, 1548, 8109, 355, 372, 756, 288, 444, 17604, 275, 984, 14, 5904, 14, 2143, 8, 1274, 14, 23462, 32255, 1012, 288, 1642, 604, 275, 3366, 360, 3168, 358, 435, 444, 17604, 435, 3366, 8, 736, 14, 19254, 9, 288, 4618, 275, 2884, 14, 739, 342, 267, 3753, 26, 288, 2884, 14, 1600, 342, 267, 2884, 275, 1551, 8, 515, 12, 283, 6603, 358, 267, 862, 26, 288, 2884, 14, 952, 8, 2246, 604, 9, 288, 2884, 14, 952, 8, 3911, 9, 267, 3753, 26, 288, 2884, 14, 1600, 342, 267, 372, 715, 199, 199, 2686, 63, 815, 63, 264, 275, 295, 14, 2014, 8, 82, 624, 62, 2229, 48, 28, 354, 422, 30, 2229, 48, 28, 354, 29587, 9, 2801, 2229, 48, 28, 422, 3072, 68, 11198, 430, 17076, 1816, 971, 14, 2686, 13, 815, 4, 7208, 295, 14, 16075, 9, 199, 199, 318, 1738, 63, 374, 63, 31882, 8, 354, 12, 9989, 694, 304, 272, 408, 272, 1432, 715, 340, 314, 12509, 9989, 315, 9989, 694, 1077, 2621, 1901, 15111, 773, 14, 272, 408, 272, 536, 63, 5900, 770, 275, 536, 14, 1814, 6096, 401, 2668, 531, 272, 367, 1242, 315, 747, 14, 7374, 8, 11798, 694, 304, 267, 1336, 275, 2917, 63, 815, 63, 264, 14, 1431, 8, 1053, 9, 267, 340, 1336, 436, 1336, 14, 923, 360, 354, 358, 508, 536, 63, 5900, 770, 26, 288, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 11798, 694, 12, 1242, 12, 283, 31588, 2901, 1333, 465, 9989, 26, 355, 367, 1004, 315, 9989, 26, 490, 1004, 275, 1004, 14, 2325, 1252, 6735, 342, 490, 340, 1004, 508, 298, 1231, 13, 374, 13, 31882, 26, 2549, 582, 717, 372, 715, 272, 372, 756, 421, 199, 318, 664, 63, 2373, 3438, 8, 1501, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 267, 372, 5479, 1052, 339, 327, 961, 365, 4224, 2952, 1265, 883, 986, 282, 1059, 370, 2397, 63, 3438, 17995, 1314, 272, 327, 4910, 626, 2985, 1443, 503, 1443, 440, 506, 1686, 1621, 41, 1584, 14, 710, 7427, 2348, 365, 370, 272, 327, 6202, 9186, 436, 8520, 8139, 315, 1865, 370, 1852, 3062, 1686, 1621, 41, 272, 327, 1584, 14, 272, 543, 1551, 8, 1501, 9, 465, 4090, 26, 267, 666, 275, 5228, 342, 267, 367, 1004, 315, 4090, 26, 288, 666, 14, 952, 8, 604, 14, 1913, 1012, 288, 666, 14, 952, 4582, 78, 531, 267, 666, 14, 5507, 8, 16, 9, 339, 7667, 275, 14196, 14, 7963, 15218, 342, 272, 7667, 14, 739, 3997, 8, 576, 9, 339, 8559, 275, 1052, 272, 11621, 275, 1052, 272, 340, 7667, 14, 1989, 63, 2792, 360, 6614, 63, 6429, 735, 267, 8559, 275, 1211, 8, 1850, 14, 1744, 360, 6614, 63, 6429, 1333, 272, 340, 7667, 14, 1989, 63, 2792, 360, 5885, 63, 6429, 735, 267, 11621, 275, 1211, 8, 1850, 14, 1744, 360, 5885, 63, 6429, 1333, 272, 372, 8559, 12, 11621, 421, 199, 318, 4057, 63, 11798, 63, 1725, 8, 354, 12, 2648, 12, 9989 ]
[ 199, 11532, 367, 22200, 436, 10015, 314, 298, 11798, 2, 3366, 2559, 1475, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 6555, 452, 199, 646, 7392, 199, 646, 9143, 199, 646, 8337, 199, 646, 747, 199, 646, 295, 199, 646, 5145, 199, 646, 984, 199, 199, 504, 1300, 772, 492, 8187, 6504, 63, 66, 772, 2143, 199, 504, 3031, 14, 2087, 492, 10191, 199, 199, 504, 7305, 14, 15457, 5819, 492, 14196, 12, 5228, 199, 504, 7305, 14, 3924, 492, 6378, 25663, 8117, 12, 19022, 25663, 199, 504, 7305, 14, 8022, 492, 7065, 63, 5512, 199, 504, 7305, 14, 793, 492, 2512, 199, 504, 7305, 492, 22602, 24398, 2969, 199, 504, 7305, 14, 1974, 492, 1240, 63, 5781, 12, 7666, 63, 515, 12, 1852, 63, 515, 63, 6188, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 199, 504, 7305, 423, 9884, 14, 2686, 773, 14, 6429, 492, 14914, 23560, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 421, 199, 11798, 63, 832, 275, 1987, 2191, 76, 7, 199, 199, 4612, 63, 29720, 7187, 275, 334, 17, 12, 378, 9, 421, 199, 318, 295, 2227, 8, 515, 12, 24633, 534, 4835, 3912, 297, 27461, 29, 17, 8999, 1165, 304, 272, 408, 1767, 334, 2227, 12, 2582, 9, 367, 931, 1808, 8337, 14, 1222, 8, 21734, 9471, 272, 394, 275, 8337, 14, 1222, 8, 21734, 9, 272, 2582, 275, 378, 272, 543, 1551, 8, 515, 12, 283, 4848, 358, 465, 289, 26, 267, 1853, 275, 289, 14, 739, 8, 25959, 9, 267, 1830, 1853, 26, 288, 2582, 847, 822, 8, 1457, 9, 288, 394, 14, 873, 8, 1457, 9, 288, 1853, 275, 289, 14, 739, 8, 25959, 9, 272, 10017, 275, 283, 4835, 3912, 22078, 28201, 63, 66, 772, 2143, 8, 72, 14, 5671, 8801, 2708, 360, 10378, 17, 1959, 6735, 23917, 272, 372, 334, 5671, 12, 2582, 9, 199, 199, 893, 26, 272, 2649, 272, 347, 3366, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2649, 304, 288, 372, 308, 14, 2143, 360, 4371, 358, 267, 372, 308, 199, 2590, 12746, 26, 272, 347, 3366, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 620, 304, 288, 372, 308, 14, 2143, 360, 4371, 358, 199, 199, 318, 1551, 63, 509, 63, 4737, 8, 354, 12, 818, 304, 272, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 267, 12992, 275, 1052, 267, 2517, 275, 283, 66, 7, 272, 587, 26, 267, 12992, 275, 469, 283, 12210, 356, 2125, 789, 267, 2517, 275, 2125, 272, 372, 1551, 8, 354, 12, 818, 435, 2517, 12, 1011, 7530, 9, 199, 199, 318, 5325, 63, 1579, 8, 515, 304, 272, 408, 11328, 327, 1, 1548, 543, 327, 1, 15, 515, 15, 475, 15, 1548, 272, 1432, 715, 340, 570, 1990, 2896, 1041, 272, 327, 5787, 24973, 14647, 911, 1929, 370, 506, 4588, 272, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 267, 2884, 275, 1551, 8, 515, 12, 283, 4848, 358, 267, 862, 26, 288, 1642, 604, 275, 2884, 14, 6407, 342, 288, 340, 440, 1642, 604, 14, 2460, 8, 3008, 360, 3168, 1548, 8109, 355, 372, 756, 288, 444, 17604, 275, 984, 14, 5904, 14, 2143, 8, 1274, 14, 23462, 32255, 1012, 288, 1642, 604, 275, 3366, 360, 3168, 358, 435, 444, 17604, 435, 3366, 8, 736, 14, 19254, 9, 288, 4618, 275, 2884, 14, 739, 342, 267, 3753, 26, 288, 2884, 14, 1600, 342, 267, 2884, 275, 1551, 8, 515, 12, 283, 6603, 358, 267, 862, 26, 288, 2884, 14, 952, 8, 2246, 604, 9, 288, 2884, 14, 952, 8, 3911, 9, 267, 3753, 26, 288, 2884, 14, 1600, 342, 267, 372, 715, 199, 199, 2686, 63, 815, 63, 264, 275, 295, 14, 2014, 8, 82, 624, 62, 2229, 48, 28, 354, 422, 30, 2229, 48, 28, 354, 29587, 9, 2801, 2229, 48, 28, 422, 3072, 68, 11198, 430, 17076, 1816, 971, 14, 2686, 13, 815, 4, 7208, 295, 14, 16075, 9, 199, 199, 318, 1738, 63, 374, 63, 31882, 8, 354, 12, 9989, 694, 304, 272, 408, 272, 1432, 715, 340, 314, 12509, 9989, 315, 9989, 694, 1077, 2621, 1901, 15111, 773, 14, 272, 408, 272, 536, 63, 5900, 770, 275, 536, 14, 1814, 6096, 401, 2668, 531, 272, 367, 1242, 315, 747, 14, 7374, 8, 11798, 694, 304, 267, 1336, 275, 2917, 63, 815, 63, 264, 14, 1431, 8, 1053, 9, 267, 340, 1336, 436, 1336, 14, 923, 360, 354, 358, 508, 536, 63, 5900, 770, 26, 288, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 11798, 694, 12, 1242, 12, 283, 31588, 2901, 1333, 465, 9989, 26, 355, 367, 1004, 315, 9989, 26, 490, 1004, 275, 1004, 14, 2325, 1252, 6735, 342, 490, 340, 1004, 508, 298, 1231, 13, 374, 13, 31882, 26, 2549, 582, 717, 372, 715, 272, 372, 756, 421, 199, 318, 664, 63, 2373, 3438, 8, 1501, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 267, 372, 5479, 1052, 339, 327, 961, 365, 4224, 2952, 1265, 883, 986, 282, 1059, 370, 2397, 63, 3438, 17995, 1314, 272, 327, 4910, 626, 2985, 1443, 503, 1443, 440, 506, 1686, 1621, 41, 1584, 14, 710, 7427, 2348, 365, 370, 272, 327, 6202, 9186, 436, 8520, 8139, 315, 1865, 370, 1852, 3062, 1686, 1621, 41, 272, 327, 1584, 14, 272, 543, 1551, 8, 1501, 9, 465, 4090, 26, 267, 666, 275, 5228, 342, 267, 367, 1004, 315, 4090, 26, 288, 666, 14, 952, 8, 604, 14, 1913, 1012, 288, 666, 14, 952, 4582, 78, 531, 267, 666, 14, 5507, 8, 16, 9, 339, 7667, 275, 14196, 14, 7963, 15218, 342, 272, 7667, 14, 739, 3997, 8, 576, 9, 339, 8559, 275, 1052, 272, 11621, 275, 1052, 272, 340, 7667, 14, 1989, 63, 2792, 360, 6614, 63, 6429, 735, 267, 8559, 275, 1211, 8, 1850, 14, 1744, 360, 6614, 63, 6429, 1333, 272, 340, 7667, 14, 1989, 63, 2792, 360, 5885, 63, 6429, 735, 267, 11621, 275, 1211, 8, 1850, 14, 1744, 360, 5885, 63, 6429, 1333, 272, 372, 8559, 12, 11621, 421, 199, 318, 4057, 63, 11798, 63, 1725, 8, 354, 12, 2648, 12, 9989, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Impactstory/total-impact-webapp
totalimpact/providers/altmetric_com.py
2
8342
from totalimpact.providers import provider from totalimpact.providers.provider import Provider, ProviderContentMalformedError import json, re, os, requests, socket from operator import itemgetter import logging logger = logging.getLogger('ti.providers.altmetric_com') class Altmetric_Com(Provider): example_id = ("doi", "10.1101/gr.161315.113") url = "http://www.altmetric.com" descr = "We make article level metrics easy." aliases_url_template = 'http://api.altmetric.com/v1/fetch/%s?key=' + os.environ["ALTMETRIC_COM_KEY"] metrics_url_template_via_fetch = 'http://api.altmetric.com/v1/fetch/id/%s?key=' + os.environ["ALTMETRIC_COM_KEY"] metrics_url_template_via_citations = 'http://api.altmetric.com/v1/citations/1y?key=' + os.environ["ALTMETRIC_COM_KEY"] provenance_url_template = 'http://www.altmetric.com/details.php?citation_id=%s&src=impactstory.org' static_meta_dict = { "tweets": { "display_name": "Twitter tweets", "provider": "Altmetric.com", "provider_url": "http://twitter.com", "description": "Number of times the product has been tweeted", "icon": "https://twitter.com/favicon.ico", }, "facebook_posts": { "display_name": "Facebook public posts", "provider": "Altmetric.com", "provider_url": "http://facebook.com", "description": "Number of posts mentioning the product on a public Facebook wall", "icon": "http://facebook.com/favicon.ico", }, "gplus_posts": { "display_name": "Google+ posts", "provider": "Altmetric.com", "provider_url": "http://plus.google.com", "description": "Number of posts mentioning the product on Google+", "icon": "http://plus.google.com/favicon.ico", }, "blog_posts": { "display_name": "blog posts", "provider": "Altmetric.com", "provider_url": "", "description": "Number of blog posts mentioning the product", "icon": "http://impactstory.org/static/img/blogs-icon.png", } } def __init__(self): super(Altmetric_Com, self).__init__() @property def provides_aliases(self): return True @property def provides_metrics(self): return True def is_relevant_alias(self, alias): (namespace, nid) = alias return namespace in ["doi"] def get_best_id(self, aliases): # return it with the id type as a prefix before / because that's how the altmetric.com api expects it aliases_dict = provider.alias_dict_from_tuples(aliases) if "altmetric_com" in aliases_dict: best_id = aliases_dict["altmetric_com"][0] else: best_id = None return(best_id) def provenance_url(self, metric_name, aliases): aliases_dict = provider.alias_dict_from_tuples(aliases) try: drilldown_url = self._get_templated_url(self.provenance_url_template, aliases_dict["altmetric_com"][0]) except KeyError: drilldown_url = "" return drilldown_url def get_id_for_aliases(self, aliases): # return it with the id type as a prefix before / because that's how the altmetric.com api expects it aliases_dict = provider.alias_dict_from_tuples(aliases) if "doi" in aliases_dict: best_id = "doi/{id}".format(id=aliases_dict["doi"][0]) elif "pmid" in aliases_dict: best_id = "pmid/{id}".format(id=aliases_dict["pmid"][0]) elif "arxiv" in aliases_dict: best_id = "arxiv_id/{id}".format(id=aliases_dict["arxiv"][0]) elif "altmetric_com" in aliases_dict: best_id = "altmetric_com/{id}".format(id=aliases_dict["altmetric_com"][0]) else: best_id = None return(best_id) def aliases(self, aliases, provider_url_template=None, cache_enabled=True): aliases_dict = provider.alias_dict_from_tuples(aliases) if "altmetric_com" in aliases_dict: return [] # nothing new to add nid = self.get_id_for_aliases(aliases) if not nid: return [] new_aliases = self._get_aliases_for_id(nid, provider_url_template, cache_enabled) return new_aliases def _extract_aliases(self, page, id=None): dict_of_keylists = {"altmetric_com": ["altmetric_id"]} aliases_dict = provider._extract_from_json(page, dict_of_keylists) if aliases_dict: aliases_list = [("altmetric_com", str(aliases_dict["altmetric_com"]))] else: aliases_list = [] return aliases_list def get_tweet_ids(self, altmetric_posts): tweet_ids = [p["tweet_id"] for p in altmetric_posts] return tweet_ids def _extract_metrics_via_fetch(self, page, status_code=200, id=None): dict_of_keylists = { 'altmetric_com:tweets' : ['counts', 'twitter', 'posts_count'], 'altmetric_com:unique_tweeters' : ['counts', 'twitter', 'unique_users_count'], 'altmetric_com:demographics' : ['demographics'], 'altmetric_com:posts' : ['posts'] } metrics_dict = provider._extract_from_json(page, dict_of_keylists) try: if metrics_dict['altmetric_com:posts'] and "twitter" in metrics_dict['altmetric_com:posts']: altmetric_posts = metrics_dict['altmetric_com:posts']["twitter"] except KeyError: pass # no posts return metrics_dict def _extract_metrics_for_via_citation_call(self, data, status_code=200, id=None): dict_of_keylists = { 'altmetric_com:gplus_posts' : ['cited_by_gplus_count'], 'altmetric_com:facebook_posts' : ['cited_by_fbwalls_count'], 'altmetric_com:blog_posts' : ['cited_by_feeds_count'] } entry = data["results"][0] metrics_dict = provider._extract_from_data_dict(entry, dict_of_keylists) return metrics_dict def get_metrics_for_via_citation_call(self, id, provider_url_template=None, cache_enabled=True): # self.logger.debug(u"%s getting metrics for %s" % (self.provider_name, id)) headers = {u'content-type': u'application/x-www-form-urlencoded', u'accept': u'application/json'} r = requests.post(self.metrics_url_template_via_citations, data="citation_ids="+id, headers=headers) # extract the metrics try: data = r.json() metrics_dict = self._extract_metrics_for_via_citation_call(data) except socket.timeout, e: # can apparently be thrown here self.logger.info(u"%s Provider timed out *after* GET in socket" %(self.provider_name)) raise ProviderTimeout("Provider timed out *after* GET in socket", e) except (AttributeError, TypeError, ValueError): # ValueError includes simplejson.decoder.JSONDecodeError # expected response if nothing found metrics_dict = {} return metrics_dict def metrics(self, aliases, provider_url_template=None, cache_enabled=True): id = self.get_best_id(aliases) # Only lookup metrics for items with appropriate ids if not id: #self.logger.debug(u"%s not checking metrics, no relevant alias" % (self.provider_name)) return {} metrics = {} new_metrics = self.get_metrics_for_id(id, self.metrics_url_template_via_fetch, cache_enabled, extract_metrics_method=self._extract_metrics_via_fetch) if new_metrics: metrics.update(new_metrics) new_metrics = self.get_metrics_for_via_citation_call(id) if new_metrics: metrics.update(new_metrics) metrics_and_drilldown = {} for metric_name in metrics: drilldown_url = self.provenance_url(metric_name, aliases) metrics_and_drilldown[metric_name] = (metrics[metric_name], drilldown_url) return metrics_and_drilldown
mit
[ 504, 3141, 31822, 14, 9710, 492, 5022, 199, 504, 3141, 31822, 14, 9710, 14, 3780, 492, 18489, 12, 18489, 2714, 29513, 547, 199, 199, 646, 2022, 12, 295, 12, 747, 12, 4145, 12, 2838, 199, 504, 4182, 492, 1242, 7416, 199, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 360, 280, 14, 9710, 14, 4478, 5165, 63, 957, 358, 199, 199, 533, 437, 4116, 5165, 63, 4373, 8, 6663, 304, 257, 339, 2893, 63, 344, 275, 1689, 27334, 401, 298, 709, 14, 24827, 15, 2587, 14, 975, 969, 1046, 14, 9225, 531, 339, 1166, 275, 298, 1014, 921, 1544, 14, 4478, 5165, 14, 957, 2, 272, 16193, 275, 298, 6004, 1852, 9772, 2166, 7186, 8837, 2122, 272, 5481, 63, 633, 63, 1160, 275, 283, 1014, 921, 1246, 14, 4478, 5165, 14, 957, 15, 86, 17, 15, 3535, 3149, 83, 31, 498, 534, 435, 747, 14, 2314, 905, 19600, 20141, 63, 11265, 63, 3078, 937, 272, 7186, 63, 633, 63, 1160, 63, 12897, 63, 3535, 275, 283, 1014, 921, 1246, 14, 4478, 5165, 14, 957, 15, 86, 17, 15, 3535, 15, 344, 3149, 83, 31, 498, 534, 435, 747, 14, 2314, 905, 19600, 20141, 63, 11265, 63, 3078, 937, 272, 7186, 63, 633, 63, 1160, 63, 12897, 63, 14422, 1298, 275, 283, 1014, 921, 1246, 14, 4478, 5165, 14, 957, 15, 86, 17, 15, 14422, 1298, 15, 17, 89, 31, 498, 534, 435, 747, 14, 2314, 905, 19600, 20141, 63, 11265, 63, 3078, 937, 272, 557, 1856, 554, 63, 633, 63, 1160, 275, 283, 1014, 921, 1544, 14, 4478, 5165, 14, 957, 15, 5087, 14, 8624, 31, 6210, 63, 344, 2458, 83, 6, 2164, 29, 31822, 17372, 14, 1308, 7, 339, 2955, 63, 2024, 63, 807, 275, 221, 469, 267, 298, 84, 18588, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 24540, 307, 18588, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 298, 1014, 921, 13746, 14, 957, 401, 288, 298, 1802, 582, 298, 3259, 402, 5431, 314, 3336, 965, 2757, 8900, 1024, 471, 401, 288, 298, 4677, 582, 298, 2859, 921, 13746, 14, 957, 15, 22229, 14, 12802, 401, 267, 1660, 267, 298, 16652, 63, 18084, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 13414, 2706, 4575, 22238, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 298, 1014, 921, 16652, 14, 957, 401, 288, 298, 1802, 582, 298, 3259, 402, 22238, 20811, 316, 314, 3336, 641, 282, 4575, 27107, 19882, 401, 288, 298, 4677, 582, 298, 1014, 921, 16652, 14, 957, 15, 22229, 14, 12802, 401, 267, 1660, 267, 298, 71, 6666, 63, 18084, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 13266, 11, 22238, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 298, 1014, 921, 6666, 14, 3098, 14, 957, 401, 288, 298, 1802, 582, 298, 3259, 402, 22238, 20811, 316, 314, 3336, 641, 4475, 22758, 288, 298, 4677, 582, 298, 1014, 921, 6666, 14, 3098, 14, 957, 15, 22229, 14, 12802, 401, 267, 1660, 267, 298, 11486, 63, 18084, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 11486, 22238, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 4873, 288, 298, 1802, 582, 298, 3259, 402, 19936, 22238, 20811, 316, 314, 3336, 401, 288, 298, 4677, 582, 298, 1014, 921, 31822, 17372, 14, 1308, 15, 1986, 15, 4060, 15, 66, 7270, 13, 4677, 14, 4524, 401, 267, 789, 272, 789, 1362, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 16985, 5165, 63, 4373, 12, 291, 2843, 826, 4533, 339, 768, 1829, 272, 347, 6571, 63, 8602, 8, 277, 304, 267, 372, 715, 339, 768, 1829, 272, 347, 6571, 63, 6759, 8, 277, 304, 267, 372, 715, 339, 347, 365, 63, 21906, 63, 3620, 8, 277, 12, 5162, 304, 267, 334, 3251, 12, 302, 344, 9, 275, 5162, 267, 372, 3231, 315, 2097, 27334, 937, 339, 347, 664, 63, 7010, 63, 344, 8, 277, 12, 5481, 304, 267, 327, 372, 652, 543, 314, 1305, 730, 465, 282, 2403, 2544, 1182, 2952, 626, 1159, 4212, 314, 8791, 5165, 14, 957, 2986, 14292, 652, 267, 5481, 63, 807, 275, 5022, 14, 3620, 63, 807, 63, 504, 63, 11760, 8, 8602, 9, 267, 340, 298, 4478, 5165, 63, 957, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 5481, 63, 807, 905, 4478, 5165, 63, 957, 9210, 16, 61, 267, 587, 26, 288, 5526, 63, 344, 275, 488, 267, 372, 8, 7010, 63, 344, 9, 2378, 347, 557, 1856, 554, 63, 633, 8, 277, 12, 6370, 63, 354, 12, 5481, 304, 267, 5481, 63, 807, 275, 5022, 14, 3620, 63, 807, 63, 504, 63, 11760, 8, 8602, 9, 267, 862, 26, 288, 20921, 914, 2110, 63, 633, 275, 291, 423, 362, 63, 1160, 68, 63, 633, 8, 277, 14, 496, 1856, 554, 63, 633, 63, 1160, 12, 5481, 63, 807, 905, 4478, 5165, 63, 957, 9210, 16, 566, 267, 871, 4067, 26, 288, 20921, 914, 2110, 63, 633, 275, 3087, 267, 372, 20921, 914, 2110, 63, 633, 2378, 347, 664, 63, 344, 63, 509, 63, 8602, 8, 277, 12, 5481, 304, 267, 327, 372, 652, 543, 314, 1305, 730, 465, 282, 2403, 2544, 1182, 2952, 626, 1159, 4212, 314, 8791, 5165, 14, 957, 2986, 14292, 652, 267, 5481, 63, 807, 275, 5022, 14, 3620, 63, 807, 63, 504, 63, 11760, 8, 8602, 9, 267, 340, 298, 27334, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 298, 27334, 5321, 344, 5469, 908, 8, 344, 29, 8602, 63, 807, 905, 27334, 9210, 16, 566, 267, 916, 298, 7073, 344, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 298, 7073, 344, 5321, 344, 5469, 908, 8, 344, 29, 8602, 63, 807, 905, 7073, 344, 9210, 16, 566, 267, 916, 298, 27290, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 298, 27290, 63, 344, 5321, 344, 5469, 908, 8, 344, 29, 8602, 63, 807, 905, 27290, 9210, 16, 566, 267, 916, 298, 4478, 5165, 63, 957, 2 ]
[ 3141, 31822, 14, 9710, 492, 5022, 199, 504, 3141, 31822, 14, 9710, 14, 3780, 492, 18489, 12, 18489, 2714, 29513, 547, 199, 199, 646, 2022, 12, 295, 12, 747, 12, 4145, 12, 2838, 199, 504, 4182, 492, 1242, 7416, 199, 199, 646, 2050, 199, 2921, 275, 2050, 14, 5572, 360, 280, 14, 9710, 14, 4478, 5165, 63, 957, 358, 199, 199, 533, 437, 4116, 5165, 63, 4373, 8, 6663, 304, 257, 339, 2893, 63, 344, 275, 1689, 27334, 401, 298, 709, 14, 24827, 15, 2587, 14, 975, 969, 1046, 14, 9225, 531, 339, 1166, 275, 298, 1014, 921, 1544, 14, 4478, 5165, 14, 957, 2, 272, 16193, 275, 298, 6004, 1852, 9772, 2166, 7186, 8837, 2122, 272, 5481, 63, 633, 63, 1160, 275, 283, 1014, 921, 1246, 14, 4478, 5165, 14, 957, 15, 86, 17, 15, 3535, 3149, 83, 31, 498, 534, 435, 747, 14, 2314, 905, 19600, 20141, 63, 11265, 63, 3078, 937, 272, 7186, 63, 633, 63, 1160, 63, 12897, 63, 3535, 275, 283, 1014, 921, 1246, 14, 4478, 5165, 14, 957, 15, 86, 17, 15, 3535, 15, 344, 3149, 83, 31, 498, 534, 435, 747, 14, 2314, 905, 19600, 20141, 63, 11265, 63, 3078, 937, 272, 7186, 63, 633, 63, 1160, 63, 12897, 63, 14422, 1298, 275, 283, 1014, 921, 1246, 14, 4478, 5165, 14, 957, 15, 86, 17, 15, 14422, 1298, 15, 17, 89, 31, 498, 534, 435, 747, 14, 2314, 905, 19600, 20141, 63, 11265, 63, 3078, 937, 272, 557, 1856, 554, 63, 633, 63, 1160, 275, 283, 1014, 921, 1544, 14, 4478, 5165, 14, 957, 15, 5087, 14, 8624, 31, 6210, 63, 344, 2458, 83, 6, 2164, 29, 31822, 17372, 14, 1308, 7, 339, 2955, 63, 2024, 63, 807, 275, 221, 469, 267, 298, 84, 18588, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 24540, 307, 18588, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 298, 1014, 921, 13746, 14, 957, 401, 288, 298, 1802, 582, 298, 3259, 402, 5431, 314, 3336, 965, 2757, 8900, 1024, 471, 401, 288, 298, 4677, 582, 298, 2859, 921, 13746, 14, 957, 15, 22229, 14, 12802, 401, 267, 1660, 267, 298, 16652, 63, 18084, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 13414, 2706, 4575, 22238, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 298, 1014, 921, 16652, 14, 957, 401, 288, 298, 1802, 582, 298, 3259, 402, 22238, 20811, 316, 314, 3336, 641, 282, 4575, 27107, 19882, 401, 288, 298, 4677, 582, 298, 1014, 921, 16652, 14, 957, 15, 22229, 14, 12802, 401, 267, 1660, 267, 298, 71, 6666, 63, 18084, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 13266, 11, 22238, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 298, 1014, 921, 6666, 14, 3098, 14, 957, 401, 288, 298, 1802, 582, 298, 3259, 402, 22238, 20811, 316, 314, 3336, 641, 4475, 22758, 288, 298, 4677, 582, 298, 1014, 921, 6666, 14, 3098, 14, 957, 15, 22229, 14, 12802, 401, 267, 1660, 267, 298, 11486, 63, 18084, 582, 469, 288, 298, 2918, 63, 354, 582, 298, 11486, 22238, 401, 288, 298, 3780, 582, 298, 16985, 5165, 14, 957, 401, 288, 298, 3780, 63, 633, 582, 4873, 288, 298, 1802, 582, 298, 3259, 402, 19936, 22238, 20811, 316, 314, 3336, 401, 288, 298, 4677, 582, 298, 1014, 921, 31822, 17372, 14, 1308, 15, 1986, 15, 4060, 15, 66, 7270, 13, 4677, 14, 4524, 401, 267, 789, 272, 789, 1362, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 16985, 5165, 63, 4373, 12, 291, 2843, 826, 4533, 339, 768, 1829, 272, 347, 6571, 63, 8602, 8, 277, 304, 267, 372, 715, 339, 768, 1829, 272, 347, 6571, 63, 6759, 8, 277, 304, 267, 372, 715, 339, 347, 365, 63, 21906, 63, 3620, 8, 277, 12, 5162, 304, 267, 334, 3251, 12, 302, 344, 9, 275, 5162, 267, 372, 3231, 315, 2097, 27334, 937, 339, 347, 664, 63, 7010, 63, 344, 8, 277, 12, 5481, 304, 267, 327, 372, 652, 543, 314, 1305, 730, 465, 282, 2403, 2544, 1182, 2952, 626, 1159, 4212, 314, 8791, 5165, 14, 957, 2986, 14292, 652, 267, 5481, 63, 807, 275, 5022, 14, 3620, 63, 807, 63, 504, 63, 11760, 8, 8602, 9, 267, 340, 298, 4478, 5165, 63, 957, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 5481, 63, 807, 905, 4478, 5165, 63, 957, 9210, 16, 61, 267, 587, 26, 288, 5526, 63, 344, 275, 488, 267, 372, 8, 7010, 63, 344, 9, 2378, 347, 557, 1856, 554, 63, 633, 8, 277, 12, 6370, 63, 354, 12, 5481, 304, 267, 5481, 63, 807, 275, 5022, 14, 3620, 63, 807, 63, 504, 63, 11760, 8, 8602, 9, 267, 862, 26, 288, 20921, 914, 2110, 63, 633, 275, 291, 423, 362, 63, 1160, 68, 63, 633, 8, 277, 14, 496, 1856, 554, 63, 633, 63, 1160, 12, 5481, 63, 807, 905, 4478, 5165, 63, 957, 9210, 16, 566, 267, 871, 4067, 26, 288, 20921, 914, 2110, 63, 633, 275, 3087, 267, 372, 20921, 914, 2110, 63, 633, 2378, 347, 664, 63, 344, 63, 509, 63, 8602, 8, 277, 12, 5481, 304, 267, 327, 372, 652, 543, 314, 1305, 730, 465, 282, 2403, 2544, 1182, 2952, 626, 1159, 4212, 314, 8791, 5165, 14, 957, 2986, 14292, 652, 267, 5481, 63, 807, 275, 5022, 14, 3620, 63, 807, 63, 504, 63, 11760, 8, 8602, 9, 267, 340, 298, 27334, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 298, 27334, 5321, 344, 5469, 908, 8, 344, 29, 8602, 63, 807, 905, 27334, 9210, 16, 566, 267, 916, 298, 7073, 344, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 298, 7073, 344, 5321, 344, 5469, 908, 8, 344, 29, 8602, 63, 807, 905, 7073, 344, 9210, 16, 566, 267, 916, 298, 27290, 2, 315, 5481, 63, 807, 26, 288, 5526, 63, 344, 275, 298, 27290, 63, 344, 5321, 344, 5469, 908, 8, 344, 29, 8602, 63,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
landgraf/zeromq-Ada
fixHeader.py
1
4068
#!/usr/bin/env python import GPS from os.path import * HEADER="""############################################################################## ## ## ## 0MQ Ada-binding ## ## ## %(name)s ## ## %(ext)s ## ## ## Copyright (C) 2013-2020, per.s.sandberg@bahnhof.se ## ## ## ## 0MQ Ada-binding is free software; you can redistribute it and/or ## ## modify it under terms of the GNU General Public License as published ## ## by the Free Soft-ware Foundation; ## ## either version 2, or (at your option) any later version. ## ## 0MQ Ada-binding is distributed in the hope that it will be useful, but ## ## WITH OUT 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 distributed with GNAT; see file COPYING. If not, write ## ## to the Free Software Foundation, 51 Franklin Street, Fifth Floor, ## ## Boston, MA 02110-1301, USA. ## ## ## ## As a special exception, if other files instantiate generics from this ## ## unit, or you link this unit with other files to produce an executable, ## ## this unit does not by itself cause the resulting executable to be ## ## covered by the GNU General Public License. This exception does not ## ## however invalidate any other reasons why the executable file might be ## ## covered by the GNU Public License. ## ## ## ############################################################################## """ import string def to80Comment(s): if len(s) > 76: s = s.replace(" ",""); if len(s) > 76: s=s[:-76] n= 76 - len(s) n=n/2 ret = "##" + (" " * n) + s ret = ret + (" " * (76 - len(ret))) + "##" return ret def getHeader(f): name,ext=splitext(basename(f.name())) name=name.upper().replace("-",".") name =to80Comment( string.join(name," ")) if ext==".ads": ext =to80Comment("S p e c" ) return (HEADER % {"name" : name , "ext" : ext}).replace("#","-") elif ext==".adb": ext =to80Comment("B o d y" ) return (HEADER % {"name" : name , "ext" : ext}).replace("#","-") elif ext==".gpr": ext =to80Comment( "P r o j e c t" ) return (HEADER % {"name" : name , "ext" : ext}).replace("#","-") else: ext =to80Comment("") return HEADER % {"name" : name , "ext" : ext} def fixFile(f,of): name,ext=splitext(basename(f.name())) ed = GPS.EditorBuffer.get(f) begin=ed.beginning_of_buffer() if (ext not in [".gpr",".adb",".ads",".c",".cpp",".h",".hh",".idl"]): begin=begin.forward_line(1) last=ed.beginning_of_buffer().search(r"\n\n", regexp=True) of.write("%s\n" % "///////////////////////////////////////////////////////////////////////////////") of.write("%s\n" % f.name()) of.write("%s\n" % "<<<<<<<<<<<<<<<<<<<<<<<<<<<<") of.write("%s\n" % ed.get_chars(begin,last[0])) of.write("%s\n" % "<<<<<<<<<<<<<<<<<<<<<<<<<<<<") of.write("%s\n" % getHeader(f)) of.write("%s\n" % "///////////////////////////////////////////////////////////////////////////////") with file("temp.out","w") as of: for i in GPS.Project("zmq.tests").sources(): fixFile(i,of)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 598, 5067, 199, 504, 747, 14, 515, 492, 627, 199, 199, 7311, 11916, 4605, 199, 309, 6208, 3515, 925, 199, 309, 17907, 378, 14449, 437, 983, 13, 9140, 19242, 925, 199, 309, 6208, 3515, 925, 199, 2840, 354, 9, 83, 199, 309, 6208, 3515, 925, 199, 2840, 832, 9, 83, 199, 309, 6208, 3515, 925, 199, 309, 3322, 1898, 334, 35, 9, 6171, 13, 13934, 12, 1126, 14, 83, 14, 83, 460, 14630, 32, 2470, 6164, 526, 70, 14, 261, 3322, 925, 199, 309, 6208, 3515, 925, 199, 309, 378, 14449, 437, 983, 13, 9140, 365, 2867, 2032, 27, 221, 1265, 883, 221, 3604, 652, 221, 436, 15, 269, 420, 925, 199, 309, 2811, 652, 1334, 2895, 402, 314, 221, 1664, 1696, 1684, 844, 465, 3267, 259, 925, 199, 309, 701, 314, 2868, 27238, 13, 1068, 221, 2752, 27, 2476, 755, 925, 199, 309, 1902, 1015, 499, 12, 221, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 4483, 925, 199, 309, 378, 14449, 437, 983, 13, 9140, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 257, 925, 199, 309, 1663, 5738, 1821, 3408, 27, 2476, 7861, 925, 199, 309, 1928, 2755, 314, 221, 2478, 3750, 402, 3169, 503, 463, 925, 199, 309, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 259, 925, 199, 309, 367, 221, 1655, 2436, 14, 221, 2047, 1077, 1172, 221, 3086, 221, 282, 1331, 402, 314, 1664, 1696, 925, 199, 309, 1684, 844, 221, 1854, 543, 27650, 619, 27, 221, 1937, 570, 9685, 14, 221, 982, 440, 12, 2218, 925, 199, 309, 370, 221, 314, 221, 2868, 2290, 2752, 12, 221, 8026, 221, 11236, 221, 14259, 12, 221, 12066, 221, 11844, 12, 925, 199, 309, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 2476, 4519, 925, 199, 309, 6208, 3515, 925, 199, 309, 3709, 282, 4539, 1919, 12, 221, 340, 1163, 1584, 221, 17321, 221, 1519, 2932, 687, 642, 925, 199, 309, 4137, 12, 503, 1265, 2142, 221, 642, 4137, 543, 1163, 1584, 221, 370, 7389, 376, 7286, 12, 925, 199, 309, 642, 221, 4137, 221, 1630, 440, 221, 701, 6337, 7675, 221, 314, 9183, 221, 7286, 221, 370, 221, 506, 925, 199, 309, 24295, 221, 701, 314, 221, 1664, 221, 1696, 221, 1684, 221, 844, 14, 221, 961, 1919, 1630, 440, 925, 199, 309, 13432, 24841, 221, 1263, 1163, 14872, 10842, 221, 314, 7286, 570, 221, 5594, 506, 925, 199, 309, 24295, 701, 314, 221, 1664, 1684, 844, 14, 32543, 925, 199, 309, 6208, 3515, 925, 199, 4605, 199, 624, 4388, 199, 646, 1059, 199, 318, 370, 1257, 7488, 8, 83, 304, 2043, 340, 822, 8, 83, 9, 690, 14646, 26, 489, 308, 275, 308, 14, 1814, 480, 3872, 341, 2736, 2043, 340, 822, 8, 83, 9, 690, 14646, 26, 2126, 308, 29, 83, 4439, 2114, 61, 2043, 302, 29, 14646, 446, 822, 8, 83, 9, 2043, 302, 29, 78, 15, 18, 2043, 2203, 275, 298, 309, 2, 435, 1689, 298, 627, 302, 9, 435, 308, 2043, 2203, 275, 2203, 435, 1689, 298, 627, 334, 2114, 446, 822, 8, 3292, 1724, 435, 298, 309, 2, 2043, 372, 2203, 199, 199, 318, 664, 2567, 8, 70, 304, 2043, 536, 12, 832, 29, 7973, 8, 4846, 8, 70, 14, 354, 4059, 2043, 536, 29, 354, 14, 4142, 1252, 1814, 6096, 401, 1674, 531, 2043, 536, 275, 475, 1257, 7488, 8, 1059, 14, 904, 8, 354, 4589, 26725, 2043, 340, 1599, 389, 1674, 9402, 582, 489, 1599, 221, 275, 475, 1257, 7488, 480, 51, 299, 325, 286, 2, 776, 489, 372, 334, 7311, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 21385, 1814, 10064, 2266, 13, 531, 2043, 916, 1599, 389, 1674, 13741, 582, 489, 1599, 221, 275, 475, 1257, 7488, 480, 34, 312, 366, 612, 2, 776, 489, 372, 334, 7311, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 21385, 1814, 10064, 2266, 13, 531, 2043, 916, 1599, 389, 1674, 71, 2700, 582, 489, 1599, 221, 275, 475, 1257, 7488, 8, 298, 48, 519, 312, 1335, 325, 286, 307, 2, 776, 489, 372, 334, 7311, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 21385, 1814, 10064, 2266, 13, 531, 2043, 587, 26, 489, 1599, 221, 275, 475, 1257, 7488, 10804, 489, 372, 13053, 540, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 93, 199, 199, 318, 5325, 1173, 8, 70, 12, 1618, 304, 2043, 536, 12, 832, 29, 7973, 8, 4846, 8, 70, 14, 354, 4059, 2043, 3988, 275, 598, 5067, 14, 10423, 3299, 14, 362, 8, 70, 9, 2043, 5386, 29, 379, 14, 31272, 63, 1618, 63, 2738, 342, 2043, 340, 334, 832, 440, 315, 359, 1674, 71, 2700, 401, 1674, 13741, 401, 1674, 9402, 401, 1674, 67, 401, 1674, 5910, 401, 1674, 72, 401, 1674, 12156, 401, 1674, 13398, 21473, 489, 5386, 29, 5037, 14, 6688, 63, 604, 8, 17, 9, 2043, 2061, 29, 379, 14, 31272, 63, 1618, 63, 2738, 1252, 1733, 8, 82, 3212, 78, 60, 78, 401, 13156, 29, 549, 9, 8410, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 298, 8086, 1368, 8331, 13589, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 289, 14, 354, 1012, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 3886, 31275, 31275, 31275, 31275, 31275, 31275, 8999, 28, 531, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 3988, 14, 362, 63, 6574, 8, 5037, 12, 2019, 59, 16, 2459, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 3886, 31275, 31275, 31275, 31275, 31275, 31275, 8999, 28, 531, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 664, 2567, 8, 70, 430, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 298, 8086, 1368, 8331, 13589, 199, 199, 1045, 570, 480, 808, 14, 548, 2266, 87, 531, 465, 402, 26, 523, 367, 284, 315, 598, 5067, 14, 4761, 480, 21290, 14, 2219, 3471, 4553, 837, 1362, 5325, 1173, 8, 73, 12, 1618, 9, 6905, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 598, 5067, 199, 504, 747, 14, 515, 492, 627, 199, 199, 7311, 11916, 4605, 199, 309, 6208, 3515, 925, 199, 309, 17907, 378, 14449, 437, 983, 13, 9140, 19242, 925, 199, 309, 6208, 3515, 925, 199, 2840, 354, 9, 83, 199, 309, 6208, 3515, 925, 199, 2840, 832, 9, 83, 199, 309, 6208, 3515, 925, 199, 309, 3322, 1898, 334, 35, 9, 6171, 13, 13934, 12, 1126, 14, 83, 14, 83, 460, 14630, 32, 2470, 6164, 526, 70, 14, 261, 3322, 925, 199, 309, 6208, 3515, 925, 199, 309, 378, 14449, 437, 983, 13, 9140, 365, 2867, 2032, 27, 221, 1265, 883, 221, 3604, 652, 221, 436, 15, 269, 420, 925, 199, 309, 2811, 652, 1334, 2895, 402, 314, 221, 1664, 1696, 1684, 844, 465, 3267, 259, 925, 199, 309, 701, 314, 2868, 27238, 13, 1068, 221, 2752, 27, 2476, 755, 925, 199, 309, 1902, 1015, 499, 12, 221, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 4483, 925, 199, 309, 378, 14449, 437, 983, 13, 9140, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 257, 925, 199, 309, 1663, 5738, 1821, 3408, 27, 2476, 7861, 925, 199, 309, 1928, 2755, 314, 221, 2478, 3750, 402, 3169, 503, 463, 925, 199, 309, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 259, 925, 199, 309, 367, 221, 1655, 2436, 14, 221, 2047, 1077, 1172, 221, 3086, 221, 282, 1331, 402, 314, 1664, 1696, 925, 199, 309, 1684, 844, 221, 1854, 543, 27650, 619, 27, 221, 1937, 570, 9685, 14, 221, 982, 440, 12, 2218, 925, 199, 309, 370, 221, 314, 221, 2868, 2290, 2752, 12, 221, 8026, 221, 11236, 221, 14259, 12, 221, 12066, 221, 11844, 12, 925, 199, 309, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 2476, 4519, 925, 199, 309, 6208, 3515, 925, 199, 309, 3709, 282, 4539, 1919, 12, 221, 340, 1163, 1584, 221, 17321, 221, 1519, 2932, 687, 642, 925, 199, 309, 4137, 12, 503, 1265, 2142, 221, 642, 4137, 543, 1163, 1584, 221, 370, 7389, 376, 7286, 12, 925, 199, 309, 642, 221, 4137, 221, 1630, 440, 221, 701, 6337, 7675, 221, 314, 9183, 221, 7286, 221, 370, 221, 506, 925, 199, 309, 24295, 221, 701, 314, 221, 1664, 221, 1696, 221, 1684, 221, 844, 14, 221, 961, 1919, 1630, 440, 925, 199, 309, 13432, 24841, 221, 1263, 1163, 14872, 10842, 221, 314, 7286, 570, 221, 5594, 506, 925, 199, 309, 24295, 701, 314, 221, 1664, 1684, 844, 14, 32543, 925, 199, 309, 6208, 3515, 925, 199, 4605, 199, 624, 4388, 199, 646, 1059, 199, 318, 370, 1257, 7488, 8, 83, 304, 2043, 340, 822, 8, 83, 9, 690, 14646, 26, 489, 308, 275, 308, 14, 1814, 480, 3872, 341, 2736, 2043, 340, 822, 8, 83, 9, 690, 14646, 26, 2126, 308, 29, 83, 4439, 2114, 61, 2043, 302, 29, 14646, 446, 822, 8, 83, 9, 2043, 302, 29, 78, 15, 18, 2043, 2203, 275, 298, 309, 2, 435, 1689, 298, 627, 302, 9, 435, 308, 2043, 2203, 275, 2203, 435, 1689, 298, 627, 334, 2114, 446, 822, 8, 3292, 1724, 435, 298, 309, 2, 2043, 372, 2203, 199, 199, 318, 664, 2567, 8, 70, 304, 2043, 536, 12, 832, 29, 7973, 8, 4846, 8, 70, 14, 354, 4059, 2043, 536, 29, 354, 14, 4142, 1252, 1814, 6096, 401, 1674, 531, 2043, 536, 275, 475, 1257, 7488, 8, 1059, 14, 904, 8, 354, 4589, 26725, 2043, 340, 1599, 389, 1674, 9402, 582, 489, 1599, 221, 275, 475, 1257, 7488, 480, 51, 299, 325, 286, 2, 776, 489, 372, 334, 7311, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 21385, 1814, 10064, 2266, 13, 531, 2043, 916, 1599, 389, 1674, 13741, 582, 489, 1599, 221, 275, 475, 1257, 7488, 480, 34, 312, 366, 612, 2, 776, 489, 372, 334, 7311, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 21385, 1814, 10064, 2266, 13, 531, 2043, 916, 1599, 389, 1674, 71, 2700, 582, 489, 1599, 221, 275, 475, 1257, 7488, 8, 298, 48, 519, 312, 1335, 325, 286, 307, 2, 776, 489, 372, 334, 7311, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 21385, 1814, 10064, 2266, 13, 531, 2043, 587, 26, 489, 1599, 221, 275, 475, 1257, 7488, 10804, 489, 372, 13053, 540, 450, 2420, 354, 2, 520, 536, 2360, 298, 832, 2, 520, 1599, 93, 199, 199, 318, 5325, 1173, 8, 70, 12, 1618, 304, 2043, 536, 12, 832, 29, 7973, 8, 4846, 8, 70, 14, 354, 4059, 2043, 3988, 275, 598, 5067, 14, 10423, 3299, 14, 362, 8, 70, 9, 2043, 5386, 29, 379, 14, 31272, 63, 1618, 63, 2738, 342, 2043, 340, 334, 832, 440, 315, 359, 1674, 71, 2700, 401, 1674, 13741, 401, 1674, 9402, 401, 1674, 67, 401, 1674, 5910, 401, 1674, 72, 401, 1674, 12156, 401, 1674, 13398, 21473, 489, 5386, 29, 5037, 14, 6688, 63, 604, 8, 17, 9, 2043, 2061, 29, 379, 14, 31272, 63, 1618, 63, 2738, 1252, 1733, 8, 82, 3212, 78, 60, 78, 401, 13156, 29, 549, 9, 8410, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 298, 8086, 1368, 8331, 13589, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 289, 14, 354, 1012, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 3886, 31275, 31275, 31275, 31275, 31275, 31275, 8999, 28, 531, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 3988, 14, 362, 63, 6574, 8, 5037, 12, 2019, 59, 16, 2459, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 3886, 31275, 31275, 31275, 31275, 31275, 31275, 8999, 28, 531, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 664, 2567, 8, 70, 430, 2043, 402, 14, 952, 3647, 83, 60, 78, 2, 450, 298, 8086, 1368, 8331, 13589, 199, 199, 1045, 570, 480, 808, 14, 548, 2266, 87, 531, 465, 402, 26, 523, 367, 284, 315, 598,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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, 0, 0, 0, 0, 0, 0, 0, 0 ]
sbsdev/daisyproducer
daisyproducer/documents/models.py
1
14120
import uuid, datetime from os.path import join from shutil import rmtree from daisyproducer.documents.storage import OverwriteStorage from django.conf import settings from django.contrib.auth.models import User, Group from django.db import models from django.db.models import Max from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ class StateError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) class State(models.Model): name = models.CharField(unique=True, max_length=32) next_states = models.ManyToManyField("self", symmetrical=False, blank=True) responsible = models.ManyToManyField(Group) sort_order = models.PositiveSmallIntegerField() def __unicode__(self): return self.name def transitionTo(self, state): if not isinstance(state, State): raise TypeError("'%s' is not a registered state" % state) if not state in self.next_states.all(): raise StateError("Cannot transition to %s from %s" % (self.name, state.name)) return state # used for admin view def all_next_states(self): return ",".join([state.name for state in self.next_states.all()]) # used for admin view def all_responsible(self): return ",".join([group.name for group in self.responsible.all()]) def is_last_state(self): return self.sort_order == State.objects.aggregate(final_sort_order=Max('sort_order')).get('final_sort_order') class Meta: ordering = ['sort_order'] class Document(models.Model): # see http://www.daisy.org/z3986/2005/Z3986-2005.html for a description of all the metadata fields title = models.CharField( _("Title"), max_length=255, help_text=_("The title of the DTB, including any subtitles")) author = models.CharField( _("Author"), max_length=255, help_text=_("Names of primary author or creator of the intellectual content of the publication"), blank=True) subject = models.CharField( _("Subject"), max_length=255, help_text=_("The topic of the content of the publication"), blank=True) description = models.TextField( _("Description"), help_text=_("Plain text describing the publication's content"), blank=True) publisher = models.CharField( _("Publisher"), max_length=255, default=settings.DAISY_DEFAULT_PUBLISHER, help_text=_("The agency responsible for making the DTB available")) date = models.DateField( _("Date"), help_text=_("Date of publication of the DTB")) identifier = models.CharField( _("Identifier"), max_length=255, unique=True, help_text=_("A string or number identifying the DTB")) source = models.CharField( _("Source"), max_length=20, help_text=_("A reference to a resource (e.g., a print original, ebook, etc.) from which the DTB is derived. Best practice is to use the ISBN when available"), blank=True) language_choices = (('de', 'de'), ('de-1901', 'de-1901',), # ('de-CH', 'de-CH',), # ('de-CH-1901', 'de-CH-1901',), # ('gsw', 'gsw',), ('en', 'en',), ('fr', 'fr',), # ('it', 'it',), ('es', 'es',), # ('und', 'Undefined',), ) language = models.CharField( _("Language"), max_length=10, choices=language_choices, help_text=_("Language of the content of the publication")) rights = models.CharField( _("Rights"), max_length=255, help_text=_("Information about rights held in and over the DTB"), blank=True) source_date = models.DateField( _("Source Date"), help_text=_("Date of publication of the resource (e.g., a print original, ebook, etc.) from which the DTB is derived"), null=True, blank=True) source_edition = models.CharField( _("Source Edition"), max_length=255, help_text=_("A string describing the edition of the resource (e.g., a print original, ebook, etc.) from which the DTB is derived"), blank=True) source_publisher = models.CharField( _("Source Publisher"), max_length=255, help_text=_("The agency responsible for making available the resource (e.g., a print original, ebook, etc.) from which the DTB is derived"), blank=True) source_rights = models.CharField( _("Source Rights"), max_length=255, help_text=_("Information about rights held in and over the resource (e.g., a print original, ebook, etc.) from which the DTB is derived"), blank=True) PRODUCTION_SERIES_CHOICES = ( ('SJW', 'SJW'), ('PPP', 'Rucksack-Buch',), ) production_series = models.CharField( _("Production Series"), max_length=25, choices=PRODUCTION_SERIES_CHOICES, help_text=_("Information about the series under which the book is produced"), blank=True) production_series_number = models.CharField( _("Production Series Number"), max_length=25, help_text=_("Information about the number in the series under which the book is produced"), blank=True) PRODUCTION_SOURCE_CHOICES = ( ('electronicData', 'Electronic Data'), ) production_source = models.CharField( _("Production Source"), max_length=25, choices=PRODUCTION_SOURCE_CHOICES, help_text=_("Information about the source from which the book was produced, e.g. scanned book, electronic data, etc"), blank=True) state = models.ForeignKey(State, verbose_name=_("State")) assigned_to = models.ForeignKey(User, verbose_name=_("Assigned to"), null=True, blank=True) created_at = models.DateTimeField(_("Created")) modified_at = models.DateTimeField(_("Last Modified")) def __unicode__(self): return self.title def latest_version(self): return self.version_set.latest() def transitionTo(self, state): self.assigned_to = None self.state = self.state.transitionTo(state) self.save() if self.state.is_last_state(): # we just transitioned to the last state. Presumably the # production is finished now. Since the images take up a # lot of space we'll remove them all. If a production is # picked up again we can alwas upload them again. for image in self.image_set.all(): # we have to loop over the images themselves to make # sure the delete method is invoked (which deletes the # image on the file system) image.delete() def has_local_words(self): return self.localword_set.exists() def save(self, *args, **kwargs): if not self.id: self.created_at = datetime.datetime.now() self.date = datetime.date.today() self.modified_at = datetime.datetime.now() # set initial state if not self.pk and not hasattr(self, 'state'): self.state = State.objects.filter(name='new')[0] if not self.identifier: self.identifier = "ch-sbs-%s" % str(uuid.uuid4()) super(Document, self).save(*args, **kwargs) def delete(self, *args, **kwargs): old_id = self.id super(Document, self).delete(*args, **kwargs) # remove the folders for versions and attachments on the file system rmtree(join(settings.MEDIA_ROOT, str(old_id))) def get_version_path(instance, filename): return '%s/versions/%s.xml' % (instance.document_id, instance.id) class Version(models.Model): comment = models.CharField(max_length=255) document = models.ForeignKey(Document) content = models.FileField(upload_to=get_version_path) created_by = models.ForeignKey(User, verbose_name=_("Created by")) created_at = models.DateTimeField(auto_now_add=True) def __unicode__(self): return u'%s, %s, %s' % (self.comment, self.created_by, self.created_at) def delete(self, *args, **kwargs): # remove the files on the file system self.content.delete() super(Version, self).delete(*args, **kwargs) class Meta: get_latest_by = "created_at" ordering = ['-created_at'] def get_attachment_path(instance, filename): return '%s/attachments/%s' % (instance.document_id, filename) class Attachment(models.Model): MIME_TYPE_CHOICES = ( ('application/pdf', 'Portable Document Format, PDF'), ('application/msword', 'Microsoft Word files'), ('application/rtf', 'Microsoft RTF files'), ('text/html', 'HTML'), ) comment = models.CharField(max_length=255) mime_type = models.CharField(max_length=32, choices=MIME_TYPE_CHOICES) document = models.ForeignKey(Document) content = models.FileField(upload_to=get_attachment_path) created_by = models.ForeignKey(User, verbose_name=_("Created by")) created_at = models.DateTimeField(auto_now_add=True) def delete(self, *args, **kwargs): # remove the files on the file system self.content.delete() super(Attachment, self).delete(*args, **kwargs) class Meta: ordering = ['-created_at'] def get_image_path(instance, filename): return '%s/images/%s' % (instance.document_id, filename) class Image(models.Model): MIME_TYPE_CHOICES = ( ('image/jpeg', 'JPEG image'), ('image/png', 'PNG image'), ) document = models.ForeignKey(Document) content = models.FileField(upload_to=get_image_path, storage=OverwriteStorage()) def __unicode__(self): return u'%s, %s' % (self.document, self.content) def delete(self, *args, **kwargs): # remove the files on the file system self.content.delete() super(Image, self).delete(*args, **kwargs) class Meta: unique_together = ('document', 'content') ordering = ['content'] class Product(models.Model): PRODUCT_TYPE_CHOICES = ( (0, 'Braille'), (1, 'Large Print'), (2, 'EBook'), (3, 'E-Text'), ) identifier = models.CharField(_("Identifier"), max_length=255, unique=True) type = models.PositiveSmallIntegerField(_("Type"), choices=PRODUCT_TYPE_CHOICES) document = models.ForeignKey(Document) def __unicode__(self): return self.identifier # Profiles class BrailleProfile(models.Model): BRAILLE_CONTRACTION_GRADE_CHOICES = ( ('0', _('Grade 0')), ('1', _('Grade 1')), ('2', _('Grade 2')), ) cells_per_line = models.PositiveSmallIntegerField(_("Cells per Line"), default=40) lines_per_page = models.PositiveSmallIntegerField(_("Lines per Page"), default=28) contraction = models.PositiveSmallIntegerField(_("Contraction"), default=0, choices=BRAILLE_CONTRACTION_GRADE_CHOICES) hyphenation = models.BooleanField(_("Hyphenation"), default=True) show_original_page_numbers = models.BooleanField(_("Show original page numbers"), default=True) enable_capitalization = models.BooleanField(_("Enable Capitalization"), default=False) detailed_accented_characters = models.BooleanField(_("Detailed Accented Characters"), default=False) class LargePrintProfile(models.Model): FONTSIZE_CHOICES = ( ('12pt', '12pt'), ('14pt', '14pt'), ('17pt', '17pt'), ('20pt', '20pt'), ('25pt', '25pt'), ) FONT_CHOICES = ( ('Tiresias LPfont', 'Tiresias LPfont'), ('Latin Modern Roman', 'Latin Modern Roman'), ('Latin Modern Sans', 'Latin Modern Sans'), ('Latin Modern Mono', 'Latin Modern Mono'), ) PAGESTYLE_CHOICES = ( ('plain', _('Plain')), ('withPageNums', _('With original page numbers')), ('spacious', _('Spacious')), ('scientific', _('Scientific')), ) ALIGNMENT_CHOICES = ( ('justified', _('justified')), ('left', _('left aligned')), ) PAPERSIZE_CHOICES = ( ('a3paper', 'a3paper'), ('a4paper', 'a4paper'), ) LINESPACING_CHOICES = ( ('singlespacing', _('Single spacing')), ('onehalfspacing', _('One-and-a-half spacing')), ('doublespacing', _('Double spacing')), ) ENDNOTE_CHOICES = ( ('none', _('Plain Footnotes')), ('document', _('Document Endnotes')), ('chapter', _('Chapter Endnotes')), ) IMAGE_CHOICES = ( ('show', _('Show Images')), ('ignore', _('Hide Images')), ) font_size = models.CharField(_("Fontsize"), default='17pt', max_length=4, choices=FONTSIZE_CHOICES) font = models.CharField(_("Font"), default='Tiresias LPfont', max_length=60, choices=FONT_CHOICES) page_style = models.CharField(_("Page style"), default='plain', max_length=16, choices=PAGESTYLE_CHOICES) alignment = models.CharField(default='left', max_length=16, choices=ALIGNMENT_CHOICES) stock_size = models.CharField(_("Stocksize"), default='a4paper', max_length=16, choices=PAPERSIZE_CHOICES) line_spacing = models.CharField(_("Line Spacing"), default='onehalfspacing', max_length=16, choices=LINESPACING_CHOICES) replace_em_with_quote = models.BooleanField(_("Replace italics with quote"), default=True) end_notes = models.CharField(_("End Notes"), default='none', max_length=16, choices=ENDNOTE_CHOICES) image_visibility = models.CharField(_("Images"), default='ignore', max_length=16, choices=IMAGE_CHOICES) class LargePrintProfileForm(ModelForm): class Meta: fields = "__all__" model = LargePrintProfile
agpl-3.0
[ 646, 5377, 12, 2197, 199, 504, 747, 14, 515, 492, 4263, 199, 504, 5145, 492, 20978, 199, 199, 504, 12927, 19765, 16376, 14, 12233, 14, 3494, 492, 7259, 952, 6408, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 12, 5611, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 8228, 199, 504, 1639, 14, 3351, 492, 28455, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 533, 8511, 547, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 339, 347, 636, 495, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 585, 9, 199, 199, 533, 8511, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 3235, 29, 549, 12, 1390, 63, 1267, 29, 708, 9, 272, 2163, 63, 4981, 275, 1709, 14, 7624, 480, 277, 401, 30091, 29, 797, 12, 4596, 29, 549, 9, 272, 17845, 275, 1709, 14, 7624, 8, 2448, 9, 272, 4069, 63, 1648, 275, 1709, 14, 25197, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 14116, 1378, 8, 277, 12, 1174, 304, 267, 340, 440, 1228, 8, 929, 12, 8511, 304, 288, 746, 3146, 21065, 83, 7, 365, 440, 282, 7264, 1174, 2, 450, 1174, 9, 267, 340, 440, 1174, 315, 291, 14, 2184, 63, 4981, 14, 452, 837, 288, 746, 8511, 547, 480, 6612, 14116, 370, 450, 83, 687, 450, 83, 2, 450, 334, 277, 14, 354, 12, 1174, 14, 354, 430, 267, 372, 1174, 2286, 327, 1202, 367, 4628, 2455, 272, 347, 1006, 63, 2184, 63, 4981, 8, 277, 304, 267, 372, 19089, 904, 779, 929, 14, 354, 367, 1174, 315, 291, 14, 2184, 63, 4981, 14, 452, 9383, 339, 327, 1202, 367, 4628, 2455, 272, 347, 1006, 63, 3853, 1164, 8, 277, 304, 267, 372, 19089, 904, 779, 923, 14, 354, 367, 1572, 315, 291, 14, 3853, 1164, 14, 452, 9383, 339, 347, 365, 63, 2019, 63, 929, 8, 277, 304, 267, 372, 291, 14, 3191, 63, 1648, 508, 8511, 14, 1462, 14, 7516, 8, 5094, 63, 3191, 63, 1648, 29, 4261, 360, 3191, 63, 1648, 11103, 362, 360, 5094, 63, 3191, 63, 1648, 358, 339, 1021, 6288, 26, 267, 7794, 275, 788, 3191, 63, 1648, 418, 199, 199, 533, 7543, 8, 992, 14, 1685, 304, 339, 327, 1937, 1455, 921, 1544, 14, 983, 19765, 14, 1308, 15, 90, 29451, 15, 9397, 15, 58, 29451, 13, 9397, 14, 1360, 367, 282, 1369, 402, 1006, 314, 3341, 1504, 272, 2538, 275, 1709, 14, 2183, 8, 267, 3824, 6888, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 1918, 2538, 402, 314, 19852, 34, 12, 5893, 1263, 19297, 2237, 272, 4132, 275, 1709, 14, 2183, 8, 267, 3824, 5949, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 5866, 402, 5062, 4132, 503, 14875, 402, 314, 27925, 1264, 1061, 1564, 402, 314, 31997, 1288, 267, 4596, 29, 549, 9, 272, 5420, 275, 1709, 14, 2183, 8, 267, 3824, 13528, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 1918, 7482, 402, 314, 1564, 402, 314, 31997, 1288, 267, 4596, 29, 549, 9, 272, 1369, 275, 1709, 14, 6254, 8, 267, 3824, 5831, 1288, 267, 1720, 63, 505, 9384, 20711, 1318, 13660, 314, 31997, 1159, 1564, 1288, 267, 4596, 29, 549, 9, 272, 19704, 275, 1709, 14, 2183, 8, 267, 3824, 27341, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 267, 849, 29, 1751, 14, 8980, 1311, 57, 63, 3472, 63, 30266, 1311, 3452, 12, 267, 1720, 63, 505, 9384, 1918, 1839, 9501, 17845, 367, 10663, 314, 19852, 34, 2808, 2237, 272, 1434, 275, 1709, 14, 14071, 8, 267, 3824, 2506, 1288, 267, 1720, 63, 505, 9384, 2506, 402, 31997, 402, 314, 19852, 34, 2237, 272, 5148, 275, 1709, 14, 2183, 8, 267, 3824, 7544, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 267, 3747, 29, 549, 12, 267, 1720, 63, 505, 9384, 33, 1059, 503, 1329, 21119, 314, 19852, 34, 2237, 272, 1350, 275, 1709, 14, 2183, 8, 267, 3824, 2980, 1288, 267, 1390, 63, 1267, 29, 1165, 12, 4960, 1720, 63, 505, 9384, 33, 3659, 370, 282, 2073, 334, 69, 14, 71, 2020, 282, 870, 3379, 12, 325, 2706, 12, 5423, 4959, 687, 1314, 314, 19852, 34, 365, 7131, 14, 699, 597, 24471, 365, 370, 675, 314, 2281, 18273, 1380, 2808, 1288, 4960, 4596, 29, 549, 9, 272, 2637, 63, 4577, 275, 13636, 271, 297, 283, 271, 659, 717, 661, 271, 13, 1167, 614, 297, 283, 271, 13, 1167, 614, 5529, 717, 327, 661, 271, 13, 1244, 297, 283, 271, 13, 1244, 5529, 717, 327, 661, 271, 13, 1244, 13, 1167, 614, 297, 283, 271, 13, 1244, 13, 1167, 614, 5529, 717, 327, 661, 458, 87, 297, 283, 458, 87, 5529, 717, 661, 287, 297, 283, 287, 5529, 717, 661, 4391, 297, 283, 4391, 5529, 717, 327, 661, 390, 297, 283, 390, 5529, 717, 661, 397, 297, 283, 397, 5529, 717, 327, 661, 725, 297, 283, 16283, 5529, 717, 776, 272, 2637, 275, 1709, 14, 2183, 8, 267, 3824, 8493, 1288, 267, 1390, 63, 1267, 29, 709, 12, 267, 3415, 29, 3671, 63, 4577, 12, 267, 1720, 63, 505, 9384, 8493, 402, 314, 1564, 402, 314, 31997, 2237, 272, 4481, 275, 1709, 14, 2183, 8, 267, 3824, 50, 2492, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 4935, 3595, 4481, 23608, 315, 436, 1806, 314, 19852, 34, 1288, 267, 4596, 29, 549, 9, 2286, 1350, 63, 602, 275, 1709, 14, 14071, 8, 267, 3824, 2980, 6148, 1288, 267, 1720, 63, 505, 9384, 2506, 402, 31997, 402, 314, 2073, 334, 69, 14, 71, 2020, 282, 870, 3379, 12, 325, 2706, 12, 5423, 4959, 687, 1314, 314, 19852, 34, 365, 7131, 1288, 267, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 1350, 63, 69, 1671, 275, 1709, 14, 2183, 8, 267, 3824, 2980, 662, 1671, 1288, 4960, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 33, 1059 ]
[ 5377, 12, 2197, 199, 504, 747, 14, 515, 492, 4263, 199, 504, 5145, 492, 20978, 199, 199, 504, 12927, 19765, 16376, 14, 12233, 14, 3494, 492, 7259, 952, 6408, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 12, 5611, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 8228, 199, 504, 1639, 14, 3351, 492, 28455, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 533, 8511, 547, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 339, 347, 636, 495, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 585, 9, 199, 199, 533, 8511, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 3235, 29, 549, 12, 1390, 63, 1267, 29, 708, 9, 272, 2163, 63, 4981, 275, 1709, 14, 7624, 480, 277, 401, 30091, 29, 797, 12, 4596, 29, 549, 9, 272, 17845, 275, 1709, 14, 7624, 8, 2448, 9, 272, 4069, 63, 1648, 275, 1709, 14, 25197, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 14116, 1378, 8, 277, 12, 1174, 304, 267, 340, 440, 1228, 8, 929, 12, 8511, 304, 288, 746, 3146, 21065, 83, 7, 365, 440, 282, 7264, 1174, 2, 450, 1174, 9, 267, 340, 440, 1174, 315, 291, 14, 2184, 63, 4981, 14, 452, 837, 288, 746, 8511, 547, 480, 6612, 14116, 370, 450, 83, 687, 450, 83, 2, 450, 334, 277, 14, 354, 12, 1174, 14, 354, 430, 267, 372, 1174, 2286, 327, 1202, 367, 4628, 2455, 272, 347, 1006, 63, 2184, 63, 4981, 8, 277, 304, 267, 372, 19089, 904, 779, 929, 14, 354, 367, 1174, 315, 291, 14, 2184, 63, 4981, 14, 452, 9383, 339, 327, 1202, 367, 4628, 2455, 272, 347, 1006, 63, 3853, 1164, 8, 277, 304, 267, 372, 19089, 904, 779, 923, 14, 354, 367, 1572, 315, 291, 14, 3853, 1164, 14, 452, 9383, 339, 347, 365, 63, 2019, 63, 929, 8, 277, 304, 267, 372, 291, 14, 3191, 63, 1648, 508, 8511, 14, 1462, 14, 7516, 8, 5094, 63, 3191, 63, 1648, 29, 4261, 360, 3191, 63, 1648, 11103, 362, 360, 5094, 63, 3191, 63, 1648, 358, 339, 1021, 6288, 26, 267, 7794, 275, 788, 3191, 63, 1648, 418, 199, 199, 533, 7543, 8, 992, 14, 1685, 304, 339, 327, 1937, 1455, 921, 1544, 14, 983, 19765, 14, 1308, 15, 90, 29451, 15, 9397, 15, 58, 29451, 13, 9397, 14, 1360, 367, 282, 1369, 402, 1006, 314, 3341, 1504, 272, 2538, 275, 1709, 14, 2183, 8, 267, 3824, 6888, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 1918, 2538, 402, 314, 19852, 34, 12, 5893, 1263, 19297, 2237, 272, 4132, 275, 1709, 14, 2183, 8, 267, 3824, 5949, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 5866, 402, 5062, 4132, 503, 14875, 402, 314, 27925, 1264, 1061, 1564, 402, 314, 31997, 1288, 267, 4596, 29, 549, 9, 272, 5420, 275, 1709, 14, 2183, 8, 267, 3824, 13528, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 1918, 7482, 402, 314, 1564, 402, 314, 31997, 1288, 267, 4596, 29, 549, 9, 272, 1369, 275, 1709, 14, 6254, 8, 267, 3824, 5831, 1288, 267, 1720, 63, 505, 9384, 20711, 1318, 13660, 314, 31997, 1159, 1564, 1288, 267, 4596, 29, 549, 9, 272, 19704, 275, 1709, 14, 2183, 8, 267, 3824, 27341, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 267, 849, 29, 1751, 14, 8980, 1311, 57, 63, 3472, 63, 30266, 1311, 3452, 12, 267, 1720, 63, 505, 9384, 1918, 1839, 9501, 17845, 367, 10663, 314, 19852, 34, 2808, 2237, 272, 1434, 275, 1709, 14, 14071, 8, 267, 3824, 2506, 1288, 267, 1720, 63, 505, 9384, 2506, 402, 31997, 402, 314, 19852, 34, 2237, 272, 5148, 275, 1709, 14, 2183, 8, 267, 3824, 7544, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 267, 3747, 29, 549, 12, 267, 1720, 63, 505, 9384, 33, 1059, 503, 1329, 21119, 314, 19852, 34, 2237, 272, 1350, 275, 1709, 14, 2183, 8, 267, 3824, 2980, 1288, 267, 1390, 63, 1267, 29, 1165, 12, 4960, 1720, 63, 505, 9384, 33, 3659, 370, 282, 2073, 334, 69, 14, 71, 2020, 282, 870, 3379, 12, 325, 2706, 12, 5423, 4959, 687, 1314, 314, 19852, 34, 365, 7131, 14, 699, 597, 24471, 365, 370, 675, 314, 2281, 18273, 1380, 2808, 1288, 4960, 4596, 29, 549, 9, 272, 2637, 63, 4577, 275, 13636, 271, 297, 283, 271, 659, 717, 661, 271, 13, 1167, 614, 297, 283, 271, 13, 1167, 614, 5529, 717, 327, 661, 271, 13, 1244, 297, 283, 271, 13, 1244, 5529, 717, 327, 661, 271, 13, 1244, 13, 1167, 614, 297, 283, 271, 13, 1244, 13, 1167, 614, 5529, 717, 327, 661, 458, 87, 297, 283, 458, 87, 5529, 717, 661, 287, 297, 283, 287, 5529, 717, 661, 4391, 297, 283, 4391, 5529, 717, 327, 661, 390, 297, 283, 390, 5529, 717, 661, 397, 297, 283, 397, 5529, 717, 327, 661, 725, 297, 283, 16283, 5529, 717, 776, 272, 2637, 275, 1709, 14, 2183, 8, 267, 3824, 8493, 1288, 267, 1390, 63, 1267, 29, 709, 12, 267, 3415, 29, 3671, 63, 4577, 12, 267, 1720, 63, 505, 9384, 8493, 402, 314, 1564, 402, 314, 31997, 2237, 272, 4481, 275, 1709, 14, 2183, 8, 267, 3824, 50, 2492, 1288, 267, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 4935, 3595, 4481, 23608, 315, 436, 1806, 314, 19852, 34, 1288, 267, 4596, 29, 549, 9, 2286, 1350, 63, 602, 275, 1709, 14, 14071, 8, 267, 3824, 2980, 6148, 1288, 267, 1720, 63, 505, 9384, 2506, 402, 31997, 402, 314, 2073, 334, 69, 14, 71, 2020, 282, 870, 3379, 12, 325, 2706, 12, 5423, 4959, 687, 1314, 314, 19852, 34, 365, 7131, 1288, 267, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 1350, 63, 69, 1671, 275, 1709, 14, 2183, 8, 267, 3824, 2980, 662, 1671, 1288, 4960, 1390, 63, 1267, 29, 2299, 12, 4960, 1720, 63, 505, 9384, 33, 1059, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
coberger/DIRAC
ResourceStatusSystem/Policy/test/Test_RSS_Policy_AlwaysActivePolicy.py
8
1380
# $HeadURL: $ ''' Test_RSS_Policy_AlwaysActivePolicy ''' import unittest import DIRAC.ResourceStatusSystem.Policy.AlwaysActivePolicy as moduleTested __RCSID__ = '$Id: $' ################################################################################ class AlwaysActivePolicy_TestCase( unittest.TestCase ): def setUp( self ): ''' Setup ''' self.moduleTested = moduleTested self.testClass = self.moduleTested.AlwaysActivePolicy def tearDown( self ): ''' TearDown ''' del self.testClass del self.moduleTested ################################################################################ # Tests class AlwaysActivePolicy_Success( AlwaysActivePolicy_TestCase ): def test_instantiate( self ): ''' tests that we can instantiate one object of the tested class ''' policy = self.testClass() self.assertEqual( 'AlwaysActivePolicy', policy.__class__.__name__ ) def test_evaluate( self ): ''' tests the evaluate method ''' policy = self.testClass() res = policy.evaluate() self.assertEqual( True, res[ 'OK' ] ) self.assertEqual( 'Active', res[ 'Value' ][ 'Status' ] ) ################################################################################ #EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
gpl-3.0
[ 3, 2672, 11664, 2632, 26, 221, 2672, 199, 2344, 1379, 63, 22786, 63, 4845, 63, 2439, 2885, 7472, 4845, 199, 2344, 199, 199, 646, 2882, 199, 199, 646, 26565, 14, 4031, 3694, 3989, 14, 4845, 14, 2439, 2885, 7472, 4845, 465, 859, 52, 3505, 199, 199, 363, 50, 3298, 998, 363, 275, 4505, 1304, 26, 2672, 7, 199, 199, 13289, 199, 199, 533, 16763, 7472, 4845, 63, 1746, 8, 2882, 14, 1746, 3461, 12244, 347, 3613, 8, 291, 3461, 272, 1449, 272, 12439, 272, 1449, 5493, 291, 14, 578, 52, 3505, 275, 859, 52, 3505, 272, 291, 14, 396, 2543, 259, 275, 291, 14, 578, 52, 3505, 14, 2439, 2885, 7472, 4845, 27404, 347, 6766, 8, 291, 3461, 272, 1449, 272, 377, 25236, 272, 1449, 272, 2150, 291, 14, 396, 2543, 272, 2150, 291, 14, 578, 52, 3505, 268, 199, 13289, 199, 3, 6496, 199, 199, 533, 16763, 7472, 4845, 63, 8300, 8, 16763, 7472, 4845, 63, 1746, 3461, 12244, 347, 511, 63, 3615, 18973, 8, 291, 3461, 272, 1449, 2295, 626, 781, 883, 17321, 1373, 909, 402, 314, 12470, 1021, 272, 1449, 257, 2286, 4592, 275, 291, 14, 396, 2543, 342, 272, 291, 14, 629, 8, 283, 2439, 2885, 7472, 4845, 297, 4592, 855, 533, 4914, 354, 363, 776, 257, 12244, 347, 511, 63, 7383, 8, 291, 3461, 272, 1449, 2295, 314, 9352, 1083, 272, 1449, 2286, 4592, 275, 291, 14, 396, 2543, 342, 272, 522, 275, 4592, 14, 7383, 342, 2286, 291, 14, 629, 8, 715, 12, 522, 59, 283, 3593, 7, 1622, 776, 272, 291, 14, 629, 8, 283, 7472, 297, 522, 59, 283, 1110, 7, 30479, 283, 3694, 7, 1622, 776, 26339, 199, 13289, 199, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2672, 11664, 2632, 26, 221, 2672, 199, 2344, 1379, 63, 22786, 63, 4845, 63, 2439, 2885, 7472, 4845, 199, 2344, 199, 199, 646, 2882, 199, 199, 646, 26565, 14, 4031, 3694, 3989, 14, 4845, 14, 2439, 2885, 7472, 4845, 465, 859, 52, 3505, 199, 199, 363, 50, 3298, 998, 363, 275, 4505, 1304, 26, 2672, 7, 199, 199, 13289, 199, 199, 533, 16763, 7472, 4845, 63, 1746, 8, 2882, 14, 1746, 3461, 12244, 347, 3613, 8, 291, 3461, 272, 1449, 272, 12439, 272, 1449, 5493, 291, 14, 578, 52, 3505, 275, 859, 52, 3505, 272, 291, 14, 396, 2543, 259, 275, 291, 14, 578, 52, 3505, 14, 2439, 2885, 7472, 4845, 27404, 347, 6766, 8, 291, 3461, 272, 1449, 272, 377, 25236, 272, 1449, 272, 2150, 291, 14, 396, 2543, 272, 2150, 291, 14, 578, 52, 3505, 268, 199, 13289, 199, 3, 6496, 199, 199, 533, 16763, 7472, 4845, 63, 8300, 8, 16763, 7472, 4845, 63, 1746, 3461, 12244, 347, 511, 63, 3615, 18973, 8, 291, 3461, 272, 1449, 2295, 626, 781, 883, 17321, 1373, 909, 402, 314, 12470, 1021, 272, 1449, 257, 2286, 4592, 275, 291, 14, 396, 2543, 342, 272, 291, 14, 629, 8, 283, 2439, 2885, 7472, 4845, 297, 4592, 855, 533, 4914, 354, 363, 776, 257, 12244, 347, 511, 63, 7383, 8, 291, 3461, 272, 1449, 2295, 314, 9352, 1083, 272, 1449, 2286, 4592, 275, 291, 14, 396, 2543, 342, 272, 522, 275, 4592, 14, 7383, 342, 2286, 291, 14, 629, 8, 715, 12, 522, 59, 283, 3593, 7, 1622, 776, 272, 291, 14, 629, 8, 283, 7472, 297, 522, 59, 283, 1110, 7, 30479, 283, 3694, 7, 1622, 776, 26339, 199, 13289, 199, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 3, 13178, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
EttusResearch/gnuradio
gr-blocks/python/blocks/qa_type_conversions.py
33
11818
#!/usr/bin/env python # # Copyright 2012,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, or (at your option) # any later version. # # GNU Radio 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 GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # from gnuradio import gr, gr_unittest, blocks from math import sqrt, atan2 class test_type_conversions(gr_unittest.TestCase): def setUp(self): self.tb = gr.top_block() def tearDown(self): self.tb = None def test_char_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) src = blocks.vector_source_b(src_data) op = blocks.char_to_float() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_char_to_float_scale(self): src_data = (1, 2, 3, 4, 5) expected_data = (0.5, 1.0, 1.5, 2.0, 2.5) src = blocks.vector_source_b(src_data) op = blocks.char_to_float(scale=2.0) dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_char_to_short(self): src_data = (1, 2, 3, 4, 5) expected_data = (256, 512, 768, 1024, 1280) src = blocks.vector_source_b(src_data) op = blocks.char_to_short() dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_complex_to_interleaved_short(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) src = blocks.vector_source_c(src_data) op = blocks.complex_to_interleaved_short() dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_complex_to_float_1(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (1.0, 3.0, 5.0, 7.0, 9.0) src = blocks.vector_source_c(src_data) op = blocks.complex_to_float() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_complex_to_float_2(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data1 = (1.0, 3.0, 5.0, 7.0, 9.0) expected_data2 = (2.0, 4.0, 6.0, 8.0, 10.0) src = blocks.vector_source_c(src_data) op = blocks.complex_to_float() dst1 = blocks.vector_sink_f() dst2 = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect((op, 0), dst1) self.tb.connect((op, 1), dst2) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data1, dst1.data()) self.assertFloatTuplesAlmostEqual(expected_data2, dst2.data()) def test_complex_to_real(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (1.0, 3.0, 5.0, 7.0, 9.0) src = blocks.vector_source_c(src_data) op = blocks.complex_to_real() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_complex_to_imag(self): src_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) expected_data = (2.0, 4.0, 6.0, 8.0, 10.0) src = blocks.vector_source_c(src_data) op = blocks.complex_to_imag() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_complex_to_mag(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (sqrt(5), sqrt(25), sqrt(61), sqrt(113), sqrt(181)) src = blocks.vector_source_c(src_data) op = blocks.complex_to_mag() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 5) def test_complex_to_mag_squared(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (5.0, 25.0, 61.0, 113.0, 181.0) src = blocks.vector_source_c(src_data) op = blocks.complex_to_mag_squared() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_complex_to_arg(self): src_data = (1+2j, 3-4j, 5+6j, 7-8j, -9+10j) expected_data = (atan2(2, 1), atan2(-4,3), atan2(6, 5), atan2(-8, 7), atan2(10,-9)) src = blocks.vector_source_c(src_data) op = blocks.complex_to_arg() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data(), 2) def test_float_to_char_identity(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (1, 2, 3, 4, 5) src = blocks.vector_source_f(src_data) op = blocks.float_to_char() dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_float_to_char_scale(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (5, 10, 15, 20, 25) src = blocks.vector_source_f(src_data) op = blocks.float_to_char(1, 5) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_float_to_complex_1(self): src_data = (1.0, 3.0, 5.0, 7.0, 9.0) expected_data = (1+0j, 3+0j, 5+0j, 7+0j, 9+0j) src = blocks.vector_source_f(src_data) op = blocks.float_to_complex() dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_float_to_complex_2(self): src1_data = (1.0, 3.0, 5.0, 7.0, 9.0) src2_data = (2.0, 4.0, 6.0, 8.0, 10.0) expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) src1 = blocks.vector_source_f(src1_data) src2 = blocks.vector_source_f(src2_data) op = blocks.float_to_complex() dst = blocks.vector_sink_c() self.tb.connect(src1, (op, 0)) self.tb.connect(src2, (op, 1)) self.tb.connect(op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_float_to_int_identity(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (1, 2, 3, 4, 5) src = blocks.vector_source_f(src_data) op = blocks.float_to_int() dst = blocks.vector_sink_i() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_float_to_int_scale(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (5, 10, 15, 20, 25) src = blocks.vector_source_f(src_data) op = blocks.float_to_int(1, 5) dst = blocks.vector_sink_i() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_float_to_short_identity(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (1, 2, 3, 4, 5) src = blocks.vector_source_f(src_data) op = blocks.float_to_short() dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_float_to_short_scale(self): src_data = (1.0, 2.0, 3.0, 4.0, 5.0) expected_data = (5, 10, 15, 20, 25) src = blocks.vector_source_f(src_data) op = blocks.float_to_short(1, 5) dst = blocks.vector_sink_s() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_float_to_uchar(self): src_data = (1.0, -2.0, 3.0, -4.0, 256.0) expected_data = (1, 0, 3, 0, 255) src = blocks.vector_source_f(src_data) op = blocks.float_to_uchar() dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_int_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) src = blocks.vector_source_i(src_data) op = blocks.int_to_float() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_int_to_float_scale(self): src_data = (1, 2, 3, 4, 5) expected_data = (0.2, 0.4, 0.6, 0.8, 1.0) src = blocks.vector_source_i(src_data) op = blocks.int_to_float(1, 5) dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) def test_interleaved_short_to_complex(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) src = blocks.vector_source_s(src_data) op = blocks.interleaved_short_to_complex() dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_short_to_char(self): src_data = (256, 512, 768, 1024, 1280) expected_data = (1, 2, 3, 4, 5) src = blocks.vector_source_s(src_data) op = blocks.short_to_char() dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_short_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) src = blocks.vector_source_s(src_data) op = blocks.short_to_float() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_short_to_float_scale(self): src_data = (5, 10, 15, 20, 25) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) src = blocks.vector_source_s(src_data) op = blocks.short_to_float(1, 5) dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) def test_uchar_to_float(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) src = blocks.vector_source_b(src_data) op = blocks.uchar_to_float() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertEqual(expected_data, dst.data()) if __name__ == '__main__': gr_unittest.run(test_type_conversions, "test_type_conversions.xml")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 12, 6965, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 24526, 492, 7192, 12, 7192, 63, 2796, 12, 5664, 199, 199, 504, 3473, 492, 7452, 12, 31393, 18, 199, 199, 533, 511, 63, 466, 63, 388, 6234, 8, 2587, 63, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 5842, 275, 7192, 14, 2119, 63, 1457, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 5842, 275, 488, 339, 347, 511, 63, 1560, 63, 475, 63, 1609, 63, 5582, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 9, 267, 1420, 63, 576, 275, 334, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 12, 841, 14, 16, 12, 959, 14, 16, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 1560, 63, 475, 63, 1609, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 479, 5136, 7075, 83, 7331, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 1560, 63, 475, 63, 1609, 63, 3467, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 9, 267, 1420, 63, 576, 275, 334, 16, 14, 21, 12, 413, 14, 16, 12, 413, 14, 21, 12, 499, 14, 16, 12, 499, 14, 21, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 1560, 63, 475, 63, 1609, 8, 3467, 29, 18, 14, 16, 9, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 479, 5136, 7075, 83, 7331, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 1560, 63, 475, 63, 3612, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 9, 267, 1420, 63, 576, 275, 334, 3912, 12, 10574, 12, 32404, 12, 6619, 12, 3144, 1257, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 1560, 63, 475, 63, 3612, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 83, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 5254, 63, 475, 63, 1058, 274, 4292, 63, 3612, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 11, 18, 74, 12, 650, 11, 20, 74, 12, 959, 11, 22, 74, 12, 1520, 11, 24, 74, 12, 1749, 11, 709, 74, 9, 267, 1420, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 12, 1616, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 67, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 5254, 63, 475, 63, 1058, 274, 4292, 63, 3612, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 83, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 5254, 63, 475, 63, 1609, 63, 17, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 11, 18, 74, 12, 650, 11, 20, 74, 12, 959, 11, 22, 74, 12, 1520, 11, 24, 74, 12, 1749, 11, 709, 74, 9, 267, 1420, 63, 576, 275, 334, 17, 14, 16, 12, 650, 14, 16, 12, 959, 14, 16, 12, 1520, 14, 16, 12, 1749, 14, 16, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 67, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 5254, 63, 475, 63, 1609, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 479, 5136, 7075, 83, 7331, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 5254, 63, 475, 63, 1609, 63, 18, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 11, 18, 74, 12, 650, 11, 20, 74, 12, 959, 11, 22, 74, 12, 1520, 11, 24, 74, 12, 1749, 11, 709, 74, 9, 267, 1420, 63, 576, 17, 275, 334, 17, 14, 16, 12, 650, 14, 16, 12, 959, 14, 16, 12, 1520, 14, 16, 12, 1749, 14, 16, 9, 267, 1420, 63, 576, 18, 275, 334, 18, 14, 16, 12, 841 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6029, 12, 6965, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 24526, 492, 7192, 12, 7192, 63, 2796, 12, 5664, 199, 199, 504, 3473, 492, 7452, 12, 31393, 18, 199, 199, 533, 511, 63, 466, 63, 388, 6234, 8, 2587, 63, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 5842, 275, 7192, 14, 2119, 63, 1457, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 5842, 275, 488, 339, 347, 511, 63, 1560, 63, 475, 63, 1609, 63, 5582, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 9, 267, 1420, 63, 576, 275, 334, 17, 14, 16, 12, 499, 14, 16, 12, 650, 14, 16, 12, 841, 14, 16, 12, 959, 14, 16, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 1560, 63, 475, 63, 1609, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 479, 5136, 7075, 83, 7331, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 1560, 63, 475, 63, 1609, 63, 3467, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 9, 267, 1420, 63, 576, 275, 334, 16, 14, 21, 12, 413, 14, 16, 12, 413, 14, 21, 12, 499, 14, 16, 12, 499, 14, 21, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 1560, 63, 475, 63, 1609, 8, 3467, 29, 18, 14, 16, 9, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 479, 5136, 7075, 83, 7331, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 1560, 63, 475, 63, 3612, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 9, 267, 1420, 63, 576, 275, 334, 3912, 12, 10574, 12, 32404, 12, 6619, 12, 3144, 1257, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 66, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 1560, 63, 475, 63, 3612, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 83, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 5254, 63, 475, 63, 1058, 274, 4292, 63, 3612, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 11, 18, 74, 12, 650, 11, 20, 74, 12, 959, 11, 22, 74, 12, 1520, 11, 24, 74, 12, 1749, 11, 709, 74, 9, 267, 1420, 63, 576, 275, 334, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 12, 1616, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 67, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 5254, 63, 475, 63, 1058, 274, 4292, 63, 3612, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 83, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 629, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 5254, 63, 475, 63, 1609, 63, 17, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 11, 18, 74, 12, 650, 11, 20, 74, 12, 959, 11, 22, 74, 12, 1520, 11, 24, 74, 12, 1749, 11, 709, 74, 9, 267, 1420, 63, 576, 275, 334, 17, 14, 16, 12, 650, 14, 16, 12, 959, 14, 16, 12, 1520, 14, 16, 12, 1749, 14, 16, 9, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 67, 8, 2164, 63, 576, 9, 267, 1687, 275, 5664, 14, 5254, 63, 475, 63, 1609, 342, 267, 5042, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 2242, 8, 2164, 12, 1687, 12, 5042, 9, 267, 291, 14, 5842, 14, 1065, 342, 267, 291, 14, 479, 5136, 7075, 83, 7331, 8, 2062, 63, 576, 12, 5042, 14, 576, 1012, 339, 347, 511, 63, 5254, 63, 475, 63, 1609, 63, 18, 8, 277, 304, 267, 2928, 63, 576, 275, 334, 17, 11, 18, 74, 12, 650, 11, 20, 74, 12, 959, 11, 22, 74, 12, 1520, 11, 24, 74, 12, 1749, 11, 709, 74, 9, 267, 1420, 63, 576, 17, 275, 334, 17, 14, 16, 12, 650, 14, 16, 12, 959, 14, 16, 12, 1520, 14, 16, 12, 1749, 14, 16, 9, 267, 1420, 63, 576, 18, 275, 334, 18, 14, 16, 12, 841, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
openmotics/gateway
testing/unittests/gateway_tests/output_controller_test.py
1
15041
# Copyright (C) 2020 OpenMotics BV # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import import unittest import fakesleep import mock from peewee import SqliteDatabase from bus.om_bus_client import MessageClient from gateway.dto import OutputDTO, OutputStatusDTO from gateway.events import GatewayEvent from gateway.hal.master_controller import MasterController from gateway.hal.master_event import MasterEvent from gateway.maintenance_controller import MaintenanceController from gateway.models import Output, Room from gateway.output_controller import OutputController, OutputStateCache from gateway.pubsub import PubSub from ioc import SetTestMode, SetUpTestInjections MODELS = [Output, Room] class OutputControllerTest(unittest.TestCase): @classmethod def setUpClass(cls): SetTestMode() cls.test_db = SqliteDatabase(':memory:') fakesleep.monkey_patch() @classmethod def tearDownClass(cls): super(OutputControllerTest, cls).tearDownClass() fakesleep.monkey_restore() def setUp(self): self.test_db.bind(MODELS, bind_refs=False, bind_backrefs=False) self.test_db.connect() self.test_db.create_tables(MODELS) self.master_controller = mock.Mock(MasterController) self.pubsub = PubSub() SetUpTestInjections(maintenance_controller=mock.Mock(MaintenanceController), master_controller=self.master_controller, message_client=mock.Mock(MessageClient), pubsub=self.pubsub) self.controller = OutputController() def tearDown(self): self.test_db.drop_tables(MODELS) self.test_db.close() def test_orm_sync(self): events = [] def handle_event(gateway_event): events.append(gateway_event) self.pubsub.subscribe_gateway_events(PubSub.GatewayTopics.CONFIG, handle_event) output_dto = OutputDTO(id=42) with mock.patch.object(self.master_controller, 'load_outputs', return_value=[output_dto]): self.controller.run_sync_orm() self.pubsub._publish_all_events() assert Output.select().where(Output.number == output_dto.id).count() == 1 assert GatewayEvent(GatewayEvent.Types.CONFIG_CHANGE, {'type': 'output'}) in events assert len(events) == 1 def test_output_sync_change(self): events = [] def on_change(gateway_event): events.append(gateway_event) self.pubsub.subscribe_gateway_events(PubSub.GatewayTopics.STATE, on_change) outputs = {2: OutputDTO(id=2), 40: OutputDTO(id=40, module_type='D')} select_mock = mock.Mock() select_mock.join_from.return_value = [Output(id=0, number=2), Output(id=1, number=40, room=Room(id=2, number=3))] with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', side_effect=lambda output_id: outputs.get(output_id)), \ mock.patch.object(self.master_controller, 'load_output_status', return_value=[OutputStatusDTO(id=2, status=True), OutputStatusDTO(id=40, status=True)]): self.controller._sync_state() self.pubsub._publish_all_events() assert [GatewayEvent('OUTPUT_CHANGE', {'id': 2, 'status': {'on': True, 'locked': False}, 'location': {'room_id': 255}}), GatewayEvent('OUTPUT_CHANGE', {'id': 40, 'status': {'on': True, 'value': 0, 'locked': False}, 'location': {'room_id': 3}})] == events select_mock = mock.Mock() select_mock.join_from.return_value = [Output(id=0, number=2), Output(id=1, number=40, room=Room(id=2, number=3))] with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', side_effect=lambda output_id: outputs.get(output_id)), \ mock.patch.object(self.master_controller, 'load_output_status', return_value=[OutputStatusDTO(id=2, status=True, dimmer=0), OutputStatusDTO(id=40, status=True, dimmer=50)]): events = [] self.controller._sync_state() self.pubsub._publish_all_events() assert [GatewayEvent('OUTPUT_CHANGE', {'id': 2, 'status': {'on': True, 'locked': False}, 'location': {'room_id': 255}}), GatewayEvent('OUTPUT_CHANGE', {'id': 40, 'status': {'on': True, 'value': 50, 'locked': False}, 'location': {'room_id': 3}})] == events def test_output_master_change(self): events = [] def on_change(gateway_event): events.append(gateway_event) self.pubsub.subscribe_gateway_events(PubSub.GatewayTopics.STATE, on_change) self.controller._cache.update_outputs([OutputDTO(id=2), OutputDTO(id=40, module_type='D', room=3)]) self.controller._handle_master_event(MasterEvent('OUTPUT_STATUS', {'state': OutputStatusDTO(id=2, status=False)})) self.controller._handle_master_event(MasterEvent('OUTPUT_STATUS', {'state': OutputStatusDTO(id=40, status=True, dimmer=100)})) self.pubsub._publish_all_events() events = [] self.controller._handle_master_event(MasterEvent('OUTPUT_STATUS', {'state': OutputStatusDTO(id=2, status=True)})) self.controller._handle_master_event(MasterEvent('OUTPUT_STATUS', {'state': OutputStatusDTO(id=40, status=True)})) self.pubsub._publish_all_events() assert [GatewayEvent('OUTPUT_CHANGE', {'id': 2, 'status': {'on': True, 'locked': False}, 'location': {'room_id': 255}})] == events events = [] self.controller._handle_master_event(MasterEvent('OUTPUT_STATUS', {'state': OutputStatusDTO(id=40, dimmer=50)})) self.pubsub._publish_all_events() assert [GatewayEvent('OUTPUT_CHANGE', {'id': 40, 'status': {'on': True, 'value': 50, 'locked': False}, 'location': {'room_id': 3}})] == events def test_get_last_outputs(self): master_dtos = {1: OutputDTO(id=1, name='one'), 2: OutputDTO(id=2, name='two')} orm_outputs = [Output(id=10, number=1), Output(id=11, number=2)] select_mock = mock.Mock() select_mock.join_from.return_value = orm_outputs with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', side_effect=lambda output_id: master_dtos.get(output_id)): fakesleep.reset(0) self.controller.load_outputs() # test 1: all outputs should have a new status upon init last_outputs = self.controller.get_last_outputs() self.assertEqual([1, 2], last_outputs) # test 2: after 10 seconds, all statuses are stable, and not in last outputs fakesleep.sleep(15) last_outputs = self.controller.get_last_outputs() self.assertEqual([], last_outputs) # test 3: a new state comes from the master, this should trigger and appear in the recent list master_event = MasterEvent(event_type=MasterEvent.Types.OUTPUT_STATUS, data={'state': OutputStatusDTO(id=2, status=True)}) self.controller._handle_master_event(master_event) last_outputs = self.controller.get_last_outputs() self.assertEqual([2], last_outputs) # test 4: after 10 seconds, all statuses are stable, and not in last outputs fakesleep.sleep(15) last_outputs = self.controller.get_last_outputs() self.assertEqual([], last_outputs) # test 3: a new state comes from the master, this should also trigger and appear in the recent list master_event = MasterEvent(event_type=MasterEvent.Types.OUTPUT_STATUS, data={'state': OutputStatusDTO(id=2, status=False)}) self.controller._handle_master_event(master_event) last_outputs = self.controller.get_last_outputs() self.assertEqual([2], last_outputs) def test_get_output_status(self): select_mock = mock.Mock() select_mock.join_from.return_value = [Output(id=0, number=2), Output(id=1, number=40, room=Room(id=2, number=3))] with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', side_effect=lambda output_id: OutputDTO(id=output_id)), \ mock.patch.object(self.master_controller, 'load_output_status', return_value=[OutputStatusDTO(id=2, status=False), OutputStatusDTO(id=40, status=True)]): self.controller._sync_state() status = self.controller.get_output_status(40) assert status == OutputStatusDTO(id=40, status=True) def test_get_output_statuses(self): select_mock = mock.Mock() select_mock.join_from.return_value = [Output(id=0, number=2), Output(id=1, number=40, module_type='D', room=Room(id=2, number=3))] with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', side_effect=lambda output_id: OutputDTO(id=output_id)), \ mock.patch.object(self.master_controller, 'load_output_status', return_value=[OutputStatusDTO(id=2, status=False, dimmer=0), OutputStatusDTO(id=40, status=True, dimmer=50)]): self.controller._sync_state() status = self.controller.get_output_statuses() assert len(status) == 2 assert OutputStatusDTO(id=2, status=False) in status assert OutputStatusDTO(id=40, status=True, dimmer=50) in status def test_load_output(self): where_mock = mock.Mock() where_mock.get.return_value = Output(id=1, number=42, room=Room(id=2, number=3)) join_from_mock = mock.Mock() join_from_mock.where.return_value = where_mock select_mock = mock.Mock() select_mock.join_from.return_value = join_from_mock with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', return_value=OutputDTO(id=42)) as load: output = self.controller.load_output(42) assert output == OutputDTO(id=42, room=3) load.assert_called_with(output_id=42) def test_load_outputs(self): select_mock = mock.Mock() select_mock.join_from.return_value = [Output(id=1, number=42, room=Room(id=2, number=3))] with mock.patch.object(Output, 'select', return_value=select_mock), \ mock.patch.object(self.master_controller, 'load_output', return_value=OutputDTO(id=42)) as load: outputs = self.controller.load_outputs() assert OutputDTO(id=42, room=3) in outputs load.assert_called_with(output_id=42) def test_output_actions(self): room = Room.create(number=10) Output.create(number=2, room=room) Output.create(number=3) with mock.patch.object(self.master_controller, 'set_all_lights') as call: self.controller.set_all_lights(action='OFF') call.assert_called_once_with(action='OFF') with mock.patch.object(self.master_controller, 'set_all_lights') as call: self.controller.set_all_lights(action='ON') call.assert_called_once_with(action='ON') class OutputStateCacheTest(unittest.TestCase): def test_update(self): _ = self cache = OutputStateCache() cache.update_outputs([OutputDTO(id=0), OutputDTO(id=1), OutputDTO(id=2)]) current_state = cache.get_state() assert {0: OutputStatusDTO(id=0), 1: OutputStatusDTO(id=1), 2: OutputStatusDTO(id=2)} == current_state # Everything is off. assert cache.handle_change(OutputStatusDTO(0, status=False))[0] is False assert cache.handle_change(OutputStatusDTO(1, status=False))[0] is False assert cache.handle_change(OutputStatusDTO(2, status=False))[0] is False # Turn two outputs on. assert cache.handle_change(OutputStatusDTO(0, status=False))[0] is False changed, output_dto = cache.handle_change(OutputStatusDTO(2, status=True)) assert output_dto.state.status is True assert changed is True changed, output_dto = cache.handle_change(OutputStatusDTO(1, status=True)) assert output_dto.state.status is True assert changed is True # Turn one outputs off again. assert cache.handle_change(OutputStatusDTO(0, status=False))[0] is False changed, output_dto = cache.handle_change(OutputStatusDTO(1, status=False)) assert output_dto.state.status is False assert changed is True # Change dimmer value. assert cache.handle_change(OutputStatusDTO(0, dimmer=0))[0] is False changed, output_dto = cache.handle_change(OutputStatusDTO(1, status=True, dimmer=100)) assert output_dto.state.dimmer == 100 assert changed is True changed, output_dto = cache.handle_change(OutputStatusDTO(1, dimmer=50)) assert output_dto.state.dimmer is 50 assert changed is True # Change lock. assert cache.handle_change(OutputStatusDTO(0, locked=False))[0] is False changed, output_dto = cache.handle_change(OutputStatusDTO(1, locked=True)) assert output_dto.state.locked is True assert changed is True
agpl-3.0
[ 3, 1898, 334, 35, 9, 25455, 3232, 3716, 7769, 699, 54, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2882, 199, 199, 646, 14063, 3614, 199, 646, 1683, 199, 504, 4837, 546, 1024, 492, 428, 29498, 7243, 199, 199, 504, 10414, 14, 676, 63, 5610, 63, 1258, 492, 6430, 3041, 199, 504, 10391, 14, 68, 475, 492, 7242, 36, 2566, 12, 7242, 3694, 36, 2566, 199, 504, 10391, 14, 4368, 492, 27166, 2390, 199, 504, 10391, 14, 19785, 14, 4133, 63, 5538, 492, 26728, 7506, 199, 504, 10391, 14, 19785, 14, 4133, 63, 1430, 492, 26728, 2390, 199, 504, 10391, 14, 19725, 63, 5538, 492, 11298, 12182, 7506, 199, 504, 10391, 14, 992, 492, 7242, 12, 6848, 676, 199, 504, 10391, 14, 1199, 63, 5538, 492, 7242, 7506, 12, 7242, 2223, 4437, 199, 504, 10391, 14, 20213, 492, 510, 456, 2610, 199, 504, 284, 679, 492, 2494, 774, 1385, 12, 2494, 1721, 774, 607, 6532, 2452, 199, 199, 11429, 51, 275, 359, 2959, 12, 6848, 676, 61, 421, 199, 533, 7242, 7506, 774, 8, 2796, 14, 1746, 304, 272, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 2494, 774, 1385, 342, 267, 843, 14, 396, 63, 697, 275, 428, 29498, 7243, 6176, 4844, 10993, 267, 14063, 3614, 14, 20372, 63, 2068, 342, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 1613, 8, 2959, 7506, 774, 12, 843, 680, 12336, 2543, 342, 267, 14063, 3614, 14, 20372, 63, 8011, 342, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 396, 63, 697, 14, 3409, 8, 11429, 51, 12, 5398, 63, 7655, 29, 797, 12, 5398, 63, 894, 7655, 29, 797, 9, 267, 291, 14, 396, 63, 697, 14, 2242, 342, 267, 291, 14, 396, 63, 697, 14, 981, 63, 5987, 8, 11429, 51, 9, 267, 291, 14, 4133, 63, 5538, 275, 1683, 14, 3346, 8, 12288, 7506, 9, 267, 291, 14, 20213, 275, 510, 456, 2610, 342, 267, 2494, 1721, 774, 607, 6532, 2452, 8, 19725, 63, 5538, 29, 1805, 14, 3346, 8, 6756, 12182, 7506, 395, 1169, 5288, 63, 5538, 29, 277, 14, 4133, 63, 5538, 12, 1169, 1245, 63, 1258, 29, 1805, 14, 3346, 8, 2209, 3041, 395, 1169, 7974, 954, 29, 277, 14, 20213, 9, 267, 291, 14, 5538, 275, 7242, 7506, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 396, 63, 697, 14, 4824, 63, 5987, 8, 11429, 51, 9, 267, 291, 14, 396, 63, 697, 14, 1600, 342, 339, 347, 511, 63, 1025, 63, 5186, 8, 277, 304, 267, 4474, 275, 942, 398, 347, 2429, 63, 1430, 8, 7019, 63, 1430, 304, 288, 4474, 14, 740, 8, 7019, 63, 1430, 9, 398, 291, 14, 20213, 14, 10108, 63, 7019, 63, 4368, 8, 18060, 2610, 14, 12455, 6105, 2932, 14, 5569, 12, 2429, 63, 1430, 9, 398, 1072, 63, 68, 475, 275, 7242, 36, 2566, 8, 344, 29, 2260, 9, 267, 543, 1683, 14, 2068, 14, 785, 8, 277, 14, 4133, 63, 5538, 12, 283, 912, 63, 4467, 297, 372, 63, 585, 1524, 1199, 63, 68, 475, 4682, 288, 291, 14, 5538, 14, 1065, 63, 5186, 63, 1025, 342, 288, 291, 14, 20213, 423, 4763, 63, 452, 63, 4368, 342, 288, 702, 7242, 14, 2416, 1252, 4509, 8, 2959, 14, 1955, 508, 1072, 63, 68, 475, 14, 344, 680, 835, 342, 508, 413, 288, 702, 27166, 2390, 8, 12455, 2390, 14, 4100, 14, 5569, 63, 16062, 12, 791, 466, 356, 283, 1199, 3071, 315, 4474, 288, 702, 822, 8, 4368, 9, 508, 413, 339, 347, 511, 63, 1199, 63, 5186, 63, 1461, 8, 277, 304, 267, 4474, 275, 942, 398, 347, 641, 63, 1461, 8, 7019, 63, 1430, 304, 288, 4474, 14, 740, 8, 7019, 63, 1430, 9, 398, 291, 14, 20213, 14, 10108, 63, 7019, 63, 4368, 8, 18060, 2610, 14, 12455, 6105, 2932, 14, 6689, 12, 641, 63, 1461, 9, 398, 4704, 275, 469, 18, 26, 7242, 36, 2566, 8, 344, 29, 18, 395, 673, 6335, 26, 7242, 36, 2566, 8, 344, 29, 2167, 12, 859, 63, 466, 534, 36, 21004, 267, 3504, 63, 1805, 275, 1683, 14, 3346, 342, 267, 3504, 63, 1805, 14, 904, 63, 504, 14, 1107, 63, 585, 275, 359, 2959, 8, 344, 29, 16, 12, 1329, 29, 18, 395, 6343, 7242, 8, 344, 29, 17, 12, 1329, 29, 2167, 12, 14726, 29, 25779, 8, 344, 29, 18, 12, 1329, 29, 19, 10524, 267, 543, 1683, 14, 2068, 14, 785, 8, 2959, 12, 283, 2416, 297, 372, 63, 585, 29, 2416, 63, 1805, 395, 971, 1467, 1683, 14, 2068, 14, 785, 8, 277, 14, 4133, 63, 5538, 12, 283, 912, 63, 1199, 297, 3044, 5366, 63, 5881, 29, 2734, 1072, 63, 344, 26, 4704, 14, 362, 8, 1199, 63, 344, 1826, 971, 1467, 1683, 14, 2068, 14, 785, 8, 277, 14, 4133, 63, 5538, 12, 283, 912, 63, 1199, 63, 1205, 297, 3044, 372, 63, 585, 1524, 2959, 3694, 36, 2566, 8, 344, 29, 18, 12, 2004, 29, 549, 395, 6163, 7242, 3694, 36, 2566, 8, 344, 29, 2167, 12, 2004, 29, 549, 31540, 288, 291, 14, 5538, 423, 5186, 63, 929, 342, 288, 291, 14, 20213, 423, 4763, 63, 452, 63, 4368, 342, 288, 702, 359, 12455, 2390, 360, 8414, 63 ]
[ 1898, 334, 35, 9, 25455, 3232, 3716, 7769, 699, 54, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2882, 199, 199, 646, 14063, 3614, 199, 646, 1683, 199, 504, 4837, 546, 1024, 492, 428, 29498, 7243, 199, 199, 504, 10414, 14, 676, 63, 5610, 63, 1258, 492, 6430, 3041, 199, 504, 10391, 14, 68, 475, 492, 7242, 36, 2566, 12, 7242, 3694, 36, 2566, 199, 504, 10391, 14, 4368, 492, 27166, 2390, 199, 504, 10391, 14, 19785, 14, 4133, 63, 5538, 492, 26728, 7506, 199, 504, 10391, 14, 19785, 14, 4133, 63, 1430, 492, 26728, 2390, 199, 504, 10391, 14, 19725, 63, 5538, 492, 11298, 12182, 7506, 199, 504, 10391, 14, 992, 492, 7242, 12, 6848, 676, 199, 504, 10391, 14, 1199, 63, 5538, 492, 7242, 7506, 12, 7242, 2223, 4437, 199, 504, 10391, 14, 20213, 492, 510, 456, 2610, 199, 504, 284, 679, 492, 2494, 774, 1385, 12, 2494, 1721, 774, 607, 6532, 2452, 199, 199, 11429, 51, 275, 359, 2959, 12, 6848, 676, 61, 421, 199, 533, 7242, 7506, 774, 8, 2796, 14, 1746, 304, 272, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 2494, 774, 1385, 342, 267, 843, 14, 396, 63, 697, 275, 428, 29498, 7243, 6176, 4844, 10993, 267, 14063, 3614, 14, 20372, 63, 2068, 342, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 1613, 8, 2959, 7506, 774, 12, 843, 680, 12336, 2543, 342, 267, 14063, 3614, 14, 20372, 63, 8011, 342, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 396, 63, 697, 14, 3409, 8, 11429, 51, 12, 5398, 63, 7655, 29, 797, 12, 5398, 63, 894, 7655, 29, 797, 9, 267, 291, 14, 396, 63, 697, 14, 2242, 342, 267, 291, 14, 396, 63, 697, 14, 981, 63, 5987, 8, 11429, 51, 9, 267, 291, 14, 4133, 63, 5538, 275, 1683, 14, 3346, 8, 12288, 7506, 9, 267, 291, 14, 20213, 275, 510, 456, 2610, 342, 267, 2494, 1721, 774, 607, 6532, 2452, 8, 19725, 63, 5538, 29, 1805, 14, 3346, 8, 6756, 12182, 7506, 395, 1169, 5288, 63, 5538, 29, 277, 14, 4133, 63, 5538, 12, 1169, 1245, 63, 1258, 29, 1805, 14, 3346, 8, 2209, 3041, 395, 1169, 7974, 954, 29, 277, 14, 20213, 9, 267, 291, 14, 5538, 275, 7242, 7506, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 396, 63, 697, 14, 4824, 63, 5987, 8, 11429, 51, 9, 267, 291, 14, 396, 63, 697, 14, 1600, 342, 339, 347, 511, 63, 1025, 63, 5186, 8, 277, 304, 267, 4474, 275, 942, 398, 347, 2429, 63, 1430, 8, 7019, 63, 1430, 304, 288, 4474, 14, 740, 8, 7019, 63, 1430, 9, 398, 291, 14, 20213, 14, 10108, 63, 7019, 63, 4368, 8, 18060, 2610, 14, 12455, 6105, 2932, 14, 5569, 12, 2429, 63, 1430, 9, 398, 1072, 63, 68, 475, 275, 7242, 36, 2566, 8, 344, 29, 2260, 9, 267, 543, 1683, 14, 2068, 14, 785, 8, 277, 14, 4133, 63, 5538, 12, 283, 912, 63, 4467, 297, 372, 63, 585, 1524, 1199, 63, 68, 475, 4682, 288, 291, 14, 5538, 14, 1065, 63, 5186, 63, 1025, 342, 288, 291, 14, 20213, 423, 4763, 63, 452, 63, 4368, 342, 288, 702, 7242, 14, 2416, 1252, 4509, 8, 2959, 14, 1955, 508, 1072, 63, 68, 475, 14, 344, 680, 835, 342, 508, 413, 288, 702, 27166, 2390, 8, 12455, 2390, 14, 4100, 14, 5569, 63, 16062, 12, 791, 466, 356, 283, 1199, 3071, 315, 4474, 288, 702, 822, 8, 4368, 9, 508, 413, 339, 347, 511, 63, 1199, 63, 5186, 63, 1461, 8, 277, 304, 267, 4474, 275, 942, 398, 347, 641, 63, 1461, 8, 7019, 63, 1430, 304, 288, 4474, 14, 740, 8, 7019, 63, 1430, 9, 398, 291, 14, 20213, 14, 10108, 63, 7019, 63, 4368, 8, 18060, 2610, 14, 12455, 6105, 2932, 14, 6689, 12, 641, 63, 1461, 9, 398, 4704, 275, 469, 18, 26, 7242, 36, 2566, 8, 344, 29, 18, 395, 673, 6335, 26, 7242, 36, 2566, 8, 344, 29, 2167, 12, 859, 63, 466, 534, 36, 21004, 267, 3504, 63, 1805, 275, 1683, 14, 3346, 342, 267, 3504, 63, 1805, 14, 904, 63, 504, 14, 1107, 63, 585, 275, 359, 2959, 8, 344, 29, 16, 12, 1329, 29, 18, 395, 6343, 7242, 8, 344, 29, 17, 12, 1329, 29, 2167, 12, 14726, 29, 25779, 8, 344, 29, 18, 12, 1329, 29, 19, 10524, 267, 543, 1683, 14, 2068, 14, 785, 8, 2959, 12, 283, 2416, 297, 372, 63, 585, 29, 2416, 63, 1805, 395, 971, 1467, 1683, 14, 2068, 14, 785, 8, 277, 14, 4133, 63, 5538, 12, 283, 912, 63, 1199, 297, 3044, 5366, 63, 5881, 29, 2734, 1072, 63, 344, 26, 4704, 14, 362, 8, 1199, 63, 344, 1826, 971, 1467, 1683, 14, 2068, 14, 785, 8, 277, 14, 4133, 63, 5538, 12, 283, 912, 63, 1199, 63, 1205, 297, 3044, 372, 63, 585, 1524, 2959, 3694, 36, 2566, 8, 344, 29, 18, 12, 2004, 29, 549, 395, 6163, 7242, 3694, 36, 2566, 8, 344, 29, 2167,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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 ]
ahmadassaf/zulip
zerver/lib/db.py
3
2323
from __future__ import absolute_import import time from psycopg2.extensions import cursor, connection from typing import Callable, Optional, Iterable, Any, Dict, Union, TypeVar, \ Mapping, Sequence from six import text_type from zerver.lib.str_utils import NonBinaryStr CursorObj = TypeVar('CursorObj', bound=cursor) ParamsT = Union[Iterable[Any], Mapping[text_type, Any]] # Similar to the tracking done in Django's CursorDebugWrapper, but done at the # psycopg2 cursor level so it works with SQLAlchemy. def wrapper_execute(self, action, sql, params=()): # type: (CursorObj, Callable[[NonBinaryStr, Optional[ParamsT]], CursorObj], NonBinaryStr, ParamsT) -> CursorObj start = time.time() try: return action(sql, params) finally: stop = time.time() duration = stop - start self.connection.queries.append({ 'time': "%.3f" % duration, }) class TimeTrackingCursor(cursor): """A psycopg2 cursor class that tracks the time spent executing queries.""" def execute(self, query, vars=None): # type: (NonBinaryStr, Optional[ParamsT]) -> TimeTrackingCursor return wrapper_execute(self, super(TimeTrackingCursor, self).execute, query, vars) def executemany(self, query, vars): # type: (NonBinaryStr, Iterable[Any]) -> TimeTrackingCursor return wrapper_execute(self, super(TimeTrackingCursor, self).executemany, query, vars) class TimeTrackingConnection(connection): """A psycopg2 connection class that uses TimeTrackingCursors.""" def __init__(self, *args, **kwargs): # type: (Sequence[Any], Mapping[text_type, Any]) -> None self.queries = [] # type: List[Dict[str, str]] super(TimeTrackingConnection, self).__init__(*args, **kwargs) def cursor(self, name=None): # type: (Optional[text_type]) -> TimeTrackingCursor if name is None: return super(TimeTrackingConnection, self).cursor(cursor_factory=TimeTrackingCursor) else: return super(TimeTrackingConnection, self).cursor(name, cursor_factory=TimeTrackingCursor) def reset_queries(): # type: () -> None from django.db import connections for conn in connections.all(): if conn.connection is not None: conn.connection.queries = []
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 900, 199, 504, 15492, 18, 14, 5359, 492, 3920, 12, 1950, 199, 199, 504, 14090, 492, 16975, 12, 4879, 12, 19937, 12, 6184, 12, 7448, 12, 15961, 12, 2434, 5894, 12, 971, 272, 12340, 12, 10975, 199, 504, 3816, 492, 1318, 63, 466, 199, 504, 19959, 14, 773, 14, 495, 63, 1208, 492, 10172, 6636, 2848, 199, 199, 8993, 5665, 275, 2434, 5894, 360, 8993, 5665, 297, 3914, 29, 3937, 9, 199, 6007, 52, 275, 15961, 59, 20852, 59, 9874, 467, 12340, 59, 505, 63, 466, 12, 6184, 2677, 199, 199, 3, 20046, 370, 314, 15161, 4224, 315, 5634, 1159, 20385, 7084, 4590, 12, 1325, 4224, 737, 314, 199, 3, 15492, 18, 3920, 2166, 880, 652, 5419, 543, 14303, 14, 199, 318, 4975, 63, 2526, 8, 277, 12, 1595, 12, 3875, 12, 1862, 23603, 272, 327, 730, 26, 334, 8993, 5665, 12, 16975, 9046, 6932, 6636, 2848, 12, 4879, 59, 6007, 52, 2365, 20385, 5665, 467, 10172, 6636, 2848, 12, 30370, 52, 9, 1035, 20385, 5665, 272, 1343, 275, 900, 14, 521, 342, 272, 862, 26, 267, 372, 1595, 8, 3009, 12, 1862, 9, 272, 3753, 26, 267, 3631, 275, 900, 14, 521, 342, 267, 7373, 275, 3631, 446, 1343, 267, 291, 14, 2105, 14, 10590, 14, 740, 2561, 355, 283, 521, 356, 31681, 19, 70, 2, 450, 7373, 12, 355, 3828, 199, 199, 533, 4703, 23785, 8993, 8, 3937, 304, 272, 408, 33, 15492, 18, 3920, 1021, 626, 18917, 314, 900, 2249, 484, 14043, 9212, 1041, 339, 347, 5341, 8, 277, 12, 1827, 12, 6802, 29, 403, 304, 267, 327, 730, 26, 334, 6932, 6636, 2848, 12, 4879, 59, 6007, 52, 566, 1035, 4703, 23785, 8993, 267, 372, 4975, 63, 2526, 8, 277, 12, 1613, 8, 1366, 23785, 8993, 12, 291, 680, 2526, 12, 1827, 12, 6802, 9, 339, 347, 2146, 25450, 8, 277, 12, 1827, 12, 6802, 304, 267, 327, 730, 26, 334, 6932, 6636, 2848, 12, 19937, 59, 9874, 566, 1035, 4703, 23785, 8993, 267, 372, 4975, 63, 2526, 8, 277, 12, 1613, 8, 1366, 23785, 8993, 12, 291, 680, 31162, 12, 1827, 12, 6802, 9, 199, 199, 533, 4703, 23785, 3225, 8, 2105, 304, 272, 408, 33, 15492, 18, 1950, 1021, 626, 4440, 4703, 23785, 3864, 83, 1384, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 730, 26, 334, 5826, 59, 9874, 467, 12340, 59, 505, 63, 466, 12, 6184, 566, 1035, 488, 267, 291, 14, 10590, 275, 942, 327, 730, 26, 3820, 59, 2141, 59, 495, 12, 620, 2677, 267, 1613, 8, 1366, 23785, 3225, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 3920, 8, 277, 12, 536, 29, 403, 304, 267, 327, 730, 26, 334, 7012, 59, 505, 63, 466, 566, 1035, 4703, 23785, 8993, 267, 340, 536, 365, 488, 26, 288, 372, 1613, 8, 1366, 23785, 3225, 12, 291, 680, 3937, 8, 3937, 63, 3702, 29, 1366, 23785, 8993, 9, 267, 587, 26, 288, 372, 1613, 8, 1366, 23785, 3225, 12, 291, 680, 3937, 8, 354, 12, 3920, 63, 3702, 29, 1366, 23785, 8993, 9, 199, 199, 318, 5305, 63, 10590, 837, 272, 327, 730, 26, 6248, 1035, 488, 272, 687, 1639, 14, 697, 492, 6947, 272, 367, 2557, 315, 6947, 14, 452, 837, 267, 340, 2557, 14, 2105, 365, 440, 488, 26, 288, 2557, 14, 2105, 14, 10590, 275, 942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 900, 199, 504, 15492, 18, 14, 5359, 492, 3920, 12, 1950, 199, 199, 504, 14090, 492, 16975, 12, 4879, 12, 19937, 12, 6184, 12, 7448, 12, 15961, 12, 2434, 5894, 12, 971, 272, 12340, 12, 10975, 199, 504, 3816, 492, 1318, 63, 466, 199, 504, 19959, 14, 773, 14, 495, 63, 1208, 492, 10172, 6636, 2848, 199, 199, 8993, 5665, 275, 2434, 5894, 360, 8993, 5665, 297, 3914, 29, 3937, 9, 199, 6007, 52, 275, 15961, 59, 20852, 59, 9874, 467, 12340, 59, 505, 63, 466, 12, 6184, 2677, 199, 199, 3, 20046, 370, 314, 15161, 4224, 315, 5634, 1159, 20385, 7084, 4590, 12, 1325, 4224, 737, 314, 199, 3, 15492, 18, 3920, 2166, 880, 652, 5419, 543, 14303, 14, 199, 318, 4975, 63, 2526, 8, 277, 12, 1595, 12, 3875, 12, 1862, 23603, 272, 327, 730, 26, 334, 8993, 5665, 12, 16975, 9046, 6932, 6636, 2848, 12, 4879, 59, 6007, 52, 2365, 20385, 5665, 467, 10172, 6636, 2848, 12, 30370, 52, 9, 1035, 20385, 5665, 272, 1343, 275, 900, 14, 521, 342, 272, 862, 26, 267, 372, 1595, 8, 3009, 12, 1862, 9, 272, 3753, 26, 267, 3631, 275, 900, 14, 521, 342, 267, 7373, 275, 3631, 446, 1343, 267, 291, 14, 2105, 14, 10590, 14, 740, 2561, 355, 283, 521, 356, 31681, 19, 70, 2, 450, 7373, 12, 355, 3828, 199, 199, 533, 4703, 23785, 8993, 8, 3937, 304, 272, 408, 33, 15492, 18, 3920, 1021, 626, 18917, 314, 900, 2249, 484, 14043, 9212, 1041, 339, 347, 5341, 8, 277, 12, 1827, 12, 6802, 29, 403, 304, 267, 327, 730, 26, 334, 6932, 6636, 2848, 12, 4879, 59, 6007, 52, 566, 1035, 4703, 23785, 8993, 267, 372, 4975, 63, 2526, 8, 277, 12, 1613, 8, 1366, 23785, 8993, 12, 291, 680, 2526, 12, 1827, 12, 6802, 9, 339, 347, 2146, 25450, 8, 277, 12, 1827, 12, 6802, 304, 267, 327, 730, 26, 334, 6932, 6636, 2848, 12, 19937, 59, 9874, 566, 1035, 4703, 23785, 8993, 267, 372, 4975, 63, 2526, 8, 277, 12, 1613, 8, 1366, 23785, 8993, 12, 291, 680, 31162, 12, 1827, 12, 6802, 9, 199, 199, 533, 4703, 23785, 3225, 8, 2105, 304, 272, 408, 33, 15492, 18, 1950, 1021, 626, 4440, 4703, 23785, 3864, 83, 1384, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 730, 26, 334, 5826, 59, 9874, 467, 12340, 59, 505, 63, 466, 12, 6184, 566, 1035, 488, 267, 291, 14, 10590, 275, 942, 327, 730, 26, 3820, 59, 2141, 59, 495, 12, 620, 2677, 267, 1613, 8, 1366, 23785, 3225, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 3920, 8, 277, 12, 536, 29, 403, 304, 267, 327, 730, 26, 334, 7012, 59, 505, 63, 466, 566, 1035, 4703, 23785, 8993, 267, 340, 536, 365, 488, 26, 288, 372, 1613, 8, 1366, 23785, 3225, 12, 291, 680, 3937, 8, 3937, 63, 3702, 29, 1366, 23785, 8993, 9, 267, 587, 26, 288, 372, 1613, 8, 1366, 23785, 3225, 12, 291, 680, 3937, 8, 354, 12, 3920, 63, 3702, 29, 1366, 23785, 8993, 9, 199, 199, 318, 5305, 63, 10590, 837, 272, 327, 730, 26, 6248, 1035, 488, 272, 687, 1639, 14, 697, 492, 6947, 272, 367, 2557, 315, 6947, 14, 452, 837, 267, 340, 2557, 14, 2105, 365, 440, 488, 26, 288, 2557, 14, 2105, 14, 10590, 275, 942, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mavenlin/tensorflow
tensorflow/contrib/ffmpeg/ffmpeg_ops.py
22
3729
# Copyright 2016 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. # ============================================================================= """Encoding and decoding audio using FFmpeg.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.ffmpeg.ops import gen_decode_audio_op_py from tensorflow.contrib.ffmpeg.ops import gen_encode_audio_op_py from tensorflow.contrib.util import loader from tensorflow.python.framework import ops from tensorflow.python.platform import resource_loader _ffmpeg_so = loader.load_op_library( resource_loader.get_path_to_datafile('ffmpeg.so')) def decode_audio(contents, file_format=None, samples_per_second=None, channel_count=None): """Create an op that decodes the contents of an audio file. Note that ffmpeg is free to select the "best" audio track from an mp4. https://trac.ffmpeg.org/wiki/Map Args: contents: The binary contents of the audio file to decode. This is a scalar. file_format: A string or scalar string tensor specifying which format the contents will conform to. This can be mp3, mp4, ogg, or wav. samples_per_second: The number of samples per second that is assumed, as an `int` or scalar `int32` tensor. In some cases, resampling will occur to generate the correct sample rate. channel_count: The number of channels that should be created from the audio contents, as an `int` or scalar `int32` tensor. If the `contents` have more than this number, then some channels will be merged or dropped. If `contents` has fewer than this, then additional channels will be created from the existing ones. Returns: A rank-2 tensor that has time along dimension 0 and channels along dimension 1. Dimension 0 will be `samples_per_second * length_in_seconds` wide, and dimension 1 will be `channel_count` wide. If ffmpeg fails to decode the audio then an empty tensor will be returned. """ return gen_decode_audio_op_py.decode_audio_v2( contents, file_format=file_format, samples_per_second=samples_per_second, channel_count=channel_count) ops.NotDifferentiable('DecodeAudio') def encode_audio(audio, file_format=None, samples_per_second=None): """Creates an op that encodes an audio file using sampled audio from a tensor. Args: audio: A rank-2 `Tensor` that has time along dimension 0 and channels along dimension 1. Dimension 0 is `samples_per_second * length_in_seconds` long. file_format: The type of file to encode, as a string or rank-0 string tensor. "wav" is the only supported format. samples_per_second: The number of samples in the audio tensor per second of audio, as an `int` or rank-0 `int32` tensor. Returns: A scalar tensor that contains the encoded audio in the specified file format. """ return gen_encode_audio_op_py.encode_audio_v2( audio, file_format=file_format, samples_per_second=samples_per_second, bits_per_second=192000) # not used by WAV ops.NotDifferentiable('EncodeAudio')
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 26237, 199, 624, 7630, 436, 15952, 10491, 1808, 25046, 16801, 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, 3228, 14, 2828, 14, 27648, 14, 1483, 492, 3805, 63, 2708, 63, 8130, 63, 411, 63, 647, 199, 504, 3228, 14, 2828, 14, 27648, 14, 1483, 492, 3805, 63, 2143, 63, 8130, 63, 411, 63, 647, 199, 504, 3228, 14, 2828, 14, 1974, 492, 5077, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 199, 63, 27648, 63, 1152, 275, 5077, 14, 912, 63, 411, 63, 4342, 8, 272, 2073, 63, 3422, 14, 362, 63, 515, 63, 475, 63, 31423, 360, 27648, 14, 1152, 1333, 421, 199, 318, 4849, 63, 8130, 8, 4407, 12, 570, 63, 908, 29, 403, 12, 5845, 63, 529, 63, 4375, 29, 403, 12, 326, 3623, 63, 835, 29, 403, 304, 523, 408, 2499, 376, 1687, 626, 4849, 83, 314, 4072, 402, 376, 10491, 570, 14, 819, 3390, 626, 16328, 16801, 365, 2867, 370, 3504, 314, 298, 7010, 2, 10491, 4426, 687, 376, 6118, 20, 14, 523, 4178, 921, 23047, 14, 27648, 14, 1308, 15, 6797, 15, 2956, 819, 3033, 26, 272, 4072, 26, 710, 3366, 4072, 402, 314, 10491, 570, 370, 4849, 14, 961, 365, 282, 267, 6917, 14, 272, 570, 63, 908, 26, 437, 1059, 503, 6917, 1059, 2345, 9176, 1314, 267, 1475, 314, 4072, 911, 26449, 370, 14, 961, 883, 506, 6118, 19, 12, 6118, 20, 12, 312, 2721, 12, 267, 503, 336, 1214, 14, 272, 5845, 63, 529, 63, 4375, 26, 710, 1329, 402, 5845, 1126, 3499, 626, 365, 267, 10826, 12, 465, 376, 658, 442, 64, 503, 6917, 658, 442, 708, 64, 2345, 14, 1010, 2005, 5560, 12, 267, 522, 23144, 911, 4781, 370, 3550, 314, 3211, 2690, 6634, 14, 272, 3623, 63, 835, 26, 710, 1329, 402, 9245, 626, 1077, 506, 2737, 687, 314, 267, 10491, 4072, 12, 465, 376, 658, 442, 64, 503, 6917, 658, 442, 708, 64, 2345, 14, 982, 314, 267, 658, 4407, 64, 1172, 1655, 2419, 642, 1329, 12, 2066, 2005, 9245, 911, 267, 506, 9545, 503, 17481, 14, 982, 658, 4407, 64, 965, 27392, 2419, 642, 12, 2066, 267, 4722, 9245, 911, 506, 2737, 687, 314, 3411, 7869, 14, 819, 1803, 26, 272, 437, 6915, 13, 18, 2345, 626, 965, 900, 3180, 6240, 378, 436, 9245, 3180, 272, 6240, 413, 14, 25291, 378, 911, 506, 658, 3356, 63, 529, 63, 4375, 627, 272, 2582, 63, 262, 63, 4515, 64, 20239, 12, 436, 6240, 413, 911, 506, 658, 2775, 63, 835, 64, 272, 20239, 14, 982, 16328, 16801, 6918, 370, 4849, 314, 10491, 2066, 376, 2701, 2345, 911, 272, 506, 2138, 14, 523, 408, 523, 372, 3805, 63, 2708, 63, 8130, 63, 411, 63, 647, 14, 2708, 63, 8130, 63, 86, 18, 8, 489, 4072, 12, 570, 63, 908, 29, 493, 63, 908, 12, 5845, 63, 529, 63, 4375, 29, 3356, 63, 529, 63, 4375, 12, 489, 3623, 63, 835, 29, 2775, 63, 835, 9, 421, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 9400, 15484, 358, 421, 199, 318, 3752, 63, 8130, 8, 8130, 12, 570, 63, 908, 29, 403, 12, 5845, 63, 529, 63, 4375, 29, 403, 304, 523, 408, 10607, 376, 1687, 626, 3752, 83, 376, 10491, 570, 1808, 24914, 10491, 687, 282, 2345, 14, 819, 3033, 26, 272, 10491, 26, 437, 6915, 13, 18, 658, 3861, 64, 626, 965, 900, 3180, 6240, 378, 436, 267, 9245, 3180, 6240, 413, 14, 25291, 378, 365, 658, 3356, 63, 529, 63, 4375, 627, 267, 2582, 63, 262, 63, 4515, 64, 1846, 14, 272, 570, 63, 908, 26, 710, 730, 402, 570, 370, 3752, 12, 465, 282, 1059, 503, 6915, 13, 16, 267, 1059, 2345, 14, 298, 19118, 2, 365, 314, 1454, 3748, 1475, 14, 272, 5845, 63, 529, 63, 4375, 26, 710, 1329, 402, 5845, 315, 314, 10491, 2345, 1126, 267, 3499, 402, 10491, 12, 465, 376, 658, 442, 64, 503, 6915, 13, 16, 658, 442, 708, 64, 2345, 14, 819, 1803, 26, 272, 437, 6917, 2345, 626, 3509, 314, 5737, 10491, 315, 314, 2013, 570, 272, 1475, 14, 523, 408, 523, 372, 3805, 63, 2143, 63, 8130, 63, 411, 63, 647, 14, 2143, 63, 8130, 63, 86, 18, 8, 489, 10491, 12, 489, 570, 63, 908, 29, 493, 63, 908, 12, 489, 5845, 63, 529, 63, 4375, 29, 3356, 63, 529, 63, 4375, 12, 489, 5821, 63, 529, 63, 4375, 29, 5756, 1493, 9, 221, 327, 440, 1202, 701, 644, 6087, 421, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 9686, 15484, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 26237, 199, 624, 7630, 436, 15952, 10491, 1808, 25046, 16801, 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, 3228, 14, 2828, 14, 27648, 14, 1483, 492, 3805, 63, 2708, 63, 8130, 63, 411, 63, 647, 199, 504, 3228, 14, 2828, 14, 27648, 14, 1483, 492, 3805, 63, 2143, 63, 8130, 63, 411, 63, 647, 199, 504, 3228, 14, 2828, 14, 1974, 492, 5077, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2073, 63, 3422, 199, 199, 63, 27648, 63, 1152, 275, 5077, 14, 912, 63, 411, 63, 4342, 8, 272, 2073, 63, 3422, 14, 362, 63, 515, 63, 475, 63, 31423, 360, 27648, 14, 1152, 1333, 421, 199, 318, 4849, 63, 8130, 8, 4407, 12, 570, 63, 908, 29, 403, 12, 5845, 63, 529, 63, 4375, 29, 403, 12, 326, 3623, 63, 835, 29, 403, 304, 523, 408, 2499, 376, 1687, 626, 4849, 83, 314, 4072, 402, 376, 10491, 570, 14, 819, 3390, 626, 16328, 16801, 365, 2867, 370, 3504, 314, 298, 7010, 2, 10491, 4426, 687, 376, 6118, 20, 14, 523, 4178, 921, 23047, 14, 27648, 14, 1308, 15, 6797, 15, 2956, 819, 3033, 26, 272, 4072, 26, 710, 3366, 4072, 402, 314, 10491, 570, 370, 4849, 14, 961, 365, 282, 267, 6917, 14, 272, 570, 63, 908, 26, 437, 1059, 503, 6917, 1059, 2345, 9176, 1314, 267, 1475, 314, 4072, 911, 26449, 370, 14, 961, 883, 506, 6118, 19, 12, 6118, 20, 12, 312, 2721, 12, 267, 503, 336, 1214, 14, 272, 5845, 63, 529, 63, 4375, 26, 710, 1329, 402, 5845, 1126, 3499, 626, 365, 267, 10826, 12, 465, 376, 658, 442, 64, 503, 6917, 658, 442, 708, 64, 2345, 14, 1010, 2005, 5560, 12, 267, 522, 23144, 911, 4781, 370, 3550, 314, 3211, 2690, 6634, 14, 272, 3623, 63, 835, 26, 710, 1329, 402, 9245, 626, 1077, 506, 2737, 687, 314, 267, 10491, 4072, 12, 465, 376, 658, 442, 64, 503, 6917, 658, 442, 708, 64, 2345, 14, 982, 314, 267, 658, 4407, 64, 1172, 1655, 2419, 642, 1329, 12, 2066, 2005, 9245, 911, 267, 506, 9545, 503, 17481, 14, 982, 658, 4407, 64, 965, 27392, 2419, 642, 12, 2066, 267, 4722, 9245, 911, 506, 2737, 687, 314, 3411, 7869, 14, 819, 1803, 26, 272, 437, 6915, 13, 18, 2345, 626, 965, 900, 3180, 6240, 378, 436, 9245, 3180, 272, 6240, 413, 14, 25291, 378, 911, 506, 658, 3356, 63, 529, 63, 4375, 627, 272, 2582, 63, 262, 63, 4515, 64, 20239, 12, 436, 6240, 413, 911, 506, 658, 2775, 63, 835, 64, 272, 20239, 14, 982, 16328, 16801, 6918, 370, 4849, 314, 10491, 2066, 376, 2701, 2345, 911, 272, 506, 2138, 14, 523, 408, 523, 372, 3805, 63, 2708, 63, 8130, 63, 411, 63, 647, 14, 2708, 63, 8130, 63, 86, 18, 8, 489, 4072, 12, 570, 63, 908, 29, 493, 63, 908, 12, 5845, 63, 529, 63, 4375, 29, 3356, 63, 529, 63, 4375, 12, 489, 3623, 63, 835, 29, 2775, 63, 835, 9, 421, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 9400, 15484, 358, 421, 199, 318, 3752, 63, 8130, 8, 8130, 12, 570, 63, 908, 29, 403, 12, 5845, 63, 529, 63, 4375, 29, 403, 304, 523, 408, 10607, 376, 1687, 626, 3752, 83, 376, 10491, 570, 1808, 24914, 10491, 687, 282, 2345, 14, 819, 3033, 26, 272, 10491, 26, 437, 6915, 13, 18, 658, 3861, 64, 626, 965, 900, 3180, 6240, 378, 436, 267, 9245, 3180, 6240, 413, 14, 25291, 378, 365, 658, 3356, 63, 529, 63, 4375, 627, 267, 2582, 63, 262, 63, 4515, 64, 1846, 14, 272, 570, 63, 908, 26, 710, 730, 402, 570, 370, 3752, 12, 465, 282, 1059, 503, 6915, 13, 16, 267, 1059, 2345, 14, 298, 19118, 2, 365, 314, 1454, 3748, 1475, 14, 272, 5845, 63, 529, 63, 4375, 26, 710, 1329, 402, 5845, 315, 314, 10491, 2345, 1126, 267, 3499, 402, 10491, 12, 465, 376, 658, 442, 64, 503, 6915, 13, 16, 658, 442, 708, 64, 2345, 14, 819, 1803, 26, 272, 437, 6917, 2345, 626, 3509, 314, 5737, 10491, 315, 314, 2013, 570, 272, 1475, 14, 523, 408, 523, 372, 3805, 63, 2143, 63, 8130, 63, 411, 63, 647, 14, 2143, 63, 8130, 63, 86, 18, 8, 489, 10491, 12, 489, 570, 63, 908, 29, 493, 63, 908, 12, 489, 5845, 63, 529, 63, 4375, 29, 3356, 63, 529, 63, 4375, 12, 489, 5821, 63, 529, 63, 4375, 29, 5756, 1493, 9, 221, 327, 440, 1202, 701, 644, 6087, 421, 199, 1483, 14, 1763, 16384, 30906, 461, 360, 9686, 15484, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
liuwenf/moose
python/chigger/annotations/TimeAnnotationSource.py
6
2466
#pylint: disable=missing-docstring ################################################################# # DO NOT MODIFY THIS HEADER # # MOOSE - Multiphysics Object Oriented Simulation Environment # # # # (c) 2010 Battelle Energy Alliance, LLC # # ALL RIGHTS RESERVED # # # # Prepared by Battelle Energy Alliance, LLC # # Under Contract No. DE-AC07-05ID14517 # # With the U. S. Department of Energy # # # # See COPYRIGHT for full restrictions # ################################################################# import datetime from TextAnnotationSource import TextAnnotationSource class TimeAnnotationSource(TextAnnotationSource): """ Source for creating time stamps. """ @staticmethod def getOptions(): """ Return default options for this object. """ opt = TextAnnotationSource.getOptions() opt.add('time', 330667320, "The time to display, in seconds.", vtype=float) opt.add('prefix', 'Time:', "The text to display prior to the time string.") opt.add('suffix', None, "The text to display after the time string.", vtype=str) opt.add('timedelta', False, "Format the time using the python datetime.timedelta") opt.setDefault('position', [0.01, 0.01]) opt.pop('text') return opt def update(self, **kwargs): """ Converts timestamp to a text string for display. (override) """ super(TimeAnnotationSource, self).update(**kwargs) # The time to display time = self.getOption('time') # Build the text string text = [] if self.isOptionValid('prefix'): text.append(self.getOption('prefix')) if self.isOptionValid('timedelta') and self.getOption('timedelta'): t = datetime.timedelta(seconds=time) text.append(str(t)) else: text.append(str(time)) if self.isOptionValid('suffix'): text.append(self.getOption('suffix')) self._vtkmapper.GetTextProperty().Modified() self._vtkmapper.SetInput(' '.join(text))
lgpl-2.1
[ 3, 26324, 26, 3507, 29, 4752, 13, 12485, 199, 3060, 3, 199, 3, 7861, 3506, 2845, 10362, 1914, 18114, 5749, 13053, 540, 7861, 327, 199, 3, 221, 603, 5757, 899, 446, 6879, 24724, 6935, 593, 322, 287, 471, 10751, 5332, 9711, 221, 327, 199, 3, 2476, 17388, 327, 199, 3, 3322, 334, 67, 9, 7129, 699, 292, 14146, 274, 662, 1372, 4312, 4580, 3636, 12, 20376, 3777, 327, 199, 3, 10473, 11727, 7052, 51, 12565, 540, 14112, 10473, 327, 199, 3, 2476, 17388, 327, 199, 3, 3698, 5543, 9508, 701, 699, 292, 14146, 274, 662, 1372, 4312, 4580, 3636, 12, 20376, 3698, 327, 199, 3, 3777, 25010, 1448, 6908, 3091, 14, 3265, 13, 1348, 1780, 13, 1717, 998, 11731, 1196, 4519, 327, 199, 3, 4519, 8777, 314, 738, 14, 428, 14, 1487, 12493, 402, 662, 1372, 4312, 4519, 327, 199, 3, 2476, 17388, 327, 199, 3, 4519, 1666, 5877, 367, 2615, 24488, 4519, 327, 199, 3060, 3, 199, 646, 2197, 199, 199, 504, 4516, 16768, 2980, 492, 4516, 16768, 2980, 199, 199, 533, 4703, 16768, 2980, 8, 1872, 16768, 2980, 304, 272, 408, 272, 5800, 367, 6425, 900, 2612, 13408, 14, 272, 408, 339, 768, 4639, 272, 347, 664, 4558, 837, 267, 408, 267, 1432, 849, 1511, 367, 642, 909, 14, 267, 408, 267, 2450, 275, 4516, 16768, 2980, 14, 362, 4558, 342, 267, 2450, 14, 525, 360, 521, 297, 13540, 14916, 12122, 12, 298, 1918, 900, 370, 2929, 12, 315, 4696, 4765, 29878, 29, 1609, 9, 267, 2450, 14, 525, 360, 1861, 297, 283, 1366, 6536, 298, 1918, 1318, 370, 2929, 6791, 370, 314, 900, 1059, 2685, 267, 2450, 14, 525, 360, 4511, 297, 488, 12, 298, 1918, 1318, 370, 2929, 2410, 314, 900, 1059, 4765, 29878, 29, 495, 9, 267, 2450, 14, 525, 360, 7473, 297, 756, 12, 298, 3484, 314, 900, 1808, 314, 2366, 2197, 14, 7473, 531, 267, 2450, 14, 409, 2698, 360, 3124, 297, 359, 16, 14, 614, 12, 378, 14, 614, 566, 267, 2450, 14, 1935, 360, 505, 358, 267, 372, 2450, 339, 347, 1678, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 19107, 4913, 370, 282, 1318, 1059, 367, 2929, 14, 334, 4415, 9, 267, 408, 267, 1613, 8, 1366, 16768, 2980, 12, 291, 680, 873, 3682, 958, 9, 398, 327, 710, 900, 370, 2929, 267, 900, 275, 291, 14, 362, 2602, 360, 521, 358, 398, 327, 6516, 314, 1318, 1059, 267, 1318, 275, 942, 267, 340, 291, 14, 374, 2602, 3490, 360, 1861, 735, 288, 1318, 14, 740, 8, 277, 14, 362, 2602, 360, 1861, 1333, 398, 340, 291, 14, 374, 2602, 3490, 360, 7473, 358, 436, 291, 14, 362, 2602, 360, 7473, 735, 288, 307, 275, 2197, 14, 7473, 8, 4515, 29, 521, 9, 288, 1318, 14, 740, 8, 495, 8, 84, 430, 267, 587, 26, 288, 1318, 14, 740, 8, 495, 8, 521, 430, 398, 340, 291, 14, 374, 2602, 3490, 360, 4511, 735, 288, 1318, 14, 740, 8, 277, 14, 362, 2602, 360, 4511, 1333, 398, 291, 423, 11919, 7153, 14, 1002, 1872, 3697, 1252, 11911, 342, 267, 291, 423, 11919, 7153, 14, 24029, 360, 1987, 904, 8, 505, 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 ]
[ 26324, 26, 3507, 29, 4752, 13, 12485, 199, 3060, 3, 199, 3, 7861, 3506, 2845, 10362, 1914, 18114, 5749, 13053, 540, 7861, 327, 199, 3, 221, 603, 5757, 899, 446, 6879, 24724, 6935, 593, 322, 287, 471, 10751, 5332, 9711, 221, 327, 199, 3, 2476, 17388, 327, 199, 3, 3322, 334, 67, 9, 7129, 699, 292, 14146, 274, 662, 1372, 4312, 4580, 3636, 12, 20376, 3777, 327, 199, 3, 10473, 11727, 7052, 51, 12565, 540, 14112, 10473, 327, 199, 3, 2476, 17388, 327, 199, 3, 3698, 5543, 9508, 701, 699, 292, 14146, 274, 662, 1372, 4312, 4580, 3636, 12, 20376, 3698, 327, 199, 3, 3777, 25010, 1448, 6908, 3091, 14, 3265, 13, 1348, 1780, 13, 1717, 998, 11731, 1196, 4519, 327, 199, 3, 4519, 8777, 314, 738, 14, 428, 14, 1487, 12493, 402, 662, 1372, 4312, 4519, 327, 199, 3, 2476, 17388, 327, 199, 3, 4519, 1666, 5877, 367, 2615, 24488, 4519, 327, 199, 3060, 3, 199, 646, 2197, 199, 199, 504, 4516, 16768, 2980, 492, 4516, 16768, 2980, 199, 199, 533, 4703, 16768, 2980, 8, 1872, 16768, 2980, 304, 272, 408, 272, 5800, 367, 6425, 900, 2612, 13408, 14, 272, 408, 339, 768, 4639, 272, 347, 664, 4558, 837, 267, 408, 267, 1432, 849, 1511, 367, 642, 909, 14, 267, 408, 267, 2450, 275, 4516, 16768, 2980, 14, 362, 4558, 342, 267, 2450, 14, 525, 360, 521, 297, 13540, 14916, 12122, 12, 298, 1918, 900, 370, 2929, 12, 315, 4696, 4765, 29878, 29, 1609, 9, 267, 2450, 14, 525, 360, 1861, 297, 283, 1366, 6536, 298, 1918, 1318, 370, 2929, 6791, 370, 314, 900, 1059, 2685, 267, 2450, 14, 525, 360, 4511, 297, 488, 12, 298, 1918, 1318, 370, 2929, 2410, 314, 900, 1059, 4765, 29878, 29, 495, 9, 267, 2450, 14, 525, 360, 7473, 297, 756, 12, 298, 3484, 314, 900, 1808, 314, 2366, 2197, 14, 7473, 531, 267, 2450, 14, 409, 2698, 360, 3124, 297, 359, 16, 14, 614, 12, 378, 14, 614, 566, 267, 2450, 14, 1935, 360, 505, 358, 267, 372, 2450, 339, 347, 1678, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 19107, 4913, 370, 282, 1318, 1059, 367, 2929, 14, 334, 4415, 9, 267, 408, 267, 1613, 8, 1366, 16768, 2980, 12, 291, 680, 873, 3682, 958, 9, 398, 327, 710, 900, 370, 2929, 267, 900, 275, 291, 14, 362, 2602, 360, 521, 358, 398, 327, 6516, 314, 1318, 1059, 267, 1318, 275, 942, 267, 340, 291, 14, 374, 2602, 3490, 360, 1861, 735, 288, 1318, 14, 740, 8, 277, 14, 362, 2602, 360, 1861, 1333, 398, 340, 291, 14, 374, 2602, 3490, 360, 7473, 358, 436, 291, 14, 362, 2602, 360, 7473, 735, 288, 307, 275, 2197, 14, 7473, 8, 4515, 29, 521, 9, 288, 1318, 14, 740, 8, 495, 8, 84, 430, 267, 587, 26, 288, 1318, 14, 740, 8, 495, 8, 521, 430, 398, 340, 291, 14, 374, 2602, 3490, 360, 4511, 735, 288, 1318, 14, 740, 8, 277, 14, 362, 2602, 360, 4511, 1333, 398, 291, 423, 11919, 7153, 14, 1002, 1872, 3697, 1252, 11911, 342, 267, 291, 423, 11919, 7153, 14, 24029, 360, 1987, 904, 8, 505, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
florianholzapfel/home-assistant
homeassistant/components/media_player/mpchc.py
10
4969
""" Support to interface with the MPC-HC Web API. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/media_player.mpchc/ """ import logging import re import requests import voluptuous as vol from homeassistant.components.media_player import ( SUPPORT_VOLUME_MUTE, SUPPORT_PAUSE, SUPPORT_STOP, SUPPORT_NEXT_TRACK, SUPPORT_PREVIOUS_TRACK, SUPPORT_VOLUME_STEP, MediaPlayerDevice, PLATFORM_SCHEMA) from homeassistant.const import ( STATE_OFF, STATE_IDLE, STATE_PAUSED, STATE_PLAYING, CONF_NAME, CONF_HOST, CONF_PORT) import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = 'MPC-HC' DEFAULT_PORT = 13579 SUPPORT_MPCHC = SUPPORT_VOLUME_MUTE | SUPPORT_PAUSE | SUPPORT_STOP | \ SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_VOLUME_STEP PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, }) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the MPC-HC platform.""" name = config.get(CONF_NAME) url = '{}:{}'.format(config.get(CONF_HOST), config.get(CONF_PORT)) add_devices([MpcHcDevice(name, url)]) class MpcHcDevice(MediaPlayerDevice): """Representation of a MPC-HC server.""" def __init__(self, name, url): """Initialize the MPC-HC device.""" self._name = name self._url = url self.update() def update(self): """Get the latest details.""" self._player_variables = dict() try: response = requests.get('{}/variables.html'.format(self._url), data=None, timeout=3) mpchc_variables = re.findall(r'<p id="(.+?)">(.+?)</p>', response.text) self._player_variables = dict() for var in mpchc_variables: self._player_variables[var[0]] = var[1].lower() except requests.exceptions.RequestException: _LOGGER.error("Could not connect to MPC-HC at: %s", self._url) def _send_command(self, command_id): """Send a command to MPC-HC via its window message ID.""" try: params = {"wm_command": command_id} requests.get("{}/command.html".format(self._url), params=params, timeout=3) except requests.exceptions.RequestException: _LOGGER.error("Could not send command %d to MPC-HC at: %s", command_id, self._url) @property def name(self): """Return the name of the device.""" return self._name @property def state(self): """Return the state of the device.""" state = self._player_variables.get('statestring', None) if state is None: return STATE_OFF if state == 'playing': return STATE_PLAYING elif state == 'paused': return STATE_PAUSED else: return STATE_IDLE @property def media_title(self): """Title of current playing media.""" return self._player_variables.get('file', None) @property def volume_level(self): """Volume level of the media player (0..1).""" return int(self._player_variables.get('volumelevel', 0)) / 100.0 @property def is_volume_muted(self): """Boolean if volume is currently muted.""" return self._player_variables.get('muted', '0') == '1' @property def media_duration(self): """Duration of current playing media in seconds.""" duration = self._player_variables.get('durationstring', "00:00:00").split(':') return \ int(duration[0]) * 3600 + \ int(duration[1]) * 60 + \ int(duration[2]) @property def supported_media_commands(self): """Flag of media commands that are supported.""" return SUPPORT_MPCHC def volume_up(self): """Volume up the media player.""" self._send_command(907) def volume_down(self): """Volume down media player.""" self._send_command(908) def mute_volume(self, mute): """Mute the volume.""" self._send_command(909) def media_play(self): """Send play command.""" self._send_command(887) def media_pause(self): """Send pause command.""" self._send_command(888) def media_stop(self): """Send stop command.""" self._send_command(890) def media_next_track(self): """Send next track command.""" self._send_command(921) def media_previous_track(self): """Send previous track command.""" self._send_command(920)
mit
[ 624, 199, 11532, 370, 3217, 543, 314, 603, 4222, 13, 28460, 6001, 3261, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 4603, 63, 6147, 14, 311, 335, 67, 15, 199, 624, 199, 646, 2050, 199, 646, 295, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 4603, 63, 6147, 492, 334, 272, 13756, 63, 16689, 63, 45, 4586, 12, 13756, 63, 8470, 4701, 12, 13756, 63, 11632, 12, 13756, 63, 21917, 63, 19755, 12, 272, 13756, 63, 28422, 25657, 63, 19755, 12, 13756, 63, 16689, 63, 17988, 12, 12300, 10921, 2510, 12, 272, 21966, 63, 10926, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 11377, 63, 7517, 12, 11377, 63, 23715, 12, 11377, 63, 8470, 8558, 12, 11377, 63, 11625, 1206, 12, 6392, 63, 2339, 12, 6392, 63, 5449, 12, 272, 6392, 63, 3657, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3472, 63, 2339, 275, 283, 1658, 35, 13, 28460, 7, 199, 3472, 63, 3657, 275, 23051, 1965, 199, 199, 10640, 63, 1658, 1244, 35, 275, 13756, 63, 16689, 63, 45, 4586, 1204, 13756, 63, 8470, 4701, 1204, 13756, 63, 11632, 1204, 971, 272, 13756, 63, 28422, 25657, 63, 19755, 1204, 13756, 63, 21917, 63, 19755, 1204, 13756, 63, 16689, 63, 17988, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 3657, 12, 849, 29, 3472, 63, 3657, 304, 6277, 14, 719, 12, 199, 1552, 421, 199, 3, 4287, 26, 3507, 29, 8618, 13, 2094, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 8555, 314, 603, 4222, 13, 28460, 4298, 1041, 272, 536, 275, 1101, 14, 362, 8, 3103, 63, 2339, 9, 272, 1166, 275, 9005, 26, 11123, 908, 8, 888, 14, 362, 8, 3103, 63, 5449, 395, 1101, 14, 362, 8, 3103, 63, 3657, 430, 339, 1050, 63, 6410, 779, 45, 2352, 40, 67, 2510, 8, 354, 12, 1166, 3948, 421, 199, 533, 603, 2352, 40, 67, 2510, 8, 11398, 10921, 2510, 304, 272, 408, 20609, 402, 282, 603, 4222, 13, 28460, 1654, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1166, 304, 267, 408, 9345, 314, 603, 4222, 13, 28460, 2243, 1041, 267, 291, 423, 354, 275, 536, 267, 291, 423, 633, 275, 1166, 398, 291, 14, 873, 342, 339, 347, 1678, 8, 277, 304, 267, 408, 1002, 314, 8839, 2436, 1041, 267, 291, 423, 6147, 63, 3669, 275, 1211, 342, 398, 862, 26, 288, 1177, 275, 4145, 14, 362, 17519, 15, 3669, 14, 1360, 1370, 908, 8, 277, 423, 633, 395, 2511, 666, 29, 403, 12, 2653, 29, 19, 9, 953, 6118, 335, 67, 63, 3669, 275, 295, 14, 6452, 8, 82, 7601, 80, 1305, 628, 28149, 9, 1743, 28149, 15939, 80, 4206, 1460, 1177, 14, 505, 9, 953, 291, 423, 6147, 63, 3669, 275, 1211, 342, 288, 367, 2729, 315, 6118, 335, 67, 63, 3669, 26, 355, 291, 423, 6147, 63, 3669, 59, 1391, 59, 16, 2677, 275, 2729, 59, 17, 1055, 2325, 342, 267, 871, 4145, 14, 3924, 14, 28724, 26, 288, 485, 10186, 14, 705, 480, 6531, 440, 4907, 370, 603, 4222, 13, 28460, 737, 26, 450, 83, 401, 291, 423, 633, 9, 339, 347, 485, 2254, 63, 1531, 8, 277, 12, 1414, 63, 344, 304, 267, 408, 6795, 282, 1414, 370, 603, 4222, 13, 28460, 4799, 2399, 4353, 1245, 2870, 1041, 267, 862, 26, 288, 1862, 275, 2420, 16240, 63, 1531, 582, 1414, 63, 344, 93, 288, 4145, 14, 362, 20794, 15, 1531, 14, 1360, 1674, 908, 8, 277, 423, 633, 395, 586, 1862, 29, 1162, 12, 2653, 29, 19, 9, 267, 871, 4145, 14, 3924, 14, 28724, 26, 288, 485, 10186, 14, 705, 480, 6531, 440, 3222, 1414, 450, 68, 370, 603, 4222, 13, 28460, 737, 26, 450, 83, 401, 2079, 1414, 63, 344, 12, 291, 423, 633, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 2243, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 2243, 1041, 267, 1174, 275, 291, 423, 6147, 63, 3669, 14, 362, 360, 929, 875, 297, 488, 9, 398, 340, 1174, 365, 488, 26, 288, 372, 11377, 63, 7517, 267, 340, 1174, 508, 283, 22224, 356, 288, 372, 11377, 63, 11625, 1206, 267, 916, 1174, 508, 283, 22478, 356, 288, 372, 11377, 63, 8470, 8558, 267, 587, 26, 288, 372, 11377, 63, 23715, 339, 768, 1829, 272, 347, 5898, 63, 1213, 8, 277, 304, 267, 408, 6888, 402, 1453, 25692, 5898, 1041, 267, 372, 291, 423, 6147, 63, 3669, 14, 362, 360, 493, 297, 488, 9, 339, 768, 1829, 272, 347, 3301, 63, 1896, 8, 277, 304, 267, 408, 6464, 2166, 402, 314, 5898, 7748, 334, 16, 703, 17, 10477, 267, 372, 1109, 8, 277, 423, 6147, 63, 3669, 14, 362, 360, 2405, 1896, 297, 378, 430, 1182, 2948, 14, 16, 339, 768, 1829, 272, 347, 365, 63, 2405, 63, 77, 4241, 8, 277, 304, 267, 408, 4082, 340, 3301, 365, 5544, 333, 4241, 1041, 267, 372, 291, 423, 6147, 63, 3669, 14, 362, 360, 77, 4241, 297, 283, 16, 358, 508, 283, 17, 7, 339, 768, 1829, 272, 347, 5898, 63, 5553, 8, 277, 304, 267, 408, 13283, 402, 1453, 25692, 5898, 315, 4696, 1041, 267, 7373, 275, 291, 423, 6147, 63, 3669, 14, 362, 360, 5553, 875, 297, 6343, 298, 383, 26, 383, 26, 383, 3471, 1294, 11633, 267, 372, 971, 288, 1109, 8, 5553, 59, 16, 566, 627, 15751, 435, 971, 288, 1109, 8, 5553, 59, 17, 566, 627, 5212, 435, 971, 288, 1109, 8, 5553, 59, 18, 566, 339, 768, 1829 ]
[ 199, 11532, 370, 3217, 543, 314, 603, 4222, 13, 28460, 6001, 3261, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 4603, 63, 6147, 14, 311, 335, 67, 15, 199, 624, 199, 646, 2050, 199, 646, 295, 199, 199, 646, 4145, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 4603, 63, 6147, 492, 334, 272, 13756, 63, 16689, 63, 45, 4586, 12, 13756, 63, 8470, 4701, 12, 13756, 63, 11632, 12, 13756, 63, 21917, 63, 19755, 12, 272, 13756, 63, 28422, 25657, 63, 19755, 12, 13756, 63, 16689, 63, 17988, 12, 12300, 10921, 2510, 12, 272, 21966, 63, 10926, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 11377, 63, 7517, 12, 11377, 63, 23715, 12, 11377, 63, 8470, 8558, 12, 11377, 63, 11625, 1206, 12, 6392, 63, 2339, 12, 6392, 63, 5449, 12, 272, 6392, 63, 3657, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3472, 63, 2339, 275, 283, 1658, 35, 13, 28460, 7, 199, 3472, 63, 3657, 275, 23051, 1965, 199, 199, 10640, 63, 1658, 1244, 35, 275, 13756, 63, 16689, 63, 45, 4586, 1204, 13756, 63, 8470, 4701, 1204, 13756, 63, 11632, 1204, 971, 272, 13756, 63, 28422, 25657, 63, 19755, 1204, 13756, 63, 21917, 63, 19755, 1204, 13756, 63, 16689, 63, 17988, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 2561, 272, 5236, 14, 8030, 8, 3103, 63, 5449, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 272, 5236, 14, 7012, 8, 3103, 63, 3657, 12, 849, 29, 3472, 63, 3657, 304, 6277, 14, 719, 12, 199, 1552, 421, 199, 3, 4287, 26, 3507, 29, 8618, 13, 2094, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 8555, 314, 603, 4222, 13, 28460, 4298, 1041, 272, 536, 275, 1101, 14, 362, 8, 3103, 63, 2339, 9, 272, 1166, 275, 9005, 26, 11123, 908, 8, 888, 14, 362, 8, 3103, 63, 5449, 395, 1101, 14, 362, 8, 3103, 63, 3657, 430, 339, 1050, 63, 6410, 779, 45, 2352, 40, 67, 2510, 8, 354, 12, 1166, 3948, 421, 199, 533, 603, 2352, 40, 67, 2510, 8, 11398, 10921, 2510, 304, 272, 408, 20609, 402, 282, 603, 4222, 13, 28460, 1654, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1166, 304, 267, 408, 9345, 314, 603, 4222, 13, 28460, 2243, 1041, 267, 291, 423, 354, 275, 536, 267, 291, 423, 633, 275, 1166, 398, 291, 14, 873, 342, 339, 347, 1678, 8, 277, 304, 267, 408, 1002, 314, 8839, 2436, 1041, 267, 291, 423, 6147, 63, 3669, 275, 1211, 342, 398, 862, 26, 288, 1177, 275, 4145, 14, 362, 17519, 15, 3669, 14, 1360, 1370, 908, 8, 277, 423, 633, 395, 2511, 666, 29, 403, 12, 2653, 29, 19, 9, 953, 6118, 335, 67, 63, 3669, 275, 295, 14, 6452, 8, 82, 7601, 80, 1305, 628, 28149, 9, 1743, 28149, 15939, 80, 4206, 1460, 1177, 14, 505, 9, 953, 291, 423, 6147, 63, 3669, 275, 1211, 342, 288, 367, 2729, 315, 6118, 335, 67, 63, 3669, 26, 355, 291, 423, 6147, 63, 3669, 59, 1391, 59, 16, 2677, 275, 2729, 59, 17, 1055, 2325, 342, 267, 871, 4145, 14, 3924, 14, 28724, 26, 288, 485, 10186, 14, 705, 480, 6531, 440, 4907, 370, 603, 4222, 13, 28460, 737, 26, 450, 83, 401, 291, 423, 633, 9, 339, 347, 485, 2254, 63, 1531, 8, 277, 12, 1414, 63, 344, 304, 267, 408, 6795, 282, 1414, 370, 603, 4222, 13, 28460, 4799, 2399, 4353, 1245, 2870, 1041, 267, 862, 26, 288, 1862, 275, 2420, 16240, 63, 1531, 582, 1414, 63, 344, 93, 288, 4145, 14, 362, 20794, 15, 1531, 14, 1360, 1674, 908, 8, 277, 423, 633, 395, 586, 1862, 29, 1162, 12, 2653, 29, 19, 9, 267, 871, 4145, 14, 3924, 14, 28724, 26, 288, 485, 10186, 14, 705, 480, 6531, 440, 3222, 1414, 450, 68, 370, 603, 4222, 13, 28460, 737, 26, 450, 83, 401, 2079, 1414, 63, 344, 12, 291, 423, 633, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 2243, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 2243, 1041, 267, 1174, 275, 291, 423, 6147, 63, 3669, 14, 362, 360, 929, 875, 297, 488, 9, 398, 340, 1174, 365, 488, 26, 288, 372, 11377, 63, 7517, 267, 340, 1174, 508, 283, 22224, 356, 288, 372, 11377, 63, 11625, 1206, 267, 916, 1174, 508, 283, 22478, 356, 288, 372, 11377, 63, 8470, 8558, 267, 587, 26, 288, 372, 11377, 63, 23715, 339, 768, 1829, 272, 347, 5898, 63, 1213, 8, 277, 304, 267, 408, 6888, 402, 1453, 25692, 5898, 1041, 267, 372, 291, 423, 6147, 63, 3669, 14, 362, 360, 493, 297, 488, 9, 339, 768, 1829, 272, 347, 3301, 63, 1896, 8, 277, 304, 267, 408, 6464, 2166, 402, 314, 5898, 7748, 334, 16, 703, 17, 10477, 267, 372, 1109, 8, 277, 423, 6147, 63, 3669, 14, 362, 360, 2405, 1896, 297, 378, 430, 1182, 2948, 14, 16, 339, 768, 1829, 272, 347, 365, 63, 2405, 63, 77, 4241, 8, 277, 304, 267, 408, 4082, 340, 3301, 365, 5544, 333, 4241, 1041, 267, 372, 291, 423, 6147, 63, 3669, 14, 362, 360, 77, 4241, 297, 283, 16, 358, 508, 283, 17, 7, 339, 768, 1829, 272, 347, 5898, 63, 5553, 8, 277, 304, 267, 408, 13283, 402, 1453, 25692, 5898, 315, 4696, 1041, 267, 7373, 275, 291, 423, 6147, 63, 3669, 14, 362, 360, 5553, 875, 297, 6343, 298, 383, 26, 383, 26, 383, 3471, 1294, 11633, 267, 372, 971, 288, 1109, 8, 5553, 59, 16, 566, 627, 15751, 435, 971, 288, 1109, 8, 5553, 59, 17, 566, 627, 5212, 435, 971, 288, 1109, 8, 5553, 59, 18, 566, 339, 768, 1829, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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Project Model @copyright: 2011-2012 (c) Sahana Software Foundation @license: MIT 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. """ __all__ = ["S3ProjectModel", "S3ProjectDRRModel", "S3ProjectTaskModel", "S3ProjectTaskHRMModel", "S3ProjectTaskIReportModel", "project_rheader", "S3ProjectTaskVirtualfields"] import datetime from gluon import * from gluon.dal import Row from gluon.storage import Storage from gluon.sqlhtml import CheckboxesWidget from ..s3 import * try: from lxml import etree, html except ImportError: import sys print >> sys.stderr, "ERROR: lxml module needed for XML handling" raise # ============================================================================= class S3ProjectModel(S3Model): """ Project Model Note: This module operates in 2 quite different modes: - 'drr': suitable for use by multinational organisations tracking projects at a high level - non-drr: suitable for use by a smaller organsiation tracking tasks at a detailed level This class contains the tables common to both uses There are additional tabels in S3ProjectDRRModel and S3ProjectTaskModel for the other 2 use cases There are also additional Classes for optional Link Tables """ names = ["project_theme", "project_hazard", "project_project", "project_activity_type", "project_activity", "project_activity_contact", "project_project_id", "project_activity_id", "project_hfa_opts", "project_project_represent", ] def model(self): T = current.T db = current.db request = current.request s3 = current.response.s3 settings = current.deployment_settings currency_type = s3.currency_type person_id = self.pr_person_id location_id = self.gis_location_id countries_id = self.gis_countries_id organisation_id = self.org_organisation_id sector_id = self.org_sector_id human_resource_id = self.hrm_human_resource_id s3_date_format = settings.get_L10n_date_format() s3_date_represent = lambda dt: S3DateTime.date_represent(dt, utc=True) # Enable DRR extensions? drr = settings.get_project_drr() pca = settings.get_project_community_activity() # Shortcuts add_component = self.add_component comments = s3.comments configure = self.configure crud_strings = s3.crud_strings define_table = self.define_table meta_fields = s3.meta_fields super_link = self.super_link # --------------------------------------------------------------------- # Theme # @ToDo: Move to link table to move to S3ProjectDRRModel # tablename = "project_theme" table = define_table(tablename, Field("name", length=128, notnull=True, unique=True), Field("comments"), format = "%(name)s", *meta_fields()) # Field configuration? # CRUD Strings? # Search Method? # Resource Configuration? # Reusable Field multi_theme_id = S3ReusableField("multi_theme_id", "list:reference project_theme", label = T("Themes"), sortby = "name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_theme.id", "%(name)s", sort=True, multiple=True)), represent = lambda opt, row=None: \ self.multiref_represent(opt, "project_theme"), default = [], ondelete = "RESTRICT", widget = lambda f, v: \ CheckboxesWidgetS3.widget(f, v, cols = 3)) # --------------------------------------------------------------------- # Hazard # @ToDo: Move to link table to move to S3ProjectDRRModel # tablename = "project_hazard" table = define_table(tablename, Field("name", length=128, notnull=True, unique=True), Field("comments"), format="%(name)s", *meta_fields()) # Field configuration? # CRUD Strings? # Search Method? # Resource Configuration? # Reusable Field multi_hazard_id = S3ReusableField("multi_hazard_id", "list:reference project_hazard", sortby = "name", label = T("Hazards"), requires = IS_NULL_OR(IS_ONE_OF(db, "project_hazard.id", "%(name)s", sort=True, multiple=True)), represent = lambda opt, row=None: \ self.multiref_represent(opt, "project_hazard"), ondelete = "RESTRICT", widget = lambda f, v: CheckboxesWidgetS3.widget(f, v, cols = 3)) # --------------------------------------------------------------------- # Project # # HFA # @todo: localization? project_hfa_opts = { 1: "HFA1: Ensure that disaster risk reduction is a national and a local priority with a strong institutional basis for implementation.", 2: "HFA2: Identify, assess and monitor disaster risks and enhance early warning.", 3: "HFA3: Use knowledge, innovation and education to build a culture of safety and resilience at all levels.", 4: "HFA4: Reduce the underlying risk factors.", 5: "HFA5: Strengthen disaster preparedness for effective response at all levels.", } tablename = "project_project" table = define_table(tablename, super_link("doc_id", "doc_entity"), # drr uses the separate project_organisation table organisation_id( readable=False if drr else True, writable=False if drr else True, ), Field("name", label = T("Name"), # Require unique=True if using IS_NOT_ONE_OF like here (same table, # no filter) in order to allow both automatic indexing (faster) # and key-based de-duplication (i.e. before field validation) unique = True, requires = [IS_NOT_EMPTY(error_message=T("Please fill this!")), IS_NOT_ONE_OF(db, "project_project.name")] ), Field("code", label = T("Code"), readable=False, writable=False, ), Field("description", "text", label = T("Description")), # NB There is additional client-side validation for start/end date in the Controller Field("start_date", "date", label = T("Start date"), represent = s3_date_represent, requires = IS_NULL_OR(IS_DATE(format = s3_date_format)), widget = S3DateWidget() ), Field("end_date", "date", label = T("End date"), represent = s3_date_represent, requires = IS_NULL_OR(IS_DATE(format = s3_date_format)), widget = S3DateWidget() ), Field("duration", readable=False, writable=False, label = T("Duration")), Field("calendar", readable=False if drr else True, writable=False if drr else True, label = T("Calendar"), requires = IS_NULL_OR(IS_URL()), comment = DIV(_class="tooltip", _title="%s|%s" % (T("Calendar"), T("URL to a Google Calendar to display on the project timeline.")))), currency_type( readable=False if drr else True, writable=False if drr else True, ), Field("budget", "double", # DRR handles on the Organisations Tab readable=False if drr else True, writable=False if drr else True, label = T("Budget")), sector_id( #readable=False, #writable=False, widget=lambda f, v: \ CheckboxesWidget.widget(f, v, cols=3)), countries_id( readable=drr, writable=drr ), multi_hazard_id( readable=drr, writable=drr ), multi_theme_id( readable=drr, writable=drr ), Field("hfa", "list:integer", label = T("HFA Priorities"), readable=drr, writable=drr, requires = IS_NULL_OR(IS_IN_SET(project_hfa_opts, multiple = True)), represent = self.hfa_opts_represent, widget = CheckboxesWidgetS3.widget), Field("objectives", "text", readable = drr, writable = drr, label = T("Objectives")), human_resource_id(label=T("Contact Person")), comments(comment=DIV(_class="tooltip", _title="%s|%s" % (T("Comments"), T("Outcomes, Impact, Challenges")))), format="%(name)s", *meta_fields()) # Field configuration? # CRUD Strings ADD_PROJECT = T("Add Project") crud_strings[tablename] = Storage( title_create = ADD_PROJECT, title_display = T("Project Details"), title_list = T("List Projects"), title_update = T("Edit Project"), title_search = T("Search Projects"), title_upload = T("Import Project List"), subtitle_create = T("Add New Project"), subtitle_list = T("Projects"), subtitle_upload = T("Upload Project List"), label_list_button = T("List Projects"), label_create_button = ADD_PROJECT, label_delete_button = T("Delete Project"), msg_record_created = T("Project added"), msg_record_modified = T("Project updated"), msg_record_deleted = T("Project deleted"), msg_list_empty = T("No Projects currently registered")) # Search Method if settings.get_ui_cluster(): sector = T("Cluster") else: sector = T("Sector") if drr: project_search = S3Search( advanced = ( S3SearchSimpleWidget( name = "project_search_text_advanced", label = T("Description"), comment = T("Search for a Project by description."), field = [ "name", "description", ] ), S3SearchOptionsWidget( name = "project_search_sector", label = sector, field = ["sector_id"], cols = 4 ), S3SearchOptionsWidget( name = "project_search_hazard", label = T("Hazard"), field = ["multi_hazard_id"], cols = 4 ), S3SearchOptionsWidget( name = "project_search_theme", label = T("Theme"), field = ["multi_theme_id"], cols = 4 ), S3SearchOptionsWidget( name = "project_search_hfa", label = T("HFA"), field = ["hfa"], cols = 4 ), ) ) else: project_search = S3Search( advanced = ( S3SearchSimpleWidget( name = "project_search_text_advanced", label = T("Description"), comment = T("Search for a Project by description."), field = [ "name", "description", ] ), S3SearchOptionsWidget( name = "project_search_sector", label = sector, field = ["sector_id"], cols = 4 ), ) ) # Resource Configuration if drr: next = "organisation" else: next = "activity" if drr: table.virtualfields.append(S3ProjectVirtualfields()) list_fields=["id", "name", (T("Lead Organisation"), "organisation"), "sector_id", "start_date", "end_date", "countries_id", "multi_hazard_id", "multi_theme_id", ] else: list_fields=["id", "name", "organisation_id", "start_date", "end_date", ] configure(tablename, super_entity="doc_entity", deduplicate=self.project_project_deduplicate, onvalidation=self.project_project_onvalidation, onaccept=self.project_project_onaccept, create_next=URL(c="project", f="project", args=["[id]", next]), search_method=project_search, list_fields=list_fields) # Reusable Field project_id = S3ReusableField("project_id", db.project_project, sortby="name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_project.id", "%(name)s")), represent = self.project_represent, comment = s3_popup_comment(c="project", f="project", title=ADD_PROJECT, tooltip=T("If you don't see the project in the list, you can add a new one by clicking link 'Add Project'.")), label = T("Project"), ondelete = "CASCADE") # --------------------------------------------------------------------- # Custom Methods self.set_method(tablename, method="timeline", action=self.project_timeline) # Components # Organisations add_component("project_organisation", project_project="project_id") # Sites add_component("project_site", project_project="project_id") # Activities add_component("project_activity", project_project="project_id") # Milestones add_component("project_milestone", project_project="project_id") # Beneficiaries add_component("project_beneficiary", project_project="project_id") # Tasks add_component("project_task", project_project=Storage( link="project_task_project", joinby="project_id", key="task_id", actuate="replace", autocomplete="name", autodelete=False)) # --------------------------------------------------------------------- # Activity Type # tablename = "project_activity_type" table = define_table(tablename, Field("name", length=128, notnull=True, unique=True), format="%(name)s", *meta_fields()) # Field configuration? # CRUD Strings ADD_ACTIVITY_TYPE = T("Add Activity Type") LIST_ACTIVITY_TYPES = T("List of Activity Types") crud_strings[tablename] = Storage( title_create = ADD_ACTIVITY_TYPE, title_display = T("Activity Type"), title_list = LIST_ACTIVITY_TYPES, title_update = T("Edit Activity Type"), title_search = T("Search for Activity Type"), subtitle_create = T("Add New Activity Type"), subtitle_list = T("All Activity Types"), label_list_button = LIST_ACTIVITY_TYPES, label_create_button = ADD_ACTIVITY_TYPE, msg_record_created = T("Activity Type Added"), msg_record_modified = T("Activity Type Updated"), msg_record_deleted = T("Activity Type Deleted"), msg_list_empty = T("No Activity Types Found") ) # Search Method? # Resource Configuration? # Reusable Fields activity_type_id = S3ReusableField("activity_type_id", db.project_activity_type, sortby="name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_activity_type.id", "%(name)s", sort=True)), represent = lambda id, row=None: \ s3_get_db_field_value(tablename = "project_activity_type", fieldname = "name", look_up_value = id), label = T("Activity Type"), comment = s3_popup_comment(c="project", f="activity_type", title=ADD_ACTIVITY_TYPE, tooltip=T("If you don't see the type in the list, you can add a new one by clicking link 'Add Activity Type'.")), ondelete = "RESTRICT") multi_activity_type_id = S3ReusableField("multi_activity_type_id", "list:reference project_activity_type", sortby = "name", label = T("Types of Activities"), requires = IS_NULL_OR(IS_ONE_OF(db, "project_activity_type.id", "%(name)s", sort=True, multiple=True)), represent = lambda opt, row=None: \ self.multiref_represent(opt, "project_activity_type"), #comment = skill_help, default = [], widget = lambda f, v: \ CheckboxesWidgetS3.widget(f, v, col=3), ondelete = "RESTRICT") # --------------------------------------------------------------------- # Project Activity # tablename = "project_activity" table = define_table(tablename, super_link("doc_id", "doc_entity"), project_id(), Field("name", label = T("Short Description"), requires=IS_NOT_EMPTY()), location_id( readable = drr, writable = drr, widget = S3LocationSelectorWidget(hide_address=True)), multi_activity_type_id(), Field("time_estimated", "double", readable=False if drr else True, writable=False if drr else True, label = "%s (%s)" % (T("Time Estimate"), T("hours"))), Field("time_actual", "double", readable=False if drr else True, # Gets populated from constituent Tasks writable=False, label = "%s (%s)" % (T("Time Taken"), T("hours"))), comments(), format="%(name)s", *meta_fields()) # Field configuration if pca: table.name.label = T("Name") # for list_fields table.name.readable = False table.name.writable = False table.name.requires = None # CRUD Strings if pca: ACTIVITY = T("Community") ACTIVITY_TOOLTIP = T("If you don't see the community in the list, you can add a new one by clicking link 'Add Community'.") ADD_ACTIVITY = T("Add Community") LIST_ACTIVITIES = T("List Communities") crud_strings[tablename] = Storage( title_create = ADD_ACTIVITY, title_display = T("Community Details"), title_list = LIST_ACTIVITIES, title_update = T("Edit Community Details"), title_search = T("Search Community"), title_upload = T("Import Community Data"), title_report = T("Who is doing What Where"), subtitle_create = T("Add New Community"), subtitle_list = T("Communities"), subtitle_report = T("Communities"), label_list_button = LIST_ACTIVITIES, label_create_button = ADD_ACTIVITY, msg_record_created = T("Community Added"), msg_record_modified = T("Community Updated"), msg_record_deleted = T("Community Deleted"), msg_list_empty = T("No Communities Found") ) else: ACTIVITY = T("Activity") ACTIVITY_TOOLTIP = T("If you don't see the activity in the list, you can add a new one by clicking link 'Add Activity'.") ADD_ACTIVITY = T("Add Activity") LIST_ACTIVITIES = T("List Activities") crud_strings[tablename] = Storage( title_create = ADD_ACTIVITY, title_display = T("Activity Details"), title_list = LIST_ACTIVITIES, title_update = T("Edit Activity"), title_search = T("Search Activities"), title_upload = T("Import Activity Data"), title_report = T("Who is doing What Where") if drr else T("Activity Report"), subtitle_create = T("Add New Activity"), subtitle_list = T("Activities"), subtitle_report = T("Activities"), label_list_button = LIST_ACTIVITIES, label_create_button = ADD_ACTIVITY, msg_record_created = T("Activity Added"), msg_record_modified = T("Activity Updated"), msg_record_deleted = T("Activity Deleted"), msg_list_empty = T("No Activities Found") ) # Virtual Fields if drr: table.virtualfields.append(S3ProjectActivityVirtualfields()) # Search Method if pca: project_activity_search = S3Search(field="location_id$name") else: project_activity_search = S3Search(field="name") # Resource Configuration report_fields = [] append = report_fields.append if drr: append((T("Organization"), "organisation")) append((T("Project"), "project_id")) if not pca: append((T("Activity"), "name")) append((T("Activity Type"), "multi_activity_type_id")) if drr: append((T("Sector"), "project_id$sector_id")) append((T("Theme"), "project_id$multi_theme_id")) append((T("Hazard"), "project_id$multi_hazard_id")) append((T("HFA"), "project_id$hfa")) lh = current.gis.get_location_hierarchy() lh = [(lh[opt], opt) for opt in lh] report_fields.extend(lh) append("location_id") list_fields = ["name", "project_id", "multi_activity_type_id", "comments" ] else: append((T("Time Estimated"), "time_estimated")) append((T("Time Actual"), "time_actual")) list_fields = ["name", "project_id", "location_id", "multi_activity_type_id", "comments" ] if drr: next = "beneficiary" else: next = "task" configure(tablename, super_entity="doc_entity", create_next=URL(c="project", f="activity", args=["[id]", next]), search_method=project_activity_search, onvalidation=self.project_activity_onvalidation, deduplicate=self.project_activity_deduplicate, report_rows=report_fields, report_cols=report_fields, report_fact=report_fields, list_fields = list_fields, ) # Reusable Field activity_id = S3ReusableField("activity_id", db.project_activity, sortby="name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_activity.id", "%(name)s", sort=True)), represent = lambda id, row=None: \ s3_get_db_field_value(tablename = "project_activity", fieldname = "name", look_up_value = id), label = ACTIVITY, comment = s3_popup_comment(c="project", f="activity", title=ADD_ACTIVITY, tooltip=ACTIVITY_TOOLTIP), ondelete = "CASCADE") # Components # Contact Persons add_component("pr_person", project_activity=Storage( name="contact", link="project_activity_contact", joinby="activity_id", key="person_id", actuate="hide", autodelete=False)) # Beneficiaries add_component("project_beneficiary", project_activity="activity_id") # Tasks add_component("project_task", project_activity=Storage( link="project_task_activity", joinby="activity_id", key="task_id", actuate="replace", autocomplete="name", autodelete=False)) # --------------------------------------------------------------------- # Project Activity Contact Person # # @ToDo: This is a Community Contact nmot an Activity contact,l so # should be renamed when we add proper Communities # tablename = "project_activity_contact" table = define_table(tablename, activity_id(), person_id(widget=S3AddPersonWidget(controller="pr"), requires=IS_ADD_PERSON_WIDGET(), comment=None), *meta_fields()) table.virtualfields.append(S3ProjectActivityContactVirtualFields()) # CRUD Strings ADD_CONTACT = T("Add Contact") LIST_CONTACTS = T("List Contacts") if pca: LIST_OF_CONTACTS = T("Community Contacts") else: LIST_OF_CONTACTS = T("Contacts") crud_strings[tablename] = Storage( title_create = ADD_CONTACT, title_display = T("Contact Details"), title_list = LIST_CONTACTS, title_update = T("Edit Contact Details"), title_search = T("Search Contacts"), subtitle_create = T("Add New Contact"), subtitle_list = LIST_OF_CONTACTS, label_list_button = LIST_CONTACTS, label_create_button = ADD_CONTACT, msg_record_created = T("Contact Added"), msg_record_modified = T("Contact Updated"), msg_record_deleted = T("Contact Deleted"), msg_list_empty = T("No Contacts Found")) activity_contact_search = S3Search( advanced=(S3SearchSimpleWidget( name = "activity_contact_search_simple", label = T("Name"), comment = T("You can search by person name - enter any of the first, middle or last names, separated by spaces. You may use % as wildcard. Press 'Search' without input to list all persons."), field = ["person_id$first_name", "person_id$middle_name", "person_id$last_name" ] ), S3SearchLocationHierarchyWidget( name="activity_contact_search_L1", field="person_id$L1", cols = 3, ), S3SearchLocationHierarchyWidget( name="activity_contact_search_L2", field="person_id$L2", cols = 3, ), )) # Resource configuration hierarchy = current.gis.get_location_hierarchy() configure(tablename, search_method=activity_contact_search, list_fields=["activity_id", (T("Project"), "activity_id$project_id"), "person_id", (hierarchy["L0"], "person_id$L0"), (hierarchy["L1"], "person_id$L1"), (hierarchy["L2"], "person_id$L2"), (hierarchy["L3"], "person_id$L3"), (T("Email"), "email"), (T("Mobile Phone"), "sms")]) # --------------------------------------------------------------------- # Pass variables back to global scope (response.s3.*) # return dict( project_project_id = project_id, project_activity_id = activity_id, project_hfa_opts = project_hfa_opts, project_project_represent = self.project_represent, ) # ------------------------------------------------------------------------- def defaults(self): """ Safe defaults for model-global names if module is disabled """ dummy = S3ReusableField("dummy_id", "integer", readable=False, writable=False) return Storage( project_project_id = lambda: dummy("project_id"), project_activity_id = lambda: dummy("activity_id"), project_project_represent = lambda v, r: current.messages.NONE ) # ------------------------------------------------------------------------- @staticmethod def multiref_represent(opts, tablename, represent_string = "%(name)s"): """ Represent a list of references @param opt: the current value or list of values @param tablename: the referenced table @param represent_string: format string to represent the records """ DEFAULT = "" db = current.db s3db = current.s3db UNKNOWN_OPT = current.messages.UNKNOWN_OPT table = s3db.table(tablename, None) if table is None: return DEFAULT if not isinstance(opts, (list, tuple)): opts = [opts] rows = db(table.id.belongs(opts)).select() rstr = Storage([(str(row.id), row) for row in rows]) keys = rstr.keys() represent = lambda o: str(o) in keys and \ represent_string % rstr[str(o)] or UNKNOWN_OPT vals = [represent(o) for o in opts] if len(opts) > 1: vals = ", ".join(vals) else: vals = len(vals) and vals[0] or DEFAULT return vals # --------------------------------------------------------------------- @staticmethod def project_represent(id, row=None, show_link=True): """ FK representation """ db = current.db NONE = current.messages.NONE if id: val = (id and [db.project_project[id].name] or [NONE])[0] if not show_link: return val return A(val, _href = URL(c="project", f="project", args=[id])) else: return NONE # --------------------------------------------------------------------- @staticmethod def project_project_onvalidation(form): """ Form validation """ if not form.vars.code and "name" in form.vars: # Populate code from name form.vars.code = form.vars.name return # --------------------------------------------------------------------- @staticmethod def project_project_onaccept(form): """ Set the project to be owned by the customer """ db = current.db s3db = current.s3db if "organisation_id" in form.vars: # Set Project to be owned by this Customer organisation_id = form.vars.organisation_id otable = s3db.org_organisation query = (otable.id == organisation_id) role = db(query).select(otable.owned_by_organisation, limitby=(0, 1)).first() if role: table = s3db.project_project query = (table.id == form.vars.id) db(query).update(owned_by_organisation=role.owned_by_organisation) return # --------------------------------------------------------------------- @staticmethod def project_project_deduplicate(item): """ Import item de-duplication """ if item.id: return if item.tablename == "project_project" and \ "name" in item.data: # Match project by name (all-lowercase) table = item.table name = item.data.name try: query = (table.name.lower() == name.lower()) except AttributeError, exception: s3_debug("project_deduplicate", exception.message) else: duplicate = current.db(query).select(table.id, table.name, limitby=(0, 1)).first() if duplicate: item.id = duplicate.id item.data.name = duplicate.name item.method = item.METHOD.UPDATE return # ------------------------------------------------------------------------- @staticmethod def project_timeline(r, **attr): """ Display the project on a Simile Timeline http://www.simile-widgets.org/wiki/Reference_Documentation_for_Timeline Currently this just displays a Google Calendar @ToDo: Add Milestones @ToDo: Filters for different 'layers' @ToDo: export milestones/tasks as .ics """ if r.representation == "html" and r.name == "project": T = current.T request = current.request response = current.response session = current.session s3 = response.s3 calendar = r.record.calendar # Add core Simile Code s3.scripts.append("/%s/static/scripts/simile/timeline/timeline-api.js" % request.application) # Pass vars to our JS code s3.js_global.append("S3.timeline.calendar = '%s';" % calendar) # Add our control script if session.s3.debug: s3.scripts.append("/%s/static/scripts/S3/s3.timeline.js" % request.application) else: s3.scripts.append("/%s/static/scripts/S3/s3.timeline.min.js" % request.application) # Create the DIV item = DIV(_id="s3timeline", _style="height: 400px; border: 1px solid #aaa; font-family: Trebuchet MS, sans-serif; font-size: 85%;") output = dict(item=item) output["title"] = T("Project Calendar") # Maintain RHeader for consistency if "rheader" in attr: rheader = attr["rheader"](r) if rheader: output["rheader"] = rheader response.view = "timeline.html" return output else: raise HTTP(501, BADMETHOD) # --------------------------------------------------------------------- @staticmethod def hfa_opts_represent(opt, row=None): """ Option representation """ s3 = current.response.s3 NONE = current.messages.NONE project_hfa_opts = s3.project_hfa_opts opts = opt if isinstance(opt, int): opts = [opt] elif not isinstance(opt, (list, tuple)): return NONE vals = [project_hfa_opts.get(o, NONE) for o in opts] return ", ".join(vals) # --------------------------------------------------------------------- @staticmethod def project_activity_onvalidation(form): """ """ pca = current.deployment_settings.get_project_community_activity() if pca: location_id = form.vars.location_id if location_id: db = current.db s3db = current.s3db table = s3db.gis_location query = (table.id == form.vars.location_id) row = db(query).select(table.parent, limitby=(0, 1)).first() if row and row.parent: query = (table.id == row.parent) parent = db(query).select(table.name, limitby=(0, 1)).first() if parent: form.vars.name = parent.name return # --------------------------------------------------------------------- @staticmethod def project_activity_deduplicate(item): """ Import item de-duplication """ db = current.db settings = current.deployment_settings pca = settings.get_project_community_activity() if item.id: return if item.tablename != "project_activity": return table = item.table duplicate = None if pca: if "project_id" in item.data and \ "location_id" in item.data: # Match activity by project_id and location_id project_id = item.data.project_id location_id = item.data.location_id query = (table.project_id == project_id) & \ (table.location_id == location_id) duplicate = db(query).select(table.id, limitby=(0, 1)).first() else: if "project_id" in item.data and "name" in item.data: # Match activity by project_id and name project_id = item.data.project_id name = item.data.name query = (table.project_id == project_id) & \ (table.name == name) duplicate = db(query).select(table.id, limitby=(0, 1)).first() if duplicate: item.id = duplicate.id item.method = item.METHOD.UPDATE return # ============================================================================= class S3ProjectDRRModel(S3Model): """ Project DRR Model This class contains the tabels suitable for use by multinational organisations tracking projects at a high level """ names = ["project_organisation", #"project_site", "project_beneficiary_type", "project_beneficiary", "project_organisation_roles", "project_organisation_lead_role" ] def model(self): T = current.T db = current.db s3 = current.response.s3 currency_type = s3.currency_type #location_id = self.gis_location_id organisation_id = self.org_organisation_id project_id = self.project_project_id activity_id = self.project_activity_id #multi_activity_type_id = self.project_multi_activity_type_id pca = current.deployment_settings.get_project_community_activity() messages = current.messages NONE = messages.NONE # --------------------------------------------------------------------- # Project Organisation # project_organisation_roles = { 1: T("Lead Implementer"), # T("Host National Society") 2: T("Partner"), # T("Partner National Society") 3: T("Donor"), 4: T("Customer"), # T("Beneficiary")? } project_organisation_lead_role = 1 organisation_help = T("Add all organizations which are involved in different roles in this project") tablename = "project_organisation" table = self.define_table(tablename, project_id(), organisation_id(comment = DIV(A(T("Add Organization"), _class="colorbox", _href=URL(c="org", f="organisation", args="create", vars=dict(format="popup")), _target="top", _title=T("Add Organization")), DIV(_class="tooltip", _title="%s|%s" % (T("Organization"), organisation_help)) ) ), Field("role", "integer", requires = IS_NULL_OR(IS_IN_SET(project_organisation_roles)), represent = lambda opt, row=None: \ project_organisation_roles.get(opt, NONE)), Field("amount", "double", requires = IS_FLOAT_AMOUNT(), represent = lambda v, row=None: \ IS_FLOAT_AMOUNT.represent(v, precision=2), widget = IS_FLOAT_AMOUNT.widget, label = T("Funds Contributed by this Organization")), currency_type(), s3.comments(), *s3.meta_fields()) # Field configuration? # CRUD Strings ADD_PROJECT_ORG = T("Add Organization to Project") LIST_PROJECT_ORG = T("List Project Organizations") s3.crud_strings[tablename] = Storage( title_create = ADD_PROJECT_ORG, title_display = T("Project Organization Details"), title_list = LIST_PROJECT_ORG, title_update = T("Edit Project Organization"), title_search = T("Search Project Organizations"), title_upload = T("Import Project Organizations"), title_report = T("Funding Report"), subtitle_create = T("Add Organization to Project"), subtitle_list = T("Project Organizations"), subtitle_report = T("Funding"), label_list_button = LIST_PROJECT_ORG, label_create_button = ADD_PROJECT_ORG, label_delete_button = T("Remove Organization from Project"), msg_record_created = T("Organization added to Project"), msg_record_modified = T("Project Organization updated"), msg_record_deleted = T("Organization removed from Project"), msg_list_empty = T("No Organizations for this Project")) # Search Method? # Resource Configuration self.configure(tablename, deduplicate=self.project_organisation_deduplicate, onvalidation=self.project_organisation_onvalidation) # Reusable Field # Components # --------------------------------------------------------------------- # Project Site # @ToDo: Deprecated? # # tablename = "project_site" # table = self.define_table(tablename, # self.super_link("site_id", "org_site"), # project_id(), # Field("name", notnull=True, # length=64, # Mayon Compatibility # label = T("Name")), # location_id(), # multi_activity_type_id(), # *(s3.address_fields() + s3.meta_fields())) # Field configuration # CRUD Strings # Search Method # Resource Configuration # Reusable Field # CRUD strings # ADD_PROJECT_SITE = T("Add Project Site") # LIST_PROJECT_SITE = T("List Project Sites") # s3.crud_strings[tablename] = Storage( # title_create = ADD_PROJECT_SITE, # title_display = T("Project Site Details"), # title_list = LIST_PROJECT_SITE, # title_update = T("Edit Project Site"), # title_search = T("Search Project Sites"), # title_upload = T("Import Project Sites"), # subtitle_create = T("Add New Project Site"), # subtitle_list = T("Sites"), # label_list_button = LIST_PROJECT_SITE, # label_create_button = ADD_PROJECT_SITE, # label_delete_button = T("Delete Project Site"), # msg_record_created = T("Project Site added"), # msg_record_modified = T("Project Site updated"), # msg_record_deleted = T("Project Site deleted"), # msg_list_empty = T("No Project Sites currently registered")) # project_site_id = S3ReusableField("project_site_id", db.project_site, # #sortby="default/indexname", # requires = IS_NULL_OR(IS_ONE_OF(db, "project_site.id", "%(name)s")), # represent = lambda id, row=None: \ # (id and [db(db.project_site.id == id).select(db.project_site.name, # limitby=(0, 1)).first().name] or [NONE])[0], # label = T("Project Site"), # comment = s3_popup_comment(c="project", # f="site", # title=ADD_PROJECT_SITE, # tooltip=T("If you don't see the site in the list, you can add a new one by clicking link 'Add Project Site'.")),, # ondelete = "CASCADE") # self.configure(tablename, # super_entity="org_site", # onvalidation=s3.address_onvalidation) # --------------------------------------------------------------------- # Project Beneficiary Type # tablename = "project_beneficiary_type" table = self.define_table(tablename, Field("name", length=128, unique=True, requires = IS_NOT_IN_DB(db, "project_beneficiary_type.name")), *s3.meta_fields()) # Field configuration? # CRUD Strings ADD_BNF_TYPE = T("Add Beneficiary Type") LIST_BNF_TYPE = T("List Beneficiary Types") s3.crud_strings[tablename] = Storage( title_create = ADD_BNF_TYPE, title_display = T("Beneficiary Type"), title_list = LIST_BNF_TYPE, title_update = T("Edit Beneficiary Type"), title_search = T("Search Beneficiary Types"), subtitle_create = T("Add New Beneficiary Type"), subtitle_list = T("Beneficiary Types"), label_list_button = LIST_BNF_TYPE, label_create_button = ADD_BNF_TYPE, msg_record_created = T("Beneficiary Type Added"), msg_record_modified = T("Beneficiary Type Updated"), msg_record_deleted = T("Beneficiary Type Deleted"), msg_list_empty = T("No Beneficiary Types Found") ) # Search Method? # Resource Configuration? # Reusable Field beneficiary_type_id = S3ReusableField("beneficiary_type_id", db.project_beneficiary_type, requires = IS_NULL_OR(IS_ONE_OF(db, "project_beneficiary_type.id", self.beneficiary_type_represent)), represent = self.beneficiary_type_represent, label = T("Beneficiary Type"), comment = s3_popup_comment(c="project", f="beneficiary_type", title=ADD_BNF_TYPE, tooltip=T("Please record Beneficiary according to the reporting needs of your project")), ondelete = "CASCADE") # --------------------------------------------------------------------- # Project Beneficiary # tablename = "project_beneficiary" table = self.define_table(tablename, # populated automatically project_id(readable=False, writable=False), activity_id(comment=None), beneficiary_type_id(empty=False), Field("number", "integer", label = T("Quantity"), requires = IS_INT_IN_RANGE(0, 99999999)), s3.comments(), *s3.meta_fields()) # Field configuration if pca: table.activity_id.label = T("Community") # CRUD Strings ADD_BNF = T("Add Beneficiaries") LIST_BNF = T("List Beneficiaries") s3.crud_strings[tablename] = Storage( title_create = ADD_BNF, title_display = T("Beneficiaries Details"), title_list = LIST_BNF, title_update = T("Edit Beneficiaries"), title_search = T("Search Beneficiaries"), title_report = T("Beneficiary Report"), subtitle_create = T("Add New Beneficiaries"), subtitle_list = T("Beneficiaries"), label_list_button = LIST_BNF, label_create_button = ADD_BNF, msg_record_created = T("Beneficiaries Added"), msg_record_modified = T("Beneficiaries Updated"), msg_record_deleted = T("Beneficiaries Deleted"), msg_list_empty = T("No Beneficiaries Found") ) table.virtualfields.append(S3ProjectBeneficiaryVirtualfields()) # Search Method? # Resource Configuration report_fields=[ "activity_id", (T("Beneficiary Type"), "beneficiary_type_id"), "project_id", "project_id$multi_hazard_id", "project_id$multi_theme_id", "activity_id$multi_activity_type_id" ] lh = current.gis.get_location_hierarchy() lh = [(lh[opt], opt) for opt in lh] report_fields.extend(lh) self.configure(tablename, onaccept=self.project_beneficiary_onaccept, deduplicate=self.project_beneficiary_deduplicate, report_filter=[ S3SearchOptionsWidget( field=["project_id"], name="project", label=T("Project") ), S3SearchOptionsWidget( field=["beneficiary_type_id"], name="beneficiary_type_id", label=T("Beneficiary Type") ), # Can't search be VirtualFields currently # S3SearchLocationHierarchyWidget( # name="beneficiary_search_L1", # field="activity_id$L1", # cols = 3, # ), ], report_rows=report_fields, report_cols=report_fields, report_fact=["number"], report_method=["sum"]) # Reusable Field beneficiary_id = S3ReusableField("beneficiary_id", db.project_beneficiary, sortby="name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_beneficiary.id", "%(type)s", sort=True)), represent = lambda id, row=None: \ s3_get_db_field_value(tablename = "project_beneficiary", fieldname = "type", look_up_value = id), label = T("Beneficiaries"), comment = s3_popup_comment(c="project", f="beneficiary", title=ADD_BNF, tooltip=T("If you don't see the beneficiary in the list, you can add a new one by clicking link 'Add Beneficiary'.")), ondelete = "SET NULL") # --------------------------------------------------------------------- # Pass variables back to global scope (response.s3.*) # return dict( project_organisation_roles = project_organisation_roles, project_organisation_lead_role = project_organisation_lead_role, ) # ------------------------------------------------------------------------- def defaults(self): """ Safe defaults for model-global names if module is disabled """ dummy = S3ReusableField("dummy_id", "integer", readable=False, writable=False) return Storage( ) # --------------------------------------------------------------------- @staticmethod def project_organisation_onvalidation(form, lead_role=None): """ Form validation """ db = current.db s3db = current.s3db s3 = current.response.s3 otable = s3db.project_organisation if lead_role is None: lead_role = s3.project_organisation_lead_role project_id = form.vars.project_id organisation_id = form.vars.organisation_id if str(form.vars.role) == str(lead_role) and project_id: query = (otable.deleted != True) & \ (otable.project_id == project_id) & \ (otable.role == lead_role) & \ (otable.organisation_id != organisation_id) row = db(query).select(otable.id, limitby=(0, 1)).first() if row: form.errors.role = T("Lead Implementer for this project is already set, please choose another role.") return # --------------------------------------------------------------------- @staticmethod def project_organisation_deduplicate(item): """ Import item de-duplication """ db = current.db if item.id: return if item.tablename == "project_organisation" and \ "project_id" in item.data and \ "organisation_id" in item.data: # Match project by org_id and project_id table = item.table project_id = item.data.project_id organisation_id = item.data.organisation_id query = (table.project_id == project_id) & \ (table.organisation_id == organisation_id) duplicate = db(query).select(table.id, limitby=(0, 1)).first() if duplicate: item.id = duplicate.id item.method = item.METHOD.UPDATE return # --------------------------------------------------------------------- @staticmethod def beneficiary_type_represent(type_id, row=None): """ FK representation """ db = current.db s3db = current.s3db UNKNOWN_OPT = current.messages.UNKNOWN_OPT if isinstance(type_id, Row): if "name" in type_id: return type_id.name elif "id" in type_id: type_id = type_id.id else: return UNKNOWN_OPT bnf_type = s3db.project_beneficiary_type query = bnf_type.id == type_id row = db(query).select(bnf_type.name, limitby=(0, 1)).first() if row: return row.name else: return UNKNOWN_OPT # --------------------------------------------------------------------- @staticmethod def project_beneficiary_onaccept(form): """ Record creation post-processing """ db = current.db s3db = current.s3db btable = s3db.project_beneficiary atable = s3db.project_activity record_id = form.vars.id query = (btable.id == record_id) & \ (atable.id == btable.activity_id) activity = db(query).select(atable.project_id, limitby=(0, 1)).first() if activity: db(btable.id == record_id).update(project_id=activity.project_id) return # --------------------------------------------------------------------- @staticmethod def project_beneficiary_deduplicate(item): """ Import item de-duplication """ db = current.db if item.id: return if item.tablename == "project_beneficiary" and \ "beneficiary_type_id" in item.data and \ "activity_id" in item.data: # Match beneficiary by type and activity_id table = item.table beneficiary_type_id = item.data.beneficiary_type_id activity_id = item.data.activity_id query = (table.beneficiary_type_id == beneficiary_type_id) & \ (table.activity_id == activity_id) duplicate = db(query).select(table.id, limitby=(0, 1)).first() if duplicate: item.id = duplicate.id item.method = item.METHOD.UPDATE return # ============================================================================= class S3ProjectTaskModel(S3Model): """ Project Task Model This class holds the tables used for a smaller Organisation to manage their Tasks in detail. """ names = ["project_milestone", "project_task", "project_time", "project_comment", "project_task_project", "project_task_activity", "project_task_id", ] def model(self): db = current.db T = current.T auth = current.auth request = current.request s3 = current.response.s3 settings = current.deployment_settings person_id = self.pr_person_id location_id = self.gis_location_id site_id = self.org_site_id project_id = self.project_project_id activity_id = self.project_activity_id s3_date_format = settings.get_L10n_date_format() s3_utc_represent = lambda dt: S3DateTime.datetime_represent(dt, utc=True) s3_date_represent = lambda dt: S3DateTime.date_represent(dt, utc=True) messages = current.messages NONE = messages.NONE UNKNOWN_OPT = messages.UNKNOWN_OPT # Shortcuts add_component = self.add_component comments = s3.comments configure = self.configure crud_strings = s3.crud_strings define_table = self.define_table super_link = self.super_link meta_fields = s3.meta_fields # --------------------------------------------------------------------- # Project Milestone # tablename = "project_milestone" table = define_table(tablename, # Stage Report super_link("doc_id", "doc_entity"), project_id(), Field("name", label = T("Short Description"), requires=IS_NOT_EMPTY()), Field("date", "date", label = T("Date"), represent = s3_date_represent, requires = IS_NULL_OR(IS_DATE(format = s3_date_format))), comments(), format="%(name)s", *meta_fields()) # CRUD Strings ADD_MILESTONE = T("Add Milestone") crud_strings[tablename] = Storage( title_create = ADD_MILESTONE, title_display = T("Milestone Details"), title_list = T("List Milestones"), title_update = T("Edit Milestone"), title_search = T("Search Milestones"), title_upload = T("Import Milestone Data"), subtitle_create = T("Add New Milestone"), subtitle_list = T("Milestones"), subtitle_report = T("Milestones"), label_list_button = T("List Milestones"), label_create_button = ADD_MILESTONE, msg_record_created = T("Milestone Added"), msg_record_modified = T("Milestone Updated"), msg_record_deleted = T("Milestone Deleted"), msg_list_empty = T("No Milestones Found") ) # Reusable Field milestone_id = S3ReusableField("milestone_id", db.project_milestone, sortby="name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_milestone.id", "%(name)s")), represent = self.milestone_represent, comment = s3_popup_comment(c="project", f="milestone", title=ADD_MILESTONE, tooltip=T("A project milestone marks a significant date in the calendar which shows that progress towards the overall objective is being made.")), label = T("Milestone"), ondelete = "RESTRICT") # --------------------------------------------------------------------- # Tasks # # Tasks can be linked to Activities or directly to Projects # - they can also be used by the Event/Scenario modules # # @ToDo: Recurring tasks # # These Statuses can be customised, although doing so limits the ability to do synchronization # - best bet is simply to comment statuses that you don't wish to use # project_task_status_opts = { 1: T("Draft"), 2: T("New"), 3: T("Assigned"), 4: T("Feedback"), 5: T("Blocked"), 6: T("On Hold"), 7: T("Cancelled"), 8: T("Duplicate"), 9: T("Ready"), 10: T("Verified"), 11: T("Reopened"), 12: T("Completed"), #99: T("unspecified") } project_task_active_statuses = [2, 3, 4, 11] project_task_priority_opts = { 1:T("Urgent"), 2:T("High"), 3:T("Normal"), 4:T("Low") } #staff = auth.s3_has_role("STAFF") staff = True tablename = "project_task" table = define_table(tablename, super_link("doc_id", "doc_entity"), Field("template", "boolean", default=False, readable=False, writable=False), Field("name", label = T("Short Description"), length=100, notnull=True, requires = IS_LENGTH(maxsize=100, minsize=1)), Field("description", "text", label = T("Detailed Description/URL"), comment = DIV(_class="tooltip", _title="%s|%s" % (T("Detailed Description/URL"), T("Please provide as much detail as you can, including the URL(s) where the bug occurs or you'd like the new feature to go.")))), site_id, location_id(label=T("Deployment Location"), readable=False, writable=False ), Field("source", label = T("Source")), Field("priority", "integer", requires = IS_IN_SET(project_task_priority_opts, zero=None), default = 3, label = T("Priority"), represent = lambda opt, row=None: \ project_task_priority_opts.get(opt, UNKNOWN_OPT)), # Could be a Person, Team or Organisation super_link("pe_id", "pr_pentity", readable = staff, writable = staff, label = T("Assigned to"), filterby = "instance_type", filter_opts = ["pr_person", "pr_group", "org_organisation"], represent = lambda id, row=None: \ project_assignee_represent(id), # @ToDo: Widget #widget = S3PentityWidget(), #comment = DIV(_class="tooltip", # _title="%s|%s" % (T("Assigned to"), # T("Enter some characters to bring up a list of possible matches"))) ), Field("date_due", "datetime", label = T("Date Due"), readable = staff, writable = staff, requires = [IS_EMPTY_OR( IS_UTC_DATETIME_IN_RANGE( minimum=request.utcnow - datetime.timedelta(days=1), error_message="%s %%(min)s!" % T("Enter a valid future date")))], widget = S3DateTimeWidget(past=0, future=8760), # Hours, so 1 year represent = s3_date_represent), milestone_id( readable = staff, writable = staff, ), Field("time_estimated", "double", readable = staff, writable = staff, represent = lambda v: v or "", label = "%s (%s)" % (T("Time Estimate"), T("hours"))), Field("time_actual", "double", readable = staff, # This comes from the Time component writable=False, label = "%s (%s)" % (T("Time Taken"), T("hours"))), Field("status", "integer", requires = IS_IN_SET(project_task_status_opts, zero=None), default = 2, readable = staff, writable = staff, label = T("Status"), represent = lambda opt, row=None: \ project_task_status_opts.get(opt, UNKNOWN_OPT)), *meta_fields()) # Field configurations # Comment these if you don't need a Site associated with Tasks #table.site_id.readable = table.site_id.writable = True #table.site_id.label = T("Check-in at Facility") # T("Managing Office") table.created_on.represent = s3_date_represent # CRUD Strings ADD_TASK = T("Add Task") LIST_TASKS = T("List Tasks") crud_strings[tablename] = Storage( title_create = ADD_TASK, title_display = T("Task Details"), title_list = LIST_TASKS, title_update = T("Edit Task"), title_search = T("Search Tasks"), title_upload = T("Import Tasks"), subtitle_create = T("Add New Task"), subtitle_list = T("Tasks"), label_list_button = LIST_TASKS, label_create_button = ADD_TASK, msg_record_created = T("Task added"), msg_record_modified = T("Task updated"), msg_record_deleted = T("Task deleted"), msg_list_empty = T("No tasks currently registered")) # Virtual Fields # Do just for the common report table.virtualfields.append(S3ProjectTaskVirtualfields()) # Search Method task_search = S3Search( advanced = ( # Virtual fields not supported by Search Widgets yet #S3SearchOptionsWidget( #name = "task_search_project", #label = T("Project"), #field = ["project"], #cols = 3 #), # This Syntax not supported by Search Widgets yet #S3SearchOptionsWidget( # name = "task_search_project", # label = T("Project"), # field = ["task.task_id:project_task:project_id$name"], # cols = 3 #), # Virtual fields not supported by Search Widgets yet #S3SearchOptionsWidget( #name = "task_search_activity", #label = T("Activity"), #field = ["activity"], #cols = 3 #), S3SearchOptionsWidget( name = "task_search_priority", label = T("Priority"), field = ["priority"], cols = 4 ), S3SearchSimpleWidget( name = "task_search_text_advanced", label = T("Description"), comment = T("Search for a Task by description."), field = [ "name", "description", ] ), S3SearchOptionsWidget( name = "task_search_created_by", label = T("Created By"), field = ["created_by"], cols = 4 ), S3SearchOptionsWidget( name = "task_search_assignee", label = T("Assigned To"), field = ["pe_id"], cols = 4 ), S3SearchMinMaxWidget( name="task_search_date_created", method="range", label=T("Date Created"), field=["created_on"] ), S3SearchMinMaxWidget( name="task_search_date_due", method="range", label=T("Date Due"), field=["date_due"] ), S3SearchOptionsWidget( name = "task_search_status", label = T("Status"), field = ["status"], cols = 4 ), ) ) # Resource Configuration configure(tablename, super_entity="doc_entity", copyable=True, orderby="project_task.priority", onvalidation=self.task_onvalidation, create_next=URL(f="task", args=["[id]"]), create_onaccept=self.task_create_onaccept, update_onaccept=self.task_update_onaccept, search_method=task_search, list_fields=["id", "priority", (T("ID"), "task_id"), "name", "pe_id", "milestone_id", "date_due", "time_estimated", "created_on", "status", #"site_id" ], extra="description") # Reusable field task_id = S3ReusableField("task_id", db.project_task, label = T("Task"), sortby="name", requires = IS_NULL_OR(IS_ONE_OF(db, "project_task.id", "%(name)s")), represent = lambda id, row=None: \ (id and [db.project_task[id].name] or [NONE])[0], comment = s3_popup_comment(c="project", f="task", title=ADD_TASK, tooltip=T("A task is a piece of work that an individual or team can do in 1-2 days.")), ondelete = "CASCADE") # --------------------------------------------------------------------- # Custom Methods self.set_method("project_task", method="dispatch", action=self.task_dispatch) # Components # Projects (for imports) add_component("project_project", project_task=Storage( link="project_task_project", joinby="task_id", key="project_id", actuate="embed", autocomplete="name", autodelete=False)) # Activities (for imports) add_component("project_activity", project_task=Storage( link="project_task_activity", joinby="task_id", key="activity_id", actuate="embed", autocomplete="name", autodelete=False)) # Job roles add_component("hrm_job_role", project_task=Storage( link="project_task_job_role", joinby="task_id", key="job_role_id", actuate="embed", autocomplete="name", autodelete=False)) # Human Resources (assigned) add_component("hrm_human_resource", project_task=Storage( link="project_task_human_resource", joinby="task_id", key="human_resource_id", actuate="embed", autocomplete="name", autodelete=False)) # Requests add_component("req_req", project_task=Storage( link="project_task_req", joinby="task_id", key="req_id", actuate="embed", autocomplete="request_number", autodelete=False)) # Time add_component("project_time", project_task="task_id") # Comments (for imports)) add_component("project_comment", project_task="task_id") # --------------------------------------------------------------------- # Link Tasks <-> Projects # tablename = "project_task_project" table = define_table(tablename, task_id(), project_id(), *meta_fields()) # Field configuration # CRUD Strings # Search Method # Resource Configuration # Reusable Field # --------------------------------------------------------------------- # Link task <-> activity # # Tasks <> Activities tablename = "project_task_activity" table = define_table(tablename, task_id(), activity_id(), *meta_fields()) # Field configuration # CRUD Strings # Search Method # Resource Configuration # Reusable Field # --------------------------------------------------------------------- # Project comment # # @ToDo: Attachments? # # Parent field allows us to: # * easily filter for top-level threads # * easily filter for next level of threading # * hook a new reply into the correct location in the hierarchy # tablename = "project_comment" table = define_table(tablename, Field("parent", "reference project_comment", requires = IS_EMPTY_OR(IS_ONE_OF(db, "project_comment.id")), readable=False), #project_id(), #activity_id(), task_id(), Field("body", "text", notnull=True, label = T("Comment")), *meta_fields()) # Field configuration? # CRUD Strings? # Search Method? # Resource Configuration configure(tablename, list_fields=["id", "task_id", "created_by", "modified_on" ]) # Reusable Field? # --------------------------------------------------------------------- # Project Time # - used to Log hours spent on a Task # tablename = "project_time" table = define_table(tablename, task_id(), person_id(default=auth.s3_logged_in_person()), Field("date", "datetime", label = T("Date"), requires = IS_EMPTY_OR(IS_UTC_DATETIME()), represent = s3_utc_represent, widget = S3DateTimeWidget(past=8760, # Hours, so 1 year future=0), default = request.utcnow), Field("hours", "double", label = "%s (%s)" % (T("Time"), T("hours"))), comments(), format="%(comments)s", *meta_fields()) # CRUD Strings ADD_TIME = T("Log Time Spent") crud_strings[tablename] = Storage( title_create = ADD_TIME, title_display = T("Logged Time Details"), title_list = T("List Logged Time"), title_update = T("Edit Logged Time"), title_search = T("Search Logged Time"), title_upload = T("Import Logged Time data"), title_report = T("Last Week's Work"), subtitle_create = T("Log New Time"), subtitle_list = T("Logged Time"), subtitle_report = T("Logged Time"), label_list_button = T("List Logged Time"), label_create_button = ADD_TIME, msg_record_created = T("Time Logged"), msg_record_modified = T("Time Log Updated"), msg_record_deleted = T("Time Log Deleted"), msg_list_empty = T("No Time Logged") ) if "rows" in request.get_vars and request.get_vars.rows == "project": s3.crud_strings[tablename].title_report = T("Project Time Report") # Virtual Fields table.virtualfields.append(S3ProjectTimeVirtualfields()) configure(tablename, onaccept=self.time_onaccept, list_fields=["id", (T("Project"), "project"), "task_id", "person_id", "date", "hours", "comments", ]) # --------------------------------------------------------------------- # Pass variables back to global scope (response.s3.*) # return dict( project_task_id = task_id, project_task_active_statuses = project_task_active_statuses, ) # ------------------------------------------------------------------------- def defaults(self): """ Safe defaults for model-global names if module is disabled """ dummy = S3ReusableField("dummy_id", "integer", readable=False, writable=False) return Storage( project_task_id = lambda: dummy("task_id") ) # --------------------------------------------------------------------- @staticmethod def milestone_represent(id, row=None): """ FK representation """ db = current.db NONE = current.messages.NONE if id: val = (id and [db.project_milestone[id].name] or [NONE])[0] return val else: return NONE # ------------------------------------------------------------------------- @staticmethod def task_onvalidation(form): """ Task form validation """ T = current.T vars = form.vars if str(vars.status) == "3" and not vars.pe_id: form.errors.pe_id = \ T("Status 'assigned' requires the %(fieldname)s to not be blank") % \ dict(fieldname=current.db.project_task.pe_id.label) elif vars.pe_id and str(vars.status) == "2": # Set the Status to 'Assigned' if left at default 'New' vars.status = 3 return # ------------------------------------------------------------------------- @staticmethod def task_update_onaccept(form): """ * Process the additional fields: Project/Activity * Log changes as comments * If the task is assigned to someone then notify them """ db = current.db s3db = current.s3db s3mgr = current.manager vars = form.vars id = vars.id record = form.record table = s3db.project_task changed = {} for var in vars: vvar = vars[var] rvar = record[var] if vvar != rvar: if table[var].type == "integer": vvar = int(vvar) if vvar == rvar: continue represent = table[var].represent if not represent: represent = lambda o: o if rvar: changed[var] = "%s changed from %s to %s" % \ (table[var].label, represent(rvar), represent(vvar)) else: changed[var] = "%s changed to %s" % \ (table[var].label, represent(vvar)) if changed: table = s3db.project_comment text = s3_user_represent(current.auth.user.id) for var in changed: text = "%s\n%s" % (text, changed[var]) table.insert(task_id=id, body=text) vars = current.request.post_vars if "project_id" in vars: ptable = s3db.project_project ltable = s3db.project_task_project filter = (ltable.task_id == id) if vars.project_id: # Create the link to the Project #master = s3mgr.define_resource("project", "task", id=id) #record = db(ptable.id == vars.project_id).select(ptable.id, # limitby=(0, 1)).first() #link = s3mgr.define_resource("project", "task_project") #link_id = link.update_link(master, record) query = (ltable.task_id == id) & \ (ltable.project_id == vars.project_id) record = db(query).select(ltable.id, limitby=(0, 1)).first() if record: link_id = record.id else: link_id = ltable.insert(task_id = id, project_id = vars.project_id) filter = filter & (ltable.id != link_id) # Remove any other links links = s3mgr.define_resource("project", "task_project", filter=filter) ondelete = s3mgr.model.get_config("project_task_project", "ondelete") links.delete(ondelete=ondelete) if "activity_id" in vars: atable = s3db.project_activity ltable = s3db.project_task_activity filter = (ltable.task_id == id) if vars.activity_id: # Create the link to the Activity #master = s3mgr.define_resource("project", "task", id=id) #record = db(atable.id == vars.activity_id).select(atable.id, # limitby=(0, 1)).first() #link = s3mgr.define_resource("project", "task_activity") #link_id = link.update_link(master, record) query = (ltable.task_id == id) & \ (ltable.activity_id == vars.activity_id) record = db(query).select(ltable.id, limitby=(0, 1)).first() if record: link_id = record.id else: link_id = ltable.insert(task_id = id, activity_id = vars.activity_id) filter = filter & (ltable.id != link_id) # Remove any other links links = s3mgr.define_resource("project", "task_activity", filter=filter) ondelete = s3mgr.model.get_config("project_task_activity", "ondelete") links.delete(ondelete=ondelete) # Notify Assignee task_notify(form) return # ------------------------------------------------------------------------- @staticmethod def task_create_onaccept(form): """ When a Task is created: * Process the additional fields: Project/Activity * create associated Link Tables * ensure that it is owned by the Project Customer * notify assignee """ db = current.db s3db = current.s3db session = current.session vars = form.vars id = vars.id _vars = current.request.post_vars if session.s3.event: # Create a link between this Task & the active Event etable = s3db.event_task etable.insert(event_id=session.s3.event, task_id=id) vars = current.request.post_vars table = s3db.project_task if "project_id" in vars: # Create Link to Project ltable = s3db.project_task_project if vars.project_id: link_id = ltable.insert(task_id = id, project_id = _vars.project_id) if "activity_id" in vars: # Create Link to Activity ltable = s3db.project_task_activity if vars.activity_id: link_id = ltable.insert(task_id = id, activity_id = _vars.activity_id) # Find the associated Project ptable = db.project_project ltable = db.project_task_project query = (ltable.task_id == id) & \ (ltable.project_id == ptable.id) project = db(query).select(ptable.organisation_id, limitby=(0, 1)).first() if project: # Set Task to be owned by this Customer organisation_id = project.organisation_id otable = s3db.org_organisation query = (otable.id == organisation_id) role = db(query).select(otable.owned_by_organisation, limitby=(0, 1)).first() if role: table = s3db.project_task query = (table.id == vars.id) db(query).update(owned_by_organisation=role.owned_by_organisation) # Make sure the task is also linked to the project # when created under an activity if id: lta = s3db.project_task_activity ltp = s3db.project_task_project ta = s3db.project_activity query = (ltp.task_id == id) row = db(query).select(ltp.project_id, limitby=(0, 1)).first() if not row: query = (lta.task_id == id) & \ (lta.activity_id == ta.id) row = db(query).select(ta.project_id, limitby=(0, 1)).first() if row and row.project_id: ltp.insert(task_id=id, project_id=row.project_id) # Notify Assignee task_notify(form) return # ------------------------------------------------------------------------- @staticmethod def task_dispatch(r, **attr): """ Send a Task Dispatch notice from a Task - if a location is supplied, this will be formatted as an OpenGeoSMS """ T = current.T msg = current.msg response = current.response if r.representation == "html" and \ r.name == "task" and r.id and not r.component: record = r.record text = "%s: %s" % (record.name, record.description) # Encode the message as an OpenGeoSMS message = msg.prepare_opengeosms(record.location_id, code="ST", map="google", text=text) # URL to redirect to after message sent url = URL(c="project", f="task", args=r.id) # Create the form if record.pe_id: opts = dict(recipient=record.pe_id) else: opts = dict(recipient_type="pr_person") output = msg.compose(type="SMS", message = message, url = url, **opts) # Maintain RHeader for consistency if "rheader" in attr: rheader = attr["rheader"](r) if rheader: output["rheader"] = rheader output["title"] = T("Send Task Notification") response.view = "msg/compose.html" return output else: raise HTTP(501, BADMETHOD) # ------------------------------------------------------------------------- @staticmethod def time_onaccept(form): """ When Time is logged, update the Task & Activity """ db = current.db titable = db.project_time ttable = db.project_task atable = db.project_activity tatable = db.project_task_activity # Find the Task task_id = form.vars.task_id if not task_id: # Component Form query = (titable.id == form.vars.id) record = db(query).select(titable.task_id, limitby=(0, 1)).first() if record: task_id = record.task_id # Total the Hours Logged query = (titable.deleted == False) & \ (titable.task_id == task_id) rows = db(query).select(titable.hours) hours = 0 for row in rows: hours += row.hours # Update the Task query = (ttable.id == task_id) db(query).update(time_actual=hours) # Find the Activity query = (tatable.deleted == False) & \ (tatable.task_id == task_id) activity = db(query).select(tatable.activity_id, limitby=(0, 1)).first() if activity: activity_id = activity.activity_id # Find all Tasks in this Activity query = (ttable.deleted == False) & \ (tatable.deleted == False) & \ (tatable.task_id == ttable.id) & \ (tatable.activity_id == activity_id) tasks = db(query).select(ttable.time_actual) # Total the Hours Logged hours = 0 for task in tasks: hours += task.time_actual # Update the Activity query = (atable.id == activity_id) db(query).update(time_actual=hours) return # ============================================================================= class S3ProjectTaskHRMModel(S3Model): """ Project Task HRM Model This class holds the tables used to link Tasks to Human Resources - either individuals or Job Roles """ names = ["project_task_job_role", "project_task_human_resource", ] def model(self): s3 = current.response.s3 task_id = self.project_task_id human_resource_id = self.hrm_human_resource_id job_role_id = self.hrm_job_role_id # Shortcuts define_table = self.define_table # --------------------------------------------------------------------- # Link Tasks <> Human Resources tablename = "project_task_human_resource" table = define_table(tablename, task_id(), human_resource_id(), *s3.meta_fields()) # --------------------------------------------------------------------- # Link Tasks <> Job Roles tablename = "project_task_job_role" table = define_table(tablename, task_id(), job_role_id(), *s3.meta_fields()) # --------------------------------------------------------------------- # Pass variables back to global scope (response.s3.*) # return dict( ) # ============================================================================= class S3ProjectTaskIReportModel(S3Model): """ Project Task IReport Model This class holds the table used to link Tasks with Incident Reports. """ names = ["project_task_ireport", ] def model(self): s3 = current.response.s3 task_id = self.project_task_id ireport_id = self.irs_ireport_id # --------------------------------------------------------------------- # Link Tasks <-> Incident Reports # tablename = "project_task_ireport" table = self.define_table(tablename, task_id(), ireport_id(), *s3.meta_fields()) self.configure(tablename, onaccept=self.task_ireport_onaccept) # --------------------------------------------------------------------- # Pass variables back to global scope (response.s3.*) # return dict( ) # ------------------------------------------------------------------------- @staticmethod def task_ireport_onaccept(form): """ When a Task is linked to an IReport, then populate the location_id """ vars = form.vars ireport_id = vars.ireport_id task_id = vars.task_id db = current.db s3db = current.s3db # Check if we already have a Location for the Task table = s3db.project_task query = (table.id == task_id) record = db(query).select(table.location_id, limitby=(0, 1)).first() if not record or record.location_id: return # Find the Incident Location itable = s3db.irs_ireport query = (itable.id == ireport_id) record = db(query).select(itable.location_id, limitby=(0, 1)).first() if not record or not record.location_id: return location_id = record.location_id # Update the Task query = (table.id == task_id) db(query).update(location_id=location_id) return # ----------------------------------------------------------------------------- def project_assignee_represent(id): """ Represent the Person a Task is assigned-to or list views """ db = current.db s3db = current.s3db cache = s3db.cache output = current.messages.NONE if not id: return output if isinstance(id, Row): instance_type = id.instance_type id = id.pe_id else: etable = s3db.pr_pentity query = (etable.id == id) record = db(query).select(etable.instance_type, cache=cache, limitby=(0, 1)).first() if not record: return output instance_type = record.instance_type table = s3db[instance_type] query = (table.pe_id == id) if instance_type == "pr_person": record = db(query).select(table.first_name, table.middle_name, table.last_name, table.initials, cache=cache, limitby=(0, 1)).first() if record: output = record.initials or s3_fullname(record) elif instance_type in ("pr_group", "org_organisation"): # Team or Organisation record = db(query).select(table.name, cache=cache, limitby=(0, 1)).first() if record: output = record.name else: # Should not happen of correctly filtered, return default pass return output # ============================================================================= def project_rheader(r, tabs=[]): """ Project Resource Headers - used in Project & Budget modules """ if r.representation != "html": # RHeaders only used in interactive views return None record = r.record if record is None: # List or Create form: rheader makes no sense here return None table = r.table resourcename = r.name T = current.T auth = current.auth settings = current.deployment_settings drr = settings.get_project_drr() pca = settings.get_project_community_activity() if resourcename == "project": # Tabs tabs = [(T("Basic Details"), None)] append = tabs.append if drr: append((T("Organizations"), "organisation")) ADMIN = current.session.s3.system_roles.ADMIN admin = auth.s3_has_role(ADMIN) #staff = auth.s3_has_role("STAFF") staff = True if staff or drr: append((T("Communities") if pca else T("Activities"), "activity")) if staff and not drr: append((T("Milestones"), "milestone")) if not drr: append((T("Tasks"), "task")) if drr: append((T("Documents"), "document")) elif staff: append((T("Attachments"), "document")) if record.calendar: append((T("Calendar"), "timeline")) rheader_tabs = s3_rheader_tabs(r, tabs) row3 = "" if drr: row2 = TR( TH("%s: " % table.countries_id.label), table.countries_id.represent(record.countries_id), ) else: row2 = TR( TH("%s: " % table.organisation_id.label), table.organisation_id.represent(record.organisation_id) ) if record.end_date: row3 = TR( TH("%s: " % table.end_date.label), table.end_date.represent(record.end_date) ) rheader = DIV(TABLE( TR( TH("%s: " % table.name.label), record.name ), row2, row3, ), rheader_tabs) elif resourcename == "activity": # @ToDo: integrate tabs? rheader_tabs = s3_rheader_tabs(r, tabs) tbl = TABLE() if record.project_id is not None: tbl.append( TR( TH("%s: " % table.project_id.label), table.project_id.represent(record.project_id)) ) if pca: tbl.append( TR( TH("%s: " % table.location_id.label), table.location_id.represent(record.location_id) ) ) else: tbl.append( TR( TH("%s: " % table.name.label), record.name ) ) rheader = DIV(tbl, rheader_tabs) elif resourcename == "task": db = current.db s3db = current.s3db # Tabs tabs = [(T("Details"), None)] append = tabs.append staff = auth.s3_has_role("STAFF") if staff: append((T("Time"), "time")), #append((T("Comments"), "discuss")) append((T("Attachments"), "document")) if settings.has_module("msg"): append((T("Notify"), "dispatch")) #(T("Roles"), "job_role"), #(T("Assignments"), "human_resource"), #(T("Requests"), "req") rheader_tabs = s3_rheader_tabs(r, tabs) # RHeader ptable = s3db.project_project ltable = s3db.project_task_project query = (ltable.deleted == False) & \ (ltable.task_id == r.id) & \ (ltable.project_id == ptable.id) project = db(query).select(ptable.id, limitby=(0, 1)).first() if project: project = TR( TH("%s: " % T("Project")), s3db.project_project_represent(project.id) ) else: project = "" atable = s3db.project_activity ltable = s3db.project_task_activity query = (ltable.deleted == False) & \ (ltable.task_id == r.id) & \ (ltable.activity_id == atable.id) activity = db(query).select(atable.name, limitby=(0, 1)).first() if activity: activity = TR( TH("%s: " % T("Activity")), activity.name ) else: activity = "" if record.description: description = TR( TH("%s: " % table.description.label), record.description ) else: description = "" if record.site_id: facility = TR( TH("%s: " % table.site_id.label), table.site_id.represent(record.site_id), ) else: facility = "" if record.location_id: location = TR( TH("%s: " % table.location_id.label), table.location_id.represent(record.location_id), ) else: location = "" if record.pe_id: assignee = TR( TH("%s: " % table.pe_id.label), s3db.pr_pentity_represent(record.pe_id, show_label=False), ) else: assignee = "" if record.time_estimated: time_estimated = TR( TH("%s: " % table.time_estimated.label), record.time_estimated ) else: time_estimated = "" if record.time_actual: time_actual = TR( TH("%s: " % table.time_actual.label), record.time_actual ) else: time_actual = "" # Comments # if r.method == "discuss": # comments = "" # else: # ctable = s3db.project_comment # query = (ctable.deleted == False) & \ # (ctable.task_id == r.id) # comments = db(query).select(ctable.body).last() # if comments: # try: # markup = etree.XML(comments.body) # text = markup.xpath(".//text()") # if text: # text = " ".join(text) # else: # text = "" # except etree.XMLSyntaxError: # t = html.fromstring(comments.body) # text = t.text_content() # comments = TR( # TH("%s: " % T("Latest Comment")), # A(text, # _href=URL(args=[r.id, "discuss"])) # ) # else: # comments = "" rheader = DIV(TABLE( project, activity, TR( TH("%s: " % table.name.label), record.name, ), description, facility, location, assignee, time_estimated, time_actual, #comments, ), rheader_tabs) return rheader # ------------------------------------------------------------------------- def task_notify(form): """ If the task is assigned to someone then notify them """ vars = form.vars try: pe_id = int(vars.pe_id) except TypeError, ValueError: return if form.record is None or (pe_id != form.record.pe_id): # Assignee has changed settings = current.deployment_settings if settings.has_module("msg"): # Notify assignee subject = "%s: Task assigned to you" % settings.get_system_name_short() url = "%s%s" % (settings.get_base_public_url(), URL(c="project", f="task", args=vars.id)) message = "You have been assigned a Task:\n\n%s\n\n%s\n\n%s" % \ (url, vars.name, vars.description or "") current.msg.send_by_pe_id(pe_id, subject, message) return # ============================================================================= class S3ProjectVirtualfields: """ Virtual fields for the project_project table """ def organisation(self): """ Name of the lead organisation of the project """ db = current.db s3db = current.s3db s3 = current.response.s3 otable = s3db.org_organisation ltable = s3db.project_organisation LEAD_ROLE = s3.project_organisation_lead_role query = (ltable.deleted != True) & \ (ltable.project_id == self.project_project.id) & \ (ltable.role == LEAD_ROLE) & \ (ltable.organisation_id == otable.id) org = db(query).select(otable.name, limitby=(0, 1)).first() if org: return org.name else: return None # ============================================================================= class S3ProjectActivityVirtualfields: """ Virtual fields for the project_activity table """ extra_fields = ["project_id", "location_id"] def organisation(self): """ Name of the lead organisation of the project """ db = current.db s3db = current.s3db s3 = current.response.s3 otable = s3db.org_organisation ltable = s3db.project_organisation LEAD_ROLE = s3.project_organisation_lead_role query = (ltable.deleted != True) & \ (ltable.project_id == self.project_activity.project_id) & \ (ltable.role == LEAD_ROLE) & \ (ltable.organisation_id == otable.id) org = db(query).select(otable.name, limitby=(0, 1)).first() if org: return org.name else: return None def L0(self): parents = Storage() parents = current.gis.get_parent_per_level(parents, self.project_activity.location_id, ids=False, names=True) if "L0" in parents: return parents["L0"] else: return None def L1(self): parents = Storage() parents = current.gis.get_parent_per_level(parents, self.project_activity.location_id, ids=False, names=True) if "L1" in parents: return parents["L1"] else: return None def L2(self): parents = Storage() parents = current.gis.get_parent_per_level(parents, self.project_activity.location_id, ids=False, names=True) if "L2" in parents: return parents["L2"] else: return None def L3(self): parents = Storage() parents = current.gis.get_parent_per_level(parents, self.project_activity.location_id, ids=False, names=True) if "L3" in parents: return parents["L3"] else: return None # ============================================================================= class S3ProjectBeneficiaryVirtualfields: """ Virtual fields for the project_beneficiary table """ extra_fields = ["activity_id"] def L0(self): db = current.db s3db = current.s3db s3 = current.response.s3 atable = s3db.project_activity query = (atable.id == self.project_beneficiary.activity_id) activity = db(query).select(atable.location_id, limitby=(0, 1)).first() if activity: parents = Storage() parents = current.gis.get_parent_per_level(parents, activity.location_id, ids=False, names=True) if "L0" in parents: return parents["L0"] else: return current.messages.NONE else: return current.messages.NONE def L1(self): db = current.db s3db = current.s3db s3 = current.response.s3 atable = s3db.project_activity query = (atable.id == self.project_beneficiary.activity_id) activity = db(query).select(atable.location_id, limitby=(0, 1)).first() if activity: parents = Storage() parents = current.gis.get_parent_per_level(parents, activity.location_id, ids=False, names=True) if "L1" in parents: return parents["L1"] else: return current.messages.NONE else: return current.messages.NONE def L2(self): db = current.db s3db = current.s3db s3 = current.response.s3 atable = s3db.project_activity query = (atable.id == self.project_beneficiary.activity_id) activity = db(query).select(atable.location_id, limitby=(0, 1)).first() if activity: parents = Storage() parents = current.gis.get_parent_per_level(parents, activity.location_id, ids=False, names=True) if "L2" in parents: return parents["L2"] else: return current.messages.NONE else: return current.messages.NONE def L3(self): db = current.db s3db = current.s3db s3 = current.response.s3 atable = s3db.project_activity query = (atable.id == self.project_beneficiary.activity_id) activity = db(query).select(atable.location_id, limitby=(0, 1)).first() if activity: parents = Storage() parents = current.gis.get_parent_per_level(parents, activity.location_id, ids=False, names=True) if "L3" in parents: return parents["L3"] else: return current.messages.NONE else: return current.messages.NONE # ============================================================================= class S3ProjectActivityContactVirtualFields: """ Virtual fields for the project_activity_contact table """ extra_fields = ["person_id"] def email(self): db = current.db s3db = current.s3db ptable = s3db.pr_person ctable = s3db.pr_contact person_id = self.project_activity_contact.person_id query = (ctable.deleted != True) & \ (ptable.id == person_id) & \ (ctable.pe_id == ptable.pe_id) & \ (ctable.contact_method == "EMAIL") items = db(query).select(ctable.value) return ", ".join([item.value for item in items]) def sms(self): db = current.db s3db = current.s3db ptable = s3db.pr_person ctable = s3db.pr_contact person_id = self.project_activity_contact.person_id query = (ctable.deleted != True) & \ (ptable.id == person_id) & \ (ctable.pe_id == ptable.pe_id) & \ (ctable.contact_method == "SMS") items = db(query).select(ctable.value) return ", ".join([item.value for item in items]) # ============================================================================= class S3ProjectTaskVirtualfields: """ Virtual fields for the project_task table """ extra_fields = ["id", "project_task_project:project_id$name", "project_task_activity:activity_id$name"] def project(self): """ Project associated with this task """ try: return self.project_project.name except AttributeError: return None def activity(self): """ Activity associated with this task """ try: return self.project_activity.name except AttributeError: return None def task_id(self): try: return self.project_task.id except AttributeError: return None # ============================================================================= class S3ProjectTimeVirtualfields: """ Virtual fields for the project_time table """ extra_fields = ["task_id", "person_id", "date"] def project(self): """ Project associated with this time entry - used by the 'Project Time' report """ db = current.db s3db = current.s3db ptable = s3db.project_project ltable = s3db.project_task_project query = (ltable.deleted != True) & \ (ltable.task_id == self.project_time.task_id) & \ (ltable.project_id == ptable.id) project = db(query).select(ptable.name, limitby=(0, 1)).first() if project: return project.name else: return None def day(self): """ Day of the last Week this time entry relates to - used by the 'Last Week's Work' report """ T = current.T now = current.request.utcnow thisdate = self.project_time.date if not thisdate: return "-" week = datetime.timedelta(days=7) if thisdate < (now - week): # Ignore data older than the last week # - should already be filtered in controller anyway return "-" return thisdate.date().strftime("%d %B") # END =========================================================================
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 428, 11326, 6738, 662, 848, 7290, 5822, 339, 768, 7307, 26, 7760, 13, 7409, 334, 67, 9, 428, 11326, 6738, 2290, 2752, 272, 768, 1682, 26, 10697, 339, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 272, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 272, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 272, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 272, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 272, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 272, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 272, 3704, 26, 339, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 272, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 339, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 272, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 272, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 272, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 272, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 272, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 272, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 272, 5010, 13198, 1621, 2334, 4141, 14, 199, 624, 199, 199, 363, 452, 363, 275, 2097, 51, 19, 4761, 1685, 401, 1779, 298, 51, 19, 4761, 4564, 50, 1685, 401, 1779, 298, 51, 19, 4761, 4476, 1685, 401, 1779, 298, 51, 19, 4761, 4476, 40, 11026, 1685, 401, 1779, 298, 51, 19, 4761, 4476, 41, 7457, 1685, 401, 1779, 298, 1715, 63, 82, 1291, 401, 1779, 298, 51, 19, 4761, 4476, 17146, 1458, 24603, 83, 937, 199, 199, 646, 2197, 199, 199, 504, 26752, 492, 627, 199, 504, 26752, 14, 12390, 492, 15231, 199, 504, 26752, 14, 3494, 492, 10533, 199, 504, 26752, 14, 3009, 1360, 492, 2670, 12922, 3339, 199, 504, 2508, 83, 19, 492, 627, 199, 199, 893, 26, 272, 687, 14490, 492, 7559, 12, 3517, 199, 2590, 3545, 26, 272, 492, 984, 272, 870, 4331, 984, 14, 3083, 12, 298, 3170, 26, 14490, 859, 4346, 367, 4692, 7252, 2, 272, 746, 199, 199, 3, 26237, 199, 533, 428, 19, 4761, 1685, 8, 51, 19, 1685, 304, 272, 408, 267, 7290, 5822, 398, 3390, 26, 961, 859, 1758, 2335, 315, 499, 18794, 3365, 12404, 26, 268, 446, 283, 5012, 82, 356, 257, 11233, 367, 675, 701, 20861, 3155, 279, 5981, 7199, 1298, 15161, 490, 11336, 737, 282, 4721, 2166, 268, 446, 2222, 13, 5012, 82, 26, 11233, 367, 675, 701, 282, 12700, 20765, 338, 425, 15161, 6527, 490, 737, 282, 16212, 2166, 398, 961, 1021, 3509, 314, 6716, 2863, 370, 3865, 4440, 267, 6006, 787, 4722, 307, 902, 83, 315, 428, 19, 4761, 4564, 50, 1685, 436, 428, 19, 4761, 4476, 1685, 267, 367, 314, 1163, 499, 675, 5560, 267, 6006, 787, 2597, 4722, 27939, 367, 2716, 10967, 377, 5921, 272, 408, 339, 1561, 275, 2097, 1715, 63, 7915, 401, 1467, 298, 1715, 63, 22133, 1005, 401, 1467, 298, 1715, 63, 1715, 401, 1467, 298, 1715, 63, 8240, 63, 466, 401, 1467, 298, 1715, 63, 8240, 401, 1467, 298, 1715, 63, 8240, 63, 7811, 401, 1467, 298, 1715, 63, 1715, 63, 344, 401, 1467, 298, 1715, 63, 8240, 63, 344, 401, 1467, 298, 1715, 63, 72, 667, 63, 3291, 401, 1467, 298, 1715, 63, 1715, 63, 13063, 401, 1467, 1622, 339, 347, 1402, 8, 277, 304, 398, 377, 275, 1453, 14, 52, 267, 1592, 275, 1453, 14, 697, 267, 1056, 275, 1453, 14, 1069, 267, 308, 19, 275, 1453, 14, 1310, 14, 83, 19, 267, 2202, 275, 1453, 14, 13605, 63, 1751, 398, 9952, 63, 466, 275, 308, 19, 14, 4968, 63, 466, 267, 4954, 63, 344, 275, 291, 14, 2700, 63, 5484, 63, 344, 267, 2909, 63, 344, 275, 291, 14, 5668, 63, 1985, 63, 344, 267, 26013, 63, 344, 275, 291, 14, 5668, 63, 23598, 63, 344, 267, 5981, 13181, 63, 344, 275, 291, 14, 1308, 63, 17425, 63, 344, 267, 27935, 63, 344, 275, 291, 14, 1308, 63, 22029, 63, 344, 267, 11779, 63, 1927, 63, 344, 275, 291, 14, 22276, 63, 14864, 63, 1927, 63, 344, 398, 308, 19, 63, 602, 63, 908, 275, 2202, 14, 362, 63, 44, 709, 78, 63, 602, 63, 908, 342, 267, 308, 19, 63, 602, 63, 13063, 275, 2400, 4487, 26, 428, 19, 3926, 14, 602, 63, 13063, 8, 3583, 12, 19314, 29, 549, 9, 398, 327, 12030, 577, 13381, 5478, 31, 267, 366, 9734, 275, 2202, 14, 362, 63, 1715, 63, 5012, 82, 342, 267, 29518, 275, 2202, 14, 362, 63, 1715, 63, 9387, 63, 8240, 342, 398, 327, 20124, 12946, 267, 1050, 63, 3173, 275, 291, 14, 525, 63, 3173, 267, 6786, 275, 308, 19, 14, 6223, 267, 7908, 275, 291, 14, 6472, 267, 2467, 1181, 63, 5465, 275, 308, 19, 14, 28941, 63, 5465, 267, 5627, 63, 1224, 275, 291, 14, 4640, 63, 1224, 267, 3404, 63, 955, 275, 308, 19, 14, 2024, 63, 955, 267, 1613, 63, 1073, 275, 291, 14, 4792, 63, 1073, 398, 327, 5620, 9858, 267, 327, 23978, 267, 327, 768, 1378, 2585, 26, 14171, 370, 2142, 1817, 370, 4057, 370, 428, 19, 4761, 4564, 50, 1685, 267, 327, 267, 20283, 275, 298, 1715, 63, 7915, 2, 267, 1817, 275, 5627, 63, 1224, 8, 10983, 12, 2490, 5024, 480, 354, 401, 3521, 2582, 29, 3933, 12, 3521, 440, 2307, 29, 549, 12, 3521, 3747, 29, 549, 395, 2490, 5024, 480, 6223, 1288, 2490, 1475, 275, 11792, 354, 9, 83, 401, 2490, 627, 2024, 63, 955, 1012, 398, 327, 5024, 2897, 31, 398, 327, 17101, 3383, 24361, 31, 398, 327, 8730, 9075, 31, 398, 327, 7337, 11595, 31, 398, 327, 799, 14418, 5024, 267, 3510, 63, 7915, 63, 344, 275, 428, 19, 497, 14418, 792, 480, 3029, 63, 7915, 63, 344, 401, 1460, 298, 513, 26, 4443, 2199, 63, 7915, 401, 1460, 1768, 275 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 428, 11326, 6738, 662, 848, 7290, 5822, 339, 768, 7307, 26, 7760, 13, 7409, 334, 67, 9, 428, 11326, 6738, 2290, 2752, 272, 768, 1682, 26, 10697, 339, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 272, 12408, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 272, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 272, 10588, 12, 5893, 1928, 12305, 314, 4481, 370, 675, 12, 272, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 272, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 272, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 272, 3704, 26, 339, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 272, 5120, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 339, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 272, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 272, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 272, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 272, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 272, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 272, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 272, 5010, 13198, 1621, 2334, 4141, 14, 199, 624, 199, 199, 363, 452, 363, 275, 2097, 51, 19, 4761, 1685, 401, 1779, 298, 51, 19, 4761, 4564, 50, 1685, 401, 1779, 298, 51, 19, 4761, 4476, 1685, 401, 1779, 298, 51, 19, 4761, 4476, 40, 11026, 1685, 401, 1779, 298, 51, 19, 4761, 4476, 41, 7457, 1685, 401, 1779, 298, 1715, 63, 82, 1291, 401, 1779, 298, 51, 19, 4761, 4476, 17146, 1458, 24603, 83, 937, 199, 199, 646, 2197, 199, 199, 504, 26752, 492, 627, 199, 504, 26752, 14, 12390, 492, 15231, 199, 504, 26752, 14, 3494, 492, 10533, 199, 504, 26752, 14, 3009, 1360, 492, 2670, 12922, 3339, 199, 504, 2508, 83, 19, 492, 627, 199, 199, 893, 26, 272, 687, 14490, 492, 7559, 12, 3517, 199, 2590, 3545, 26, 272, 492, 984, 272, 870, 4331, 984, 14, 3083, 12, 298, 3170, 26, 14490, 859, 4346, 367, 4692, 7252, 2, 272, 746, 199, 199, 3, 26237, 199, 533, 428, 19, 4761, 1685, 8, 51, 19, 1685, 304, 272, 408, 267, 7290, 5822, 398, 3390, 26, 961, 859, 1758, 2335, 315, 499, 18794, 3365, 12404, 26, 268, 446, 283, 5012, 82, 356, 257, 11233, 367, 675, 701, 20861, 3155, 279, 5981, 7199, 1298, 15161, 490, 11336, 737, 282, 4721, 2166, 268, 446, 2222, 13, 5012, 82, 26, 11233, 367, 675, 701, 282, 12700, 20765, 338, 425, 15161, 6527, 490, 737, 282, 16212, 2166, 398, 961, 1021, 3509, 314, 6716, 2863, 370, 3865, 4440, 267, 6006, 787, 4722, 307, 902, 83, 315, 428, 19, 4761, 4564, 50, 1685, 436, 428, 19, 4761, 4476, 1685, 267, 367, 314, 1163, 499, 675, 5560, 267, 6006, 787, 2597, 4722, 27939, 367, 2716, 10967, 377, 5921, 272, 408, 339, 1561, 275, 2097, 1715, 63, 7915, 401, 1467, 298, 1715, 63, 22133, 1005, 401, 1467, 298, 1715, 63, 1715, 401, 1467, 298, 1715, 63, 8240, 63, 466, 401, 1467, 298, 1715, 63, 8240, 401, 1467, 298, 1715, 63, 8240, 63, 7811, 401, 1467, 298, 1715, 63, 1715, 63, 344, 401, 1467, 298, 1715, 63, 8240, 63, 344, 401, 1467, 298, 1715, 63, 72, 667, 63, 3291, 401, 1467, 298, 1715, 63, 1715, 63, 13063, 401, 1467, 1622, 339, 347, 1402, 8, 277, 304, 398, 377, 275, 1453, 14, 52, 267, 1592, 275, 1453, 14, 697, 267, 1056, 275, 1453, 14, 1069, 267, 308, 19, 275, 1453, 14, 1310, 14, 83, 19, 267, 2202, 275, 1453, 14, 13605, 63, 1751, 398, 9952, 63, 466, 275, 308, 19, 14, 4968, 63, 466, 267, 4954, 63, 344, 275, 291, 14, 2700, 63, 5484, 63, 344, 267, 2909, 63, 344, 275, 291, 14, 5668, 63, 1985, 63, 344, 267, 26013, 63, 344, 275, 291, 14, 5668, 63, 23598, 63, 344, 267, 5981, 13181, 63, 344, 275, 291, 14, 1308, 63, 17425, 63, 344, 267, 27935, 63, 344, 275, 291, 14, 1308, 63, 22029, 63, 344, 267, 11779, 63, 1927, 63, 344, 275, 291, 14, 22276, 63, 14864, 63, 1927, 63, 344, 398, 308, 19, 63, 602, 63, 908, 275, 2202, 14, 362, 63, 44, 709, 78, 63, 602, 63, 908, 342, 267, 308, 19, 63, 602, 63, 13063, 275, 2400, 4487, 26, 428, 19, 3926, 14, 602, 63, 13063, 8, 3583, 12, 19314, 29, 549, 9, 398, 327, 12030, 577, 13381, 5478, 31, 267, 366, 9734, 275, 2202, 14, 362, 63, 1715, 63, 5012, 82, 342, 267, 29518, 275, 2202, 14, 362, 63, 1715, 63, 9387, 63, 8240, 342, 398, 327, 20124, 12946, 267, 1050, 63, 3173, 275, 291, 14, 525, 63, 3173, 267, 6786, 275, 308, 19, 14, 6223, 267, 7908, 275, 291, 14, 6472, 267, 2467, 1181, 63, 5465, 275, 308, 19, 14, 28941, 63, 5465, 267, 5627, 63, 1224, 275, 291, 14, 4640, 63, 1224, 267, 3404, 63, 955, 275, 308, 19, 14, 2024, 63, 955, 267, 1613, 63, 1073, 275, 291, 14, 4792, 63, 1073, 398, 327, 5620, 9858, 267, 327, 23978, 267, 327, 768, 1378, 2585, 26, 14171, 370, 2142, 1817, 370, 4057, 370, 428, 19, 4761, 4564, 50, 1685, 267, 327, 267, 20283, 275, 298, 1715, 63, 7915, 2, 267, 1817, 275, 5627, 63, 1224, 8, 10983, 12, 2490, 5024, 480, 354, 401, 3521, 2582, 29, 3933, 12, 3521, 440, 2307, 29, 549, 12, 3521, 3747, 29, 549, 395, 2490, 5024, 480, 6223, 1288, 2490, 1475, 275, 11792, 354, 9, 83, 401, 2490, 627, 2024, 63, 955, 1012, 398, 327, 5024, 2897, 31, 398, 327, 17101, 3383, 24361, 31, 398, 327, 8730, 9075, 31, 398, 327, 7337, 11595, 31, 398, 327, 799, 14418, 5024, 267, 3510, 63, 7915, 63, 344, 275, 428, 19, 497, 14418, 792, 480, 3029, 63, 7915, 63, 344, 401, 1460, 298, 513, 26, 4443, 2199, 63, 7915, 401, 1460, 1768, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rafaduran/python-mcollective
tests/integration/test_with_activemq.py
2
1425
import os from pymco.test import ctxt from . import base class ActiveMQTestCase(base.IntegrationTestCase): '''RabbitMQ integration test case.''' CTXT = { 'plugin.activemq.pool.1.port': 61614, 'plugin.activemq.pool.1.password': 'marionette', } class TestWithActiveMQMCo20x(base.MCollective20x, ActiveMQTestCase): '''MCollective integration test case.''' class TestWithActiveMQMCo22x(base.MCollective22x, ActiveMQTestCase): '''MCollective integration test case.''' class TestWithActiveMQMCo23x(base.MCollective23x, ActiveMQTestCase): '''MCollective integration test case.''' class TestWithActiveMQMCo24x(base.MCollective24x, ActiveMQTestCase): """MCollective integration test case.""" class TestWithActiveMQSSLMCo23x(base.MCollective23x, ActiveMQTestCase): '''MCollective integration test case.''' CTXT = { 'plugin.activemq.pool.1.port': 61615, 'plugin.activemq.pool.1.password': 'marionette', 'plugin.activemq.pool.1.ssl': 'true', 'plugin.activemq.pool.1.ssl.ca': os.path.join(ctxt.ROOT, 'fixtures/ca.pem'), 'plugin.activemq.pool.1.ssl.key': os.path.join( ctxt.ROOT, 'fixtures/activemq_private.pem'), 'plugin.activemq.pool.1.ssl.cert': os.path.join( ctxt.ROOT, 'fixtures/activemq_cert.pem', ), }
bsd-3-clause
[ 646, 747, 199, 199, 504, 1134, 77, 331, 14, 396, 492, 11216, 199, 199, 504, 1275, 492, 1300, 421, 199, 533, 23241, 14449, 1746, 8, 1095, 14, 20405, 1746, 304, 272, 1449, 50, 371, 2075, 14449, 13150, 511, 1930, 10595, 272, 445, 17715, 275, 469, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 719, 356, 1227, 975, 1079, 12, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 2060, 356, 283, 77, 759, 368, 14586, 297, 272, 789, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1165, 88, 8, 1095, 14, 45, 2001, 25982, 1165, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1081, 88, 8, 1095, 14, 45, 2001, 25982, 1081, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1789, 88, 8, 1095, 14, 45, 2001, 25982, 1789, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1194, 88, 8, 1095, 14, 45, 2001, 25982, 1194, 88, 12, 23241, 14449, 1746, 304, 272, 408, 45, 2001, 25982, 13150, 511, 1930, 1041, 421, 199, 533, 1379, 3007, 7472, 14449, 5413, 45, 967, 1789, 88, 8, 1095, 14, 45, 2001, 25982, 1789, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 272, 445, 17715, 275, 469, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 719, 356, 1227, 32614, 12, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 2060, 356, 283, 77, 759, 368, 14586, 297, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 356, 283, 2052, 297, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 14, 696, 356, 221, 747, 14, 515, 14, 904, 8, 6725, 14, 5441, 12, 10940, 283, 8769, 15, 696, 14, 13102, 659, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 14, 498, 356, 747, 14, 515, 14, 904, 8, 288, 11216, 14, 5441, 12, 288, 283, 8769, 15, 2682, 8334, 63, 4239, 14, 13102, 659, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 14, 4736, 356, 747, 14, 515, 14, 904, 8, 288, 11216, 14, 5441, 12, 288, 283, 8769, 15, 2682, 8334, 63, 4736, 14, 13102, 297, 267, 2318, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 199, 504, 1134, 77, 331, 14, 396, 492, 11216, 199, 199, 504, 1275, 492, 1300, 421, 199, 533, 23241, 14449, 1746, 8, 1095, 14, 20405, 1746, 304, 272, 1449, 50, 371, 2075, 14449, 13150, 511, 1930, 10595, 272, 445, 17715, 275, 469, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 719, 356, 1227, 975, 1079, 12, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 2060, 356, 283, 77, 759, 368, 14586, 297, 272, 789, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1165, 88, 8, 1095, 14, 45, 2001, 25982, 1165, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1081, 88, 8, 1095, 14, 45, 2001, 25982, 1081, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1789, 88, 8, 1095, 14, 45, 2001, 25982, 1789, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 421, 199, 533, 1379, 3007, 7472, 14449, 45, 967, 1194, 88, 8, 1095, 14, 45, 2001, 25982, 1194, 88, 12, 23241, 14449, 1746, 304, 272, 408, 45, 2001, 25982, 13150, 511, 1930, 1041, 421, 199, 533, 1379, 3007, 7472, 14449, 5413, 45, 967, 1789, 88, 8, 1095, 14, 45, 2001, 25982, 1789, 88, 12, 23241, 14449, 1746, 304, 272, 1449, 45, 2001, 25982, 13150, 511, 1930, 10595, 272, 445, 17715, 275, 469, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 719, 356, 1227, 32614, 12, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 2060, 356, 283, 77, 759, 368, 14586, 297, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 356, 283, 2052, 297, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 14, 696, 356, 221, 747, 14, 515, 14, 904, 8, 6725, 14, 5441, 12, 10940, 283, 8769, 15, 696, 14, 13102, 659, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 14, 498, 356, 747, 14, 515, 14, 904, 8, 288, 11216, 14, 5441, 12, 288, 283, 8769, 15, 2682, 8334, 63, 4239, 14, 13102, 659, 267, 283, 2718, 14, 2682, 8334, 14, 2293, 14, 17, 14, 4266, 14, 4736, 356, 747, 14, 515, 14, 904, 8, 288, 11216, 14, 5441, 12, 288, 283, 8769, 15, 2682, 8334, 63, 4736, 14, 13102, 297, 267, 2318, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yoer/hue
desktop/core/ext-py/Django-1.6.10/django/views/debug.py
98
44106
from __future__ import unicode_literals import datetime import os import re import sys import types from django.conf import settings from django.http import (HttpResponse, HttpResponseServerError, HttpResponseNotFound, HttpRequest, build_request_repr) from django.template import Template, Context, TemplateDoesNotExist from django.template.defaultfilters import force_escape, pprint from django.utils.datastructures import MultiValueDict from django.utils.html import escape from django.utils.encoding import force_bytes, smart_text from django.utils.module_loading import import_by_path from django.utils import six HIDDEN_SETTINGS = re.compile('API|TOKEN|KEY|SECRET|PASS|PROFANITIES_LIST|SIGNATURE') CLEANSED_SUBSTITUTE = '********************' def linebreak_iter(template_source): yield 0 p = template_source.find('\n') while p >= 0: yield p+1 p = template_source.find('\n', p+1) yield len(template_source) + 1 def cleanse_setting(key, value): """Cleanse an individual setting key/value of sensitive content. If the value is a dictionary, recursively cleanse the keys in that dictionary. """ try: if HIDDEN_SETTINGS.search(key): cleansed = CLEANSED_SUBSTITUTE else: if isinstance(value, dict): cleansed = dict((k, cleanse_setting(k, v)) for k,v in value.items()) else: cleansed = value except TypeError: # If the key isn't regex-able, just return as-is. cleansed = value return cleansed def get_safe_settings(): "Returns a dictionary of the settings module, with sensitive settings blurred out." settings_dict = {} for k in dir(settings): if k.isupper(): settings_dict[k] = cleanse_setting(k, getattr(settings, k)) return settings_dict def technical_500_response(request, exc_type, exc_value, tb): """ Create a technical server error response. The last three arguments are the values returned from sys.exc_info() and friends. """ reporter = ExceptionReporter(request, exc_type, exc_value, tb) if request.is_ajax(): text = reporter.get_traceback_text() return HttpResponseServerError(text, content_type='text/plain') else: html = reporter.get_traceback_html() return HttpResponseServerError(html, content_type='text/html') # Cache for the default exception reporter filter instance. default_exception_reporter_filter = None def get_exception_reporter_filter(request): global default_exception_reporter_filter if default_exception_reporter_filter is None: # Load the default filter for the first time and cache it. default_exception_reporter_filter = import_by_path( settings.DEFAULT_EXCEPTION_REPORTER_FILTER)() if request: return getattr(request, 'exception_reporter_filter', default_exception_reporter_filter) else: return default_exception_reporter_filter class ExceptionReporterFilter(object): """ Base for all exception reporter filter classes. All overridable hooks contain lenient default behaviors. """ def get_request_repr(self, request): if request is None: return repr(None) else: return build_request_repr(request, POST_override=self.get_post_parameters(request)) def get_post_parameters(self, request): if request is None: return {} else: return request.POST def get_traceback_frame_variables(self, request, tb_frame): return list(six.iteritems(tb_frame.f_locals)) class SafeExceptionReporterFilter(ExceptionReporterFilter): """ Use annotations made by the sensitive_post_parameters and sensitive_variables decorators to filter out sensitive information. """ def is_active(self, request): """ This filter is to add safety in production environments (i.e. DEBUG is False). If DEBUG is True then your site is not safe anyway. This hook is provided as a convenience to easily activate or deactivate the filter on a per request basis. """ return settings.DEBUG is False def get_cleansed_multivaluedict(self, request, multivaluedict): """ Replaces the keys in a MultiValueDict marked as sensitive with stars. This mitigates leaking sensitive POST parameters if something like request.POST['nonexistent_key'] throws an exception (#21098). """ sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', []) if self.is_active(request) and sensitive_post_parameters: multivaluedict = multivaluedict.copy() for param in sensitive_post_parameters: if param in multivaluedict: multivaluedict[param] = CLEANSED_SUBSTITUTE return multivaluedict def get_post_parameters(self, request): """ Replaces the values of POST parameters marked as sensitive with stars (*********). """ if request is None: return {} else: sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', []) if self.is_active(request) and sensitive_post_parameters: cleansed = request.POST.copy() if sensitive_post_parameters == '__ALL__': # Cleanse all parameters. for k, v in cleansed.items(): cleansed[k] = CLEANSED_SUBSTITUTE return cleansed else: # Cleanse only the specified parameters. for param in sensitive_post_parameters: if param in cleansed: cleansed[param] = CLEANSED_SUBSTITUTE return cleansed else: return request.POST def cleanse_special_types(self, request, value): if isinstance(value, HttpRequest): # Cleanse the request's POST parameters. value = self.get_request_repr(value) elif isinstance(value, MultiValueDict): # Cleanse MultiValueDicts (request.POST is the one we usually care about) value = self.get_cleansed_multivaluedict(request, value) return value def get_traceback_frame_variables(self, request, tb_frame): """ Replaces the values of variables marked as sensitive with stars (*********). """ # Loop through the frame's callers to see if the sensitive_variables # decorator was used. current_frame = tb_frame.f_back sensitive_variables = None while current_frame is not None: if (current_frame.f_code.co_name == 'sensitive_variables_wrapper' and 'sensitive_variables_wrapper' in current_frame.f_locals): # The sensitive_variables decorator was used, so we take note # of the sensitive variables' names. wrapper = current_frame.f_locals['sensitive_variables_wrapper'] sensitive_variables = getattr(wrapper, 'sensitive_variables', None) break current_frame = current_frame.f_back cleansed = {} if self.is_active(request) and sensitive_variables: if sensitive_variables == '__ALL__': # Cleanse all variables for name, value in tb_frame.f_locals.items(): cleansed[name] = CLEANSED_SUBSTITUTE else: # Cleanse specified variables for name, value in tb_frame.f_locals.items(): if name in sensitive_variables: value = CLEANSED_SUBSTITUTE else: value = self.cleanse_special_types(request, value) cleansed[name] = value else: # Potentially cleanse the request and any MultiValueDicts if they # are one of the frame variables. for name, value in tb_frame.f_locals.items(): cleansed[name] = self.cleanse_special_types(request, value) if (tb_frame.f_code.co_name == 'sensitive_variables_wrapper' and 'sensitive_variables_wrapper' in tb_frame.f_locals): # For good measure, obfuscate the decorated function's arguments in # the sensitive_variables decorator's frame, in case the variables # associated with those arguments were meant to be obfuscated from # the decorated function's frame. cleansed['func_args'] = CLEANSED_SUBSTITUTE cleansed['func_kwargs'] = CLEANSED_SUBSTITUTE return cleansed.items() class ExceptionReporter(object): """ A class to organize and coordinate reporting on exceptions. """ def __init__(self, request, exc_type, exc_value, tb, is_email=False): self.request = request self.filter = get_exception_reporter_filter(self.request) self.exc_type = exc_type self.exc_value = exc_value self.tb = tb self.is_email = is_email self.template_info = None self.template_does_not_exist = False self.loader_debug_info = None # Handle deprecated string exceptions if isinstance(self.exc_type, six.string_types): self.exc_value = Exception('Deprecated String Exception: %r' % self.exc_type) self.exc_type = type(self.exc_value) def format_path_status(self, path): if not os.path.exists(path): return "File does not exist" if not os.path.isfile(path): return "Not a file" if not os.access(path, os.R_OK): return "File is not readable" return "File exists" def get_traceback_data(self): "Return a Context instance containing traceback information." if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist): from django.template.loader import template_source_loaders self.template_does_not_exist = True self.loader_debug_info = [] # If the template_source_loaders haven't been populated yet, you need # to provide an empty list for this for loop to not fail. if template_source_loaders is None: template_source_loaders = [] for loader in template_source_loaders: try: source_list_func = loader.get_template_sources # NOTE: This assumes exc_value is the name of the template that # the loader attempted to load. template_list = [{ 'name': t, 'status': self.format_path_status(t), } for t in source_list_func(str(self.exc_value))] except AttributeError: template_list = [] loader_name = loader.__module__ + '.' + loader.__class__.__name__ self.loader_debug_info.append({ 'loader': loader_name, 'templates': template_list, }) if (settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'django_template_source')): self.get_template_exception_info() frames = self.get_traceback_frames() for i, frame in enumerate(frames): if 'vars' in frame: frame['vars'] = [(k, force_escape(pprint(v))) for k, v in frame['vars']] frames[i] = frame unicode_hint = '' if self.exc_type and issubclass(self.exc_type, UnicodeError): start = getattr(self.exc_value, 'start', None) end = getattr(self.exc_value, 'end', None) if start is not None and end is not None: unicode_str = self.exc_value.args[1] unicode_hint = smart_text(unicode_str[max(start-5, 0):min(end+5, len(unicode_str))], 'ascii', errors='replace') from django import get_version c = { 'is_email': self.is_email, 'unicode_hint': unicode_hint, 'frames': frames, 'request': self.request, 'filtered_POST': self.filter.get_post_parameters(self.request), 'settings': get_safe_settings(), 'sys_executable': sys.executable, 'sys_version_info': '%d.%d.%d' % sys.version_info[0:3], 'server_time': datetime.datetime.now(), 'django_version_info': get_version(), 'sys_path' : sys.path, 'template_info': self.template_info, 'template_does_not_exist': self.template_does_not_exist, 'loader_debug_info': self.loader_debug_info, } # Check whether exception info is available if self.exc_type: c['exception_type'] = self.exc_type.__name__ if self.exc_value: c['exception_value'] = smart_text(self.exc_value, errors='replace') if frames: c['lastframe'] = frames[-1] return c def get_traceback_html(self): "Return HTML version of debug 500 HTTP error page." t = Template(TECHNICAL_500_TEMPLATE, name='Technical 500 template') c = Context(self.get_traceback_data()) return t.render(c) def get_traceback_text(self): "Return plain text version of debug 500 HTTP error page." t = Template(TECHNICAL_500_TEXT_TEMPLATE, name='Technical 500 template') c = Context(self.get_traceback_data(), autoescape=False) return t.render(c) def get_template_exception_info(self): origin, (start, end) = self.exc_value.django_template_source template_source = origin.reload() context_lines = 10 line = 0 upto = 0 source_lines = [] before = during = after = "" for num, next in enumerate(linebreak_iter(template_source)): if start >= upto and end <= next: line = num before = escape(template_source[upto:start]) during = escape(template_source[start:end]) after = escape(template_source[end:next]) source_lines.append( (num, escape(template_source[upto:next])) ) upto = next total = len(source_lines) top = max(1, line - context_lines) bottom = min(total, line + 1 + context_lines) # In some rare cases, exc_value.args might be empty. try: message = self.exc_value.args[0] except IndexError: message = '(Could not get exception message)' self.template_info = { 'message': message, 'source_lines': source_lines[top:bottom], 'before': before, 'during': during, 'after': after, 'top': top, 'bottom': bottom, 'total': total, 'line': line, 'name': origin.name, } def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None): """ Returns context_lines before and after lineno from file. Returns (pre_context_lineno, pre_context, context_line, post_context). """ source = None if loader is not None and hasattr(loader, "get_source"): try: source = loader.get_source(module_name) except ImportError: pass if source is not None: source = source.splitlines() if source is None: try: with open(filename, 'rb') as fp: source = fp.read().splitlines() except (OSError, IOError): pass if source is None: return None, [], None, [] # If we just read the source from a file, or if the loader did not # apply tokenize.detect_encoding to decode the source into a Unicode # string, then we should do that ourselves. if isinstance(source[0], six.binary_type): encoding = 'ascii' for line in source[:2]: # File coding may be specified. Match pattern from PEP-263 # (http://www.python.org/dev/peps/pep-0263/) match = re.search(br'coding[:=]\s*([-\w.]+)', line) if match: encoding = match.group(1).decode('ascii') break source = [six.text_type(sline, encoding, 'replace') for sline in source] lower_bound = max(0, lineno - context_lines) upper_bound = lineno + context_lines pre_context = source[lower_bound:lineno] context_line = source[lineno] post_context = source[lineno+1:upper_bound] return lower_bound, pre_context, context_line, post_context def get_traceback_frames(self): frames = [] tb = self.tb while tb is not None: # Support for __traceback_hide__ which is used by a few libraries # to hide internal frames. if tb.tb_frame.f_locals.get('__traceback_hide__'): tb = tb.tb_next continue filename = tb.tb_frame.f_code.co_filename function = tb.tb_frame.f_code.co_name lineno = tb.tb_lineno - 1 loader = tb.tb_frame.f_globals.get('__loader__') module_name = tb.tb_frame.f_globals.get('__name__') or '' pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name) if pre_context_lineno is not None: frames.append({ 'tb': tb, 'type': 'django' if module_name.startswith('django.') else 'user', 'filename': filename, 'function': function, 'lineno': lineno + 1, 'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame), 'id': id(tb), 'pre_context': pre_context, 'context_line': context_line, 'post_context': post_context, 'pre_context_lineno': pre_context_lineno + 1, }) tb = tb.tb_next return frames def format_exception(self): """ Return the same data as from traceback.format_exception. """ import traceback frames = self.get_traceback_frames() tb = [ (f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames ] list = ['Traceback (most recent call last):\n'] list += traceback.format_list(tb) list += traceback.format_exception_only(self.exc_type, self.exc_value) return list def technical_404_response(request, exception): "Create a technical 404 error response. The exception should be the Http404." try: tried = exception.args[0]['tried'] except (IndexError, TypeError, KeyError): tried = [] else: if (not tried # empty URLconf or (request.path == '/' and len(tried) == 1 # default URLconf and len(tried[0]) == 1 and getattr(tried[0][0], 'app_name', '') == getattr(tried[0][0], 'namespace', '') == 'admin')): return default_urlconf(request) urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF) if isinstance(urlconf, types.ModuleType): urlconf = urlconf.__name__ t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template') c = Context({ 'urlconf': urlconf, 'root_urlconf': settings.ROOT_URLCONF, 'request_path': request.path_info[1:], # Trim leading slash 'urlpatterns': tried, 'reason': force_bytes(exception, errors='replace'), 'request': request, 'settings': get_safe_settings(), }) return HttpResponseNotFound(t.render(c), content_type='text/html') def default_urlconf(request): "Create an empty URLconf 404 error response." t = Template(DEFAULT_URLCONF_TEMPLATE, name='Default URLconf template') c = Context({}) return HttpResponse(t.render(c), content_type='text/html') # # Templates are embedded in the file so that we know the error handler will # always work even if the template loader is broken. # TECHNICAL_500_TEMPLATE = """ <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="robots" content="NONE,NOARCHIVE"> <title>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}{% if request %} at {{ request.path_info|escape }}{% endif %}</title> <style type="text/css"> html * { padding:0; margin:0; } body * { padding:10px 20px; } body * * { padding:0; } body { font:small sans-serif; } body>div { border-bottom:1px solid #ddd; } h1 { font-weight:normal; } h2 { margin-bottom:.8em; } h2 span { font-size:80%; color:#666; font-weight:normal; } h3 { margin:1em 0 .5em 0; } h4 { margin:0 0 .5em 0; font-weight: normal; } code, pre { font-size: 100%; white-space: pre-wrap; } table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; } tbody td, tbody th { vertical-align:top; padding:2px 3px; } thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; } tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; } table.vars { margin:5px 0 2px 40px; } table.vars td, table.req td { font-family:monospace; } table td.code { width:100%; } table td.code pre { overflow:hidden; } table.source th { color:#666; } table.source td { font-family:monospace; white-space:pre; border-bottom:1px solid #eee; } ul.traceback { list-style-type:none; color: #222; } ul.traceback li.frame { padding-bottom:1em; color:#666; } ul.traceback li.user { background-color:#e0e0e0; color:#000 } div.context { padding:10px 0; overflow:hidden; } div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; } div.context ol li { font-family:monospace; white-space:pre; color:#777; cursor:pointer; } div.context ol li pre { display:inline; } div.context ol.context-line li { color:#505050; background-color:#dfdfdf; } div.context ol.context-line li span { position:absolute; right:32px; } .user div.context ol.context-line li { background-color:#bbb; color:#000; } .user div.context ol li { color:#666; } div.commands { margin-left: 40px; } div.commands a { color:#555; text-decoration:none; } .user div.commands a { color: black; } #summary { background: #ffc; } #summary h2 { font-weight: normal; color: #666; } #explanation { background:#eee; } #template, #template-not-exist { background:#f6f6f6; } #template-not-exist ul { margin: 0 0 0 20px; } #unicode-hint { background:#eee; } #traceback { background:#eee; } #requestinfo { background:#f6f6f6; padding-left:120px; } #summary table { border:none; background:transparent; } #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; } #requestinfo h3 { margin-bottom:-1em; } .error { background: #ffc; } .specific { color:#cc3300; font-weight:bold; } h2 span.commands { font-size:.7em;} span.commands a:link {color:#5E5694;} pre.exception_value { font-family: sans-serif; color: #666; font-size: 1.5em; margin: 10px 0 10px 0; } </style> {% if not is_email %} <script type="text/javascript"> //<!-- function getElementsByClassName(oElm, strTagName, strClassName){ // Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for(var i=0; i<arrElements.length; i++){ oElement = arrElements[i]; if(oRegExp.test(oElement.className)){ arrReturnElements.push(oElement); } } return (arrReturnElements) } function hideAll(elems) { for (var e = 0; e < elems.length; e++) { elems[e].style.display = 'none'; } } window.onload = function() { hideAll(getElementsByClassName(document, 'table', 'vars')); hideAll(getElementsByClassName(document, 'ol', 'pre-context')); hideAll(getElementsByClassName(document, 'ol', 'post-context')); hideAll(getElementsByClassName(document, 'div', 'pastebin')); } function toggle() { for (var i = 0; i < arguments.length; i++) { var e = document.getElementById(arguments[i]); if (e) { e.style.display = e.style.display == 'none' ? 'block' : 'none'; } } return false; } function varToggle(link, id) { toggle('v' + id); var s = link.getElementsByTagName('span')[0]; var uarr = String.fromCharCode(0x25b6); var darr = String.fromCharCode(0x25bc); s.innerHTML = s.innerHTML == uarr ? darr : uarr; return false; } function switchPastebinFriendly(link) { s1 = "Switch to copy-and-paste view"; s2 = "Switch back to interactive view"; link.innerHTML = link.innerHTML == s1 ? s2 : s1; toggle('browserTraceback', 'pastebinTraceback'); return false; } //--> </script> {% endif %} </head> <body> <div id="summary"> <h1>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}{% if request %} at {{ request.path_info|escape }}{% endif %}</h1> <pre class="exception_value">{% if exception_value %}{{ exception_value|force_escape }}{% else %}No exception message supplied{% endif %}</pre> <table class="meta"> {% if request %} <tr> <th>Request Method:</th> <td>{{ request.META.REQUEST_METHOD }}</td> </tr> <tr> <th>Request URL:</th> <td>{{ request.build_absolute_uri|escape }}</td> </tr> {% endif %} <tr> <th>Django Version:</th> <td>{{ django_version_info }}</td> </tr> {% if exception_type %} <tr> <th>Exception Type:</th> <td>{{ exception_type }}</td> </tr> {% endif %} {% if exception_type and exception_value %} <tr> <th>Exception Value:</th> <td><pre>{{ exception_value|force_escape }}</pre></td> </tr> {% endif %} {% if lastframe %} <tr> <th>Exception Location:</th> <td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td> </tr> {% endif %} <tr> <th>Python Executable:</th> <td>{{ sys_executable|escape }}</td> </tr> <tr> <th>Python Version:</th> <td>{{ sys_version_info }}</td> </tr> <tr> <th>Python Path:</th> <td><pre>{{ sys_path|pprint }}</pre></td> </tr> <tr> <th>Server time:</th> <td>{{server_time|date:"r"}}</td> </tr> </table> </div> {% if unicode_hint %} <div id="unicode-hint"> <h2>Unicode error hint</h2> <p>The string that could not be encoded/decoded was: <strong>{{ unicode_hint|force_escape }}</strong></p> </div> {% endif %} {% if template_does_not_exist %} <div id="template-not-exist"> <h2>Template-loader postmortem</h2> {% if loader_debug_info %} <p>Django tried loading these templates, in this order:</p> <ul> {% for loader in loader_debug_info %} <li>Using loader <code>{{ loader.loader }}</code>: <ul> {% for t in loader.templates %}<li><code>{{ t.name }}</code> ({{ t.status }})</li>{% endfor %} </ul> </li> {% endfor %} </ul> {% else %} <p>Django couldn't find any templates because your <code>TEMPLATE_LOADERS</code> setting is empty!</p> {% endif %} </div> {% endif %} {% if template_info %} <div id="template"> <h2>Error during template rendering</h2> <p>In template <code>{{ template_info.name }}</code>, error at line <strong>{{ template_info.line }}</strong></p> <h3>{{ template_info.message }}</h3> <table class="source{% if template_info.top %} cut-top{% endif %}{% ifnotequal template_info.bottom template_info.total %} cut-bottom{% endifnotequal %}"> {% for source_line in template_info.source_lines %} {% ifequal source_line.0 template_info.line %} <tr class="error"><th>{{ source_line.0 }}</th> <td>{{ template_info.before }}<span class="specific">{{ template_info.during }}</span>{{ template_info.after }}</td></tr> {% else %} <tr><th>{{ source_line.0 }}</th> <td>{{ source_line.1 }}</td></tr> {% endifequal %} {% endfor %} </table> </div> {% endif %} {% if frames %} <div id="traceback"> <h2>Traceback <span class="commands">{% if not is_email %}<a href="#" onclick="return switchPastebinFriendly(this);">Switch to copy-and-paste view</a></span>{% endif %}</h2> {% autoescape off %} <div id="browserTraceback"> <ul class="traceback"> {% for frame in frames %} <li class="frame {{ frame.type }}"> <code>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code> {% if frame.context_line %} <div class="context" id="c{{ frame.id }}"> {% if frame.pre_context and not is_email %} <ol start="{{ frame.pre_context_lineno }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>{{ line|escape }}</pre></li>{% endfor %}</ol> {% endif %} <ol start="{{ frame.lineno }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>{{ frame.context_line|escape }}</pre>{% if not is_email %} <span>...</span>{% endif %}</li></ol> {% if frame.post_context and not is_email %} <ol start='{{ frame.lineno|add:"1" }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>{{ line|escape }}</pre></li>{% endfor %}</ol> {% endif %} </div> {% endif %} {% if frame.vars %} <div class="commands"> {% if is_email %} <h2>Local Vars</h2> {% else %} <a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a> {% endif %} </div> <table class="vars" id="v{{ frame.id }}"> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {% for var in frame.vars|dictsort:"0" %} <tr> <td>{{ var.0|force_escape }}</td> <td class="code"><pre>{{ var.1 }}</pre></td> </tr> {% endfor %} </tbody> </table> {% endif %} </li> {% endfor %} </ul> </div> {% endautoescape %} <form action="http://dpaste.com/" name="pasteform" id="pasteform" method="post"> {% if not is_email %} <div id="pastebinTraceback" class="pastebin"> <input type="hidden" name="language" value="PythonConsole"> <input type="hidden" name="title" value="{{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %}"> <input type="hidden" name="source" value="Django Dpaste Agent"> <input type="hidden" name="poster" value="Django"> <textarea name="content" id="traceback_area" cols="140" rows="25"> Environment: {% if request %} Request Method: {{ request.META.REQUEST_METHOD }} Request URL: {{ request.build_absolute_uri|escape }} {% endif %} Django Version: {{ django_version_info }} Python Version: {{ sys_version_info }} Installed Applications: {{ settings.INSTALLED_APPS|pprint }} Installed Middleware: {{ settings.MIDDLEWARE_CLASSES|pprint }} {% if template_does_not_exist %}Template Loader Error: {% if loader_debug_info %}Django tried loading these templates, in this order: {% for loader in loader_debug_info %}Using loader {{ loader.loader }}: {% for t in loader.templates %}{{ t.name }} ({{ t.status }}) {% endfor %}{% endfor %} {% else %}Django couldn't find any templates because your TEMPLATE_LOADERS setting is empty! {% endif %} {% endif %}{% if template_info %} Template error: In template {{ template_info.name }}, error at line {{ template_info.line }} {{ template_info.message }}{% for source_line in template_info.source_lines %}{% ifequal source_line.0 template_info.line %} {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }} {% else %} {{ source_line.0 }} : {{ source_line.1 }} {% endifequal %}{% endfor %}{% endif %} Traceback: {% for frame in frames %}File "{{ frame.filename|escape }}" in {{ frame.function|escape }} {% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line|escape }}{% endif %} {% endfor %} Exception Type: {{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %} Exception Value: {{ exception_value|force_escape }} </textarea> <br><br> <input type="submit" value="Share this traceback on a public Web site"> </div> </form> </div> {% endif %} {% endif %} <div id="requestinfo"> <h2>Request information</h2> {% if request %} <h3 id="get-info">GET</h3> {% if request.GET %} <table class="req"> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {% for var in request.GET.items %} <tr> <td>{{ var.0 }}</td> <td class="code"><pre>{{ var.1|pprint }}</pre></td> </tr> {% endfor %} </tbody> </table> {% else %} <p>No GET data</p> {% endif %} <h3 id="post-info">POST</h3> {% if filtered_POST %} <table class="req"> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {% for var in filtered_POST.items %} <tr> <td>{{ var.0 }}</td> <td class="code"><pre>{{ var.1|pprint }}</pre></td> </tr> {% endfor %} </tbody> </table> {% else %} <p>No POST data</p> {% endif %} <h3 id="files-info">FILES</h3> {% if request.FILES %} <table class="req"> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {% for var in request.FILES.items %} <tr> <td>{{ var.0 }}</td> <td class="code"><pre>{{ var.1|pprint }}</pre></td> </tr> {% endfor %} </tbody> </table> {% else %} <p>No FILES data</p> {% endif %} <h3 id="cookie-info">COOKIES</h3> {% if request.COOKIES %} <table class="req"> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {% for var in request.COOKIES.items %} <tr> <td>{{ var.0 }}</td> <td class="code"><pre>{{ var.1|pprint }}</pre></td> </tr> {% endfor %} </tbody> </table> {% else %} <p>No cookie data</p> {% endif %} <h3 id="meta-info">META</h3> <table class="req"> <thead> <tr> <th>Variable</th> <th>Value</th> </tr> </thead> <tbody> {% for var in request.META.items|dictsort:"0" %} <tr> <td>{{ var.0 }}</td> <td class="code"><pre>{{ var.1|pprint }}</pre></td> </tr> {% endfor %} </tbody> </table> {% else %} <p>Request data not supplied</p> {% endif %} <h3 id="settings-info">Settings</h3> <h4>Using settings module <code>{{ settings.SETTINGS_MODULE }}</code></h4> <table class="req"> <thead> <tr> <th>Setting</th> <th>Value</th> </tr> </thead> <tbody> {% for var in settings.items|dictsort:"0" %} <tr> <td>{{ var.0 }}</td> <td class="code"><pre>{{ var.1|pprint }}</pre></td> </tr> {% endfor %} </tbody> </table> </div> {% if not is_email %} <div id="explanation"> <p> You're seeing this error because you have <code>DEBUG = True</code> in your Django settings file. Change that to <code>False</code>, and Django will display a standard 500 page. </p> </div> {% endif %} </body> </html> """ TECHNICAL_500_TEXT_TEMPLATE = """{% load firstof from future %}{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %} {% firstof exception_value 'No exception message supplied' %} {% if request %} Request Method: {{ request.META.REQUEST_METHOD }} Request URL: {{ request.build_absolute_uri }}{% endif %} Django Version: {{ django_version_info }} Python Executable: {{ sys_executable }} Python Version: {{ sys_version_info }} Python Path: {{ sys_path }} Server time: {{server_time|date:"r"}} Installed Applications: {{ settings.INSTALLED_APPS|pprint }} Installed Middleware: {{ settings.MIDDLEWARE_CLASSES|pprint }} {% if template_does_not_exist %}Template loader Error: {% if loader_debug_info %}Django tried loading these templates, in this order: {% for loader in loader_debug_info %}Using loader {{ loader.loader }}: {% for t in loader.templates %}{{ t.name }} ({{ t.status }}) {% endfor %}{% endfor %} {% else %}Django couldn't find any templates because your TEMPLATE_LOADERS setting is empty! {% endif %} {% endif %}{% if template_info %} Template error: In template {{ template_info.name }}, error at line {{ template_info.line }} {{ template_info.message }}{% for source_line in template_info.source_lines %}{% ifequal source_line.0 template_info.line %} {{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }} {% else %} {{ source_line.0 }} : {{ source_line.1 }} {% endifequal %}{% endfor %}{% endif %}{% if frames %} Traceback: {% for frame in frames %}File "{{ frame.filename }}" in {{ frame.function }} {% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line }}{% endif %} {% endfor %} {% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %} {% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %} {% if request %}Request information: GET:{% for k, v in request.GET.items %} {{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %} POST:{% for k, v in filtered_POST.items %} {{ k }} = {{ v|stringformat:"r" }}{% empty %} No POST data{% endfor %} FILES:{% for k, v in request.FILES.items %} {{ k }} = {{ v|stringformat:"r" }}{% empty %} No FILES data{% endfor %} COOKIES:{% for k, v in request.COOKIES.items %} {{ k }} = {{ v|stringformat:"r" }}{% empty %} No cookie data{% endfor %} META:{% for k, v in request.META.items|dictsort:"0" %} {{ k }} = {{ v|stringformat:"r" }}{% endfor %} {% else %}Request data not supplied {% endif %} Settings: Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in settings.items|dictsort:"0" %} {{ k }} = {{ v|stringformat:"r" }}{% endfor %} You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 500 page. """ TECHNICAL_404_TEMPLATE = """ <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Page not found at {{ request.path_info|escape }}</title> <meta name="robots" content="NONE,NOARCHIVE"> <style type="text/css"> html * { padding:0; margin:0; } body * { padding:10px 20px; } body * * { padding:0; } body { font:small sans-serif; background:#eee; } body>div { border-bottom:1px solid #ddd; } h1 { font-weight:normal; margin-bottom:.4em; } h1 span { font-size:60%; color:#666; font-weight:normal; } table { border:none; border-collapse: collapse; width:100%; } td, th { vertical-align:top; padding:2px 3px; } th { width:12em; text-align:right; color:#666; padding-right:.5em; } #info { background:#f6f6f6; } #info ol { margin: 0.5em 4em; } #info ol li { font-family: monospace; } #summary { background: #ffc; } #explanation { background:#eee; border-bottom: 0px none; } </style> </head> <body> <div id="summary"> <h1>Page not found <span>(404)</span></h1> <table class="meta"> <tr> <th>Request Method:</th> <td>{{ request.META.REQUEST_METHOD }}</td> </tr> <tr> <th>Request URL:</th> <td>{{ request.build_absolute_uri|escape }}</td> </tr> </table> </div> <div id="info"> {% if urlpatterns %} <p> Using the URLconf defined in <code>{{ urlconf }}</code>, Django tried these URL patterns, in this order: </p> <ol> {% for pattern in urlpatterns %} <li> {% for pat in pattern %} {{ pat.regex.pattern }} {% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %} {% endfor %} </li> {% endfor %} </ol> <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p> {% else %} <p>{{ reason }}</p> {% endif %} </div> <div id="explanation"> <p> You're seeing this error because you have <code>DEBUG = True</code> in your Django settings file. Change that to <code>False</code>, and Django will display a standard 404 page. </p> </div> </body> </html> """ DEFAULT_URLCONF_TEMPLATE = """ <!DOCTYPE html> <html lang="en"><head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to Django</title> <style type="text/css"> html * { padding:0; margin:0; } body * { padding:10px 20px; } body * * { padding:0; } body { font:small sans-serif; } body>div { border-bottom:1px solid #ddd; } h1 { font-weight:normal; } h2 { margin-bottom:.8em; } h2 span { font-size:80%; color:#666; font-weight:normal; } h3 { margin:1em 0 .5em 0; } h4 { margin:0 0 .5em 0; font-weight: normal; } table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; } tbody td, tbody th { vertical-align:top; padding:2px 3px; } thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; } tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; } #summary { background: #e0ebff; } #summary h2 { font-weight: normal; color: #666; } #explanation { background:#eee; } #instructions { background:#f6f6f6; } #summary table { border:none; background:transparent; } </style> </head> <body> <div id="summary"> <h1>It worked!</h1> <h2>Congratulations on your first Django-powered page.</h2> </div> <div id="instructions"> <p> Of course, you haven't actually done any work yet. Next, start your first app by running <code>python manage.py startapp [appname]</code>. </p> </div> <div id="explanation"> <p> You're seeing this message because you have <code>DEBUG = True</code> in your Django settings file and you haven't configured any URLs. Get to work! </p> </div> </body></html> """
apache-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 2943, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1014, 492, 334, 16287, 12, 6183, 17692, 12, 272, 6183, 4667, 12, 20730, 12, 1900, 63, 1069, 63, 2722, 9, 199, 504, 1639, 14, 1160, 492, 5458, 12, 9470, 12, 27193, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 3542, 63, 3765, 12, 10933, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 1360, 492, 4772, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 11179, 63, 505, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 991, 63, 515, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 40, 22436, 63, 13931, 275, 295, 14, 2014, 360, 3735, 92, 8803, 92, 3078, 92, 12961, 92, 6909, 92, 2514, 29091, 19144, 63, 4924, 92, 26588, 358, 199, 199, 28663, 10934, 63, 6348, 8895, 275, 283, 3096, 1116, 7, 199, 199, 318, 1004, 4785, 63, 1661, 8, 1160, 63, 1365, 304, 272, 1995, 378, 272, 299, 275, 1978, 63, 1365, 14, 1623, 2258, 78, 358, 272, 1830, 299, 2356, 378, 26, 267, 1995, 299, 11, 17, 267, 299, 275, 1978, 63, 1365, 14, 1623, 2258, 78, 297, 299, 11, 17, 9, 272, 1995, 822, 8, 1160, 63, 1365, 9, 435, 413, 199, 199, 318, 3633, 261, 63, 6031, 8, 498, 12, 574, 304, 272, 408, 6580, 261, 376, 8212, 4260, 790, 15, 585, 402, 18423, 1564, 14, 339, 982, 314, 574, 365, 282, 2600, 12, 15035, 3633, 261, 314, 2883, 315, 272, 626, 2600, 14, 272, 408, 272, 862, 26, 267, 340, 869, 22436, 63, 13931, 14, 1733, 8, 498, 304, 288, 3633, 939, 275, 445, 906, 879, 10934, 63, 6348, 8895, 267, 587, 26, 288, 340, 1228, 8, 585, 12, 1211, 304, 355, 3633, 939, 275, 1211, 1332, 75, 12, 3633, 261, 63, 6031, 8, 75, 12, 373, 430, 367, 1022, 12, 86, 315, 574, 14, 1744, 1012, 288, 587, 26, 355, 3633, 939, 275, 574, 272, 871, 3146, 26, 267, 327, 982, 314, 790, 5712, 1133, 5163, 13, 461, 12, 2951, 372, 465, 13, 374, 14, 267, 3633, 939, 275, 574, 272, 372, 3633, 939, 199, 199, 318, 664, 63, 3489, 63, 1751, 837, 272, 298, 3407, 282, 2600, 402, 314, 2202, 859, 12, 543, 18423, 2202, 6826, 300, 581, 734, 2122, 272, 2202, 63, 807, 275, 1052, 272, 367, 1022, 315, 2935, 8, 1751, 304, 267, 340, 1022, 14, 374, 4142, 837, 288, 2202, 63, 807, 59, 75, 61, 275, 3633, 261, 63, 6031, 8, 75, 12, 2519, 8, 1751, 12, 1022, 430, 272, 372, 2202, 63, 807, 199, 199, 318, 32742, 63, 5783, 63, 1310, 8, 1069, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 7070, 304, 272, 408, 272, 2790, 282, 32742, 1654, 1125, 1177, 14, 710, 2061, 7795, 2368, 787, 272, 314, 1338, 2138, 687, 984, 14, 2804, 63, 815, 342, 436, 26157, 14, 272, 408, 272, 17663, 275, 2186, 15891, 8, 1069, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 7070, 9, 272, 340, 1056, 14, 374, 63, 12774, 837, 267, 1318, 275, 17663, 14, 362, 63, 6894, 63, 505, 342, 267, 372, 6183, 17692, 8, 505, 12, 1564, 63, 466, 534, 505, 15, 6104, 358, 272, 587, 26, 267, 3517, 275, 17663, 14, 362, 63, 6894, 63, 1360, 342, 267, 372, 6183, 17692, 8, 1360, 12, 1564, 63, 466, 534, 505, 15, 1360, 358, 199, 199, 3, 11977, 367, 314, 849, 1919, 17663, 2457, 1256, 14, 199, 885, 63, 1971, 63, 12222, 63, 1541, 275, 488, 199, 199, 318, 664, 63, 1971, 63, 12222, 63, 1541, 8, 1069, 304, 272, 2288, 849, 63, 1971, 63, 12222, 63, 1541, 272, 340, 849, 63, 1971, 63, 12222, 63, 1541, 365, 488, 26, 267, 327, 7190, 314, 849, 2457, 367, 314, 1642, 900, 436, 2581, 652, 14, 267, 849, 63, 1971, 63, 12222, 63, 1541, 275, 492, 63, 991, 63, 515, 8, 288, 2202, 14, 3472, 63, 15375, 63, 22554, 726, 1157, 63, 9905, 16315, 272, 340, 1056, 26, 267, 372, 2519, 8, 1069, 12, 283, 1971, 63, 12222, 63, 1541, 297, 849, 63, 1971, 63, 12222, 63, 1541, 9, 272, 587, 26, 267, 372, 849, 63, 1971, 63, 12222, 63, 1541, 199, 199, 533, 2186, 15891, 4131, 8, 785, 304, 272, 408, 272, 3523, 367, 1006, 1919, 17663, 2457, 3992, 14, 2900, 1806, 1677, 461, 12604, 272, 1395, 822, 6792, 849, 5112, 1384, 14, 272, 408, 339, 347, 664, 63, 1069, 63, 2722, 8, 277, 12, 1056, 304, 267, 340, 1056, 365, 488, 26, 288, 372, 4700, 8, 403, 9, 267, 587, 26, 288, 372, 1900, 63, 1069, 63, 2722, 8, 1069, 12, 8761, 63, 4415, 29, 277, 14, 362, 63, 1932, 63, 3214, 8, 1069, 430, 339, 347, 664, 63, 1932, 63, 3214, 8, 277, 12, 1056, 304, 267, 340, 1056, 365, 488, 26, 288, 372, 1052, 267, 587, 26, 288, 372, 1056, 14, 4030, 339, 347, 664, 63, 6894, 63, 1943, 63, 3669, 8, 277, 12, 1056, 12, 7070, 63, 1943, 304, 267, 372, 769, 8, 4174, 14, 4611, 8, 5842, 63, 1943, 14, 70, 63, 9350, 430, 199, 199, 533, 14969, 1726, 15891, 4131, 8, 1726, 15891, 4131, 304, 272, 408, 272, 3645, 15538, 6326, 701, 314, 18423, 63, 1932, 63, 3214, 436, 272, 18423, 63, 3669, 20419, 370, 2457, 734, 18423, 2556, 14, 272, 408, 339, 347, 365, 63, 2682, 8, 277, 12, 1056, 304, 267, 408, 267, 961, 2457, 365, 370, 1050, 30261, 315, 9920, 22196, 334, 73, 14, 69, 14, 10990, 267, 365, 756, 680, 982, 10990, 365, 715, 2066, 2195, 4770, 365, 440, 5048, 15988, 14, 267, 961, 5759, 365, 2741, 465, 282, 16777, 370, 16174, 15422, 503, 267, 25560, 314, 2457, 641, 282, 1126, 1056, 5597, 14, 267, 408, 267, 372, 2202, 14, 5287, 365, 756, 339, 347, 664, 63, 3118, 939, 63, 3029, 585, 807, 8, 277, 12, 1056, 12, 3510, 585, 807, 304, 267, 408, 267, 799, 10696, 314, 2883, 315, 282, 6879, 24811, 11584, 465, 18423 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 2943, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1014, 492, 334, 16287, 12, 6183, 17692, 12, 272, 6183, 4667, 12, 20730, 12, 1900, 63, 1069, 63, 2722, 9, 199, 504, 1639, 14, 1160, 492, 5458, 12, 9470, 12, 27193, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 3542, 63, 3765, 12, 10933, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 1360, 492, 4772, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 11179, 63, 505, 199, 504, 1639, 14, 1208, 14, 578, 63, 8786, 492, 492, 63, 991, 63, 515, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 40, 22436, 63, 13931, 275, 295, 14, 2014, 360, 3735, 92, 8803, 92, 3078, 92, 12961, 92, 6909, 92, 2514, 29091, 19144, 63, 4924, 92, 26588, 358, 199, 199, 28663, 10934, 63, 6348, 8895, 275, 283, 3096, 1116, 7, 199, 199, 318, 1004, 4785, 63, 1661, 8, 1160, 63, 1365, 304, 272, 1995, 378, 272, 299, 275, 1978, 63, 1365, 14, 1623, 2258, 78, 358, 272, 1830, 299, 2356, 378, 26, 267, 1995, 299, 11, 17, 267, 299, 275, 1978, 63, 1365, 14, 1623, 2258, 78, 297, 299, 11, 17, 9, 272, 1995, 822, 8, 1160, 63, 1365, 9, 435, 413, 199, 199, 318, 3633, 261, 63, 6031, 8, 498, 12, 574, 304, 272, 408, 6580, 261, 376, 8212, 4260, 790, 15, 585, 402, 18423, 1564, 14, 339, 982, 314, 574, 365, 282, 2600, 12, 15035, 3633, 261, 314, 2883, 315, 272, 626, 2600, 14, 272, 408, 272, 862, 26, 267, 340, 869, 22436, 63, 13931, 14, 1733, 8, 498, 304, 288, 3633, 939, 275, 445, 906, 879, 10934, 63, 6348, 8895, 267, 587, 26, 288, 340, 1228, 8, 585, 12, 1211, 304, 355, 3633, 939, 275, 1211, 1332, 75, 12, 3633, 261, 63, 6031, 8, 75, 12, 373, 430, 367, 1022, 12, 86, 315, 574, 14, 1744, 1012, 288, 587, 26, 355, 3633, 939, 275, 574, 272, 871, 3146, 26, 267, 327, 982, 314, 790, 5712, 1133, 5163, 13, 461, 12, 2951, 372, 465, 13, 374, 14, 267, 3633, 939, 275, 574, 272, 372, 3633, 939, 199, 199, 318, 664, 63, 3489, 63, 1751, 837, 272, 298, 3407, 282, 2600, 402, 314, 2202, 859, 12, 543, 18423, 2202, 6826, 300, 581, 734, 2122, 272, 2202, 63, 807, 275, 1052, 272, 367, 1022, 315, 2935, 8, 1751, 304, 267, 340, 1022, 14, 374, 4142, 837, 288, 2202, 63, 807, 59, 75, 61, 275, 3633, 261, 63, 6031, 8, 75, 12, 2519, 8, 1751, 12, 1022, 430, 272, 372, 2202, 63, 807, 199, 199, 318, 32742, 63, 5783, 63, 1310, 8, 1069, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 7070, 304, 272, 408, 272, 2790, 282, 32742, 1654, 1125, 1177, 14, 710, 2061, 7795, 2368, 787, 272, 314, 1338, 2138, 687, 984, 14, 2804, 63, 815, 342, 436, 26157, 14, 272, 408, 272, 17663, 275, 2186, 15891, 8, 1069, 12, 3178, 63, 466, 12, 3178, 63, 585, 12, 7070, 9, 272, 340, 1056, 14, 374, 63, 12774, 837, 267, 1318, 275, 17663, 14, 362, 63, 6894, 63, 505, 342, 267, 372, 6183, 17692, 8, 505, 12, 1564, 63, 466, 534, 505, 15, 6104, 358, 272, 587, 26, 267, 3517, 275, 17663, 14, 362, 63, 6894, 63, 1360, 342, 267, 372, 6183, 17692, 8, 1360, 12, 1564, 63, 466, 534, 505, 15, 1360, 358, 199, 199, 3, 11977, 367, 314, 849, 1919, 17663, 2457, 1256, 14, 199, 885, 63, 1971, 63, 12222, 63, 1541, 275, 488, 199, 199, 318, 664, 63, 1971, 63, 12222, 63, 1541, 8, 1069, 304, 272, 2288, 849, 63, 1971, 63, 12222, 63, 1541, 272, 340, 849, 63, 1971, 63, 12222, 63, 1541, 365, 488, 26, 267, 327, 7190, 314, 849, 2457, 367, 314, 1642, 900, 436, 2581, 652, 14, 267, 849, 63, 1971, 63, 12222, 63, 1541, 275, 492, 63, 991, 63, 515, 8, 288, 2202, 14, 3472, 63, 15375, 63, 22554, 726, 1157, 63, 9905, 16315, 272, 340, 1056, 26, 267, 372, 2519, 8, 1069, 12, 283, 1971, 63, 12222, 63, 1541, 297, 849, 63, 1971, 63, 12222, 63, 1541, 9, 272, 587, 26, 267, 372, 849, 63, 1971, 63, 12222, 63, 1541, 199, 199, 533, 2186, 15891, 4131, 8, 785, 304, 272, 408, 272, 3523, 367, 1006, 1919, 17663, 2457, 3992, 14, 2900, 1806, 1677, 461, 12604, 272, 1395, 822, 6792, 849, 5112, 1384, 14, 272, 408, 339, 347, 664, 63, 1069, 63, 2722, 8, 277, 12, 1056, 304, 267, 340, 1056, 365, 488, 26, 288, 372, 4700, 8, 403, 9, 267, 587, 26, 288, 372, 1900, 63, 1069, 63, 2722, 8, 1069, 12, 8761, 63, 4415, 29, 277, 14, 362, 63, 1932, 63, 3214, 8, 1069, 430, 339, 347, 664, 63, 1932, 63, 3214, 8, 277, 12, 1056, 304, 267, 340, 1056, 365, 488, 26, 288, 372, 1052, 267, 587, 26, 288, 372, 1056, 14, 4030, 339, 347, 664, 63, 6894, 63, 1943, 63, 3669, 8, 277, 12, 1056, 12, 7070, 63, 1943, 304, 267, 372, 769, 8, 4174, 14, 4611, 8, 5842, 63, 1943, 14, 70, 63, 9350, 430, 199, 199, 533, 14969, 1726, 15891, 4131, 8, 1726, 15891, 4131, 304, 272, 408, 272, 3645, 15538, 6326, 701, 314, 18423, 63, 1932, 63, 3214, 436, 272, 18423, 63, 3669, 20419, 370, 2457, 734, 18423, 2556, 14, 272, 408, 339, 347, 365, 63, 2682, 8, 277, 12, 1056, 304, 267, 408, 267, 961, 2457, 365, 370, 1050, 30261, 315, 9920, 22196, 334, 73, 14, 69, 14, 10990, 267, 365, 756, 680, 982, 10990, 365, 715, 2066, 2195, 4770, 365, 440, 5048, 15988, 14, 267, 961, 5759, 365, 2741, 465, 282, 16777, 370, 16174, 15422, 503, 267, 25560, 314, 2457, 641, 282, 1126, 1056, 5597, 14, 267, 408, 267, 372, 2202, 14, 5287, 365, 756, 339, 347, 664, 63, 3118, 939, 63, 3029, 585, 807, 8, 277, 12, 1056, 12, 3510, 585, 807, 304, 267, 408, 267, 799, 10696, 314, 2883, 315, 282, 6879, 24811, 11584, 465, 18423, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
r-barnes/waterviz
server/gauges.py
2
4840
#!/usr/bin/env python3 import os from flask import Flask, jsonify, send_from_directory, abort, Response, request, g import psycopg2 import psycopg2.extras import json import pickle import numpy as np import re app = Flask(__name__) aggregated_stats_file = 'county_agg_stats.p' aggdata = pickle.load(open(aggregated_stats_file, "rb")) @app.before_request def before_request(): g.db = psycopg2.connect("dbname='rivers' user='nelson' host='localhost' password='NONE'") @app.teardown_request def teardown_request(exception): db = getattr(g, 'db', None) if db is not None: db.close() #@app.route('/') #def index(): # return send_from_directory('.', 'index.html') @app.route('/gauges/reachflow/<string:date>', methods=['GET']) def show_reachflow(date): cur = g.db.cursor(cursor_factory = psycopg2.extras.RealDictCursor) cur.execute("SELECT * FROM reach_summary WHERE jday=%(date)s::date-'1970-01-01'::date", {"date":date}) return json.dumps({"reachflows":cur.fetchall()}) @app.route('/gauges/getvals/<string:date>', methods=['POST']) def show_getvals(date): cur = g.db.cursor(cursor_factory = psycopg2.extras.RealDictCursor) gaugelist = request.form['gauges'] gaugelist = json.loads(gaugelist) decimal = re.compile(r'[\d]+') gaugelist = list(filter(lambda x: decimal.match(x), gaugelist)) gaugelist = map(lambda x: "'"+x+"'", gaugelist) gaugelist = ','.join(gaugelist) cur.execute("SELECT * FROM gauge_summary WHERE site_code IN ("+gaugelist+") AND jday=%(date)s::date-'1970-01-01'::date", {"date":date}) return json.dumps({"gaugevals":cur.fetchall()}) @app.route('/gauges/list/<string:date>/<string:xmin>/<string:ymin>/<string:xmax>/<string:ymax>', methods=['GET']) def show_gaugelist(date,xmin,ymin,xmax,ymax): cur = g.db.cursor(cursor_factory = psycopg2.extras.RealDictCursor) cur.execute(""" SELECT site_code, lng, lat, svalue, dvalue, drank, featuredet, (SELECT station_nm FROM gageinfo WHERE gageid=site_code LIMIT 1) as name FROM (SELECT source_fea AS site_code, ST_X(geom) as lng, ST_Y(geom) as lat, featuredet FROM gageloc WHERE geom @ -- contained by, gets fewer rows -- ONE YOU NEED! ST_MakeEnvelope ( %(xmin)s, %(ymin)s, -- bounding %(xmax)s, %(ymax)s, -- box limits 900913 ) ORDER BY random() LIMIT 500) AS geo NATURAL JOIN gauge_summary gs WHERE gs.jday=%(date)s::date-'1970-01-01'::date ORDER BY site_code """, {"date":date,"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax}) return json.dumps(cur.fetchall()) @app.route('/hurricanes/<string:date>') def show_hurricanes(date): cur = g.db.cursor(cursor_factory = psycopg2.extras.RealDictCursor) cur.execute("""SELECT stormid, max(name) as name, to_char(DATE(iso_time), 'YYYY-MM-DD') as dt, avg(latitude) as lat, avg(longitude) as lon, max(wind) as wind, max(pres) as pres, max(windpercentile) as windp, max(prespercentile) as presp from hurricane where track_type='main' and stormid in (select distinct stormid from hurricane where iso_time=%(time)s) GROUP BY stormid,DATE(iso_time),track_type ORDER BY stormid,dt;""", {"time":date}) temp = cur.fetchall() print(temp) return json.dumps({"hurricanes":temp}) @app.route('/county/style/<string:water_code>') def get_mapstyle(water_code): if water_code not in aggdata: abort(404) print(request.args) percentile_max = request.args.get('percentile_max', 98); percentile_max = int(percentile_max) print(percentile_max); cdgood = [v['changedata'][0] if v['changedata'] else 0 for county, v in aggdata[water_code].items()] deving = np.array(list(filter(lambda x: x >= 0, cdgood))) nating = -np.array(list(filter(lambda x: x<0, cdgood))) devmax = np.percentile(deving,percentile_max) if len(nating)>0: natmax = np.percentile(nating,percentile_max) outdict = {} for county,v in aggdata[water_code].items(): if not v['changedata']: continue val = v['changedata'][0] if val>=0: val = val/devmax color = 'red' elif val<0: val = abs(val)/natmax color = 'green' val = min(val,1) outdict[county] = {"fillColor":color,"fillOpacity":val} return jsonify(outdict) @app.route('/county/<string:water_code>/<string:county>', methods=['GET']) def get_county_data(water_code,county): print(water_code,county) if water_code not in aggdata or county not in aggdata[water_code]: abort(404) return jsonify(aggdata[water_code][county]) @app.route('/county/list', methods=['GET']) def get_counties(): allkeys = [list(v.keys()) for x,v in aggdata.items()] allkeys = list(set([x for sl in allkeys for x in sl])) print(allkeys) return jsonify({'counties':allkeys}) if __name__ == '__main__': app.run(debug=True,processes=4)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 646, 747, 199, 504, 7209, 492, 16704, 12, 23819, 12, 3222, 63, 504, 63, 3619, 12, 12004, 12, 7232, 12, 1056, 12, 486, 199, 646, 15492, 18, 199, 646, 15492, 18, 14, 9975, 199, 646, 2022, 199, 646, 5927, 199, 646, 2680, 465, 980, 199, 646, 295, 199, 199, 571, 275, 16704, 3460, 354, 3368, 199, 199, 10978, 972, 63, 3200, 63, 493, 275, 283, 3094, 369, 63, 13452, 63, 3200, 14, 80, 7, 199, 13452, 576, 5185, 275, 5927, 14, 912, 8, 1490, 8, 10978, 972, 63, 3200, 63, 493, 12, 298, 4848, 2237, 199, 199, 32, 571, 14, 5182, 63, 1069, 199, 318, 2544, 63, 1069, 837, 523, 486, 14, 697, 275, 15492, 18, 14, 2242, 480, 13238, 534, 2046, 83, 7, 922, 534, 2715, 834, 7, 1591, 534, 5967, 7, 2505, 534, 9185, 9859, 199, 199, 32, 571, 14, 15236, 63, 1069, 199, 318, 17558, 63, 1069, 8, 1971, 304, 523, 1592, 275, 2519, 8, 71, 12, 283, 697, 297, 488, 9, 523, 340, 1592, 365, 440, 488, 26, 489, 1592, 14, 1600, 342, 199, 199, 17577, 571, 14, 4449, 7825, 199, 3, 318, 1478, 837, 199, 3, 221, 372, 3222, 63, 504, 63, 3619, 14078, 283, 1080, 14, 1360, 358, 199, 199, 32, 571, 14, 4449, 2336, 16750, 3389, 15, 12784, 1659, 8316, 875, 26, 602, 4206, 3102, 2968, 2970, 1105, 199, 318, 2498, 63, 12784, 1659, 8, 602, 304, 523, 1094, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 523, 1094, 14, 2526, 480, 4859, 627, 4442, 12276, 63, 4705, 6038, 1335, 2977, 15438, 602, 9, 83, 447, 602, 15668, 21740, 13, 614, 13, 614, 356, 26, 602, 401, 2420, 602, 582, 602, 1552, 523, 372, 2022, 14, 4180, 6333, 12784, 22777, 582, 895, 14, 10174, 22804, 199, 199, 32, 571, 14, 4449, 2336, 16750, 3389, 15, 362, 3643, 8316, 875, 26, 602, 4206, 3102, 2968, 4030, 1105, 199, 318, 2498, 63, 362, 3643, 8, 602, 304, 523, 1094, 755, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 523, 486, 30949, 513, 275, 1056, 14, 964, 459, 16750, 3389, 418, 523, 486, 30949, 513, 275, 2022, 14, 3640, 8, 26775, 513, 9, 523, 6107, 257, 275, 295, 14, 2014, 8, 82, 22123, 68, 2807, 358, 523, 486, 30949, 513, 275, 769, 8, 1541, 8, 2734, 671, 26, 6107, 14, 1431, 8, 88, 395, 486, 30949, 513, 430, 523, 486, 30949, 513, 275, 2341, 8, 2734, 671, 26, 3546, 7709, 88, 11, 4507, 401, 486, 30949, 513, 9, 523, 486, 30949, 513, 275, 12814, 904, 8, 26775, 513, 9, 523, 1094, 14, 2526, 480, 4859, 627, 4442, 486, 30949, 63, 4705, 6038, 4770, 63, 600, 1621, 1689, 11, 26775, 513, 21425, 2401, 1335, 2977, 15438, 602, 9, 83, 447, 602, 15668, 21740, 13, 614, 13, 614, 356, 26, 602, 401, 2420, 602, 582, 602, 1552, 523, 372, 2022, 14, 4180, 6333, 26775, 3643, 582, 895, 14, 10174, 22804, 199, 199, 32, 571, 14, 4449, 2336, 16750, 3389, 15, 513, 8316, 875, 26, 602, 23220, 875, 26, 21601, 23220, 875, 26, 27429, 23220, 875, 26, 28961, 23220, 875, 26, 30036, 4206, 3102, 2968, 2970, 1105, 199, 318, 2498, 63, 26775, 513, 8, 602, 12, 21601, 12, 27429, 12, 28961, 12, 30036, 304, 523, 1094, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 8330, 1094, 14, 2526, 4852, 199, 4859, 4770, 63, 600, 12, 489, 634, 2753, 12, 489, 8396, 12, 489, 308, 585, 12, 489, 366, 585, 12, 489, 366, 4648, 12, 489, 3878, 9886, 12, 489, 334, 4859, 16518, 63, 10756, 4442, 486, 474, 815, 6038, 486, 474, 344, 29, 2124, 63, 600, 5138, 413, 9, 465, 536, 199, 12491, 334, 4859, 1350, 63, 29838, 4319, 4770, 63, 600, 12, 4384, 63, 56, 8, 6481, 9, 465, 634, 2753, 12, 4384, 63, 57, 8, 6481, 9, 465, 8396, 12, 3878, 9886, 267, 4442, 257, 486, 474, 2102, 267, 6038, 221, 9671, 267, 768, 1553, 10470, 701, 12, 7545, 27392, 4730, 1553, 13051, 1488, 22050, 7110, 1149, 1, 267, 4384, 63, 5483, 28278, 334, 881, 2818, 21601, 9, 83, 12, 2818, 27429, 9, 83, 12, 1553, 16842, 881, 2818, 28961, 9, 83, 12, 2818, 30036, 9, 83, 12, 1553, 5689, 10976, 881, 1749, 8581, 969, 267, 776, 267, 16044, 6515, 2196, 342, 5138, 6891, 9, 4319, 8509, 199, 28927, 1230, 748, 10593, 486, 30949, 63, 4705, 8763, 6038, 8763, 14, 74, 2977, 15438, 602, 9, 83, 447, 602, 15668, 21740, 13, 614, 13, 614, 356, 26, 602, 16044, 6515, 4770, 63, 600, 523, 10327, 2420, 602, 582, 602, 4589, 21601, 582, 21601, 4589, 27429, 582, 27429, 4589, 28961, 582, 28961, 4589, 30036, 582, 30036, 1552, 819, 372, 2022, 14, 4180, 8, 895, 14, 10174, 1012, 199, 199, 32, 571, 14, 4449, 2336, 72, 300, 28775, 397, 8316, 875, 26, 602, 5971, 199, 318, 2498, 63, 72, 300, 28775, 397, 8, 602, 304, 523, 1094, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 523, 1094, 14, 2526, 4852, 4859, 410, 1025, 344, 12, 1390, 8, 354, 9, 465, 536, 12, 370, 63, 1560, 8, 5390, 8, 4595, 63, 521, 395, 283, 15703, 13, 3218, 13, 5745, 358, 465, 4487, 12, 12402, 8, 13331, 9, 465, 8396, 12, 12402, 8, 13803, 9, 465, 6132, 12, 1390, 8, 11530, 9, 465, 15417, 12, 1390, 8, 24919, 9, 465, 25210, 12, 1390, 8, 11530, 21188, 9, 465, 15417, 80, 12, 1390, 8, 24919, 21188, 9, 465, 299, 4518, 687, 394, 300, 1567, 5865, 221, 2382, 4426, 63, 466, 534, 973, 7, 436, 410, 1025, 344, 315, 334, 2416, 15392, 410, 1025, 344, 687, 394, 300, 1567, 5865, 2382, 11601, 63, 521, 15438, 521, 9, 83, 9, 15443, 6515, 410, 1025, 344, 12, 5390, 8, 4595, 63, 521, 395, 3885, 63, 466, 16044, 6515, 410, 1025, 344, 12, 3583, 27, 7208, 2420, 521, 582, 602, 1552, 523, 2388, 275 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 646, 747, 199, 504, 7209, 492, 16704, 12, 23819, 12, 3222, 63, 504, 63, 3619, 12, 12004, 12, 7232, 12, 1056, 12, 486, 199, 646, 15492, 18, 199, 646, 15492, 18, 14, 9975, 199, 646, 2022, 199, 646, 5927, 199, 646, 2680, 465, 980, 199, 646, 295, 199, 199, 571, 275, 16704, 3460, 354, 3368, 199, 199, 10978, 972, 63, 3200, 63, 493, 275, 283, 3094, 369, 63, 13452, 63, 3200, 14, 80, 7, 199, 13452, 576, 5185, 275, 5927, 14, 912, 8, 1490, 8, 10978, 972, 63, 3200, 63, 493, 12, 298, 4848, 2237, 199, 199, 32, 571, 14, 5182, 63, 1069, 199, 318, 2544, 63, 1069, 837, 523, 486, 14, 697, 275, 15492, 18, 14, 2242, 480, 13238, 534, 2046, 83, 7, 922, 534, 2715, 834, 7, 1591, 534, 5967, 7, 2505, 534, 9185, 9859, 199, 199, 32, 571, 14, 15236, 63, 1069, 199, 318, 17558, 63, 1069, 8, 1971, 304, 523, 1592, 275, 2519, 8, 71, 12, 283, 697, 297, 488, 9, 523, 340, 1592, 365, 440, 488, 26, 489, 1592, 14, 1600, 342, 199, 199, 17577, 571, 14, 4449, 7825, 199, 3, 318, 1478, 837, 199, 3, 221, 372, 3222, 63, 504, 63, 3619, 14078, 283, 1080, 14, 1360, 358, 199, 199, 32, 571, 14, 4449, 2336, 16750, 3389, 15, 12784, 1659, 8316, 875, 26, 602, 4206, 3102, 2968, 2970, 1105, 199, 318, 2498, 63, 12784, 1659, 8, 602, 304, 523, 1094, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 523, 1094, 14, 2526, 480, 4859, 627, 4442, 12276, 63, 4705, 6038, 1335, 2977, 15438, 602, 9, 83, 447, 602, 15668, 21740, 13, 614, 13, 614, 356, 26, 602, 401, 2420, 602, 582, 602, 1552, 523, 372, 2022, 14, 4180, 6333, 12784, 22777, 582, 895, 14, 10174, 22804, 199, 199, 32, 571, 14, 4449, 2336, 16750, 3389, 15, 362, 3643, 8316, 875, 26, 602, 4206, 3102, 2968, 4030, 1105, 199, 318, 2498, 63, 362, 3643, 8, 602, 304, 523, 1094, 755, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 523, 486, 30949, 513, 275, 1056, 14, 964, 459, 16750, 3389, 418, 523, 486, 30949, 513, 275, 2022, 14, 3640, 8, 26775, 513, 9, 523, 6107, 257, 275, 295, 14, 2014, 8, 82, 22123, 68, 2807, 358, 523, 486, 30949, 513, 275, 769, 8, 1541, 8, 2734, 671, 26, 6107, 14, 1431, 8, 88, 395, 486, 30949, 513, 430, 523, 486, 30949, 513, 275, 2341, 8, 2734, 671, 26, 3546, 7709, 88, 11, 4507, 401, 486, 30949, 513, 9, 523, 486, 30949, 513, 275, 12814, 904, 8, 26775, 513, 9, 523, 1094, 14, 2526, 480, 4859, 627, 4442, 486, 30949, 63, 4705, 6038, 4770, 63, 600, 1621, 1689, 11, 26775, 513, 21425, 2401, 1335, 2977, 15438, 602, 9, 83, 447, 602, 15668, 21740, 13, 614, 13, 614, 356, 26, 602, 401, 2420, 602, 582, 602, 1552, 523, 372, 2022, 14, 4180, 6333, 26775, 3643, 582, 895, 14, 10174, 22804, 199, 199, 32, 571, 14, 4449, 2336, 16750, 3389, 15, 513, 8316, 875, 26, 602, 23220, 875, 26, 21601, 23220, 875, 26, 27429, 23220, 875, 26, 28961, 23220, 875, 26, 30036, 4206, 3102, 2968, 2970, 1105, 199, 318, 2498, 63, 26775, 513, 8, 602, 12, 21601, 12, 27429, 12, 28961, 12, 30036, 304, 523, 1094, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 8330, 1094, 14, 2526, 4852, 199, 4859, 4770, 63, 600, 12, 489, 634, 2753, 12, 489, 8396, 12, 489, 308, 585, 12, 489, 366, 585, 12, 489, 366, 4648, 12, 489, 3878, 9886, 12, 489, 334, 4859, 16518, 63, 10756, 4442, 486, 474, 815, 6038, 486, 474, 344, 29, 2124, 63, 600, 5138, 413, 9, 465, 536, 199, 12491, 334, 4859, 1350, 63, 29838, 4319, 4770, 63, 600, 12, 4384, 63, 56, 8, 6481, 9, 465, 634, 2753, 12, 4384, 63, 57, 8, 6481, 9, 465, 8396, 12, 3878, 9886, 267, 4442, 257, 486, 474, 2102, 267, 6038, 221, 9671, 267, 768, 1553, 10470, 701, 12, 7545, 27392, 4730, 1553, 13051, 1488, 22050, 7110, 1149, 1, 267, 4384, 63, 5483, 28278, 334, 881, 2818, 21601, 9, 83, 12, 2818, 27429, 9, 83, 12, 1553, 16842, 881, 2818, 28961, 9, 83, 12, 2818, 30036, 9, 83, 12, 1553, 5689, 10976, 881, 1749, 8581, 969, 267, 776, 267, 16044, 6515, 2196, 342, 5138, 6891, 9, 4319, 8509, 199, 28927, 1230, 748, 10593, 486, 30949, 63, 4705, 8763, 6038, 8763, 14, 74, 2977, 15438, 602, 9, 83, 447, 602, 15668, 21740, 13, 614, 13, 614, 356, 26, 602, 16044, 6515, 4770, 63, 600, 523, 10327, 2420, 602, 582, 602, 4589, 21601, 582, 21601, 4589, 27429, 582, 27429, 4589, 28961, 582, 28961, 4589, 30036, 582, 30036, 1552, 819, 372, 2022, 14, 4180, 8, 895, 14, 10174, 1012, 199, 199, 32, 571, 14, 4449, 2336, 72, 300, 28775, 397, 8316, 875, 26, 602, 5971, 199, 318, 2498, 63, 72, 300, 28775, 397, 8, 602, 304, 523, 1094, 275, 486, 14, 697, 14, 3937, 8, 3937, 63, 3702, 275, 15492, 18, 14, 9975, 14, 10099, 2141, 8993, 9, 523, 1094, 14, 2526, 4852, 4859, 410, 1025, 344, 12, 1390, 8, 354, 9, 465, 536, 12, 370, 63, 1560, 8, 5390, 8, 4595, 63, 521, 395, 283, 15703, 13, 3218, 13, 5745, 358, 465, 4487, 12, 12402, 8, 13331, 9, 465, 8396, 12, 12402, 8, 13803, 9, 465, 6132, 12, 1390, 8, 11530, 9, 465, 15417, 12, 1390, 8, 24919, 9, 465, 25210, 12, 1390, 8, 11530, 21188, 9, 465, 15417, 80, 12, 1390, 8, 24919, 21188, 9, 465, 299, 4518, 687, 394, 300, 1567, 5865, 221, 2382, 4426, 63, 466, 534, 973, 7, 436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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 ]
koying/xbmc-vidonme
lib/gtest/test/gtest_output_test.py
184
12027
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Tests the text output of Google C++ Testing Framework. SYNOPSIS gtest_output_test.py --build_dir=BUILD/DIR --gengolden # where BUILD/DIR contains the built gtest_output_test_ file. gtest_output_test.py --gengolden gtest_output_test.py """ __author__ = 'wan@google.com (Zhanyong Wan)' import os import re import sys import gtest_test_utils # The flag for generating the golden file GENGOLDEN_FLAG = '--gengolden' CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS' IS_WINDOWS = os.name == 'nt' # TODO(vladl@google.com): remove the _lin suffix. GOLDEN_NAME = 'gtest_output_test_golden_lin.txt' PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_') # At least one command we exercise must not have the # --gtest_internal_skip_environment_and_ad_hoc_tests flag. COMMAND_LIST_TESTS = ({}, [PROGRAM_PATH, '--gtest_list_tests']) COMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes']) COMMAND_WITH_TIME = ({}, [PROGRAM_PATH, '--gtest_print_time', '--gtest_internal_skip_environment_and_ad_hoc_tests', '--gtest_filter=FatalFailureTest.*:LoggingTest.*']) COMMAND_WITH_DISABLED = ( {}, [PROGRAM_PATH, '--gtest_also_run_disabled_tests', '--gtest_internal_skip_environment_and_ad_hoc_tests', '--gtest_filter=*DISABLED_*']) COMMAND_WITH_SHARDING = ( {'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'}, [PROGRAM_PATH, '--gtest_internal_skip_environment_and_ad_hoc_tests', '--gtest_filter=PassingTest.*']) GOLDEN_PATH = os.path.join(gtest_test_utils.GetSourceDir(), GOLDEN_NAME) def ToUnixLineEnding(s): """Changes all Windows/Mac line endings in s to UNIX line endings.""" return s.replace('\r\n', '\n').replace('\r', '\n') def RemoveLocations(test_output): """Removes all file location info from a Google Test program's output. Args: test_output: the output of a Google Test program. Returns: output with all file location info (in the form of 'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or 'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by 'FILE_NAME:#: '. """ return re.sub(r'.*[/\\](.+)(\:\d+|\(\d+\))\: ', r'\1:#: ', test_output) def RemoveStackTraceDetails(output): """Removes all stack traces from a Google Test program's output.""" # *? means "find the shortest string that matches". return re.sub(r'Stack trace:(.|\n)*?\n\n', 'Stack trace: (omitted)\n\n', output) def RemoveStackTraces(output): """Removes all traces of stack traces from a Google Test program's output.""" # *? means "find the shortest string that matches". return re.sub(r'Stack trace:(.|\n)*?\n\n', '', output) def RemoveTime(output): """Removes all time information from a Google Test program's output.""" return re.sub(r'\(\d+ ms', '(? ms', output) def RemoveTypeInfoDetails(test_output): """Removes compiler-specific type info from Google Test program's output. Args: test_output: the output of a Google Test program. Returns: output with type information normalized to canonical form. """ # some compilers output the name of type 'unsigned int' as 'unsigned' return re.sub(r'unsigned int', 'unsigned', test_output) def NormalizeToCurrentPlatform(test_output): """Normalizes platform specific output details for easier comparison.""" if IS_WINDOWS: # Removes the color information that is not present on Windows. test_output = re.sub('\x1b\\[(0;3\d)?m', '', test_output) # Changes failure message headers into the Windows format. test_output = re.sub(r': Failure\n', r': error: ', test_output) # Changes file(line_number) to file:line_number. test_output = re.sub(r'((\w|\.)+)\((\d+)\):', r'\1:\3:', test_output) return test_output def RemoveTestCounts(output): """Removes test counts from a Google Test program's output.""" output = re.sub(r'\d+ tests?, listed below', '? tests, listed below', output) output = re.sub(r'\d+ FAILED TESTS', '? FAILED TESTS', output) output = re.sub(r'\d+ tests? from \d+ test cases?', '? tests from ? test cases', output) output = re.sub(r'\d+ tests? from ([a-zA-Z_])', r'? tests from \1', output) return re.sub(r'\d+ tests?\.', '? tests.', output) def RemoveMatchingTests(test_output, pattern): """Removes output of specified tests from a Google Test program's output. This function strips not only the beginning and the end of a test but also all output in between. Args: test_output: A string containing the test output. pattern: A regex string that matches names of test cases or tests to remove. Returns: Contents of test_output with tests whose names match pattern removed. """ test_output = re.sub( r'.*\[ RUN \] .*%s(.|\n)*?\[( FAILED | OK )\] .*%s.*\n' % ( pattern, pattern), '', test_output) return re.sub(r'.*%s.*\n' % pattern, '', test_output) def NormalizeOutput(output): """Normalizes output (the output of gtest_output_test_.exe).""" output = ToUnixLineEnding(output) output = RemoveLocations(output) output = RemoveStackTraceDetails(output) output = RemoveTime(output) return output def GetShellCommandOutput(env_cmd): """Runs a command in a sub-process, and returns its output in a string. Args: env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra environment variables to set, and element 1 is a string with the command and any flags. Returns: A string with the command's combined standard and diagnostic output. """ # Spawns cmd in a sub-process, and gets its standard I/O file objects. # Set and save the environment properly. environ = os.environ.copy() environ.update(env_cmd[0]) p = gtest_test_utils.Subprocess(env_cmd[1], env=environ, capture_stderr=False) return p.output def GetCommandOutput(env_cmd): """Runs a command and returns its output with all file location info stripped off. Args: env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra environment variables to set, and element 1 is a string with the command and any flags. """ # Disables exception pop-ups on Windows. environ, cmdline = env_cmd environ = dict(environ) # Ensures we are modifying a copy. environ[CATCH_EXCEPTIONS_ENV_VAR_NAME] = '1' return NormalizeOutput(GetShellCommandOutput((environ, cmdline))) def GetOutputOfAllCommands(): """Returns concatenated output from several representative commands.""" return (GetCommandOutput(COMMAND_WITH_COLOR) + GetCommandOutput(COMMAND_WITH_TIME) + GetCommandOutput(COMMAND_WITH_DISABLED) + GetCommandOutput(COMMAND_WITH_SHARDING)) test_list = GetShellCommandOutput(COMMAND_LIST_TESTS) SUPPORTS_DEATH_TESTS = 'DeathTest' in test_list SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list SUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list SUPPORTS_STACK_TRACES = False CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and SUPPORTS_TYPED_TESTS and SUPPORTS_THREADS) class GTestOutputTest(gtest_test_utils.TestCase): def RemoveUnsupportedTests(self, test_output): if not SUPPORTS_DEATH_TESTS: test_output = RemoveMatchingTests(test_output, 'DeathTest') if not SUPPORTS_TYPED_TESTS: test_output = RemoveMatchingTests(test_output, 'TypedTest') test_output = RemoveMatchingTests(test_output, 'TypedDeathTest') test_output = RemoveMatchingTests(test_output, 'TypeParamDeathTest') if not SUPPORTS_THREADS: test_output = RemoveMatchingTests(test_output, 'ExpectFailureWithThreadsTest') test_output = RemoveMatchingTests(test_output, 'ScopedFakeTestPartResultReporterTest') test_output = RemoveMatchingTests(test_output, 'WorksConcurrently') if not SUPPORTS_STACK_TRACES: test_output = RemoveStackTraces(test_output) return test_output def testOutput(self): output = GetOutputOfAllCommands() golden_file = open(GOLDEN_PATH, 'rb') # A mis-configured source control system can cause \r appear in EOL # sequences when we read the golden file irrespective of an operating # system used. Therefore, we need to strip those \r's from newlines # unconditionally. golden = ToUnixLineEnding(golden_file.read()) golden_file.close() # We want the test to pass regardless of certain features being # supported or not. # We still have to remove type name specifics in all cases. normalized_actual = RemoveTypeInfoDetails(output) normalized_golden = RemoveTypeInfoDetails(golden) if CAN_GENERATE_GOLDEN_FILE: self.assertEqual(normalized_golden, normalized_actual) else: normalized_actual = NormalizeToCurrentPlatform( RemoveTestCounts(normalized_actual)) normalized_golden = NormalizeToCurrentPlatform( RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden))) # This code is very handy when debugging golden file differences: if os.getenv('DEBUG_GTEST_OUTPUT_TEST'): open(os.path.join( gtest_test_utils.GetSourceDir(), '_gtest_output_test_normalized_actual.txt'), 'wb').write( normalized_actual) open(os.path.join( gtest_test_utils.GetSourceDir(), '_gtest_output_test_normalized_golden.txt'), 'wb').write( normalized_golden) self.assertEqual(normalized_golden, normalized_actual) if __name__ == '__main__': if sys.argv[1:] == [GENGOLDEN_FLAG]: if CAN_GENERATE_GOLDEN_FILE: output = GetOutputOfAllCommands() golden_file = open(GOLDEN_PATH, 'wb') golden_file.write(output) golden_file.close() else: message = ( """Unable to write a golden file when compiled in an environment that does not support all the required features (death tests, typed tests, and multiple threads). Please generate the golden file using a binary built with those features enabled.""") sys.stderr.write(message) sys.exit(1) else: gtest_test_utils.Main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 314, 1318, 1072, 402, 4475, 445, 4176, 11940, 22545, 14, 199, 199, 31802, 21665, 1311, 2126, 9088, 63, 1199, 63, 396, 14, 647, 1553, 1506, 63, 694, 29, 8248, 15, 3022, 1553, 2268, 19440, 268, 327, 2382, 22974, 15, 3022, 3509, 314, 6137, 9088, 63, 1199, 63, 396, 63, 570, 14, 2126, 9088, 63, 1199, 63, 396, 14, 647, 1553, 2268, 19440, 2126, 9088, 63, 1199, 63, 396, 14, 647, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 3, 710, 3305, 367, 12999, 314, 17631, 570, 199, 9289, 39, 5104, 742, 63, 3719, 275, 2850, 2268, 19440, 7, 199, 35, 8078, 63, 25054, 63, 9984, 63, 5568, 63, 2339, 275, 283, 16151, 63, 35, 8078, 63, 25054, 7, 199, 199, 1311, 63, 20509, 275, 747, 14, 354, 508, 283, 343, 7, 199, 199, 3, 3254, 8, 7300, 350, 76, 32, 3098, 14, 957, 304, 2813, 314, 485, 472, 4739, 14, 199, 39, 5104, 742, 63, 2339, 275, 283, 8385, 63, 1199, 63, 396, 63, 19440, 63, 472, 14, 2424, 7, 199, 199, 15605, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 1199, 63, 396, 15452, 199, 199, 3, 2854, 5210, 1373, 1414, 781, 26511, 1471, 440, 1172, 314, 199, 3, 1553, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 3305, 14, 199, 10761, 63, 4924, 63, 7569, 275, 11459, 1386, 359, 15605, 63, 3243, 12, 2850, 8385, 63, 513, 63, 2219, 1105, 199, 10761, 63, 9139, 63, 7134, 275, 11459, 1386, 359, 15605, 63, 3243, 12, 2850, 8385, 63, 2326, 29, 5066, 1105, 199, 10761, 63, 9139, 63, 4961, 275, 11459, 1386, 359, 15605, 63, 3243, 12, 2079, 2850, 8385, 63, 1361, 63, 521, 297, 2079, 2850, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 297, 2079, 2850, 8385, 63, 1541, 29, 19507, 6782, 774, 2795, 26, 14054, 774, 2795, 1105, 199, 10761, 63, 9139, 63, 16205, 275, 334, 272, 5479, 359, 15605, 63, 3243, 12, 268, 2850, 8385, 63, 12344, 63, 1065, 63, 7011, 63, 2219, 297, 268, 2850, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 297, 268, 2850, 8385, 63, 1541, 29, 10, 16205, 15192, 1105, 199, 10761, 63, 9139, 63, 3234, 7816, 1206, 275, 334, 272, 791, 16151, 63, 3234, 7816, 63, 10215, 356, 283, 17, 297, 283, 16151, 63, 15386, 63, 11152, 3177, 356, 283, 18, 2267, 272, 359, 15605, 63, 3243, 12, 1362, 2850, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 297, 1362, 2850, 8385, 63, 1541, 29, 4986, 316, 774, 2795, 1105, 199, 199, 39, 5104, 742, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 8385, 63, 396, 63, 1208, 14, 1002, 2980, 3567, 1062, 598, 5104, 742, 63, 2339, 9, 421, 199, 318, 4005, 21607, 3049, 3005, 316, 8, 83, 304, 523, 408, 13907, 1006, 5417, 15, 3399, 1004, 1284, 780, 315, 308, 370, 22242, 1004, 1284, 780, 1041, 819, 372, 308, 14, 1814, 2258, 82, 60, 78, 297, 1557, 78, 1959, 1814, 2258, 82, 297, 1557, 78, 358, 421, 199, 318, 5852, 27727, 8, 396, 63, 1199, 304, 523, 408, 22948, 1006, 570, 2909, 2256, 687, 282, 4475, 1379, 2240, 1159, 1072, 14, 819, 3033, 26, 2126, 511, 63, 1199, 26, 221, 314, 1072, 402, 282, 4475, 1379, 2240, 14, 819, 1803, 26, 2126, 1072, 543, 1006, 570, 2909, 2256, 334, 262, 314, 1824, 402, 2126, 283, 16436, 15, 3817, 63, 2339, 26, 6174, 63, 9190, 26, 283, 269, 2126, 283, 16436, 1103, 3817, 63, 2339, 8, 6174, 63, 9190, 304, 5320, 8717, 701, 2126, 283, 3817, 63, 2339, 26, 12573, 1987, 523, 408, 819, 372, 295, 14, 954, 8, 82, 1370, 23033, 15, 1103, 8738, 6977, 10127, 3427, 68, 11, 6113, 2961, 68, 7896, 25105, 26, 1656, 519, 1154, 17, 26, 12573, 1656, 511, 63, 1199, 9, 421, 199, 318, 5852, 4851 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 2925, 314, 1318, 1072, 402, 4475, 445, 4176, 11940, 22545, 14, 199, 199, 31802, 21665, 1311, 2126, 9088, 63, 1199, 63, 396, 14, 647, 1553, 1506, 63, 694, 29, 8248, 15, 3022, 1553, 2268, 19440, 268, 327, 2382, 22974, 15, 3022, 3509, 314, 6137, 9088, 63, 1199, 63, 396, 63, 570, 14, 2126, 9088, 63, 1199, 63, 396, 14, 647, 1553, 2268, 19440, 2126, 9088, 63, 1199, 63, 396, 14, 647, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 3, 710, 3305, 367, 12999, 314, 17631, 570, 199, 9289, 39, 5104, 742, 63, 3719, 275, 2850, 2268, 19440, 7, 199, 35, 8078, 63, 25054, 63, 9984, 63, 5568, 63, 2339, 275, 283, 16151, 63, 35, 8078, 63, 25054, 7, 199, 199, 1311, 63, 20509, 275, 747, 14, 354, 508, 283, 343, 7, 199, 199, 3, 3254, 8, 7300, 350, 76, 32, 3098, 14, 957, 304, 2813, 314, 485, 472, 4739, 14, 199, 39, 5104, 742, 63, 2339, 275, 283, 8385, 63, 1199, 63, 396, 63, 19440, 63, 472, 14, 2424, 7, 199, 199, 15605, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 1199, 63, 396, 15452, 199, 199, 3, 2854, 5210, 1373, 1414, 781, 26511, 1471, 440, 1172, 314, 199, 3, 1553, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 3305, 14, 199, 10761, 63, 4924, 63, 7569, 275, 11459, 1386, 359, 15605, 63, 3243, 12, 2850, 8385, 63, 513, 63, 2219, 1105, 199, 10761, 63, 9139, 63, 7134, 275, 11459, 1386, 359, 15605, 63, 3243, 12, 2850, 8385, 63, 2326, 29, 5066, 1105, 199, 10761, 63, 9139, 63, 4961, 275, 11459, 1386, 359, 15605, 63, 3243, 12, 2079, 2850, 8385, 63, 1361, 63, 521, 297, 2079, 2850, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 297, 2079, 2850, 8385, 63, 1541, 29, 19507, 6782, 774, 2795, 26, 14054, 774, 2795, 1105, 199, 10761, 63, 9139, 63, 16205, 275, 334, 272, 5479, 359, 15605, 63, 3243, 12, 268, 2850, 8385, 63, 12344, 63, 1065, 63, 7011, 63, 2219, 297, 268, 2850, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 297, 268, 2850, 8385, 63, 1541, 29, 10, 16205, 15192, 1105, 199, 10761, 63, 9139, 63, 3234, 7816, 1206, 275, 334, 272, 791, 16151, 63, 3234, 7816, 63, 10215, 356, 283, 17, 297, 283, 16151, 63, 15386, 63, 11152, 3177, 356, 283, 18, 2267, 272, 359, 15605, 63, 3243, 12, 1362, 2850, 8385, 63, 4672, 63, 2759, 63, 5418, 63, 460, 63, 350, 63, 20402, 63, 2219, 297, 1362, 2850, 8385, 63, 1541, 29, 4986, 316, 774, 2795, 1105, 199, 199, 39, 5104, 742, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 8385, 63, 396, 63, 1208, 14, 1002, 2980, 3567, 1062, 598, 5104, 742, 63, 2339, 9, 421, 199, 318, 4005, 21607, 3049, 3005, 316, 8, 83, 304, 523, 408, 13907, 1006, 5417, 15, 3399, 1004, 1284, 780, 315, 308, 370, 22242, 1004, 1284, 780, 1041, 819, 372, 308, 14, 1814, 2258, 82, 60, 78, 297, 1557, 78, 1959, 1814, 2258, 82, 297, 1557, 78, 358, 421, 199, 318, 5852, 27727, 8, 396, 63, 1199, 304, 523, 408, 22948, 1006, 570, 2909, 2256, 687, 282, 4475, 1379, 2240, 1159, 1072, 14, 819, 3033, 26, 2126, 511, 63, 1199, 26, 221, 314, 1072, 402, 282, 4475, 1379, 2240, 14, 819, 1803, 26, 2126, 1072, 543, 1006, 570, 2909, 2256, 334, 262, 314, 1824, 402, 2126, 283, 16436, 15, 3817, 63, 2339, 26, 6174, 63, 9190, 26, 283, 269, 2126, 283, 16436, 1103, 3817, 63, 2339, 8, 6174, 63, 9190, 304, 5320, 8717, 701, 2126, 283, 3817, 63, 2339, 26, 12573, 1987, 523, 408, 819, 372, 295, 14, 954, 8, 82, 1370, 23033, 15, 1103, 8738, 6977, 10127, 3427, 68, 11, 6113, 2961, 68, 7896, 25105, 26, 1656, 519, 1154, 17, 26, 12573, 1656, 511, 63, 1199, 9, 421, 199, 318, 5852, 4851, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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. import uuid from oslo_config import cfg from nova.tests.functional.v3 import api_sample_base from nova.tests.unit.image import fake CONF = cfg.CONF CONF.import_opt('osapi_compute_extension', 'nova.api.openstack.compute.extensions') class SchedulerHintsJsonTest(api_sample_base.ApiSampleTestBaseV3): extension_name = "os-scheduler-hints" # TODO(madhuri): Overriding '_api_version' till all functional tests # are merged between v2 and v2.1. After that base class variable # itself can be changed to 'v2' _api_version = 'v2' def _get_flags(self): f = super(SchedulerHintsJsonTest, self)._get_flags() f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] f['osapi_compute_extension'].append( "nova.api.openstack.compute.contrib.scheduler_hints." "Scheduler_hints") return f def test_scheduler_hints_post(self): # Get api sample of scheduler hint post request. subs = self._get_regexes() subs.update({'image_id': fake.get_valid_image_id(), 'image_near': str(uuid.uuid4())}) response = self._do_post('servers', 'scheduler-hints-post-req', subs) self._verify_response('scheduler-hints-post-resp', subs, response, 202)
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, 199, 199, 646, 5377, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 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, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 736, 1246, 63, 3357, 63, 3435, 297, 355, 283, 6765, 14, 1246, 14, 8512, 14, 3357, 14, 5359, 358, 421, 199, 533, 32051, 40, 13141, 9653, 774, 8, 1246, 63, 3271, 63, 1095, 14, 7394, 8176, 14440, 54, 19, 304, 272, 3329, 63, 354, 275, 298, 736, 13, 8874, 13, 12354, 2, 339, 327, 3254, 8, 77, 350, 72, 2302, 304, 7259, 15526, 2513, 1246, 63, 1023, 7, 31801, 1006, 22380, 2295, 272, 327, 787, 9545, 3382, 373, 18, 436, 373, 18, 14, 17, 14, 12836, 626, 1300, 1021, 1750, 272, 327, 6337, 883, 506, 2896, 370, 283, 86, 18, 7, 272, 485, 1246, 63, 1023, 275, 283, 86, 18, 7, 339, 347, 485, 362, 63, 2469, 8, 277, 304, 267, 289, 275, 1613, 8, 11251, 40, 13141, 9653, 774, 12, 291, 10445, 362, 63, 2469, 342, 267, 289, 459, 736, 1246, 63, 3357, 63, 3435, 418, 275, 6392, 14, 736, 1246, 63, 3357, 63, 3435, 5873, 267, 289, 459, 736, 1246, 63, 3357, 63, 3435, 2278, 740, 8, 288, 298, 6765, 14, 1246, 14, 8512, 14, 3357, 14, 2828, 14, 8874, 63, 12354, 2122, 288, 298, 11251, 63, 12354, 531, 267, 372, 289, 339, 347, 511, 63, 8874, 63, 12354, 63, 1932, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 11899, 8328, 2963, 1056, 14, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 13868, 14, 873, 3252, 1569, 63, 344, 356, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 1062, 2151, 283, 1569, 63, 21078, 356, 620, 8, 2580, 14, 2580, 20, 1012, 1552, 267, 1177, 275, 291, 423, 1117, 63, 1932, 360, 5871, 297, 283, 8874, 13, 12354, 13, 1932, 13, 2103, 297, 639, 13868, 9, 267, 291, 423, 4712, 63, 1310, 360, 8874, 13, 12354, 13, 1932, 13, 4518, 297, 13868, 12, 1177, 12, 19328, 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 ]
[ 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, 199, 199, 646, 5377, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 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, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 736, 1246, 63, 3357, 63, 3435, 297, 355, 283, 6765, 14, 1246, 14, 8512, 14, 3357, 14, 5359, 358, 421, 199, 533, 32051, 40, 13141, 9653, 774, 8, 1246, 63, 3271, 63, 1095, 14, 7394, 8176, 14440, 54, 19, 304, 272, 3329, 63, 354, 275, 298, 736, 13, 8874, 13, 12354, 2, 339, 327, 3254, 8, 77, 350, 72, 2302, 304, 7259, 15526, 2513, 1246, 63, 1023, 7, 31801, 1006, 22380, 2295, 272, 327, 787, 9545, 3382, 373, 18, 436, 373, 18, 14, 17, 14, 12836, 626, 1300, 1021, 1750, 272, 327, 6337, 883, 506, 2896, 370, 283, 86, 18, 7, 272, 485, 1246, 63, 1023, 275, 283, 86, 18, 7, 339, 347, 485, 362, 63, 2469, 8, 277, 304, 267, 289, 275, 1613, 8, 11251, 40, 13141, 9653, 774, 12, 291, 10445, 362, 63, 2469, 342, 267, 289, 459, 736, 1246, 63, 3357, 63, 3435, 418, 275, 6392, 14, 736, 1246, 63, 3357, 63, 3435, 5873, 267, 289, 459, 736, 1246, 63, 3357, 63, 3435, 2278, 740, 8, 288, 298, 6765, 14, 1246, 14, 8512, 14, 3357, 14, 2828, 14, 8874, 63, 12354, 2122, 288, 298, 11251, 63, 12354, 531, 267, 372, 289, 339, 347, 511, 63, 8874, 63, 12354, 63, 1932, 8, 277, 304, 267, 327, 2372, 2986, 2690, 402, 11899, 8328, 2963, 1056, 14, 267, 13868, 275, 291, 423, 362, 63, 29283, 342, 267, 13868, 14, 873, 3252, 1569, 63, 344, 356, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 1062, 2151, 283, 1569, 63, 21078, 356, 620, 8, 2580, 14, 2580, 20, 1012, 1552, 267, 1177, 275, 291, 423, 1117, 63, 1932, 360, 5871, 297, 283, 8874, 13, 12354, 13, 1932, 13, 2103, 297, 639, 13868, 9, 267, 291, 423, 4712, 63, 1310, 360, 8874, 13, 12354, 13, 1932, 13, 4518, 297, 13868, 12, 1177, 12, 19328, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
andrewjpage/gff3toembl
gff3toembl/EMBLWriter.py
2
4237
import sys import subprocess from gt import GFF3InStream import os import re from gff3toembl.EMBLConverter import EMBLConverter from gff3toembl.VisitorStream import VisitorStream class EMBLWriter(object): def __init__(self, gff3_file, organism, taxonid, project, description, authors, title, publication, genome_type, classification, output_filename, locus_tag = None, translation_table = 11, chromosome_list = None): self.locus_tag = locus_tag self.translation_table = translation_table self.conv = EMBLConverter(locus_tag, translation_table) self.gff3_file = gff3_file self.organism = organism self.taxonid = taxonid self.project = project self.authors = authors self.title = title self.publication = publication self.genome_type = genome_type self.classification = classification self.output_filename = output_filename self.chromosome_list = chromosome_list self.fixed_gff_file = str(self.gff3_file)+"_fixed.gff" def create_output_file(self, organism, taxonid, project, authors, title, publication, genome_type, classification): target = open(self.output_filename, 'w') for sequence_identifier, contig in sorted(self.conv.contigs.items()): contig.add_header( authors = authors, classification = classification, genome_type = genome_type, organism = organism, project = project, publication = publication, sequence_identifier = sequence_identifier, sequence_length = contig.sequence.length, sequence_name = sequence_identifier, taxon_id = taxonid, title = title, ) target.write(contig.format()) target.write("//\n") target.close() def create_chromosome_list(self, chromosome_list_filename, embl_filename): if chromosome_list_filename == None: return if not os.path.exists(embl_filename): return embl_file = open(embl_filename, 'r') chromosome_list_file = open(chromosome_list_filename, 'w') object_accessions = [] object_sizes = [] for embl_line in embl_file.readlines(): sequence_size_match = re.search("; (\d+) BP.", embl_line) if sequence_size_match != None and sequence_size_match.group(1): object_sizes.append(int(sequence_size_match.group(1))) m = re.match("AC \* _(\w+)", embl_line) if m != None and m.group(1): object_accessions.append(m.group(1)) for index, object_accession in enumerate(object_accessions): chromosome_name = str((index+1)) # TODO make it work for more than just Bacteria chromosome_type = "Chromosome" chr_name_search = re.search("chr", object_accession) if chr_name_search != None and chr_name_search.group(): chromosome_type = "Chromosome" elif index > 0 and object_sizes[index] < 1000000: chromosome_type = "Plasmid" chromosome_list_file.write(object_accession + "\t" + chromosome_name + "\t" + chromosome_type + "\n") def sort_and_tidy_gff_file(self): try: subprocess.check_call("gt gff3 -force -sort -retainids -tidy -o "+str(self.fixed_gff_file)+" "+str(self.gff3_file), shell=True) except: sys.exit("Failed to sort and tidy gff file with GT") def parse_and_run(self): self.sort_and_tidy_gff_file() ins = GFF3InStream(self.fixed_gff_file) vs = VisitorStream(ins, self.conv) try: while (vs.next_tree()): pass except Exception as e: print(e) exit(1) self.create_output_file(self.organism, self.taxonid, self.project, self.authors, self.title, self.publication, self.genome_type, self.classification) self.create_chromosome_list(self.chromosome_list, self.output_filename) os.remove(self.fixed_gff_file)
gpl-3.0
[ 646, 984, 199, 646, 3873, 199, 504, 16484, 492, 598, 1665, 19, 607, 3296, 199, 646, 747, 199, 646, 295, 199, 199, 504, 486, 556, 19, 475, 18847, 76, 14, 2769, 7847, 11907, 492, 662, 4567, 44, 11907, 199, 504, 486, 556, 19, 475, 18847, 76, 14, 18324, 3296, 492, 29614, 269, 3296, 199, 199, 533, 662, 4567, 44, 6261, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 486, 556, 19, 63, 493, 12, 5981, 7199, 77, 12, 9067, 265, 344, 12, 2199, 12, 1369, 12, 11462, 12, 2538, 12, 221, 31997, 12, 29924, 63, 466, 12, 12505, 12, 221, 1072, 63, 1501, 12, 4355, 527, 63, 1450, 275, 488, 12, 7761, 63, 1224, 275, 4119, 12, 20074, 26803, 63, 513, 275, 488, 304, 267, 291, 14, 2102, 527, 63, 1450, 3515, 275, 4355, 527, 63, 1450, 267, 291, 14, 6893, 63, 1224, 221, 275, 7761, 63, 1224, 267, 291, 14, 5598, 5185, 275, 662, 4567, 44, 11907, 8, 2102, 527, 63, 1450, 12, 7761, 63, 1224, 9, 267, 291, 14, 71, 556, 19, 63, 493, 3515, 275, 486, 556, 19, 63, 493, 267, 291, 14, 1308, 7199, 77, 3698, 275, 5981, 7199, 77, 267, 291, 14, 5530, 265, 344, 3322, 275, 9067, 265, 344, 267, 291, 14, 1715, 3322, 275, 2199, 267, 291, 14, 8149, 3322, 275, 11462, 267, 291, 14, 1213, 4519, 275, 2538, 267, 291, 14, 22678, 263, 275, 31997, 267, 291, 14, 27776, 63, 466, 263, 275, 29924, 63, 466, 267, 291, 14, 14368, 258, 275, 12505, 267, 291, 14, 1199, 63, 1501, 259, 275, 1072, 63, 1501, 267, 291, 14, 23473, 26803, 63, 513, 259, 275, 20074, 26803, 63, 513, 267, 291, 14, 5964, 63, 71, 556, 63, 493, 258, 275, 620, 8, 277, 14, 71, 556, 19, 63, 493, 18663, 63, 5964, 14, 71, 556, 2, 339, 347, 1218, 63, 1199, 63, 493, 8, 277, 12, 5981, 7199, 77, 12, 9067, 265, 344, 12, 2199, 12, 11462, 12, 2538, 12, 31997, 12, 29924, 63, 466, 12, 12505, 304, 267, 1347, 275, 1551, 8, 277, 14, 1199, 63, 1501, 12, 283, 87, 358, 267, 367, 3414, 63, 5364, 12, 406, 17277, 315, 3355, 8, 277, 14, 5598, 14, 388, 280, 458, 14, 1744, 5109, 288, 406, 17277, 14, 525, 63, 1291, 8, 1598, 11462, 275, 11462, 12, 1598, 12505, 275, 12505, 12, 1598, 29924, 63, 466, 275, 29924, 63, 466, 12, 1598, 5981, 7199, 77, 275, 5981, 7199, 77, 12, 1598, 2199, 275, 2199, 12, 1598, 31997, 275, 31997, 12, 1598, 3414, 63, 5364, 275, 3414, 63, 5364, 12, 1598, 3414, 63, 1267, 275, 406, 17277, 14, 4041, 14, 1267, 12, 1598, 3414, 63, 354, 275, 3414, 63, 5364, 12, 1598, 9067, 265, 63, 344, 275, 9067, 265, 344, 12, 1598, 2538, 275, 2538, 12, 288, 776, 288, 1347, 14, 952, 8, 27952, 14, 908, 1012, 288, 1347, 14, 952, 21816, 60, 78, 531, 267, 1347, 14, 1600, 342, 339, 347, 1218, 63, 23473, 26803, 63, 513, 8, 277, 12, 20074, 26803, 63, 513, 63, 1501, 12, 25316, 76, 63, 1501, 304, 267, 340, 20074, 26803, 63, 513, 63, 1501, 508, 488, 26, 881, 372, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 18847, 76, 63, 1501, 304, 881, 372, 398, 25316, 76, 63, 493, 275, 1551, 8, 18847, 76, 63, 1501, 12, 283, 82, 358, 267, 20074, 26803, 63, 513, 63, 493, 275, 1551, 8, 23473, 26803, 63, 513, 63, 1501, 12, 283, 87, 358, 267, 909, 63, 645, 823, 1356, 275, 942, 267, 909, 63, 7723, 275, 942, 398, 367, 25316, 76, 63, 604, 315, 25316, 76, 63, 493, 14, 9684, 837, 881, 3414, 63, 890, 63, 1431, 275, 295, 14, 1733, 480, 27, 14749, 68, 8771, 699, 48, 4765, 25316, 76, 63, 604, 9, 881, 340, 3414, 63, 890, 63, 1431, 1137, 488, 436, 3414, 63, 890, 63, 1431, 14, 923, 8, 17, 304, 288, 909, 63, 7723, 14, 740, 8, 442, 8, 4041, 63, 890, 63, 1431, 14, 923, 8, 17, 1724, 881, 333, 275, 295, 14, 1431, 480, 1348, 971, 10, 485, 2961, 87, 11, 4186, 25316, 76, 63, 604, 9, 881, 340, 333, 1137, 488, 436, 333, 14, 923, 8, 17, 304, 288, 909, 63, 645, 823, 1356, 14, 740, 8, 77, 14, 923, 8, 17, 430, 398, 367, 1478, 12, 909, 63, 645, 823, 438, 315, 3874, 8, 785, 63, 645, 823, 1356, 304, 881, 20074, 26803, 63, 354, 275, 620, 1332, 1080, 11, 17, 430, 881, 327, 3254, 1852, 652, 1736, 367, 1655, 2419, 2951, 699, 22265, 881, 20074, 26803, 63, 466, 275, 298, 1049, 417, 26803, 2, 1779, 881, 8678, 63, 354, 63, 1733, 275, 295, 14, 1733, 480, 10194, 401, 909, 63, 645, 823, 438, 9, 881, 340, 8678, 63, 354, 63, 1733, 1137, 488, 436, 8678, 63, 354, 63, 1733, 14, 923, 837, 288, 20074, 26803, 63, 466, 275, 298, 1049, 417, 26803, 2, 881, 916, 1478, 690, 378, 436, 909, 63, 7723, 59, 1080, 61, 665, 19492, 26, 288, 20074, 26803, 63, 466, 275, 298, 3714, 305, 8523, 2, 881, 20074, 26803, 63, 513, 63, 493, 14, 952, 8, 785, 63, 645, 823, 438, 435, 1867, 84, 2, 435, 20074, 26803, 63, 354, 435, 1867, 84, 2, 435, 20074, 26803, 63, 466, 435, 1867, 78, 531, 339, 347, 4069, 63, 460, 63, 5700, 89, 63, 71, 556, 63, 493, 8, 277, 304, 267, 862, 26, 881, 3873, 14, 1074, 63, 1250, 480, 3308, 486, 556, 19, 446, 3990, 446, 3191, 446, 264, 877, 1580, 446, 5700, 89, 446, 79, 7210, 495, 8, 277, 14, 5964, 63, 71, 556, 63, 493, 18663, 7210, 495, 8, 277, 14, 71, 556, 19, 63, 493, 395, 5218, 29, 549, 9, 267, 871, 26, 881, 984, 14, 2224, 480, 4276, 370, 4069, 436, 3367, 8161, 486, 556, 570, 543, 598, 52, 531, 339, 347, 2198, 63, 460, 63, 1065, 8, 277, 304, 267, 291, 14, 3191, 63, 460, 63, 5700, 89, 63, 71, 556, 63, 493, 342, 267, 5261, 275, 598, 1665, 19, 607, 3296, 8, 277, 14, 5964, 63, 71, 556, 63, 493, 9, 267, 8118, 275, 29614, 269, 3296, 8, 3617, 12, 291, 14, 5598, 9, 267 ]
[ 984, 199, 646, 3873, 199, 504, 16484, 492, 598, 1665, 19, 607, 3296, 199, 646, 747, 199, 646, 295, 199, 199, 504, 486, 556, 19, 475, 18847, 76, 14, 2769, 7847, 11907, 492, 662, 4567, 44, 11907, 199, 504, 486, 556, 19, 475, 18847, 76, 14, 18324, 3296, 492, 29614, 269, 3296, 199, 199, 533, 662, 4567, 44, 6261, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 486, 556, 19, 63, 493, 12, 5981, 7199, 77, 12, 9067, 265, 344, 12, 2199, 12, 1369, 12, 11462, 12, 2538, 12, 221, 31997, 12, 29924, 63, 466, 12, 12505, 12, 221, 1072, 63, 1501, 12, 4355, 527, 63, 1450, 275, 488, 12, 7761, 63, 1224, 275, 4119, 12, 20074, 26803, 63, 513, 275, 488, 304, 267, 291, 14, 2102, 527, 63, 1450, 3515, 275, 4355, 527, 63, 1450, 267, 291, 14, 6893, 63, 1224, 221, 275, 7761, 63, 1224, 267, 291, 14, 5598, 5185, 275, 662, 4567, 44, 11907, 8, 2102, 527, 63, 1450, 12, 7761, 63, 1224, 9, 267, 291, 14, 71, 556, 19, 63, 493, 3515, 275, 486, 556, 19, 63, 493, 267, 291, 14, 1308, 7199, 77, 3698, 275, 5981, 7199, 77, 267, 291, 14, 5530, 265, 344, 3322, 275, 9067, 265, 344, 267, 291, 14, 1715, 3322, 275, 2199, 267, 291, 14, 8149, 3322, 275, 11462, 267, 291, 14, 1213, 4519, 275, 2538, 267, 291, 14, 22678, 263, 275, 31997, 267, 291, 14, 27776, 63, 466, 263, 275, 29924, 63, 466, 267, 291, 14, 14368, 258, 275, 12505, 267, 291, 14, 1199, 63, 1501, 259, 275, 1072, 63, 1501, 267, 291, 14, 23473, 26803, 63, 513, 259, 275, 20074, 26803, 63, 513, 267, 291, 14, 5964, 63, 71, 556, 63, 493, 258, 275, 620, 8, 277, 14, 71, 556, 19, 63, 493, 18663, 63, 5964, 14, 71, 556, 2, 339, 347, 1218, 63, 1199, 63, 493, 8, 277, 12, 5981, 7199, 77, 12, 9067, 265, 344, 12, 2199, 12, 11462, 12, 2538, 12, 31997, 12, 29924, 63, 466, 12, 12505, 304, 267, 1347, 275, 1551, 8, 277, 14, 1199, 63, 1501, 12, 283, 87, 358, 267, 367, 3414, 63, 5364, 12, 406, 17277, 315, 3355, 8, 277, 14, 5598, 14, 388, 280, 458, 14, 1744, 5109, 288, 406, 17277, 14, 525, 63, 1291, 8, 1598, 11462, 275, 11462, 12, 1598, 12505, 275, 12505, 12, 1598, 29924, 63, 466, 275, 29924, 63, 466, 12, 1598, 5981, 7199, 77, 275, 5981, 7199, 77, 12, 1598, 2199, 275, 2199, 12, 1598, 31997, 275, 31997, 12, 1598, 3414, 63, 5364, 275, 3414, 63, 5364, 12, 1598, 3414, 63, 1267, 275, 406, 17277, 14, 4041, 14, 1267, 12, 1598, 3414, 63, 354, 275, 3414, 63, 5364, 12, 1598, 9067, 265, 63, 344, 275, 9067, 265, 344, 12, 1598, 2538, 275, 2538, 12, 288, 776, 288, 1347, 14, 952, 8, 27952, 14, 908, 1012, 288, 1347, 14, 952, 21816, 60, 78, 531, 267, 1347, 14, 1600, 342, 339, 347, 1218, 63, 23473, 26803, 63, 513, 8, 277, 12, 20074, 26803, 63, 513, 63, 1501, 12, 25316, 76, 63, 1501, 304, 267, 340, 20074, 26803, 63, 513, 63, 1501, 508, 488, 26, 881, 372, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 18847, 76, 63, 1501, 304, 881, 372, 398, 25316, 76, 63, 493, 275, 1551, 8, 18847, 76, 63, 1501, 12, 283, 82, 358, 267, 20074, 26803, 63, 513, 63, 493, 275, 1551, 8, 23473, 26803, 63, 513, 63, 1501, 12, 283, 87, 358, 267, 909, 63, 645, 823, 1356, 275, 942, 267, 909, 63, 7723, 275, 942, 398, 367, 25316, 76, 63, 604, 315, 25316, 76, 63, 493, 14, 9684, 837, 881, 3414, 63, 890, 63, 1431, 275, 295, 14, 1733, 480, 27, 14749, 68, 8771, 699, 48, 4765, 25316, 76, 63, 604, 9, 881, 340, 3414, 63, 890, 63, 1431, 1137, 488, 436, 3414, 63, 890, 63, 1431, 14, 923, 8, 17, 304, 288, 909, 63, 7723, 14, 740, 8, 442, 8, 4041, 63, 890, 63, 1431, 14, 923, 8, 17, 1724, 881, 333, 275, 295, 14, 1431, 480, 1348, 971, 10, 485, 2961, 87, 11, 4186, 25316, 76, 63, 604, 9, 881, 340, 333, 1137, 488, 436, 333, 14, 923, 8, 17, 304, 288, 909, 63, 645, 823, 1356, 14, 740, 8, 77, 14, 923, 8, 17, 430, 398, 367, 1478, 12, 909, 63, 645, 823, 438, 315, 3874, 8, 785, 63, 645, 823, 1356, 304, 881, 20074, 26803, 63, 354, 275, 620, 1332, 1080, 11, 17, 430, 881, 327, 3254, 1852, 652, 1736, 367, 1655, 2419, 2951, 699, 22265, 881, 20074, 26803, 63, 466, 275, 298, 1049, 417, 26803, 2, 1779, 881, 8678, 63, 354, 63, 1733, 275, 295, 14, 1733, 480, 10194, 401, 909, 63, 645, 823, 438, 9, 881, 340, 8678, 63, 354, 63, 1733, 1137, 488, 436, 8678, 63, 354, 63, 1733, 14, 923, 837, 288, 20074, 26803, 63, 466, 275, 298, 1049, 417, 26803, 2, 881, 916, 1478, 690, 378, 436, 909, 63, 7723, 59, 1080, 61, 665, 19492, 26, 288, 20074, 26803, 63, 466, 275, 298, 3714, 305, 8523, 2, 881, 20074, 26803, 63, 513, 63, 493, 14, 952, 8, 785, 63, 645, 823, 438, 435, 1867, 84, 2, 435, 20074, 26803, 63, 354, 435, 1867, 84, 2, 435, 20074, 26803, 63, 466, 435, 1867, 78, 531, 339, 347, 4069, 63, 460, 63, 5700, 89, 63, 71, 556, 63, 493, 8, 277, 304, 267, 862, 26, 881, 3873, 14, 1074, 63, 1250, 480, 3308, 486, 556, 19, 446, 3990, 446, 3191, 446, 264, 877, 1580, 446, 5700, 89, 446, 79, 7210, 495, 8, 277, 14, 5964, 63, 71, 556, 63, 493, 18663, 7210, 495, 8, 277, 14, 71, 556, 19, 63, 493, 395, 5218, 29, 549, 9, 267, 871, 26, 881, 984, 14, 2224, 480, 4276, 370, 4069, 436, 3367, 8161, 486, 556, 570, 543, 598, 52, 531, 339, 347, 2198, 63, 460, 63, 1065, 8, 277, 304, 267, 291, 14, 3191, 63, 460, 63, 5700, 89, 63, 71, 556, 63, 493, 342, 267, 5261, 275, 598, 1665, 19, 607, 3296, 8, 277, 14, 5964, 63, 71, 556, 63, 493, 9, 267, 8118, 275, 29614, 269, 3296, 8, 3617, 12, 291, 14, 5598, 9, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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. # ============================================================================== """Image ops. The `tf.image` module contains various functions for image processing and decoding-encoding Ops. Many of the encoding/decoding functions are also available in the core `tf.io` module. ## Image processing ### Resizing The resizing Ops accept input images as tensors of several types. They always output resized images as float32 tensors. The convenience function `tf.image.resize` supports both 4-D and 3-D tensors as input and output. 4-D tensors are for batches of images, 3-D tensors for individual images. Resized images will be distorted if their original aspect ratio is not the same as size. To avoid distortions see tf.image.resize_with_pad. * `tf.image.resize` * `tf.image.resize_with_pad` * `tf.image.resize_with_crop_or_pad` The Class `tf.image.ResizeMethod` provides various resize methods like `bilinear`, `nearest_neighbor`. ### Converting Between Colorspaces Image ops work either on individual images or on batches of images, depending on the shape of their input Tensor. If 3-D, the shape is `[height, width, channels]`, and the Tensor represents one image. If 4-D, the shape is `[batch_size, height, width, channels]`, and the Tensor represents `batch_size` images. Currently, `channels` can usefully be 1, 2, 3, or 4. Single-channel images are grayscale, images with 3 channels are encoded as either RGB or HSV. Images with 2 or 4 channels include an alpha channel, which has to be stripped from the image before passing the image to most image processing functions (and can be re-attached later). Internally, images are either stored in as one `float32` per channel per pixel (implicitly, values are assumed to lie in `[0,1)`) or one `uint8` per channel per pixel (values are assumed to lie in `[0,255]`). TensorFlow can convert between images in RGB or HSV or YIQ. * `tf.image.rgb_to_grayscale`, `tf.image.grayscale_to_rgb` * `tf.image.rgb_to_hsv`, `tf.image.hsv_to_rgb` * `tf.image.rgb_to_yiq`, `tf.image.yiq_to_rgb` * `tf.image.rgb_to_yuv`, `tf.image.yuv_to_rgb` * `tf.image.image_gradients` * `tf.image.convert_image_dtype` ### Image Adjustments TensorFlow provides functions to adjust images in various ways: brightness, contrast, hue, and saturation. Each adjustment can be done with predefined parameters or with random parameters picked from predefined intervals. Random adjustments are often useful to expand a training set and reduce overfitting. If several adjustments are chained it is advisable to minimize the number of redundant conversions by first converting the images to the most natural data type and representation. * `tf.image.adjust_brightness` * `tf.image.adjust_contrast` * `tf.image.adjust_gamma` * `tf.image.adjust_hue` * `tf.image.adjust_jpeg_quality` * `tf.image.adjust_saturation` * `tf.image.random_brightness` * `tf.image.random_contrast` * `tf.image.random_hue` * `tf.image.random_saturation` * `tf.image.per_image_standardization` ### Working with Bounding Boxes * `tf.image.draw_bounding_boxes` * `tf.image.combined_non_max_suppression` * `tf.image.generate_bounding_box_proposals` * `tf.image.non_max_suppression` * `tf.image.non_max_suppression_overlaps` * `tf.image.non_max_suppression_padded` * `tf.image.non_max_suppression_with_scores` * `tf.image.pad_to_bounding_box` * `tf.image.sample_distorted_bounding_box` ### Cropping * `tf.image.central_crop` * `tf.image.crop_and_resize` * `tf.image.crop_to_bounding_box` * `tf.io.decode_and_crop_jpeg` * `tf.image.extract_glimpse` * `tf.image.random_crop` * `tf.image.resize_with_crop_or_pad` ### Flipping, Rotating and Transposing * `tf.image.flip_left_right` * `tf.image.flip_up_down` * `tf.image.random_flip_left_right` * `tf.image.random_flip_up_down` * `tf.image.rot90` * `tf.image.transpose` ## Image decoding and encoding TensorFlow provides Ops to decode and encode JPEG and PNG formats. Encoded images are represented by scalar string Tensors, decoded images by 3-D uint8 tensors of shape `[height, width, channels]`. (PNG also supports uint16.) Note: `decode_gif` returns a 4-D array `[num_frames, height, width, 3]` The encode and decode Ops apply to one image at a time. Their input and output are all of variable size. If you need fixed size images, pass the output of the decode Ops to one of the cropping and resizing Ops. * `tf.io.decode_bmp` * `tf.io.decode_gif` * `tf.io.decode_image` * `tf.io.decode_jpeg` * `tf.io.decode_and_crop_jpeg` * `tf.io.decode_png` * `tf.io.encode_jpeg` * `tf.io.encode_png` """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_image_ops from tensorflow.python.ops import linalg_ops # go/tf-wildcard-import # pylint: disable=wildcard-import from tensorflow.python.ops.gen_image_ops import * from tensorflow.python.ops.image_ops_impl import * # pylint: enable=wildcard-import # TODO(drpng): remove these once internal use has discontinued. # pylint: disable=unused-import from tensorflow.python.ops.image_ops_impl import _Check3DImage from tensorflow.python.ops.image_ops_impl import _ImageDimensions # pylint: enable=unused-import _IMAGE_DTYPES = frozenset([ dtypes.uint8, dtypes.int32, dtypes.int64, dtypes.float16, dtypes.float32, dtypes.float64 ]) def flat_transforms_to_matrices(transforms): """Converts `tf.contrib.image` projective transforms to affine matrices. Note that the output matrices map output coordinates to input coordinates. For the forward transformation matrix, call `tf.linalg.inv` on the result. Args: transforms: Vector of length 8, or batches of transforms with shape `(N, 8)`. Returns: 3D tensor of matrices with shape `(N, 3, 3)`. The output matrices map the *output coordinates* (in homogeneous coordinates) of each transform to the corresponding *input coordinates*. Raises: ValueError: If `transforms` have an invalid shape. """ with ops.name_scope("flat_transforms_to_matrices"): transforms = ops.convert_to_tensor(transforms, name="transforms") if transforms.shape.ndims not in (1, 2): raise ValueError("Transforms should be 1D or 2D, got: %s" % transforms) # Make the transform(s) 2D in case the input is a single transform. transforms = array_ops.reshape(transforms, constant_op.constant([-1, 8])) num_transforms = array_ops.shape(transforms)[0] # Add a column of ones for the implicit last entry in the matrix. return array_ops.reshape( array_ops.concat( [transforms, array_ops.ones([num_transforms, 1])], axis=1), constant_op.constant([-1, 3, 3])) def matrices_to_flat_transforms(transform_matrices): """Converts affine matrices to `tf.contrib.image` projective transforms. Note that we expect matrices that map output coordinates to input coordinates. To convert forward transformation matrices, call `tf.linalg.inv` on the matrices and use the result here. Args: transform_matrices: One or more affine transformation matrices, for the reverse transformation in homogeneous coordinates. Shape `(3, 3)` or `(N, 3, 3)`. Returns: 2D tensor of flat transforms with shape `(N, 8)`, which may be passed into `tf.contrib.image.transform`. Raises: ValueError: If `transform_matrices` have an invalid shape. """ with ops.name_scope("matrices_to_flat_transforms"): transform_matrices = ops.convert_to_tensor( transform_matrices, name="transform_matrices") if transform_matrices.shape.ndims not in (2, 3): raise ValueError("Matrices should be 2D or 3D, got: %s" % transform_matrices) # Flatten each matrix. transforms = array_ops.reshape(transform_matrices, constant_op.constant([-1, 9])) # Divide each matrix by the last entry (normally 1). transforms /= transforms[:, 8:9] return transforms[:, :8] @ops.RegisterGradient("ImageProjectiveTransformV2") def _image_projective_transform_grad(op, grad): """Computes the gradient for ImageProjectiveTransform.""" images = op.inputs[0] transforms = op.inputs[1] interpolation = op.get_attr("interpolation") fill_mode = op.get_attr("fill_mode") image_or_images = ops.convert_to_tensor(images, name="images") transform_or_transforms = ops.convert_to_tensor( transforms, name="transforms", dtype=dtypes.float32) if image_or_images.dtype.base_dtype not in _IMAGE_DTYPES: raise TypeError("Invalid dtype %s." % image_or_images.dtype) if len(transform_or_transforms.get_shape()) == 1: transforms = transform_or_transforms[None] elif len(transform_or_transforms.get_shape()) == 2: transforms = transform_or_transforms else: raise TypeError("Transforms should have rank 1 or 2.") # Invert transformations transforms = flat_transforms_to_matrices(transforms=transforms) inverse = linalg_ops.matrix_inverse(transforms) transforms = matrices_to_flat_transforms(inverse) output = gen_image_ops.image_projective_transform_v2( images=grad, transforms=transforms, output_shape=array_ops.shape(image_or_images)[1:3], interpolation=interpolation, fill_mode=fill_mode) return [output, None, None] @ops.RegisterGradient("ImageProjectiveTransformV3") def _image_projective_transform_v3_grad(op, grad): """Computes the gradient for ImageProjectiveTransform.""" images = op.inputs[0] transforms = op.inputs[1] interpolation = op.get_attr("interpolation") fill_mode = op.get_attr("fill_mode") image_or_images = ops.convert_to_tensor(images, name="images") transform_or_transforms = ops.convert_to_tensor( transforms, name="transforms", dtype=dtypes.float32) if image_or_images.dtype.base_dtype not in _IMAGE_DTYPES: raise TypeError("Invalid dtype %s." % image_or_images.dtype) if len(transform_or_transforms.get_shape()) == 1: transforms = transform_or_transforms[None] elif len(transform_or_transforms.get_shape()) == 2: transforms = transform_or_transforms else: raise TypeError("Transforms should have rank 1 or 2.") # Invert transformations transforms = flat_transforms_to_matrices(transforms=transforms) inverse = linalg_ops.matrix_inverse(transforms) transforms = matrices_to_flat_transforms(inverse) output = gen_image_ops.image_projective_transform_v3( images=grad, transforms=transforms, output_shape=array_ops.shape(image_or_images)[1:3], interpolation=interpolation, fill_mode=fill_mode, fill_value=0.0) return [output, None, None, None]
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, 3491, 4156, 14, 199, 199, 1918, 658, 3249, 14, 1569, 64, 859, 3509, 7750, 3423, 367, 1834, 199, 6338, 436, 15952, 13, 2991, 593, 1190, 14, 199, 199, 4089, 402, 314, 2644, 15, 12796, 3423, 787, 2597, 2808, 315, 314, 199, 1018, 658, 3249, 14, 2308, 64, 859, 14, 199, 199, 309, 6047, 6661, 199, 199, 5680, 799, 30639, 199, 199, 1918, 295, 30639, 593, 1190, 4729, 1324, 5935, 465, 10519, 402, 9978, 2943, 14, 9322, 3544, 199, 1199, 295, 15308, 5935, 465, 2069, 708, 10519, 14, 199, 199, 1918, 16777, 805, 658, 3249, 14, 1569, 14, 8709, 64, 5171, 3865, 841, 13, 36, 199, 460, 650, 13, 36, 10519, 465, 1324, 436, 1072, 14, 221, 841, 13, 36, 10519, 787, 367, 19593, 402, 5935, 12, 199, 19, 13, 36, 10519, 367, 8212, 5935, 14, 199, 199, 497, 15308, 5935, 911, 506, 2917, 1376, 340, 3932, 3379, 17435, 10463, 365, 440, 314, 199, 7191, 465, 1568, 14, 4005, 5126, 2917, 18434, 1937, 2833, 14, 1569, 14, 8709, 63, 1045, 63, 6226, 14, 199, 199, 10, 257, 658, 3249, 14, 1569, 14, 8709, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 8709, 63, 1045, 63, 6226, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 8709, 63, 1045, 63, 15816, 63, 269, 63, 6226, 64, 199, 199, 1918, 8089, 658, 3249, 14, 1569, 14, 24559, 3767, 64, 6571, 7750, 15210, 3102, 2839, 199, 64, 66, 382, 1132, 285, 3559, 658, 16615, 63, 13881, 2313, 199, 199, 5680, 23258, 31535, 3109, 3626, 1384, 4285, 199, 199, 3491, 4156, 1736, 1902, 641, 8212, 5935, 503, 641, 19593, 402, 5935, 12, 10298, 641, 199, 1589, 2215, 402, 3932, 1324, 5878, 14, 199, 199, 3917, 650, 13, 36, 12, 314, 2215, 365, 14505, 3333, 12, 3462, 12, 9245, 61, 3559, 436, 314, 5878, 8469, 1373, 199, 1569, 14, 982, 841, 13, 36, 12, 314, 2215, 365, 14505, 2912, 63, 890, 12, 4569, 12, 3462, 12, 9245, 61, 3559, 436, 314, 199, 3861, 8469, 658, 2912, 63, 890, 64, 5935, 14, 199, 199, 31499, 12, 658, 6324, 64, 883, 2997, 590, 506, 413, 12, 499, 12, 650, 12, 503, 841, 14, 13050, 13, 2775, 5935, 787, 199, 12150, 3467, 12, 5935, 543, 650, 9245, 787, 5737, 465, 1902, 19013, 503, 869, 4985, 14, 32658, 199, 1045, 499, 503, 841, 9245, 2387, 376, 5131, 3623, 12, 1314, 965, 370, 506, 14489, 687, 314, 199, 1569, 2544, 9476, 314, 1834, 370, 4750, 1834, 6661, 3423, 334, 460, 883, 506, 199, 264, 13, 17099, 2945, 680, 199, 199, 607, 1203, 1183, 12, 5935, 787, 1902, 5489, 315, 465, 1373, 658, 1609, 708, 64, 1126, 3623, 1126, 7148, 199, 8, 31120, 12, 1338, 787, 10826, 370, 1212, 69, 315, 14505, 16, 12, 17, 9, 10522, 503, 1373, 658, 1635, 24, 64, 1126, 3623, 199, 529, 7148, 334, 1459, 787, 10826, 370, 1212, 69, 315, 14505, 16, 12, 2299, 61, 14963, 199, 199, 26998, 883, 3957, 3382, 5935, 315, 19013, 503, 869, 4985, 503, 1488, 23559, 14, 199, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 12150, 3467, 3559, 658, 3249, 14, 1569, 14, 12150, 3467, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 72, 2772, 3559, 658, 3249, 14, 1569, 14, 72, 2772, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 89, 9962, 3559, 658, 3249, 14, 1569, 14, 89, 9962, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 89, 9154, 3559, 658, 3249, 14, 1569, 14, 89, 9154, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 1569, 63, 13065, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 3916, 63, 1569, 63, 2271, 64, 199, 199, 5680, 6047, 26412, 1470, 199, 199, 26998, 6571, 3423, 370, 11311, 5935, 315, 7750, 15217, 26, 27702, 12, 199, 17926, 270, 12, 28679, 12, 436, 21845, 1542, 14, 221, 7048, 27999, 883, 506, 4224, 543, 27684, 199, 3214, 503, 543, 2196, 2633, 29438, 687, 27684, 15802, 14, 9571, 199, 10917, 1470, 787, 14115, 2997, 370, 6544, 282, 6093, 663, 436, 7114, 1806, 3269, 1337, 14, 199, 199, 3917, 9978, 11311, 1470, 787, 6036, 379, 652, 365, 1503, 5068, 461, 370, 24720, 314, 1329, 402, 199, 581, 17013, 24796, 701, 1642, 13806, 314, 5935, 370, 314, 4750, 19981, 666, 199, 466, 436, 6025, 14, 199, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 22298, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 17926, 270, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 7325, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 25016, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 14230, 63, 9161, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 14997, 1542, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 2355, 63, 22298, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 2355, 63, 17926, 270, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 2355, 63, 25016, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 2355, 63, 14997, 1542, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 529, 63, 1569, 63 ]
[ 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, 3491, 4156, 14, 199, 199, 1918, 658, 3249, 14, 1569, 64, 859, 3509, 7750, 3423, 367, 1834, 199, 6338, 436, 15952, 13, 2991, 593, 1190, 14, 199, 199, 4089, 402, 314, 2644, 15, 12796, 3423, 787, 2597, 2808, 315, 314, 199, 1018, 658, 3249, 14, 2308, 64, 859, 14, 199, 199, 309, 6047, 6661, 199, 199, 5680, 799, 30639, 199, 199, 1918, 295, 30639, 593, 1190, 4729, 1324, 5935, 465, 10519, 402, 9978, 2943, 14, 9322, 3544, 199, 1199, 295, 15308, 5935, 465, 2069, 708, 10519, 14, 199, 199, 1918, 16777, 805, 658, 3249, 14, 1569, 14, 8709, 64, 5171, 3865, 841, 13, 36, 199, 460, 650, 13, 36, 10519, 465, 1324, 436, 1072, 14, 221, 841, 13, 36, 10519, 787, 367, 19593, 402, 5935, 12, 199, 19, 13, 36, 10519, 367, 8212, 5935, 14, 199, 199, 497, 15308, 5935, 911, 506, 2917, 1376, 340, 3932, 3379, 17435, 10463, 365, 440, 314, 199, 7191, 465, 1568, 14, 4005, 5126, 2917, 18434, 1937, 2833, 14, 1569, 14, 8709, 63, 1045, 63, 6226, 14, 199, 199, 10, 257, 658, 3249, 14, 1569, 14, 8709, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 8709, 63, 1045, 63, 6226, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 8709, 63, 1045, 63, 15816, 63, 269, 63, 6226, 64, 199, 199, 1918, 8089, 658, 3249, 14, 1569, 14, 24559, 3767, 64, 6571, 7750, 15210, 3102, 2839, 199, 64, 66, 382, 1132, 285, 3559, 658, 16615, 63, 13881, 2313, 199, 199, 5680, 23258, 31535, 3109, 3626, 1384, 4285, 199, 199, 3491, 4156, 1736, 1902, 641, 8212, 5935, 503, 641, 19593, 402, 5935, 12, 10298, 641, 199, 1589, 2215, 402, 3932, 1324, 5878, 14, 199, 199, 3917, 650, 13, 36, 12, 314, 2215, 365, 14505, 3333, 12, 3462, 12, 9245, 61, 3559, 436, 314, 5878, 8469, 1373, 199, 1569, 14, 982, 841, 13, 36, 12, 314, 2215, 365, 14505, 2912, 63, 890, 12, 4569, 12, 3462, 12, 9245, 61, 3559, 436, 314, 199, 3861, 8469, 658, 2912, 63, 890, 64, 5935, 14, 199, 199, 31499, 12, 658, 6324, 64, 883, 2997, 590, 506, 413, 12, 499, 12, 650, 12, 503, 841, 14, 13050, 13, 2775, 5935, 787, 199, 12150, 3467, 12, 5935, 543, 650, 9245, 787, 5737, 465, 1902, 19013, 503, 869, 4985, 14, 32658, 199, 1045, 499, 503, 841, 9245, 2387, 376, 5131, 3623, 12, 1314, 965, 370, 506, 14489, 687, 314, 199, 1569, 2544, 9476, 314, 1834, 370, 4750, 1834, 6661, 3423, 334, 460, 883, 506, 199, 264, 13, 17099, 2945, 680, 199, 199, 607, 1203, 1183, 12, 5935, 787, 1902, 5489, 315, 465, 1373, 658, 1609, 708, 64, 1126, 3623, 1126, 7148, 199, 8, 31120, 12, 1338, 787, 10826, 370, 1212, 69, 315, 14505, 16, 12, 17, 9, 10522, 503, 1373, 658, 1635, 24, 64, 1126, 3623, 199, 529, 7148, 334, 1459, 787, 10826, 370, 1212, 69, 315, 14505, 16, 12, 2299, 61, 14963, 199, 199, 26998, 883, 3957, 3382, 5935, 315, 19013, 503, 869, 4985, 503, 1488, 23559, 14, 199, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 12150, 3467, 3559, 658, 3249, 14, 1569, 14, 12150, 3467, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 72, 2772, 3559, 658, 3249, 14, 1569, 14, 72, 2772, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 89, 9962, 3559, 658, 3249, 14, 1569, 14, 89, 9962, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10090, 63, 475, 63, 89, 9154, 3559, 658, 3249, 14, 1569, 14, 89, 9154, 63, 475, 63, 10090, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 1569, 63, 13065, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 3916, 63, 1569, 63, 2271, 64, 199, 199, 5680, 6047, 26412, 1470, 199, 199, 26998, 6571, 3423, 370, 11311, 5935, 315, 7750, 15217, 26, 27702, 12, 199, 17926, 270, 12, 28679, 12, 436, 21845, 1542, 14, 221, 7048, 27999, 883, 506, 4224, 543, 27684, 199, 3214, 503, 543, 2196, 2633, 29438, 687, 27684, 15802, 14, 9571, 199, 10917, 1470, 787, 14115, 2997, 370, 6544, 282, 6093, 663, 436, 7114, 1806, 3269, 1337, 14, 199, 199, 3917, 9978, 11311, 1470, 787, 6036, 379, 652, 365, 1503, 5068, 461, 370, 24720, 314, 1329, 402, 199, 581, 17013, 24796, 701, 1642, 13806, 314, 5935, 370, 314, 4750, 19981, 666, 199, 466, 436, 6025, 14, 199, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 22298, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 17926, 270, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 7325, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 25016, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 14230, 63, 9161, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 10917, 63, 14997, 1542, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 2355, 63, 22298, 64, 199, 10, 257, 658, 3249, 14, 1569, 14, 2355, 63, 17926, 270, 64, 199, 10, 257, 658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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 ]
incaser/server-tools
database_cleanup/model/purge_models.py
31
6248
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # This module copyright (C) 2014 Therp BV (<http://therp.nl>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import orm, fields from openerp.tools.translate import _ from openerp.addons.base.ir.ir_model import MODULE_UNINSTALL_FLAG class IrModel(orm.Model): _inherit = 'ir.model' def _drop_table(self, cr, uid, ids, context=None): # Allow to skip this step during model unlink # The super method crashes if the model cannot be instantiated if context and context.get('no_drop_table'): return True return super(IrModel, self)._drop_table(cr, uid, ids, context=context) def _inherited_models(self, cr, uid, ids, field_name, arg, context=None): """this function crashes for undefined models""" result = dict((i, []) for i in ids) existing_model_ids = [ this.id for this in self.browse(cr, uid, ids, context=context) if self.pool.get(this.model) ] super_result = super(IrModel, self)._inherited_models( cr, uid, existing_model_ids, field_name, arg, context=context) result.update(super_result) return result def _register_hook(self, cr): # patch the function field instead of overwriting it if self._columns['inherited_model_ids']._fnct !=\ self._inherited_models.__func__: self._columns['inherited_model_ids']._fnct =\ self._inherited_models.__func__ return super(IrModel, self)._register_hook(cr) class CleanupPurgeLineModel(orm.TransientModel): _inherit = 'cleanup.purge.line' _name = 'cleanup.purge.line.model' _columns = { 'wizard_id': fields.many2one( 'cleanup.purge.wizard.model', 'Purge Wizard', readonly=True), } def purge(self, cr, uid, ids, context=None): """ Unlink models upon manual confirmation. """ model_pool = self.pool['ir.model'] attachment_pool = self.pool['ir.attachment'] constraint_pool = self.pool['ir.model.constraint'] fields_pool = self.pool['ir.model.fields'] relation_pool = self.pool['ir.model.relation'] local_context = (context or {}).copy() local_context.update({ MODULE_UNINSTALL_FLAG: True, 'no_drop_table': True, }) for line in self.browse(cr, uid, ids, context=context): cr.execute( "SELECT id, model from ir_model WHERE model = %s", (line.name,)) row = cr.fetchone() if row: self.logger.info('Purging model %s', row[1]) attachment_ids = attachment_pool.search( cr, uid, [('res_model', '=', line.name)], context=context) if attachment_ids: cr.execute( "UPDATE ir_attachment SET res_model = FALSE " "WHERE id in %s", (tuple(attachment_ids), )) constraint_ids = constraint_pool.search( cr, uid, [('model', '=', line.name)], context=context) if constraint_ids: constraint_pool.unlink( cr, uid, constraint_ids, context=context) relation_ids = fields_pool.search( cr, uid, [('relation', '=', row[1])], context=context) for relation in relation_ids: try: # Fails if the model on the target side # cannot be instantiated fields_pool.unlink(cr, uid, [relation], context=local_context) except KeyError: pass except AttributeError: pass relation_ids = relation_pool.search( cr, uid, [('model', '=', line.name)], context=context) for relation in relation_ids: relation_pool.unlink(cr, uid, [relation], context=local_context) model_pool.unlink(cr, uid, [row[0]], context=local_context) line.write({'purged': True}) cr.commit() return True class CleanupPurgeWizardModel(orm.TransientModel): _inherit = 'cleanup.purge.wizard' _name = 'cleanup.purge.wizard.model' def default_get(self, cr, uid, fields, context=None): res = super(CleanupPurgeWizardModel, self).default_get( cr, uid, fields, context=context) if 'name' in fields: res['name'] = _('Purge models') return res def find(self, cr, uid, context=None): """ Search for models that cannot be instantiated. """ res = [] cr.execute("SELECT model from ir_model") for (model,) in cr.fetchall(): if not self.pool.get(model): res.append((0, 0, {'name': model})) if not res: raise orm.except_orm( _('Nothing to do'), _('No orphaned models found')) return res _columns = { 'purge_line_ids': fields.one2many( 'cleanup.purge.line.model', 'wizard_id', 'Models to purge'), }
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, 961, 859, 4248, 334, 35, 9, 6927, 377, 2523, 80, 699, 54, 8642, 1014, 921, 728, 80, 14, 7530, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 5166, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 492, 30223, 63, 1734, 16811, 63, 3719, 421, 199, 533, 473, 82, 1685, 8, 1025, 14, 1685, 304, 272, 485, 6486, 275, 283, 723, 14, 1238, 7, 339, 347, 485, 4824, 63, 1224, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 327, 9812, 370, 3372, 642, 3650, 5309, 1402, 17002, 267, 327, 710, 1613, 1083, 2467, 9030, 340, 314, 1402, 3913, 506, 17544, 267, 340, 1067, 436, 1067, 14, 362, 360, 889, 63, 4824, 63, 1224, 735, 288, 372, 715, 267, 372, 1613, 8, 32602, 1685, 12, 291, 10445, 4824, 63, 1224, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 339, 347, 485, 17571, 63, 992, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 403, 304, 267, 408, 3749, 805, 2467, 9030, 367, 10942, 1709, 624, 267, 754, 275, 1211, 1332, 73, 12, 3073, 367, 284, 315, 2762, 9, 267, 3411, 63, 1238, 63, 1580, 275, 359, 288, 642, 14, 344, 367, 642, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 288, 340, 291, 14, 2293, 14, 362, 8, 3749, 14, 1238, 9, 267, 1622, 267, 1613, 63, 1099, 275, 1613, 8, 32602, 1685, 12, 291, 10445, 17571, 63, 992, 8, 288, 2467, 12, 1747, 12, 3411, 63, 1238, 63, 1580, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 1100, 9, 267, 754, 14, 873, 8, 4792, 63, 1099, 9, 267, 372, 754, 339, 347, 485, 2683, 63, 3664, 8, 277, 12, 2467, 304, 267, 327, 3371, 314, 805, 901, 3140, 402, 32592, 652, 267, 340, 291, 423, 3406, 459, 17571, 63, 1238, 63, 1580, 26099, 2324, 319, 1137, 60, 355, 291, 423, 17571, 63, 992, 855, 1532, 10651, 288, 291, 423, 3406, 459, 17571, 63, 1238, 63, 1580, 26099, 2324, 319, 26447, 355, 291, 423, 17571, 63, 992, 855, 1532, 363, 267, 372, 1613, 8, 32602, 1685, 12, 291, 10445, 2683, 63, 3664, 8, 1556, 9, 421, 199, 533, 30022, 14959, 303, 3049, 1685, 8, 1025, 14, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 7661, 14, 18254, 14, 604, 7, 272, 485, 354, 275, 283, 7661, 14, 18254, 14, 604, 14, 1238, 7, 339, 485, 3406, 275, 469, 267, 283, 9819, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 7661, 14, 18254, 14, 9819, 14, 1238, 297, 283, 14959, 303, 644, 6281, 297, 6863, 29, 549, 395, 267, 789, 339, 347, 18503, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 1910, 1073, 1709, 12188, 8722, 18791, 14, 267, 408, 267, 1402, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 418, 267, 12193, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 8905, 418, 267, 5828, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 5631, 418, 267, 1504, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 955, 418, 267, 5850, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 5690, 418, 398, 2257, 63, 1100, 275, 334, 1100, 503, 13056, 1574, 342, 267, 2257, 63, 1100, 14, 873, 2561, 288, 30223, 63, 1734, 16811, 63, 3719, 26, 715, 12, 288, 283, 889, 63, 4824, 63, 1224, 356, 715, 12, 288, 3828, 398, 367, 1004, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 2467, 14, 2526, 8, 355, 298, 4859, 1305, 12, 1402, 687, 8190, 63, 1238, 6038, 1402, 275, 450, 83, 401, 355, 334, 604, 14, 354, 4641, 288, 1962, 275, 2467, 14, 11591, 342, 288, 340, 1962, 26, 355, 291, 14, 2921, 14, 815, 360, 14959, 1540, 1402, 450, 83, 297, 1962, 59, 17, 566, 355, 12193, 63, 1580, 275, 12193, 63, 2293, 14, 1733, 8, 490, 2467, 12, 1747, 12, 4274, 470, 63, 1238, 297, 6291, 1004, 14, 354, 4360, 1067, 29, 1100, 9, 355, 340, 12193, 63, 1580, 26, 490, 2467, 14, 2526, 8, 717, 298, 10383, 8190, 63, 8905, 11543, 522, 63, 1238, 275, 481, 17361, 298, 717, 298, 17688, 1305, 315, 450, 83, 401, 717, 334, 2960, 8, 8905, 63, 1580, 395, 5082, 355, 5828, 63, 1580, 275, 5828, 63, 2293, 14, 1733, 8, 490, 2467, 12, 1747, 12, 4274, 1238, 297, 6291, 1004, 14, 354, 4360, 1067, 29, 1100, 9, 355, 340, 5828, 63, 1580, 26, 490, 5828, 63, 2293, 14, 7162, 8, 717, 2467, 12, 1747, 12, 5828, 63, 1580, 12, 1067, 29, 1100, 9, 355, 5850, 63, 1580, 275, 1504, 63, 2293, 14, 1733, 8, 490, 2467, 12, 1747, 12, 4274, 5690, 297, 6291, 1962, 59, 17, 27520, 1067, 29, 1100, 9, 355, 367, 5850 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 961, 859, 4248, 334, 35, 9, 6927, 377, 2523, 80, 699, 54, 8642, 1014, 921, 728, 80, 14, 7530, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9813, 12, 1504, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 5166, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 492, 30223, 63, 1734, 16811, 63, 3719, 421, 199, 533, 473, 82, 1685, 8, 1025, 14, 1685, 304, 272, 485, 6486, 275, 283, 723, 14, 1238, 7, 339, 347, 485, 4824, 63, 1224, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 327, 9812, 370, 3372, 642, 3650, 5309, 1402, 17002, 267, 327, 710, 1613, 1083, 2467, 9030, 340, 314, 1402, 3913, 506, 17544, 267, 340, 1067, 436, 1067, 14, 362, 360, 889, 63, 4824, 63, 1224, 735, 288, 372, 715, 267, 372, 1613, 8, 32602, 1685, 12, 291, 10445, 4824, 63, 1224, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 339, 347, 485, 17571, 63, 992, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 403, 304, 267, 408, 3749, 805, 2467, 9030, 367, 10942, 1709, 624, 267, 754, 275, 1211, 1332, 73, 12, 3073, 367, 284, 315, 2762, 9, 267, 3411, 63, 1238, 63, 1580, 275, 359, 288, 642, 14, 344, 367, 642, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 288, 340, 291, 14, 2293, 14, 362, 8, 3749, 14, 1238, 9, 267, 1622, 267, 1613, 63, 1099, 275, 1613, 8, 32602, 1685, 12, 291, 10445, 17571, 63, 992, 8, 288, 2467, 12, 1747, 12, 3411, 63, 1238, 63, 1580, 12, 901, 63, 354, 12, 1680, 12, 1067, 29, 1100, 9, 267, 754, 14, 873, 8, 4792, 63, 1099, 9, 267, 372, 754, 339, 347, 485, 2683, 63, 3664, 8, 277, 12, 2467, 304, 267, 327, 3371, 314, 805, 901, 3140, 402, 32592, 652, 267, 340, 291, 423, 3406, 459, 17571, 63, 1238, 63, 1580, 26099, 2324, 319, 1137, 60, 355, 291, 423, 17571, 63, 992, 855, 1532, 10651, 288, 291, 423, 3406, 459, 17571, 63, 1238, 63, 1580, 26099, 2324, 319, 26447, 355, 291, 423, 17571, 63, 992, 855, 1532, 363, 267, 372, 1613, 8, 32602, 1685, 12, 291, 10445, 2683, 63, 3664, 8, 1556, 9, 421, 199, 533, 30022, 14959, 303, 3049, 1685, 8, 1025, 14, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 7661, 14, 18254, 14, 604, 7, 272, 485, 354, 275, 283, 7661, 14, 18254, 14, 604, 14, 1238, 7, 339, 485, 3406, 275, 469, 267, 283, 9819, 63, 344, 356, 1504, 14, 3479, 18, 368, 8, 288, 283, 7661, 14, 18254, 14, 9819, 14, 1238, 297, 283, 14959, 303, 644, 6281, 297, 6863, 29, 549, 395, 267, 789, 339, 347, 18503, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 1910, 1073, 1709, 12188, 8722, 18791, 14, 267, 408, 267, 1402, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 418, 267, 12193, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 8905, 418, 267, 5828, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 5631, 418, 267, 1504, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 955, 418, 267, 5850, 63, 2293, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 5690, 418, 398, 2257, 63, 1100, 275, 334, 1100, 503, 13056, 1574, 342, 267, 2257, 63, 1100, 14, 873, 2561, 288, 30223, 63, 1734, 16811, 63, 3719, 26, 715, 12, 288, 283, 889, 63, 4824, 63, 1224, 356, 715, 12, 288, 3828, 398, 367, 1004, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 2467, 14, 2526, 8, 355, 298, 4859, 1305, 12, 1402, 687, 8190, 63, 1238, 6038, 1402, 275, 450, 83, 401, 355, 334, 604, 14, 354, 4641, 288, 1962, 275, 2467, 14, 11591, 342, 288, 340, 1962, 26, 355, 291, 14, 2921, 14, 815, 360, 14959, 1540, 1402, 450, 83, 297, 1962, 59, 17, 566, 355, 12193, 63, 1580, 275, 12193, 63, 2293, 14, 1733, 8, 490, 2467, 12, 1747, 12, 4274, 470, 63, 1238, 297, 6291, 1004, 14, 354, 4360, 1067, 29, 1100, 9, 355, 340, 12193, 63, 1580, 26, 490, 2467, 14, 2526, 8, 717, 298, 10383, 8190, 63, 8905, 11543, 522, 63, 1238, 275, 481, 17361, 298, 717, 298, 17688, 1305, 315, 450, 83, 401, 717, 334, 2960, 8, 8905, 63, 1580, 395, 5082, 355, 5828, 63, 1580, 275, 5828, 63, 2293, 14, 1733, 8, 490, 2467, 12, 1747, 12, 4274, 1238, 297, 6291, 1004, 14, 354, 4360, 1067, 29, 1100, 9, 355, 340, 5828, 63, 1580, 26, 490, 5828, 63, 2293, 14, 7162, 8, 717, 2467, 12, 1747, 12, 5828, 63, 1580, 12, 1067, 29, 1100, 9, 355, 5850, 63, 1580, 275, 1504, 63, 2293, 14, 1733, 8, 490, 2467, 12, 1747, 12, 4274, 5690, 297, 6291, 1962, 59, 17, 27520, 1067, 29, 1100, 9, 355, 367, 5850, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Remillard/VHDL-Mode
vhdl_lang.py
1
62003
# pylint: disable=C0103, C0111 """ -------------------------------------------------------------------------------- VHDL Language Module. Defines class structures and methods for identifying and manipulating text structures, and extracting and replicating lexical elements. -------------------------------------------------------------------------------- """ import re import collections import copy import sublime import ruamel.yaml _debug = False # ------------------------------------------------------------------------------ def debug(string): """ Some of these functions ended up with a lot of debug output for analyzing processing. I needed a way to turn it on and off. """ if _debug: print(string) # ------------------------------------------------------------------------------ def check_for_comment(line): """ Simple method that will return False if a line does not begin with a comment, otherwise True. Mainly used for disabling alignment. """ pattern = r'^\s*--' p = re.compile(pattern, re.IGNORECASE) s = re.search(p, line) return bool(s) # ------------------------------------------------------------------------------ class Parentheses(): ''' An object whose purpose is to keep track of parenthesis counts and provide helper functions while traversing a text file. May be initialized with a two element list indicating the starting counts if needed. open_cnt and close_cnt represent the current number of unmatched open and closing parentheses. open_pos and close_pos represent the character position of the UNMATCHED open and closing parentheses in the last scanned string. ''' def __init__(self, counts=[0, 0]): self.open_cnt = counts[0] self.close_cnt = counts[1] self.open_pos = [] self.close_pos = [] @property def delta(self): return self.open_cnt - self.close_cnt @property def balanced(self): return bool(self.open_cnt == self.close_cnt) def reset(self): self.__init__() def scan(self, line): # Reset the position lists. self.open_pos = [] self.close_pos = [] for i in range(len(line)): if line[i] == '(': # If we find a ( then increment the count and append the # position. self.open_cnt += 1 self.open_pos.append(i) elif line[i] == ')': # If we find a ) there are several options. # If open_pos has members, pop off the mate. Also decrement # the count. # If open_cnt > 0 then decrement the count of the prior # unmatched open. # If open_cnt = 0 then increment the closing count and # append the position. if self.open_pos: self.open_cnt -= 1 self.open_pos.pop() elif self.open_cnt > 0: self.open_cnt -= 1 else: self.close_pos.append(i) self.close_cnt += 1 def stats(self): return '#(={}, #)={}, OPos={}, CPos={}'.format(self.open_cnt, self.close_cnt, self.open_pos, self.close_pos) def extract(self, line): '''Given a string, extracts the contents of the next parenthetical grouping (including interior parenthetical groups.)''' start = 0 end = 0 pcount = 0 for i in range(len(line)): if line[i] == '(' and pcount == 0: pcount += 1 start = i + 1 elif line[i] == '(': pcount += 1 if line[i] == ')' and pcount > 1: pcount -= 1 elif line[i] == ')' and pcount == 1: end = i pcount -= 1 break if start >= end: return None else: return line[start:end] def first_close(self, line): """Given a string, returns a boolean if the first character is a closing paren which is useful for identifying end of group conditions.""" m = re.match(r'\s*\)', line) if m: return True return False # ------------------------------------------------------------------------------ class CodeLine(): """ The CodeLine object encapsulates a number of methods used to manipulate a string of code. * Masking methods block off portions of the string in order not to trigger any regular expression hits in strings or comments. * Left Justify removes space at the beginning of the line, prelude to indentation efforts. * Padding symbols is done to ensure spaces around symbols which aids pattern matching. Only done for symbols we intend to align vertically. * Removing extra space (except in strings and comments) is done to prep the line for alignment. WARNING: When using CodeLine masking, should always mask strings before comments simply because the regexp for comments gets triggerred when the pattern is in a string. """ def __init__(self, line): self.line = line self.matches = [] self.index = 0 def mask_strings(self): matches = re.finditer(r'(\".*?\")', self.line) for m in matches: x, y = m.start(), m.end() pattern = '$%02d' % self.index + 'x'*(y-x-3) self.line = self.line.replace(m.group(0), pattern) self.matches.append([pattern, m.group(0)]) self.index = self.index + 1 def mask_comments(self): matches = re.finditer(r'(--.*)', self.line) for m in matches: x, y = m.start(), m.end() pattern = '$%02d' % self.index + 'x'*(y-x-3) self.line = self.line.replace(m.group(0), pattern) self.matches.append([pattern, m.group(0)]) self.index = self.index + 1 def restore(self): # Reversing the order of matches for the case of nested masks for pattern, original in reversed(self.matches): self.line = self.line.replace(pattern, original) self.matches = [] self.index = 0 def left_justify(self): self.line = re.sub(r'^\s*', '', self.line) def pad_vhdl_symbols(self): self.line = re.sub(':(?!=)', ' : ', self.line) self.line = re.sub(':=', ' := ', self.line) self.line = re.sub('<=', ' <= ', self.line) self.line = re.sub('=>', ' => ', self.line) self.line = re.sub(';', '; ', self.line) def remove_spaces(self): self.line = re.sub(r'\s+', ' ', self.line) self.line = re.sub(r'\t', ' ', self.line) self.line = re.sub(r'\s*$', '', self.line) @property def is_full_comment(self): return bool(re.search(r'^\s*(--.*)', self.line, re.I)) @property def has_inline_comment(self): # Masking strings so we don't get a false positive for the pattern # inside a string literal. self.mask_strings() s = re.search(r'^\s*(?!--)\S+.*(--.*)', self.line, re.I) self.restore() return bool(s) # ------------------------------------------------------------------------------ class CodeBlock(): """ The CodeBlock is a way of encapsulating the CodeLine functions and contains whole region or block manipulations for the code. ] CodeBlock receives a list of lines nominally and turns them into a list of CodeLines. Another factory constructor permits receiving a block of text with embedded newlines from which it will then extract the lines and construct the list of CodeLines. There is also an append method for incrementally generating this block. CodeBlock similarly provides methods for returning the CodeLines via a list of lines or a block of text. CodeBlock provides methods for manipulating the lines of code in various ways (justifying, aligning, indenting, etc.) """ def __init__(self, lines=None): """ Fundamental constructor from a list of lines. """ self.code_lines = [] if lines is not None: for line in lines: self.code_lines.append(CodeLine(line)) @classmethod def from_block(cls, block): """ Constructor from a block of text. """ lines = block.split('\n') return cls(lines) def to_list(self): """ Returns a list of lines. """ lines = [] for cl in self.code_lines: lines.append(cl.line) return lines def to_block(self): """ Returns the code in a block of text. """ lines = [] for cl in self.code_lines: lines.append(cl.line) return '\n'.join(lines) def append(self, line): """ Adds a single line to the list of CodeLines. """ self.code_lines.append(CodeLine(line)) def prep(self): """ This method automates a lot of the initial preparatory work with spacing and padding. """ for cl in self.code_lines: cl.mask_comments() cl.mask_strings() cl.pad_vhdl_symbols() cl.remove_spaces() cl.restore() def left_justify(self): """ This method left justifies an entire block. """ for cl in self.code_lines: cl.left_justify() def status(self): for cl in self.code_lines: debug('{}'.format(cl.line)) def align_symbol(self, expr, side='pre', scope_data=None, casewhen=False): """ This is a in-class rework of the original align block on regular expression function. The same parameters exist except it doesn't need to pass the entire block of lines because that's integral to the class members. Additionally the method no longer takes the ignore comment lines parameter because there will be a specialized method for aligning comments later. Prepares each line by masking out comments and quotes first. Scans each line for the provided regular expression pattern that should align with subsequent lines. Once the pattern is found, pushes the location onto a stack and continues to the next line. When a line is identified that breaks the chain, go back through the stack and identify the rightmost position, and then pad. There exists a parameter to pad afterwards as there is one case where we want to look for port modes and pad afterwards to align the type. There exist some lines we don't even want to monkey with because the symbols tend to conflict (conditional signals in if/thens, case choice lines, etc.) Note, the casewhen option is because the reuse of the assignment operator means the usual pattern of aligning symbols left to right doesn't work very well. So When casewhen is False, it'll ignore lines that we believe are case when clauses. Then casewhen is True, it'll ignore everything that ISN'T a case when clause. """ ignored_expr = [ r':\s+process\b', # don't remember why I ignore this one r'\bif\b', # ignore if statement conditional symbols r'\bthen\b', # ignore if statement conditional symbols r'\belsif\b' # ignore if statement conditional symbols ] casewhen_expr = r'^\s*when\b(?=.*?=>)' # Initializing variables prior_scope = "" match_data = [] # Iterating over lines of code now. Using enumerate to aid detection # of the last item in the list. for idx, cl in enumerate(self.code_lines): # Prep work cl.mask_strings() cl.mask_comments() # Check for a number of items that will trigger # Checking for the last line in the list. last_line = False if idx == len(self.code_lines)-1: last_line = True # Checking for lines we want to ignore ignored = False casewhen_search = re.search(casewhen_expr, cl.line, re.I) if (casewhen_search and not casewhen) or (not casewhen_search and casewhen) : ignored = True for pattern in ignored_expr: ignore_search = re.search(pattern, cl.line, re.I) if ignore_search: ignored = True # Checking for a change of scope on a line which will alter the # context of the symbol being searched for and should not be # aligned. This is for a particular special case that I don't # recall. scope_switch = False if scope_data is not None: if scope_data[idx] != prior_scope: scope_switch = True prior_scope = scope_data[idx] # Search for the alignment pattern and then restore the masked # strings. match = re.search(expr, cl.line, re.I) cl.restore() # If this line has a expression match and isn't an ignored line and # is in the same scope context, add it to the list. if match and not ignored and not scope_switch: # If we find a match, record the line and position if side == 'post': match_data.append((cl, match.end())) else: match_data.append((cl, match.start())) # Trigger the adjustment on past stored lines. if not match or scope_switch or last_line or ignored: if len(match_data) > 1: # Scan for the rightmost (maximum) position value and check # to see if extra space needed due to lack of preceding # space. maxpos = 0 for mcl, pos in match_data: if pos > maxpos: maxpos = pos if mcl.line[pos-1] != ' ': maxpos = maxpos + 1 # Adjust the spacial padding in the line. for mcl, pos in match_data: mcl.line = mcl.line[0:pos] + ' '*(maxpos-pos) + mcl.line[pos:] match_data = [] # Case that there was a match in a new scope context must be # added to the list after the previous batch was processed. if match and scope_switch: if side == 'post': match_data.append((cl, match.end())) else: match_data.append((cl, match.start())) def indent_vhdl(self, initial=0, tab_size=4, use_spaces=False): """ This method scans the list of code lines and processes them according to the rules laid out in the beautification rules (YAML format). This iteration of the method is based around being a member of the CodeBlock class and uses CodeBlock and CodeLine methods where appropriate. """ # Import beautification rules from YAML file yaml = ruamel.yaml.YAML() yaml.version = (1, 2) rules_str = sublime.load_resource('Packages/VHDL Mode/Syntax/beautify_rules.yaml') rules_blob = yaml.load(rules_str) key_list = rules_blob['key_list'] open_rules = rules_blob['open_rules'] close_rules = rules_blob['close_rules'] # Setup initial state with indentation and the running parenthesis # count. # closing_stack is using deque() and the elements are: # 0: The key name matched # 1: The current indent level. # Since it's used as a stack, we're always referencing element 0 (top) current_indent = next_indent = initial parens = Parentheses() closing_stack = collections.deque() unbalance_flag = False # Set the indent to tabs or spaces here according to parameter passed if use_spaces: indent_char = ' '*tab_size else: indent_char = '\t' # Scan lines for idx, cl in enumerate(self.code_lines): # Prep line for scanning and avoiding matches in comments and # strings. debug('{}: ci={} ni={} : {}'.format(idx, current_indent, next_indent, cl.line)) cl.mask_strings() cl.mask_comments() ############################################################ # Modification Rules # Priority 1: Keywords for key in key_list: skip_match = False rule = open_rules[key] key_search = re.search(rule['pattern'], cl.line, re.I) if key_search: debug('{}: Evaluation line: {}'.format(idx, cl.line)) debug('{}: Evaluation pattern: {}'.format(idx, rule['pattern'])) debug('{}: Type: {}'.format(idx, key)) debug('{}: Ignore Rules: {}'.format(idx, rule['ignore_rules'])) if rule['ignore_rules'] is not None: for ignore_rule in rule['ignore_rules']: if len(closing_stack) > 0 and ignore_rule == closing_stack[0][0]: skip_match = True if not skip_match: # If an ending type is noted, push the key onto the # stack. Save the current indent, and the current parenthetical # state as well. if rule['close_rule'] is not None: closing_stack.appendleft([key, current_indent, copy.copy(parens)]) # Apply the current and next indent values to # the current values. current_indent += rule['indent_rule'][0] next_indent += rule['indent_rule'][1] break # Priority 2: Unbalanced Parenthesis # Unbalanced parenthesis rules. The line where an unbalanced paren # begins is not modified, however for every line after that while # we are unbalanced, indent one additional level to the current # line (but not the next because we don't want to keep incrementing # outwards.) When balance is restored, reset the flag. # Adding a special check if the paren is the first non-whitespace # character on the line. In that case, we don't usually want to # preserve the indent (this is the whole reason around the 'solo # flag') parens.scan(cl.line) debug('{}: Parens After Scan {}'.format(idx, parens.stats())) if unbalance_flag: if not parens.first_close(cl.line): debug('{}: Unbalanced parenthesis indenting.'.format(idx)) current_indent += 1 else: debug('{}: Solo ) Back indent.'.format(idx)) unbalance_flag = not parens.balanced # Special: Closing Item Reset # Scan the line for ending key if one exists. If parentheses are # balanced and then ending key has been found then reset the # current and next indent level to this state. The evaluate flag # is used because a branching lexical structure was discovered and # the line needs to be rescanned. if len(closing_stack): eval_line = True while eval_line: debug('{}: Closing stack depth={} top={} indent={} parens={}'.format(idx, len(closing_stack), closing_stack[0][0], closing_stack[0][1], closing_stack[0][2].stats())) # Assume that we will traverse only once, and set the flag # to false. If we need to rescan, the flag will be set # true. eval_line = False # Since the closing rule pattern could be multiple patterns, # we have to scan through that item, referencing into the # close_rules dictionary for the pattern. Assigning the # rule list to another name to stop the madness of # indirection. stack_key, stack_indent, stack_parens = closing_stack[0] rules = open_rules[stack_key]['close_rule'] # Step through and search for the end pattern. for close_key, result in rules: debug('{}: Evaluation line: {}'.format(idx, cl.line)) debug('{}: Evaluation pattern: {}'.format(idx, close_rules[close_key])) close_search = re.search(close_rules[close_key], cl.line, re.I) if close_search and parens.delta == stack_parens.delta: # We've found a match and are in a balanced state. debug('{}: Found closing match to {}'.format(idx, stack_key)) if result is not None: # We have found a continuation of the structure. # Pop off the top of the stack, then append the new # key to the top of the stack and re-evaluate. debug('{}: Continuation found. Re-evaluating for {}'.format(idx, result)) closing_stack.popleft() closing_stack.appendleft([result, stack_indent, stack_parens]) # Need to do a solo line check, mainly for those is clauses. if open_rules[result]['solo_flag']: solo_search = re.search(r'^\)?\s?'+close_rules[close_key], cl.line, re.I) if solo_search: # Unindent this line most likely debug('{}: Solo intermediate found.'.format(idx)) current_indent += open_rules[result]['start_offset'] eval_line = True else: # This is the endpoint of the structure. # Behavior changes based on the solo flag if open_rules[stack_key]['solo_flag']: # Solo flag rules means we only apply the closing # rule to the current line if the symbol is alone # on a line, otherwise we apply the closing rule # to the following line. # Scan the line again to check for the beginning # of the line variation. (Small alteration to # check for an paren in the case of endclauses # that might not have the built-in paren) debug('{}: Using solo line rule.'.format(idx)) solo_search = re.search(r'^\)?\s?'+close_rules[close_key], cl.line, re.I) if solo_search: # Revert on this line debug('{}: Solo closing found here.'.format(idx)) current_indent = stack_indent + open_rules[stack_key]['close_offset'] next_indent = stack_indent else: debug('{}: Close is not alone on this line.'.format(idx)) # Revert on the next line next_indent = stack_indent else: debug('{}: Regular ending rule.'.format(idx)) # No special rule handling. Revert on this line. current_indent = next_indent = stack_indent # Pop the top of the stack and we're done with evaluating # closing strings. closing_stack.popleft() # Modify the line here. cl.line = indent_char*current_indent + cl.line cl.line = re.sub(r'\s*$', '', cl.line) cl.restore() debug('{}: ci={} ni={} : {} \n'.format(idx, current_indent, next_indent, cl.line)) # Set current for next line. current_indent = next_indent def align_comments(self, tab_size=4, use_spaces=False): """ Comments are a little different from normal alignment and identation. 1. Full comment lines should be aligned, however they should be indented to the level of the next code line, not the previous which is what happens with the indent_vhdl routine. This is most notable with case/when code regions where a comment preceding a 'when' will be indented at the level of the previous when block. Thus full comment lines should be aligned after regular indentation is complete. The method assumes that the calling code has already completed indent_vhdl. The indentation will be accomplished by copying the text between the aligning line back into the comment lines, so space/tab alignment is preserved. Also this way I don't need to know what the indent level actually is, just using what's there already. 2. Inline comment lines cannot be aligned with symbol alignment because I mask off comments. So in addition to aligning these, we'd like continuation comment lines (which might be full comment lines) to maintain the same position as the previous until non full comment line occurs. The indentation will be accomplished with spaces. There's no way to do this otherwise. However for the inline comments, I attempt to take tabs into account for spacing. To accomplish both of these, instituting a couple of properties on the CodeLine class that determine if a line is a full comment line or if a line has an inline comment. Between these, we should be able to scan a CodeBlock and adjust the indentation of comment lines. """ # Pass one, full line comments match_data = [] for idx, cl in enumerate(self.code_lines): if cl.is_full_comment: match_data.append(cl) else: # Look for the first non blank line to align comments with. bls = re.search(r'^\s*$', cl.line, re.I) nbls = re.search(r'^(\s*)\S', cl.line, re.I) if bls: # Do nothing and keep text at current indent level. match_data = [] elif nbls: # If we've got a set of lines to align, process the match. if match_data: for mcl in match_data: mcl.left_justify() mcl.line = nbls.group(1) + mcl.line match_data = [] # Pass two, inline comments. This is actually closer to the original # alignment method since I record position as well. match_data = [] for idx, cl in enumerate(self.code_lines): if cl.has_inline_comment or cl.is_full_comment: s = re.search(r'^.*?(--.*)', cl.line, re.I) if match_data: match_data.append((cl, s.start(1))) elif cl.has_inline_comment: match_data.append((cl, s.start(1))) else: # Process matches if there's more than one. if len(match_data) > 1: maxpos = 0 for mcl, pos in match_data: tab_count = mcl.line.count('\t') adj_pos = pos + tab_count*(tab_size-1) if adj_pos > maxpos: maxpos = adj_pos if mcl.line[pos-1] != ' ': maxpos = maxpos + 1 for mcl, pos in match_data: tab_count = mcl.line.count('\t') adj_pos = pos + tab_count*(tab_size-1) mcl.line = mcl.line[0:pos] + ' '*(maxpos-adj_pos) + mcl.line[pos:] match_data = [] # ------------------------------------------------------------------------------ class Port(): """ This is the class of ports and ways to manipulate ports. A port consists of a name (string), a mode (optional) (string), and a type (string). """ def __init__(self, port_str): self.name = "" self.mode = "" self.type = "" self.success = False self.parse_str(port_str) def parse_str(self, port_str): """Searches a string for the port fields.""" port_pattern = r'\s?(?P<name>.*?)\s?(?::)\s?(?P<mode>in\b|out\b|inout\b|buffer\b)?\s?(?P<type>.*)' pp = re.compile(port_pattern, re.IGNORECASE) s = re.search(pp, port_str) if s: self.name = s.group('name') self.mode = s.group('mode') # Sometimes the type has a trailing space. Eliminating it. self.type = re.sub(r'\s*$', '', s.group('type')) self.success = True else: print('vhdl-mode: Could not parse port string.') self.success = False def print_as_signal(self): """Returns a string with the port formatted for a signal.""" # Trailing semicolon provided by calling routine. line = 'signal {} : {}'.format(self.name, self.type) return line def print_as_portmap(self): """Returns a string with the port formatted as a portmap.""" # A port name might be a comma separated list which # needs to be split into several lines. # Remove any spaces. compact = re.sub(r'\s', '', self.name) # Split at commas names = compact.split(',') lines = [] for name in names: lines.append('{} => {}'.format(name, name)) # This is a departure from the other "print as" methods as # it returns a list instead of a string. return lines def print_as_port(self): """Returns a string with the port formatted as a port.""" # Trailing semicolon provided by calling routine. line = '{} : {} {}'.format(self.name, self.mode, self.type) return line # ------------------------------------------------------------------------------ class Generic(): """ This is the class of generics and ways to manipulate them. A generic consists of a name (string), a type (string), and a default value (string). """ def __init__(self, gen_str): self.gentype = False self.name = "" self.type = "" self.success = False self.parse_str(gen_str) def parse_str(self, gen_str): """Attempts to extract the information from a generic interface.""" # Right now I'm going to punt. There are so many variations # on these that it's difficult to write a RE for it. Also # there are few ways to have to rewrite it. We will extract # a name, and then a type string (which may include defaults) # # VHDL 2008 defines the capability to declare a generic type. To # support this, I created the gentype attribute. I'll use the name # attribute to carry the type's name, however since this isn't a # declaration WITH a type, that attribute will not be used. gentype_pattern = r'\s*type\s+(?P<name>\w+)' gps = re.search(gentype_pattern, gen_str, re.I) if gps: self.gentype = True self.name = gps.group('name') self.success = True return True constant_pattern = r'\s?(?P<name>.*?)\s?(?::)\s?(?P<type>.*)' s = re.search(constant_pattern, gen_str, re.I) if s: self.name = s.group('name') # Sometimes the type has a trailing space. Eliminating it. self.type = re.sub(r'\s*$', '', s.group('type')) self.success = True return True else: print('vhdl-mode: Could not parse generic string.') self.success = False return False def print_as_generic(self): """Returns a string with the generic interface as a generic.""" if self.gentype: line = 'type {}'.format(self.name) else: line = '{} : {}'.format(self.name, self.type) return line def print_as_genmap(self): """Returns a string with the generic interface as a generic map.""" line = '{} => {}'.format(self.name, self.name) return line def print_as_constant(self): '''Returns a string with the generic interface as a constant.''' # So... generic doesn't necessarily have to have a default value # even though it should. So this requires a little detective work # to know whether to include the whole line or add in the necessary # constant definition. # # Technically using VHDL-2008 generic type isn't a constant, but for # the moment, I'm going to include it here and just adjust the # testbench template. if self.gentype: line = 'type {}'.format(self.name) else: s = re.search(r':=', self.type, re.I) if s: line = 'constant {} : {}'.format(self.name, self.type) else: line = 'constant {} : {} := <value>'.format(self.name, self.type) return line # ------------------------------------------------------------------------------ class Parameter(): """ This is the class of subprogram parameters. Might ultimately replace even Port and Generic as the pattern has improved since starting the package. """ def __init__(self, param_str): self.storage = "" self.identifier = "" self.mode = "" self.type = "" self.expression = "" self.success = False self.parse_str(param_str) def parse_str(self, param_str): """Better regexp should be able to extract everything!""" regex = r"^\s*((?P<storage>constant|signal|variable|file)\s*)?((?P<name>.*?)\s*)(?::\s*)((?P<mode>inout\b|in\b|out\b|buffer\b)\s*)?((?P<type>.*?)\s*)((?:\:\=)\s*(?P<expression>.*?)\s*)?$" s = re.search(regex, param_str) if s: if s.group('storage'): self.storage = s.group('storage') self.identifier = s.group('name') if s.group('mode'): self.mode = s.group('mode') self.type = s.group('type') if s.group('expression'): self.expression = s.group('expression') self.success = True else: print('vhdl-mode: Could not parse parameter string.') self.success = False def print_formal(self): """Lots of optional parameters, needs to be build up gradually.""" string = "" if self.storage: string = string + '{} '.format(self.storage) string = string + '{} : '.format(self.identifier) if self.mode: string = string + '{} '.format(self.mode) string = string + '{}'.format(self.type) if self.expression: string = string + ' := {}'.format(self.expression) return string def print_call(self): """Super easy transform.""" string = '{} => {}'.format(self.identifier, self.identifier) return string # ------------------------------------------------------------------------------ class Interface(): """ The Interface class contains the essential elements to a VHDL interface structure as defined by an entity or component declaration. In addition, it comprises the methods used to extract the structural elements from strings passed to it from the Sublime Text API routines, and to produce string variations on these structures so that the structure can be transformed in various ways. """ def __init__(self): self.name = "" self.type = "" self.if_string = "" self.if_ports = [] self.if_generics = [] def interface_start(self, line): """Attempts to identify the start of an interface.""" # Checks for both entity or component starting lines head_pattern = r"(?P<type>entity|component)\s*(?P<name>\w*)\s*(?:is)" p = re.compile(head_pattern, re.IGNORECASE) s = re.search(p, line) if s: # Note, it's returning the horizontal position which # is different from the "startpoint" class variable # above which is the position in the file. self.type = s.group('type') self.name = s.group('name') return s.start() else: return None def interface_end(self, line): """Attempts to identify the end of an interface.""" # Checks to see if the line passed contains the # end string matching the starting type. The # type and name are optional technically. tail_pattern = r"(?:end)\s*(?:{})?\s*(?:{})?\s*;".format(self.type, self.name) p = re.compile(tail_pattern, re.IGNORECASE) s = re.search(p, line) if s: # The end point (from experimentation) seems to # be the index AFTER the final character, so # subtracting 1 here for the return value. return s.end() else: return None def strip_comments(self): """Removes comments from the interface to aid parsing.""" # Comments will likely screw up the parsing of the # block and we don't need to copy them, so strip them out # TODO : Handle block comments someday. p = re.compile(r"(?:--).*?(\n|$)") self.if_string = re.sub(p, r"\n", self.if_string) def strip_whitespace(self): """Removes extra whitespace to aid parsing.""" # Making sure I don't have to deal with newlines while # parsing. Changing all whitespace to a single space. # This is required due to rules regarding port modes # which might conflict with type names. p = re.compile(r"\s+") self.if_string = re.sub(p, " ", self.if_string) def parse_generic_port(self): """Attempts to break the interface into known generic and port sections and then calls individual parsing routines.""" # Initialize things. self.if_ports = [] self.if_generics = [] # Now checking for the existence of generic and port zones. # Split into generic string and port strings and then parse # each separately. Standard demands generic first, then port. gen_pattern = re.compile(r'generic\s*\(', re.I) port_pattern = re.compile(r'port\s*\(', re.I) gen_search = re.search(gen_pattern, self.if_string) port_search = re.search(port_pattern, self.if_string) # The potential for a passive block in an entity means the previous # method of extracting the port string will no longer work and the # more tedious (though foolproof) method of searching forward from # the port starting point is necessary. if port_search: port_str = Parentheses().extract(self.if_string[port_search.start():]) if port_str is not None: port_list = port_str.split(';') for item in port_list: port = Port(item) if port.success: self.if_ports.append(port) else: print('vhdl-mode: No ports found.') port_str = "" else: print('vhdl-mode: No ports found.') port_str = "" if gen_search: gen_str = Parentheses().extract(self.if_string[gen_search.start():]) if gen_str is not None: gen_list = gen_str.split(';') for item in gen_list: generic = Generic(item) if generic.success: self.if_generics.append(generic) else: print('vhdl-mode: No generics found.') gen_str = "" else: print('vhdl-mode: No generics found.') gen_str = "" def parse_block(self): """Top level routine for extracting information out of a string block believed to contain a VHDL interface.""" # This contains the whole parsing routine in a single method # because the calling command method doesn't need to know # about it. self.strip_comments() self.strip_whitespace() self.parse_generic_port() def signals(self): """ This method returns a string that consists of the interface listed as signals """ lines = [] # Construct structure and insert if self.if_ports: for port in self.if_ports: lines.append(port.print_as_signal() + ';') cb = CodeBlock(lines) cb.align_symbol(r':(?!=)', 'pre', None) cb.align_symbol(r'<|:(?==)', 'pre', None) cb.indent_vhdl(1) return cb.to_block() else: return None def constants(self): ''' This method returns the generic portion of the interface listed as constants. ''' lines = [] if self.if_generics: for generic in self.if_generics: lines.append(generic.print_as_constant() + ';') cb = CodeBlock(lines) cb.align_symbol(r':', 'pre', None) cb.align_symbol(r':=', 'pre', None) cb.indent_vhdl(1) return cb.to_block() else: return None def instance(self, instances={}, name=""): """This method returns a string that consists of the interface listed as an instantiation """ # Choose a name based on a given (for testbench use) or # regular instantiation. if name: inst_name = name elif self.name in instances: instance_count = len(instances[self.name]) inst_name = self.name+'_{}'.format(instance_count+1) # Check for duplicate name and just increment index until clear. while inst_name in instances[self.name]: instance_count += 1 inst_name = self.name+'_{}'.format(instance_count+1) else: inst_name = self.name+'_1' lines = [] lines.append("{} : entity work.{}".format(inst_name, self.name)) if self.if_generics: lines.append("generic map (") # Put the generics in here. Join with , and a temp # character then split at the temp character. That # should create the lines with semicolons on all but # the last. gen_strings = [] for generic in self.if_generics: gen_strings.append(generic.print_as_genmap()) gen_strings = ',^'.join(gen_strings).split('^') for gen_str in gen_strings: lines.append(gen_str) lines.append(")") if self.if_ports: lines.append("port map (") # Put the ports in here. Same as before. port_strings = [] for port in self.if_ports: # Print as portmap returns a list unlike others for mapping in port.print_as_portmap(): port_strings.append(mapping) port_strings = ',^'.join(port_strings).split('^') for port_str in port_strings: lines.append(port_str) lines.append(");") cb = CodeBlock(lines) cb.align_symbol(r'\=\>', 'pre', None) cb.indent_vhdl(1) return cb.to_block() def component(self): """ Returns a string with a formatted component variation of the interface.3 """ # Construct structure lines = [] lines.append("component {} is".format(self.name)) if self.if_generics: lines.append("generic (") # Put the generics in here. Join with ; and a temp # character then split at the temp character. That # should create the lines with semicolons on all but # the last. gen_strings = [] for generic in self.if_generics: gen_strings.append(generic.print_as_generic()) gen_strings = ';^'.join(gen_strings).split('^') for gen_str in gen_strings: lines.append(gen_str) lines.append(");") if self.if_ports: lines.append("port (") # Put the ports in here. Same as before. port_strings = [] for port in self.if_ports: port_strings.append(port.print_as_port()) port_strings = ';^'.join(port_strings).split('^') for port_str in port_strings: lines.append(port_str) lines.append(");") lines.append("end component {};".format(self.name)) cb = CodeBlock(lines) cb.align_symbol(r':(?!=)', 'pre', None) cb.align_symbol(r':(?!=)\s?(?:in\b|out\b|inout\b|buffer\b)?\s*', 'post', None) cb.align_symbol(r'<|:(?==)', 'pre', None) cb.indent_vhdl(1) return cb.to_block() def entity(self): """ Returns a string with the interface written as an entity declaration. """ # Construct structure lines = [] lines.append("entity {} is".format(self.name)) if self.if_generics: lines.append("generic (") # Put the generics in here. Join with ; and a temp # character then split at the temp character. That # should create the lines with semicolons on all but # the last. gen_strings = [] for generic in self.if_generics: gen_strings.append(generic.print_as_generic()) gen_strings = ';^'.join(gen_strings).split('^') for gen_str in gen_strings: lines.append(gen_str) lines.append(");") if self.if_ports: lines.append("port (") # Put the ports in here. Same as before. port_strings = [] for port in self.if_ports: port_strings.append(port.print_as_port()) port_strings = ';^'.join(port_strings).split('^') for port_str in port_strings: lines.append(port_str) lines.append(");") lines.append("end entity {};".format(self.name)) cb = CodeBlock(lines) cb.align_symbol(r':(?!=)', 'pre', None) cb.align_symbol(r':(?!=)\s?(?:in\b|out\b|inout\b|buffer\b)?\s*', 'post', None) cb.align_symbol(r'<|:(?==)', 'pre', None) cb.indent_vhdl(0) return cb.to_block() def flatten(self): ''' Iterates over the generics and ports and if there is a line with multiple token names on the same line, will make copies of that port with the individual token names. ''' if self.if_generics: new_generics = [] for generic in self.if_generics: if ',' in generic.name: name_list = re.sub(r'\s*,\s*', ',', generic.name).split(',') for name in name_list: new_generic = copy.copy(generic) new_generic.name = name new_generics.append(new_generic) else: new_generics.append(generic) self.if_generics = new_generics if self.if_ports: new_ports = [] for port in self.if_ports: if ',' in port.name: name_list = re.sub(r'\s*,\s*', ',', port.name).split(',') for name in name_list: new_port = copy.copy(port) new_port.name = name new_ports.append(new_port) else: new_ports.append(port) self.if_ports = new_ports def reverse(self): ''' Iterates over the ports and flips the direction/mode. in becomes out out and buffer become in inout is unchanged. ''' if self.if_ports: for port in self.if_ports: if port.mode.lower() == 'in': port.mode = 'out' elif port.mode.lower() == 'out' or port.mode.lower() == 'buffer': port.mode = 'in' # ------------------------------------------------------------------------------ class Subprogram(): """ Class that contains information about a VHDL subprogram declaration and methods to enable rewriting it in some fashion. """ def __init__(self): self.name = "" self.type = "" self.purity = "" self.if_string = "" self.if_params = [] self.if_generics = [] self.if_return = "" self.paren_count = [0, 0] def reset(self): """Subprograms need a reset simply because there's a lot of optional things that change from copy to copy. In the entity/component world, it's a lot more uniform.""" self.name = "" self.type = "" self.purity = "" self.if_string = "" self.if_params = [] self.if_generics = [] self.if_return = "" self.parens = Parentheses() def subprogram_start(self, line): """Attempts to identify the start of a subprogram specification.""" # Resetting the paren count here in case we end up calling this # entire command multiple times. Finding the end depends on it. head_pattern = r"((?P<purity>impure|pure)\s+)?(?P<type>procedure|function)\s+(?P<name>\w*)" s = re.search(head_pattern, line, re.I) if s: if s.group('purity'): self.purity = s.group('purity') self.type = s.group('type') self.name = s.group('name') self.parens.reset() return s.start() else: return None def subprogram_end(self, line): """Attempts to identify the end of the subprogram specification. This is somewhat trickier than finding the end of an entity or component simply because there's no end clause. A procedure specification block ends on a semicolon in the case of the prototype, and ends on 'is' in the case of a declaration. A function ends on return <type>; or return <type> is. Due to the procedure semicolon ending (which will get also used in the parameters) we have to match and count parens and only validate a tail when all parens are balanced.""" # Patterns to check. proc_tail_pattern = r";|is" func_tail_pattern = r"return\s+(?P<rtype>.*?)\s*(;|is)" # Find our parenthesis state. self.parens.scan(line) # If we are unbalanced, then there's nothing to do and return. Otherwise # use the last paren location to trim the line and perform the search. if self.parens.balanced: if self.parens.close_pos: new_line = line[self.parens.close_pos[-1]:] offset = self.parens.close_pos[-1] else: new_line = line offset = 0 if self.type.lower() == 'function': s = re.search(func_tail_pattern, new_line, re.I) if s: self.if_return = s.group('rtype') return s.end() + offset else: return None elif self.type.lower() == 'procedure': s = re.search(proc_tail_pattern, new_line, re.I) if s: return s.end() + offset else: return None else: return None else: return None def parse_block(self): """Chops up the string and extracts the internal declarations.""" # Remove comments, newlines, and compress spaces. self.if_string = re.sub(r'--.*?(\n|$)', r'\n', self.if_string) self.if_string = re.sub(r'\n', r'', self.if_string) self.if_string = re.sub(r'\s+', r' ', self.if_string) # Strip return clause if a function. if self.type == 'function': func_tail_pattern = r"return\s+(?P<rtype>.*?)\s*(;|is)" s = re.search(func_tail_pattern, self.if_string, re.I) self.if_string = self.if_string[:s.start()] # Extract parameter block. start, stop = None, None for i in range(len(self.if_string)): if self.if_string[i] == '(' and not start: start = i+1 if self.if_string[-i] == ')' and not stop: stop = -i if start and stop: break if start and stop: self.if_string = self.if_string[start:stop] param_list = self.if_string.split(';') for param_str in param_list: param = Parameter(param_str) if param.success: self.if_params.append(param) else: print('vhdl-mode: No subprogram parameters found.') def print(self): """For debug""" print('Purity: {}'.format(self.purity)) print('SP Type: {}'.format(self.type)) print('SP Name: {}'.format(self.name)) print('Params: {}'.format(self.if_params)) print('Return: {}'.format(self.if_return)) def declaration(self): """Constructs a subprogram declaration from the currently copied subprogram. Again there are many optional things so construction is piece by piece. Going to format in K&R style. """ lines = [] if self.type == 'function': if self.if_params: if self.purity: lines.append('{} {} {} ('.format(self.purity, self.type, self.name)) else: lines.append('{} {} ('.format(self.type, self.name)) param_strings = [] for param in self.if_params: param_strings.append(param.print_formal()) param_strings = ';^'.join(param_strings).split('^') for param_str in param_strings: lines.append(param_str) lines.append(') return {};'.format(self.if_return)) else: if self.purity: lines.append('{} {} {} return {};'.format(self.purity, self.type, self.name, self.rtype)) else: lines.append('{} {} return {};'.format(self.type, self.name, self.if_return)) else: # Procedure if self.if_params: lines.append('{} {} ('.format(self.type, self.name)) param_strings = [] for param in self.if_params: param_strings.append(param.print_formal()) param_strings = ';^'.join(param_strings).split('^') for param_str in param_strings: lines.append(param_str) lines.append(');') else: lines.append('{} {};'.format(self.type, self.name)) cb = CodeBlock(lines) cb.align_symbol(r':(?!=)', 'pre', None) cb.align_symbol(r':(?!=)\s?(?:in\b|out\b|inout\b|buffer\b)?\s*', 'post', None) cb.align_symbol(r'<|:(?==)', 'pre', None) cb.indent_vhdl(1) return cb.to_block() def body(self): """Constructs a subprogram body from the currently copied subprogram. Again there are many optional things so construction is piece by piece. Going to format in K&R style. """ lines = [] if self.type == 'function': if self.if_params: if self.purity: lines.append('{} {} {} ('.format(self.purity, self.type, self.name)) else: lines.append('{} {} ('.format(self.type, self.name)) param_strings = [] for param in self.if_params: param_strings.append(param.print_formal()) param_strings = ';^'.join(param_strings).split('^') for param_str in param_strings: lines.append(param_str) lines.append(') return {} is'.format(self.if_return)) else: if self.purity: lines.append('{} {} {} return {} is'.format(self.purity, self.type, self.name, self.rtype)) else: lines.append('{} {} return {} is'.format(self.type, self.name, self.if_return)) else: # Procedure if self.if_params: lines.append('{} {} ('.format(self.type, self.name)) param_strings = [] for param in self.if_params: param_strings.append(param.print_formal()) param_strings = ';^'.join(param_strings).split('^') for param_str in param_strings: lines.append(param_str) lines.append(') is') else: lines.append('{} {} is'.format(self.type, self.name)) lines.append('begin') lines.append(' ') lines.append('end {} {};'.format(self.type, self.name)) cb = CodeBlock(lines) cb.align_symbol(r':(?!=)', 'pre', None) cb.align_symbol(r':(?!=)\s?(?:in\b|out\b|inout\b|buffer\b)?\s*', 'post', None) cb.align_symbol(r'<|:(?==)', 'pre', None) cb.indent_vhdl(1) return cb.to_block() def call(self): """Constructs a subprogram call. Much simpler than the declaration.""" lines = [] param_strings = [] if self.if_params: lines.append('{} ('.format(self.name)) for param in self.if_params: param_strings.append(param.print_call()) param_strings = ',^'.join(param_strings).split('^') for param_str in param_strings: lines.append(param_str) lines.append(');') else: lines.append('{};'.format(self.name)) cb = CodeBlock(lines) cb.align_symbol(r'\=\>', 'pre', None) cb.indent_vhdl(1) return cb.to_block() def flatten(self): new_params = [] if self.if_params: for param in self.if_params: if ',' in param.identifier: name_list = re.sub(r'\s*,\s*', ',', param.identifier).split(',') for name in name_list: new_param = copy.copy(param) new_param.identifier = name new_params.append(new_param) else: new_params.append(param) self.if_params = new_params
mit
[ 3, 4287, 26, 3507, 29, 35, 28399, 12, 445, 28107, 202, 199, 624, 202, 199, 3606, 777, 1223, 812, 40, 8045, 8466, 5673, 14, 10060, 25022, 1021, 13955, 436, 3102, 367, 21119, 436, 1223, 13335, 20529, 1318, 13955, 12, 436, 30137, 436, 1833, 606, 1958, 1223, 7103, 2652, 4008, 14, 202, 199, 3606, 777, 202, 199, 624, 202, 199, 646, 295, 202, 199, 646, 5055, 202, 199, 646, 1331, 202, 199, 646, 1007, 18687, 202, 199, 646, 519, 85, 14868, 14, 5963, 2999, 199, 63, 1757, 275, 756, 8065, 199, 3, 5620, 10965, 202, 199, 318, 3105, 8, 875, 304, 1128, 408, 1128, 6601, 402, 3520, 3423, 22480, 1536, 543, 282, 13918, 402, 3105, 1072, 367, 5909, 20135, 1128, 6661, 14, 221, 473, 4346, 282, 4340, 370, 7485, 652, 641, 436, 2331, 14, 1128, 408, 1128, 340, 485, 1757, 26, 1039, 870, 8, 875, 9, 8065, 199, 3, 5620, 10965, 202, 199, 318, 1104, 63, 509, 63, 3349, 8, 604, 304, 1128, 408, 1128, 5870, 1083, 626, 911, 372, 756, 340, 282, 1004, 1630, 440, 1128, 5386, 543, 282, 3721, 12, 4257, 715, 14, 221, 11298, 590, 1202, 367, 1128, 30723, 13177, 14, 1128, 408, 1128, 3851, 275, 519, 15542, 83, 10, 306, 7, 1128, 299, 275, 295, 14, 2014, 8, 3401, 12, 295, 14, 15434, 9, 1128, 308, 275, 295, 14, 1733, 8, 80, 12, 1004, 9, 1128, 372, 2155, 8, 83, 9, 8065, 199, 3, 5620, 10965, 202, 199, 533, 10164, 828, 15528, 837, 1128, 1449, 1128, 1626, 909, 7447, 12016, 365, 370, 4215, 4426, 402, 32002, 8242, 1128, 436, 5647, 5922, 3423, 1830, 1468, 422, 1044, 282, 1318, 570, 14, 2958, 10162, 506, 10038, 543, 282, 2877, 1819, 769, 9297, 314, 6617, 1128, 8242, 340, 4346, 14, 2958, 1551, 63, 6507, 436, 4002, 63, 6507, 2954, 314, 1453, 1329, 402, 625, 10151, 1128, 1551, 436, 11261, 23592, 14, 2958, 1551, 63, 1712, 436, 4002, 63, 1712, 2954, 314, 4528, 3421, 402, 314, 6778, 14747, 1149, 1128, 1551, 436, 11261, 23592, 315, 314, 2061, 28261, 1059, 14, 1128, 1449, 1128, 347, 636, 826, 721, 277, 12, 8242, 1524, 16, 12, 378, 4682, 1039, 291, 14, 1490, 63, 6507, 275, 8242, 59, 16, 61, 1039, 291, 14, 1600, 63, 6507, 275, 8242, 59, 17, 61, 1039, 291, 14, 1490, 63, 1712, 275, 942, 1039, 291, 14, 1600, 63, 1712, 275, 942, 2958, 768, 1829, 1128, 347, 5762, 8, 277, 304, 1039, 372, 291, 14, 1490, 63, 6507, 446, 291, 14, 1600, 63, 6507, 2958, 768, 1829, 1128, 347, 14094, 68, 8, 277, 304, 1039, 372, 2155, 8, 277, 14, 1490, 63, 6507, 508, 291, 14, 1600, 63, 6507, 9, 2958, 347, 5305, 8, 277, 304, 1039, 291, 855, 826, 4533, 2958, 347, 8000, 8, 277, 12, 1004, 304, 1039, 327, 15510, 314, 3421, 5548, 14, 1039, 291, 14, 1490, 63, 1712, 275, 942, 1039, 291, 14, 1600, 63, 1712, 275, 942, 1039, 367, 284, 315, 1425, 8, 552, 8, 604, 2298, 1675, 340, 1004, 59, 73, 61, 508, 283, 6176, 2628, 327, 982, 781, 2342, 282, 334, 2066, 11609, 314, 2338, 436, 5666, 314, 2628, 327, 3421, 14, 2628, 291, 14, 1490, 63, 6507, 847, 413, 2628, 291, 14, 1490, 63, 1712, 14, 740, 8, 73, 9, 1675, 916, 1004, 59, 73, 61, 508, 5320, 356, 2628, 327, 982, 781, 2342, 282, 776, 2337, 787, 9978, 1511, 14, 2628, 327, 982, 1551, 63, 1712, 965, 7556, 12, 4560, 2331, 314, 333, 323, 14, 221, 6121, 477, 4062, 2628, 327, 314, 2338, 14, 2628, 327, 982, 1551, 63, 6507, 690, 378, 2066, 477, 4062, 314, 2338, 402, 314, 6791, 2628, 327, 625, 10151, 1551, 14, 2628, 327, 982, 1551, 63, 6507, 275, 378, 2066, 11609, 314, 11261, 2338, 436, 2628, 327, 5666, 314, 3421, 14, 2628, 340, 291, 14, 1490, 63, 1712, 26, 4906, 291, 14, 1490, 63, 6507, 4862, 413, 4906, 291, 14, 1490, 63, 1712, 14, 1935, 342, 2628, 916, 291, 14, 1490, 63, 6507, 690, 378, 26, 4906, 291, 14, 1490, 63, 6507, 4862, 413, 2628, 587, 26, 4906, 291, 14, 1600, 63, 1712, 14, 740, 8, 73, 9, 4906, 291, 14, 1600, 63, 6507, 847, 413, 2958, 347, 5020, 8, 277, 304, 1039, 372, 3943, 8, 10324, 327, 9, 10324, 593, 6981, 10324, 445, 6981, 27244, 908, 8, 277, 14, 1490, 63, 6507, 12, 1675, 291, 14, 1600, 63, 6507, 12, 291, 14, 1490, 63, 1712, 12, 291, 14, 1600, 63, 1712, 9, 2958, 347, 5536, 8, 277, 12, 1004, 304, 1039, 1449, 13735, 282, 1059, 12, 5536, 83, 314, 4072, 402, 314, 2163, 13566, 1589, 3294, 1039, 17786, 334, 15768, 4661, 17942, 13566, 1589, 3294, 4652, 4959, 2344, 1039, 1343, 275, 378, 1039, 1284, 275, 378, 1039, 299, 835, 275, 378, 1039, 367, 284, 315, 1425, 8, 552, 8, 604, 2298, 1675, 340, 1004, 59, 73, 61, 508, 16746, 436, 299, 835, 508, 378, 26, 2628, 299, 835, 847, 413, 2628, 1343, 275, 284, 435, 413, 1675, 916, 1004, 59, 73, 61, 508, 283, 6176, 2628, 299, 835, 847, 413, 11556, 340, 1004, 59, 73, 61, 508, 16107, 436, 299, 835, 690, 413, 26, 2628, 299, 835, 4862, 413, 1675, 916, 1004, 59, 73, 61, 508, 16107, 436, 299, 835, 508, 413, 26, 2628, 1284, 275, 284, 2628, 299, 835, 4862, 413, 2628, 2059, 1039, 340, 1343, 2356, 1284, 26, 1675, 372, 488, 1039, 587, 26, 1675, 372, 1004, 59, 928, 26, 500, 61, 2958, 347, 1642, 63, 1600, 8, 277, 12, 1004, 304, 1039, 408, 13735, 282, 1059, 12, 2529, 282, 5046, 340, 314, 1642, 4528, 1039, 365, 282, 11261, 13566, 1314, 365, 2997, 367, 21119, 1284, 402, 1039, 1572, 3704, 1041, 1039, 333, 275, 295, 14, 1431, 8, 82, 1154, 83, 7590, 3196, 1004, 9, 1039, 340, 333, 26, 1675, 372, 715, 1039, 372, 756, 2999, 199, 3, 5620, 10965, 202, 199, 533, 5495, 3049, 837, 1128, 408, 1128, 710, 5495, 3049, 909, 22667, 15409, 282, 1329, 402, 3102, 1202, 370, 27232, 282, 1128, 1059, 402, 1233, 14, 1128, 627, 17581, 316, 3102, 1853, 2331, 12468, 402, 314, 1059, 315, 1865, 440, 370, 6804, 8608, 1263, 5578, 3965, 19745, 315, 3326, 503, 6786, 14, 1128, 627, 29350 ]
[ 4287, 26, 3507, 29, 35, 28399, 12, 445, 28107, 202, 199, 624, 202, 199, 3606, 777, 1223, 812, 40, 8045, 8466, 5673, 14, 10060, 25022, 1021, 13955, 436, 3102, 367, 21119, 436, 1223, 13335, 20529, 1318, 13955, 12, 436, 30137, 436, 1833, 606, 1958, 1223, 7103, 2652, 4008, 14, 202, 199, 3606, 777, 202, 199, 624, 202, 199, 646, 295, 202, 199, 646, 5055, 202, 199, 646, 1331, 202, 199, 646, 1007, 18687, 202, 199, 646, 519, 85, 14868, 14, 5963, 2999, 199, 63, 1757, 275, 756, 8065, 199, 3, 5620, 10965, 202, 199, 318, 3105, 8, 875, 304, 1128, 408, 1128, 6601, 402, 3520, 3423, 22480, 1536, 543, 282, 13918, 402, 3105, 1072, 367, 5909, 20135, 1128, 6661, 14, 221, 473, 4346, 282, 4340, 370, 7485, 652, 641, 436, 2331, 14, 1128, 408, 1128, 340, 485, 1757, 26, 1039, 870, 8, 875, 9, 8065, 199, 3, 5620, 10965, 202, 199, 318, 1104, 63, 509, 63, 3349, 8, 604, 304, 1128, 408, 1128, 5870, 1083, 626, 911, 372, 756, 340, 282, 1004, 1630, 440, 1128, 5386, 543, 282, 3721, 12, 4257, 715, 14, 221, 11298, 590, 1202, 367, 1128, 30723, 13177, 14, 1128, 408, 1128, 3851, 275, 519, 15542, 83, 10, 306, 7, 1128, 299, 275, 295, 14, 2014, 8, 3401, 12, 295, 14, 15434, 9, 1128, 308, 275, 295, 14, 1733, 8, 80, 12, 1004, 9, 1128, 372, 2155, 8, 83, 9, 8065, 199, 3, 5620, 10965, 202, 199, 533, 10164, 828, 15528, 837, 1128, 1449, 1128, 1626, 909, 7447, 12016, 365, 370, 4215, 4426, 402, 32002, 8242, 1128, 436, 5647, 5922, 3423, 1830, 1468, 422, 1044, 282, 1318, 570, 14, 2958, 10162, 506, 10038, 543, 282, 2877, 1819, 769, 9297, 314, 6617, 1128, 8242, 340, 4346, 14, 2958, 1551, 63, 6507, 436, 4002, 63, 6507, 2954, 314, 1453, 1329, 402, 625, 10151, 1128, 1551, 436, 11261, 23592, 14, 2958, 1551, 63, 1712, 436, 4002, 63, 1712, 2954, 314, 4528, 3421, 402, 314, 6778, 14747, 1149, 1128, 1551, 436, 11261, 23592, 315, 314, 2061, 28261, 1059, 14, 1128, 1449, 1128, 347, 636, 826, 721, 277, 12, 8242, 1524, 16, 12, 378, 4682, 1039, 291, 14, 1490, 63, 6507, 275, 8242, 59, 16, 61, 1039, 291, 14, 1600, 63, 6507, 275, 8242, 59, 17, 61, 1039, 291, 14, 1490, 63, 1712, 275, 942, 1039, 291, 14, 1600, 63, 1712, 275, 942, 2958, 768, 1829, 1128, 347, 5762, 8, 277, 304, 1039, 372, 291, 14, 1490, 63, 6507, 446, 291, 14, 1600, 63, 6507, 2958, 768, 1829, 1128, 347, 14094, 68, 8, 277, 304, 1039, 372, 2155, 8, 277, 14, 1490, 63, 6507, 508, 291, 14, 1600, 63, 6507, 9, 2958, 347, 5305, 8, 277, 304, 1039, 291, 855, 826, 4533, 2958, 347, 8000, 8, 277, 12, 1004, 304, 1039, 327, 15510, 314, 3421, 5548, 14, 1039, 291, 14, 1490, 63, 1712, 275, 942, 1039, 291, 14, 1600, 63, 1712, 275, 942, 1039, 367, 284, 315, 1425, 8, 552, 8, 604, 2298, 1675, 340, 1004, 59, 73, 61, 508, 283, 6176, 2628, 327, 982, 781, 2342, 282, 334, 2066, 11609, 314, 2338, 436, 5666, 314, 2628, 327, 3421, 14, 2628, 291, 14, 1490, 63, 6507, 847, 413, 2628, 291, 14, 1490, 63, 1712, 14, 740, 8, 73, 9, 1675, 916, 1004, 59, 73, 61, 508, 5320, 356, 2628, 327, 982, 781, 2342, 282, 776, 2337, 787, 9978, 1511, 14, 2628, 327, 982, 1551, 63, 1712, 965, 7556, 12, 4560, 2331, 314, 333, 323, 14, 221, 6121, 477, 4062, 2628, 327, 314, 2338, 14, 2628, 327, 982, 1551, 63, 6507, 690, 378, 2066, 477, 4062, 314, 2338, 402, 314, 6791, 2628, 327, 625, 10151, 1551, 14, 2628, 327, 982, 1551, 63, 6507, 275, 378, 2066, 11609, 314, 11261, 2338, 436, 2628, 327, 5666, 314, 3421, 14, 2628, 340, 291, 14, 1490, 63, 1712, 26, 4906, 291, 14, 1490, 63, 6507, 4862, 413, 4906, 291, 14, 1490, 63, 1712, 14, 1935, 342, 2628, 916, 291, 14, 1490, 63, 6507, 690, 378, 26, 4906, 291, 14, 1490, 63, 6507, 4862, 413, 2628, 587, 26, 4906, 291, 14, 1600, 63, 1712, 14, 740, 8, 73, 9, 4906, 291, 14, 1600, 63, 6507, 847, 413, 2958, 347, 5020, 8, 277, 304, 1039, 372, 3943, 8, 10324, 327, 9, 10324, 593, 6981, 10324, 445, 6981, 27244, 908, 8, 277, 14, 1490, 63, 6507, 12, 1675, 291, 14, 1600, 63, 6507, 12, 291, 14, 1490, 63, 1712, 12, 291, 14, 1600, 63, 1712, 9, 2958, 347, 5536, 8, 277, 12, 1004, 304, 1039, 1449, 13735, 282, 1059, 12, 5536, 83, 314, 4072, 402, 314, 2163, 13566, 1589, 3294, 1039, 17786, 334, 15768, 4661, 17942, 13566, 1589, 3294, 4652, 4959, 2344, 1039, 1343, 275, 378, 1039, 1284, 275, 378, 1039, 299, 835, 275, 378, 1039, 367, 284, 315, 1425, 8, 552, 8, 604, 2298, 1675, 340, 1004, 59, 73, 61, 508, 16746, 436, 299, 835, 508, 378, 26, 2628, 299, 835, 847, 413, 2628, 1343, 275, 284, 435, 413, 1675, 916, 1004, 59, 73, 61, 508, 283, 6176, 2628, 299, 835, 847, 413, 11556, 340, 1004, 59, 73, 61, 508, 16107, 436, 299, 835, 690, 413, 26, 2628, 299, 835, 4862, 413, 1675, 916, 1004, 59, 73, 61, 508, 16107, 436, 299, 835, 508, 413, 26, 2628, 1284, 275, 284, 2628, 299, 835, 4862, 413, 2628, 2059, 1039, 340, 1343, 2356, 1284, 26, 1675, 372, 488, 1039, 587, 26, 1675, 372, 1004, 59, 928, 26, 500, 61, 2958, 347, 1642, 63, 1600, 8, 277, 12, 1004, 304, 1039, 408, 13735, 282, 1059, 12, 2529, 282, 5046, 340, 314, 1642, 4528, 1039, 365, 282, 11261, 13566, 1314, 365, 2997, 367, 21119, 1284, 402, 1039, 1572, 3704, 1041, 1039, 333, 275, 295, 14, 1431, 8, 82, 1154, 83, 7590, 3196, 1004, 9, 1039, 340, 333, 26, 1675, 372, 715, 1039, 372, 756, 2999, 199, 3, 5620, 10965, 202, 199, 533, 5495, 3049, 837, 1128, 408, 1128, 710, 5495, 3049, 909, 22667, 15409, 282, 1329, 402, 3102, 1202, 370, 27232, 282, 1128, 1059, 402, 1233, 14, 1128, 627, 17581, 316, 3102, 1853, 2331, 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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 ]
cfehring/slack-onnow
requests/packages/chardet/charsetgroupprober.py
2929
3791
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from . import constants import sys from .charsetprober import CharSetProber class CharSetGroupProber(CharSetProber): def __init__(self): CharSetProber.__init__(self) self._mActiveNum = 0 self._mProbers = [] self._mBestGuessProber = None def reset(self): CharSetProber.reset(self) self._mActiveNum = 0 for prober in self._mProbers: if prober: prober.reset() prober.active = True self._mActiveNum += 1 self._mBestGuessProber = None def get_charset_name(self): if not self._mBestGuessProber: self.get_confidence() if not self._mBestGuessProber: return None # self._mBestGuessProber = self._mProbers[0] return self._mBestGuessProber.get_charset_name() def feed(self, aBuf): for prober in self._mProbers: if not prober: continue if not prober.active: continue st = prober.feed(aBuf) if not st: continue if st == constants.eFoundIt: self._mBestGuessProber = prober return self.get_state() elif st == constants.eNotMe: prober.active = False self._mActiveNum -= 1 if self._mActiveNum <= 0: self._mState = constants.eNotMe return self.get_state() return self.get_state() def get_confidence(self): st = self.get_state() if st == constants.eFoundIt: return 0.99 elif st == constants.eNotMe: return 0.01 bestConf = 0.0 self._mBestGuessProber = None for prober in self._mProbers: if not prober: continue if not prober.active: if constants._debug: sys.stderr.write(prober.get_charset_name() + ' not active\n') continue cf = prober.get_confidence() if constants._debug: sys.stderr.write('%s confidence = %s\n' % (prober.get_charset_name(), cf)) if bestConf < cf: bestConf = cf self._mBestGuessProber = prober if not self._mBestGuessProber: return 0.0 return bestConf # else: # self._mBestGuessProber = self._mProbers[0] # return self._mBestGuessProber.get_confidence()
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 221, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 221, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 492, 5262, 199, 646, 984, 199, 504, 1275, 6043, 19903, 492, 31727, 421, 199, 533, 6659, 1084, 2448, 8029, 8, 15159, 304, 272, 347, 636, 826, 721, 277, 304, 267, 31727, 855, 826, 721, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 291, 423, 77, 8029, 83, 275, 942, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 339, 347, 5305, 8, 277, 304, 267, 31727, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 16118, 26, 355, 16118, 14, 3958, 342, 355, 16118, 14, 2682, 275, 715, 355, 291, 423, 77, 7472, 5667, 847, 413, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 288, 291, 14, 362, 63, 13969, 342, 288, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 355, 372, 488, 199, 3, 4483, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 267, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 6043, 63, 354, 342, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 355, 1980, 288, 340, 440, 16118, 14, 2682, 26, 355, 1980, 288, 410, 275, 16118, 14, 3871, 8, 22353, 9, 288, 340, 440, 410, 26, 355, 1980, 288, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 355, 372, 291, 14, 362, 63, 929, 342, 288, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 355, 16118, 14, 2682, 275, 756, 355, 291, 423, 77, 7472, 5667, 4862, 413, 355, 340, 291, 423, 77, 7472, 5667, 2695, 378, 26, 490, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 490, 372, 291, 14, 362, 63, 929, 342, 267, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 410, 275, 291, 14, 362, 63, 929, 342, 267, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 288, 372, 378, 14, 1020, 267, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 288, 372, 378, 14, 614, 267, 5526, 8930, 275, 378, 14, 16, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 355, 1980, 288, 340, 440, 16118, 14, 2682, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 19903, 14, 362, 63, 6043, 63, 354, 342, 3660, 435, 283, 440, 4702, 60, 78, 358, 355, 1980, 288, 3980, 275, 16118, 14, 362, 63, 13969, 342, 288, 340, 5262, 423, 1757, 26, 355, 984, 14, 3083, 14, 952, 3508, 83, 15197, 275, 450, 83, 60, 78, 7, 450, 639, 334, 19903, 14, 362, 63, 6043, 63, 354, 1062, 3980, 430, 288, 340, 5526, 8930, 665, 3980, 26, 355, 5526, 8930, 275, 3980, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 288, 372, 378, 14, 16, 267, 372, 5526, 8930, 199, 3, 263, 587, 26, 199, 3, 3322, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 199, 3, 3322, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 13969, 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 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 17728, 13338, 707, 1890, 1233, 14, 199, 3, 221, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 221, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 492, 5262, 199, 646, 984, 199, 504, 1275, 6043, 19903, 492, 31727, 421, 199, 533, 6659, 1084, 2448, 8029, 8, 15159, 304, 272, 347, 636, 826, 721, 277, 304, 267, 31727, 855, 826, 721, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 291, 423, 77, 8029, 83, 275, 942, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 339, 347, 5305, 8, 277, 304, 267, 31727, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 7472, 5667, 275, 378, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 16118, 26, 355, 16118, 14, 3958, 342, 355, 16118, 14, 2682, 275, 715, 355, 291, 423, 77, 7472, 5667, 847, 413, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 288, 291, 14, 362, 63, 13969, 342, 288, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 355, 372, 488, 199, 3, 4483, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 267, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 6043, 63, 354, 342, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 355, 1980, 288, 340, 440, 16118, 14, 2682, 26, 355, 1980, 288, 410, 275, 16118, 14, 3871, 8, 22353, 9, 288, 340, 440, 410, 26, 355, 1980, 288, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 355, 372, 291, 14, 362, 63, 929, 342, 288, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 355, 16118, 14, 2682, 275, 756, 355, 291, 423, 77, 7472, 5667, 4862, 413, 355, 340, 291, 423, 77, 7472, 5667, 2695, 378, 26, 490, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 490, 372, 291, 14, 362, 63, 929, 342, 267, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 410, 275, 291, 14, 362, 63, 929, 342, 267, 340, 410, 508, 5262, 14, 69, 3601, 7940, 26, 288, 372, 378, 14, 1020, 267, 916, 410, 508, 5262, 14, 69, 1763, 1352, 26, 288, 372, 378, 14, 614, 267, 5526, 8930, 275, 378, 14, 16, 267, 291, 423, 77, 19478, 25541, 8029, 275, 488, 267, 367, 16118, 315, 291, 423, 77, 8029, 83, 26, 288, 340, 440, 16118, 26, 355, 1980, 288, 340, 440, 16118, 14, 2682, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 19903, 14, 362, 63, 6043, 63, 354, 342, 3660, 435, 283, 440, 4702, 60, 78, 358, 355, 1980, 288, 3980, 275, 16118, 14, 362, 63, 13969, 342, 288, 340, 5262, 423, 1757, 26, 355, 984, 14, 3083, 14, 952, 3508, 83, 15197, 275, 450, 83, 60, 78, 7, 450, 639, 334, 19903, 14, 362, 63, 6043, 63, 354, 1062, 3980, 430, 288, 340, 5526, 8930, 665, 3980, 26, 355, 5526, 8930, 275, 3980, 355, 291, 423, 77, 19478, 25541, 8029, 275, 16118, 267, 340, 440, 291, 423, 77, 19478, 25541, 8029, 26, 288, 372, 378, 14, 16, 267, 372, 5526, 8930, 199, 3, 263, 587, 26, 199, 3, 3322, 291, 423, 77, 19478, 25541, 8029, 275, 291, 423, 77, 8029, 83, 59, 16, 61, 199, 3, 3322, 372, 291, 423, 77, 19478, 25541, 8029, 14, 362, 63, 13969, 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,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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 ]
gr3yman/TileControl
TileCtrl.py
1
2772
#!/usr/env/python3 import subprocess import tinydb from tinydb.storages import MemoryStorage import tkinter as tk ## who knows if this is working or not? def keypress(event): if event.keysym == 'Escape': root.destroy() x = event.char if x == "Ctrl-Z": print('c z') elif x == "Ctrl-X": print('c x') else: pass ## function to get all active windows ## see man wmctrl for info on wmctrl command def buildwindb(): windodb = tinydb.TinyDB(storage=MemoryStorage) windodb.purge() with subprocess.Popen(['wmctrl -lG | tr -s " "'], shell = True, stdout=subprocess.PIPE, universal_newlines=True) as wmctrlg: winout = wmctrlg.stdout.read().splitlines() for line in winout: winline = line.split(' ') hexid = winline[0] dsktp = winline[1] xpos = winline[2] ypos = winline[3] width = winline[4] height = winline[5] windodb.insert({'hexid': hexid, 'desktop': dsktp, 'xpos': xpos, 'ypos': ypos, 'width': width, 'height': height}) print(windodb.all()) return windodb ## Function to get screen dimensions and active desktop ## see man wmctrl for info on wmctrl command ## this is also working def getscreen(): with subprocess.Popen(['wmctrl', '-d'], stdout=subprocess.PIPE, universal_newlines=True) as wmctrld: wmctrlout = wmctrld.stdout.read().splitlines() for line in wmctrlout: if "*" in line: values = line.split(' ') deskid = values[0] print (deskid) screensize = values[11] screenx, screeny = screensize.split('x') return deskid, screenx, screeny def move(winhxid, sizstrng): subprocess.call('wmctrl', '-i', '-r', winhxid, '-e', sizstrng) ##this is being called and working ##returns int def tilemeasure(strngxdim, strngydim, strngpnlhght): screeny = int(strngydim) panelheight = int(strngpnlhght) screeny = (screeny - panelheight) - 30 mastery = screeny + 10 screenx = int(strngxdim) screenx = screenx - 30 masterx = int(round(screenx / 5 * 3)) subx = screenx - masterx suby = int(round(screeny / 5 * 3)) return screeny, mastery, screenx, masterx, subx, suby root = tk.Tk() root.bind_all('<Key>', keypress) # don't show the tk window root.withdraw() root.mainloop() while True: windodb = buildwindb() deskid, screenx, screeny = getscreen() panelquery = tinydb.Query() panel = windodb.get(panelquery.desktop == '-1') panelheight = panel['height'] mastery, screeny, screenx, masterx, subx, suby = tilemeasure(screenx, screeny, panelheight) print(screeny, mastery, screenx, masterx, subx, suby)
gpl-2.0
[ 3381, 2647, 15, 1813, 15, 1548, 19, 199, 199, 646, 3873, 199, 646, 29128, 697, 199, 504, 29128, 697, 14, 3494, 83, 492, 15825, 6408, 199, 646, 22171, 465, 10157, 199, 199, 309, 3963, 19428, 340, 642, 365, 6449, 503, 440, 31, 199, 199, 318, 790, 2915, 8, 1430, 304, 272, 340, 1566, 14, 1612, 12828, 508, 283, 10260, 356, 267, 1738, 14, 7237, 342, 272, 671, 275, 1566, 14, 1560, 272, 340, 671, 508, 298, 9778, 13, 58, 582, 267, 870, 360, 67, 1315, 358, 272, 916, 671, 508, 298, 9778, 13, 56, 582, 267, 870, 360, 67, 671, 358, 272, 587, 26, 267, 986, 199, 199, 309, 805, 370, 664, 1006, 4702, 10061, 199, 309, 1937, 2169, 29835, 12476, 367, 2256, 641, 29835, 12476, 1414, 1362, 199, 318, 1900, 11530, 66, 837, 272, 15417, 13152, 275, 29128, 697, 14, 52, 8952, 2846, 8, 3494, 29, 8628, 6408, 9, 272, 15417, 13152, 14, 18254, 342, 272, 543, 3873, 14, 7942, 2941, 16240, 12476, 446, 76, 39, 1204, 5651, 446, 83, 298, 298, 995, 5218, 275, 715, 12, 3839, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 465, 29835, 12476, 71, 26, 267, 4747, 548, 275, 29835, 12476, 71, 14, 2703, 14, 739, 1252, 7644, 342, 272, 367, 1004, 315, 4747, 548, 26, 267, 4747, 604, 275, 1004, 14, 1294, 360, 5320, 267, 6318, 344, 275, 4747, 604, 59, 16, 61, 267, 366, 1339, 683, 275, 4747, 604, 59, 17, 61, 267, 671, 1712, 275, 4747, 604, 59, 18, 61, 267, 612, 1712, 275, 4747, 604, 59, 19, 61, 267, 3462, 275, 4747, 604, 59, 20, 61, 267, 4569, 275, 4747, 604, 59, 21, 61, 267, 15417, 13152, 14, 3176, 3252, 4097, 344, 356, 6318, 344, 12, 283, 14487, 356, 366, 1339, 683, 12, 283, 88, 1712, 356, 671, 1712, 12, 283, 89, 1712, 356, 612, 1712, 12, 283, 2063, 356, 3462, 12, 283, 3333, 356, 4569, 1552, 267, 870, 8, 11530, 13152, 14, 452, 1012, 1057, 272, 372, 15417, 13152, 199, 199, 309, 6801, 370, 664, 6426, 7365, 436, 4702, 19763, 199, 309, 1937, 2169, 29835, 12476, 367, 2256, 641, 29835, 12476, 1414, 199, 309, 642, 365, 2597, 6449, 199, 199, 318, 664, 5410, 837, 272, 543, 3873, 14, 7942, 2941, 16240, 12476, 297, 2475, 68, 995, 3839, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 465, 29835, 18548, 1447, 26, 267, 29835, 18548, 22316, 275, 29835, 18548, 1447, 14, 2703, 14, 739, 1252, 7644, 342, 267, 367, 1004, 315, 29835, 18548, 22316, 26, 288, 340, 22423, 315, 1004, 26, 355, 1338, 275, 1004, 14, 1294, 360, 5320, 355, 18426, 344, 275, 1338, 59, 16, 61, 355, 870, 334, 10368, 344, 9, 355, 6426, 890, 275, 1338, 59, 845, 61, 355, 6426, 88, 12, 6426, 89, 275, 6426, 890, 14, 1294, 360, 88, 358, 272, 372, 18426, 344, 12, 6426, 88, 12, 6426, 89, 199, 199, 318, 4057, 8, 2676, 72, 21352, 12, 221, 308, 565, 495, 2753, 304, 339, 3873, 14, 1250, 360, 16240, 12476, 297, 221, 2475, 73, 297, 221, 2475, 82, 297, 221, 4747, 72, 21352, 12, 2475, 69, 297, 221, 308, 565, 495, 2753, 9, 10813, 199, 309, 3749, 365, 3769, 2797, 436, 6449, 199, 309, 5808, 1109, 9948, 199, 318, 12835, 9580, 8, 495, 2753, 88, 3572, 12, 221, 620, 2753, 89, 3572, 12, 221, 620, 2753, 4812, 25514, 913, 304, 339, 6426, 89, 275, 1109, 8, 495, 2753, 89, 3572, 9, 272, 12748, 3333, 275, 1109, 8, 495, 2753, 4812, 25514, 913, 9, 272, 6426, 89, 275, 334, 5410, 89, 446, 12748, 3333, 9, 446, 4233, 272, 5288, 89, 275, 6426, 89, 435, 1616, 272, 6426, 88, 275, 1109, 8, 495, 2753, 88, 3572, 9, 272, 6426, 88, 275, 6426, 88, 446, 4233, 272, 5288, 88, 275, 1109, 8, 2363, 8, 5410, 88, 1182, 959, 627, 650, 430, 272, 1007, 88, 275, 6426, 88, 446, 5288, 88, 272, 1007, 89, 275, 1109, 8, 2363, 8, 5410, 89, 1182, 959, 627, 650, 430, 272, 372, 6426, 89, 12, 221, 5288, 89, 12, 221, 6426, 88, 12, 221, 5288, 88, 12, 221, 1007, 88, 12, 221, 1007, 89, 10813, 199, 1231, 275, 10157, 14, 15189, 342, 199, 1231, 14, 3409, 63, 452, 4827, 1197, 4206, 790, 2915, 9, 199, 3, 2793, 1133, 2498, 314, 10157, 4353, 199, 1231, 14, 1045, 5485, 342, 199, 1231, 14, 22644, 342, 199, 6710, 715, 26, 272, 15417, 13152, 275, 1900, 11530, 66, 342, 272, 18426, 344, 12, 221, 6426, 88, 12, 6426, 89, 275, 664, 5410, 342, 272, 12748, 1131, 275, 29128, 697, 14, 3227, 342, 272, 12748, 275, 15417, 13152, 14, 362, 8, 7885, 1131, 14, 14487, 508, 2475, 17, 358, 272, 12748, 3333, 275, 12748, 459, 3333, 418, 272, 5288, 89, 12, 6426, 89, 12, 6426, 88, 12, 221, 5288, 88, 12, 221, 1007, 88, 12, 221, 1007, 89, 275, 12835, 9580, 8, 5410, 88, 12, 6426, 89, 12, 12748, 3333, 9, 272, 870, 8, 5410, 89, 12, 221, 5288, 89, 12, 221, 6426, 88, 12, 221, 5288, 88, 12, 221, 1007, 88, 12, 221, 1007, 89, 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 ]
[ 2647, 15, 1813, 15, 1548, 19, 199, 199, 646, 3873, 199, 646, 29128, 697, 199, 504, 29128, 697, 14, 3494, 83, 492, 15825, 6408, 199, 646, 22171, 465, 10157, 199, 199, 309, 3963, 19428, 340, 642, 365, 6449, 503, 440, 31, 199, 199, 318, 790, 2915, 8, 1430, 304, 272, 340, 1566, 14, 1612, 12828, 508, 283, 10260, 356, 267, 1738, 14, 7237, 342, 272, 671, 275, 1566, 14, 1560, 272, 340, 671, 508, 298, 9778, 13, 58, 582, 267, 870, 360, 67, 1315, 358, 272, 916, 671, 508, 298, 9778, 13, 56, 582, 267, 870, 360, 67, 671, 358, 272, 587, 26, 267, 986, 199, 199, 309, 805, 370, 664, 1006, 4702, 10061, 199, 309, 1937, 2169, 29835, 12476, 367, 2256, 641, 29835, 12476, 1414, 1362, 199, 318, 1900, 11530, 66, 837, 272, 15417, 13152, 275, 29128, 697, 14, 52, 8952, 2846, 8, 3494, 29, 8628, 6408, 9, 272, 15417, 13152, 14, 18254, 342, 272, 543, 3873, 14, 7942, 2941, 16240, 12476, 446, 76, 39, 1204, 5651, 446, 83, 298, 298, 995, 5218, 275, 715, 12, 3839, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 465, 29835, 12476, 71, 26, 267, 4747, 548, 275, 29835, 12476, 71, 14, 2703, 14, 739, 1252, 7644, 342, 272, 367, 1004, 315, 4747, 548, 26, 267, 4747, 604, 275, 1004, 14, 1294, 360, 5320, 267, 6318, 344, 275, 4747, 604, 59, 16, 61, 267, 366, 1339, 683, 275, 4747, 604, 59, 17, 61, 267, 671, 1712, 275, 4747, 604, 59, 18, 61, 267, 612, 1712, 275, 4747, 604, 59, 19, 61, 267, 3462, 275, 4747, 604, 59, 20, 61, 267, 4569, 275, 4747, 604, 59, 21, 61, 267, 15417, 13152, 14, 3176, 3252, 4097, 344, 356, 6318, 344, 12, 283, 14487, 356, 366, 1339, 683, 12, 283, 88, 1712, 356, 671, 1712, 12, 283, 89, 1712, 356, 612, 1712, 12, 283, 2063, 356, 3462, 12, 283, 3333, 356, 4569, 1552, 267, 870, 8, 11530, 13152, 14, 452, 1012, 1057, 272, 372, 15417, 13152, 199, 199, 309, 6801, 370, 664, 6426, 7365, 436, 4702, 19763, 199, 309, 1937, 2169, 29835, 12476, 367, 2256, 641, 29835, 12476, 1414, 199, 309, 642, 365, 2597, 6449, 199, 199, 318, 664, 5410, 837, 272, 543, 3873, 14, 7942, 2941, 16240, 12476, 297, 2475, 68, 995, 3839, 29, 5781, 14, 6089, 12, 17508, 63, 13839, 29, 549, 9, 465, 29835, 18548, 1447, 26, 267, 29835, 18548, 22316, 275, 29835, 18548, 1447, 14, 2703, 14, 739, 1252, 7644, 342, 267, 367, 1004, 315, 29835, 18548, 22316, 26, 288, 340, 22423, 315, 1004, 26, 355, 1338, 275, 1004, 14, 1294, 360, 5320, 355, 18426, 344, 275, 1338, 59, 16, 61, 355, 870, 334, 10368, 344, 9, 355, 6426, 890, 275, 1338, 59, 845, 61, 355, 6426, 88, 12, 6426, 89, 275, 6426, 890, 14, 1294, 360, 88, 358, 272, 372, 18426, 344, 12, 6426, 88, 12, 6426, 89, 199, 199, 318, 4057, 8, 2676, 72, 21352, 12, 221, 308, 565, 495, 2753, 304, 339, 3873, 14, 1250, 360, 16240, 12476, 297, 221, 2475, 73, 297, 221, 2475, 82, 297, 221, 4747, 72, 21352, 12, 2475, 69, 297, 221, 308, 565, 495, 2753, 9, 10813, 199, 309, 3749, 365, 3769, 2797, 436, 6449, 199, 309, 5808, 1109, 9948, 199, 318, 12835, 9580, 8, 495, 2753, 88, 3572, 12, 221, 620, 2753, 89, 3572, 12, 221, 620, 2753, 4812, 25514, 913, 304, 339, 6426, 89, 275, 1109, 8, 495, 2753, 89, 3572, 9, 272, 12748, 3333, 275, 1109, 8, 495, 2753, 4812, 25514, 913, 9, 272, 6426, 89, 275, 334, 5410, 89, 446, 12748, 3333, 9, 446, 4233, 272, 5288, 89, 275, 6426, 89, 435, 1616, 272, 6426, 88, 275, 1109, 8, 495, 2753, 88, 3572, 9, 272, 6426, 88, 275, 6426, 88, 446, 4233, 272, 5288, 88, 275, 1109, 8, 2363, 8, 5410, 88, 1182, 959, 627, 650, 430, 272, 1007, 88, 275, 6426, 88, 446, 5288, 88, 272, 1007, 89, 275, 1109, 8, 2363, 8, 5410, 89, 1182, 959, 627, 650, 430, 272, 372, 6426, 89, 12, 221, 5288, 89, 12, 221, 6426, 88, 12, 221, 5288, 88, 12, 221, 1007, 88, 12, 221, 1007, 89, 10813, 199, 1231, 275, 10157, 14, 15189, 342, 199, 1231, 14, 3409, 63, 452, 4827, 1197, 4206, 790, 2915, 9, 199, 3, 2793, 1133, 2498, 314, 10157, 4353, 199, 1231, 14, 1045, 5485, 342, 199, 1231, 14, 22644, 342, 199, 6710, 715, 26, 272, 15417, 13152, 275, 1900, 11530, 66, 342, 272, 18426, 344, 12, 221, 6426, 88, 12, 6426, 89, 275, 664, 5410, 342, 272, 12748, 1131, 275, 29128, 697, 14, 3227, 342, 272, 12748, 275, 15417, 13152, 14, 362, 8, 7885, 1131, 14, 14487, 508, 2475, 17, 358, 272, 12748, 3333, 275, 12748, 459, 3333, 418, 272, 5288, 89, 12, 6426, 89, 12, 6426, 88, 12, 221, 5288, 88, 12, 221, 1007, 88, 12, 221, 1007, 89, 275, 12835, 9580, 8, 5410, 88, 12, 6426, 89, 12, 12748, 3333, 9, 272, 870, 8, 5410, 89, 12, 221, 5288, 89, 12, 221, 6426, 88, 12, 221, 5288, 88, 12, 221, 1007, 88, 12, 221, 1007, 89, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tymofij/werkzeug
werkzeug/http.py
110
35031
# -*- coding: utf-8 -*- """ werkzeug.http ~~~~~~~~~~~~~ Werkzeug comes with a bunch of utilities that help Werkzeug to deal with HTTP data. Most of the classes and functions provided by this module are used by the wrappers, but they are useful on their own, too, especially if the response and request objects are not used. This covers some of the more HTTP centric features of WSGI, some other utilities such as cookie handling are documented in the `werkzeug.utils` module. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import re from time import time, gmtime try: from email.utils import parsedate_tz except ImportError: # pragma: no cover from email.Utils import parsedate_tz try: from urllib2 import parse_http_list as _parse_list_header except ImportError: # pragma: no cover from urllib.request import parse_http_list as _parse_list_header from datetime import datetime, timedelta from hashlib import md5 import base64 from werkzeug._internal import _cookie_quote, _make_cookie_domain, \ _cookie_parse_impl from werkzeug._compat import to_unicode, iteritems, text_type, \ string_types, try_coerce_native, to_bytes, PY2, \ integer_types _cookie_charset = 'latin1' # for explanation of "media-range", etc. see Sections 5.3.{1,2} of RFC 7231 _accept_re = re.compile( r'''( # media-range capturing-parenthesis [^\s;,]+ # type/subtype (?:[ \t]*;[ \t]* # ";" (?: # parameter non-capturing-parenthesis [^\s;,q][^\s;,]* # token that doesn't start with "q" | # or q[^\s;,=][^\s;,]* # token that is more than just "q" ) )* # zero or more parameters ) # end of media-range (?:[ \t]*;[ \t]*q= # weight is a "q" parameter (\d*(?:\.\d+)?) # qvalue capturing-parentheses [^,]* # "extension" accept params: who cares? )? # accept params are optional ''', re.VERBOSE) _token_chars = frozenset("!#$%&'*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" '^_`abcdefghijklmnopqrstuvwxyz|~') _etag_re = re.compile(r'([Ww]/)?(?:"(.*?)"|(.*?))(?:\s*,\s*|$)') _unsafe_header_chars = set('()<>@,;:\"/[]?={} \t') _quoted_string_re = r'"[^"\\]*(?:\\.[^"\\]*)*"' _option_header_piece_re = re.compile( r';\s*(%s|[^\s;,=]+)\s*(?:=\s*(%s|[^;,]+)?)?\s*' % (_quoted_string_re, _quoted_string_re) ) _option_header_start_mime_type = re.compile(r',\s*([^;,\s]+)([;,]\s*.+)?') _entity_headers = frozenset([ 'allow', 'content-encoding', 'content-language', 'content-length', 'content-location', 'content-md5', 'content-range', 'content-type', 'expires', 'last-modified' ]) _hop_by_hop_headers = frozenset([ 'connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'transfer-encoding', 'upgrade' ]) HTTP_STATUS_CODES = { 100: 'Continue', 101: 'Switching Protocols', 102: 'Processing', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content', 207: 'Multi Status', 226: 'IM Used', # see RFC 3229 300: 'Multiple Choices', 301: 'Moved Permanently', 302: 'Found', 303: 'See Other', 304: 'Not Modified', 305: 'Use Proxy', 307: 'Temporary Redirect', 400: 'Bad Request', 401: 'Unauthorized', 402: 'Payment Required', # unused 403: 'Forbidden', 404: 'Not Found', 405: 'Method Not Allowed', 406: 'Not Acceptable', 407: 'Proxy Authentication Required', 408: 'Request Timeout', 409: 'Conflict', 410: 'Gone', 411: 'Length Required', 412: 'Precondition Failed', 413: 'Request Entity Too Large', 414: 'Request URI Too Long', 415: 'Unsupported Media Type', 416: 'Requested Range Not Satisfiable', 417: 'Expectation Failed', 418: 'I\'m a teapot', # see RFC 2324 422: 'Unprocessable Entity', 423: 'Locked', 424: 'Failed Dependency', 426: 'Upgrade Required', 428: 'Precondition Required', # see RFC 6585 429: 'Too Many Requests', 431: 'Request Header Fields Too Large', 449: 'Retry With', # proprietary MS extension 500: 'Internal Server Error', 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout', 505: 'HTTP Version Not Supported', 507: 'Insufficient Storage', 510: 'Not Extended' } def wsgi_to_bytes(data): """coerce wsgi unicode represented bytes to real ones """ if isinstance(data, bytes): return data return data.encode('latin1') # XXX: utf8 fallback? def bytes_to_wsgi(data): assert isinstance(data, bytes), 'data must be bytes' if isinstance(data, str): return data else: return data.decode('latin1') def quote_header_value(value, extra_chars='', allow_token=True): """Quote a header value if necessary. .. versionadded:: 0.5 :param value: the value to quote. :param extra_chars: a list of extra characters to skip quoting. :param allow_token: if this is enabled token values are returned unchanged. """ if isinstance(value, bytes): value = bytes_to_wsgi(value) value = str(value) if allow_token: token_chars = _token_chars | set(extra_chars) if set(value).issubset(token_chars): return value return '"%s"' % value.replace('\\', '\\\\').replace('"', '\\"') def unquote_header_value(value, is_filename=False): r"""Unquotes a header value. (Reversal of :func:`quote_header_value`). This does not use the real unquoting but what browsers are actually using for quoting. .. versionadded:: 0.5 :param value: the header value to unquote. """ if value and value[0] == value[-1] == '"': # this is not the real unquoting, but fixing this so that the # RFC is met will result in bugs with internet explorer and # probably some other browsers as well. IE for example is # uploading files with "C:\foo\bar.txt" as filename value = value[1:-1] # if this is a filename and the starting characters look like # a UNC path, then just return the value without quotes. Using the # replace sequence below on a UNC path has the effect of turning # the leading double slash into a single slash and then # _fix_ie_filename() doesn't work correctly. See #458. if not is_filename or value[:2] != '\\\\': return value.replace('\\\\', '\\').replace('\\"', '"') return value def dump_options_header(header, options): """The reverse function to :func:`parse_options_header`. :param header: the header to dump :param options: a dict of options to append. """ segments = [] if header is not None: segments.append(header) for key, value in iteritems(options): if value is None: segments.append(key) else: segments.append('%s=%s' % (key, quote_header_value(value))) return '; '.join(segments) def dump_header(iterable, allow_token=True): """Dump an HTTP header again. This is the reversal of :func:`parse_list_header`, :func:`parse_set_header` and :func:`parse_dict_header`. This also quotes strings that include an equals sign unless you pass it as dict of key, value pairs. >>> dump_header({'foo': 'bar baz'}) 'foo="bar baz"' >>> dump_header(('foo', 'bar baz')) 'foo, "bar baz"' :param iterable: the iterable or dict of values to quote. :param allow_token: if set to `False` tokens as values are disallowed. See :func:`quote_header_value` for more details. """ if isinstance(iterable, dict): items = [] for key, value in iteritems(iterable): if value is None: items.append(key) else: items.append('%s=%s' % ( key, quote_header_value(value, allow_token=allow_token) )) else: items = [quote_header_value(x, allow_token=allow_token) for x in iterable] return ', '.join(items) def parse_list_header(value): """Parse lists as described by RFC 2068 Section 2. In particular, parse comma-separated lists where the elements of the list may include quoted-strings. A quoted-string could contain a comma. A non-quoted string could have quotes in the middle. Quotes are removed automatically after parsing. It basically works like :func:`parse_set_header` just that items may appear multiple times and case sensitivity is preserved. The return value is a standard :class:`list`: >>> parse_list_header('token, "quoted value"') ['token', 'quoted value'] To create a header from the :class:`list` again, use the :func:`dump_header` function. :param value: a string with a list header. :return: :class:`list` """ result = [] for item in _parse_list_header(value): if item[:1] == item[-1:] == '"': item = unquote_header_value(item[1:-1]) result.append(item) return result def parse_dict_header(value, cls=dict): """Parse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict (or any other mapping object created from the type with a dict like interface provided by the `cls` arugment): >>> d = parse_dict_header('foo="is a fish", bar="as well"') >>> type(d) is dict True >>> sorted(d.items()) [('bar', 'as well'), ('foo', 'is a fish')] If there is no value for a key it will be `None`: >>> parse_dict_header('key_without_value') {'key_without_value': None} To create a header from the :class:`dict` again, use the :func:`dump_header` function. .. versionchanged:: 0.9 Added support for `cls` argument. :param value: a string with a dict header. :param cls: callable to use for storage of parsed results. :return: an instance of `cls` """ result = cls() if not isinstance(value, text_type): # XXX: validate value = bytes_to_wsgi(value) for item in _parse_list_header(value): if '=' not in item: result[item] = None continue name, value = item.split('=', 1) if value[:1] == value[-1:] == '"': value = unquote_header_value(value[1:-1]) result[name] = value return result def parse_options_header(value, multiple=False): """Parse a ``Content-Type`` like header into a tuple with the content type and the options: >>> parse_options_header('text/html; charset=utf8') ('text/html', {'charset': 'utf8'}) This should not be used to parse ``Cache-Control`` like headers that use a slightly different format. For these headers use the :func:`parse_dict_header` function. .. versionadded:: 0.5 :param value: the header to parse. :param multiple: Whether try to parse and return multiple MIME types :return: (mimetype, options) or (mimetype, options, mimetype, options, …) if multiple=True """ if not value: return '', {} result = [] value = "," + value.replace("\n", ",") while value: match = _option_header_start_mime_type.match(value) if not match: break result.append(match.group(1)) # mimetype options = {} # Parse options rest = match.group(2) while rest: optmatch = _option_header_piece_re.match(rest) if not optmatch: break option, option_value = optmatch.groups() option = unquote_header_value(option) if option_value is not None: option_value = unquote_header_value( option_value, option == 'filename') options[option] = option_value rest = rest[optmatch.end():] result.append(options) if multiple is False: return tuple(result) value = rest return tuple(result) def parse_accept_header(value, cls=None): """Parses an HTTP Accept-* header. This does not implement a complete valid algorithm but one that supports at least value and quality extraction. Returns a new :class:`Accept` object (basically a list of ``(value, quality)`` tuples sorted by the quality with some additional accessor methods). The second parameter can be a subclass of :class:`Accept` that is created with the parsed values and returned. :param value: the accept header string to be parsed. :param cls: the wrapper class for the return value (can be :class:`Accept` or a subclass thereof) :return: an instance of `cls`. """ if cls is None: cls = Accept if not value: return cls(None) result = [] for match in _accept_re.finditer(value): quality = match.group(2) if not quality: quality = 1 else: quality = max(min(float(quality), 1), 0) result.append((match.group(1), quality)) return cls(result) def parse_cache_control_header(value, on_update=None, cls=None): """Parse a cache control header. The RFC differs between response and request cache control, this method does not. It's your responsibility to not use the wrong control statements. .. versionadded:: 0.5 The `cls` was added. If not specified an immutable :class:`~werkzeug.datastructures.RequestCacheControl` is returned. :param value: a cache control header to be parsed. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.CacheControl` object is changed. :param cls: the class for the returned object. By default :class:`~werkzeug.datastructures.RequestCacheControl` is used. :return: a `cls` object. """ if cls is None: cls = RequestCacheControl if not value: return cls(None, on_update) return cls(parse_dict_header(value), on_update) def parse_set_header(value, on_update=None): """Parse a set-like header and return a :class:`~werkzeug.datastructures.HeaderSet` object: >>> hs = parse_set_header('token, "quoted value"') The return value is an object that treats the items case-insensitively and keeps the order of the items: >>> 'TOKEN' in hs True >>> hs.index('quoted value') 1 >>> hs HeaderSet(['token', 'quoted value']) To create a header from the :class:`HeaderSet` again, use the :func:`dump_header` function. :param value: a set header to be parsed. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.HeaderSet` object is changed. :return: a :class:`~werkzeug.datastructures.HeaderSet` """ if not value: return HeaderSet(None, on_update) return HeaderSet(parse_list_header(value), on_update) def parse_authorization_header(value): """Parse an HTTP basic/digest authorization header transmitted by the web browser. The return value is either `None` if the header was invalid or not given, otherwise an :class:`~werkzeug.datastructures.Authorization` object. :param value: the authorization header to parse. :return: a :class:`~werkzeug.datastructures.Authorization` object or `None`. """ if not value: return value = wsgi_to_bytes(value) try: auth_type, auth_info = value.split(None, 1) auth_type = auth_type.lower() except ValueError: return if auth_type == b'basic': try: username, password = base64.b64decode(auth_info).split(b':', 1) except Exception: return return Authorization('basic', {'username': bytes_to_wsgi(username), 'password': bytes_to_wsgi(password)}) elif auth_type == b'digest': auth_map = parse_dict_header(auth_info) for key in 'username', 'realm', 'nonce', 'uri', 'response': if key not in auth_map: return if 'qop' in auth_map: if not auth_map.get('nc') or not auth_map.get('cnonce'): return return Authorization('digest', auth_map) def parse_www_authenticate_header(value, on_update=None): """Parse an HTTP WWW-Authenticate header into a :class:`~werkzeug.datastructures.WWWAuthenticate` object. :param value: a WWW-Authenticate header to parse. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.WWWAuthenticate` object is changed. :return: a :class:`~werkzeug.datastructures.WWWAuthenticate` object. """ if not value: return WWWAuthenticate(on_update=on_update) try: auth_type, auth_info = value.split(None, 1) auth_type = auth_type.lower() except (ValueError, AttributeError): return WWWAuthenticate(value.strip().lower(), on_update=on_update) return WWWAuthenticate(auth_type, parse_dict_header(auth_info), on_update) def parse_if_range_header(value): """Parses an if-range header which can be an etag or a date. Returns a :class:`~werkzeug.datastructures.IfRange` object. .. versionadded:: 0.7 """ if not value: return IfRange() date = parse_date(value) if date is not None: return IfRange(date=date) # drop weakness information return IfRange(unquote_etag(value)[0]) def parse_range_header(value, make_inclusive=True): """Parses a range header into a :class:`~werkzeug.datastructures.Range` object. If the header is missing or malformed `None` is returned. `ranges` is a list of ``(start, stop)`` tuples where the ranges are non-inclusive. .. versionadded:: 0.7 """ if not value or '=' not in value: return None ranges = [] last_end = 0 units, rng = value.split('=', 1) units = units.strip().lower() for item in rng.split(','): item = item.strip() if '-' not in item: return None if item.startswith('-'): if last_end < 0: return None begin = int(item) end = None last_end = -1 elif '-' in item: begin, end = item.split('-', 1) begin = int(begin) if begin < last_end or last_end < 0: return None if end: end = int(end) + 1 if begin >= end: return None else: end = None last_end = end ranges.append((begin, end)) return Range(units, ranges) def parse_content_range_header(value, on_update=None): """Parses a range header into a :class:`~werkzeug.datastructures.ContentRange` object or `None` if parsing is not possible. .. versionadded:: 0.7 :param value: a content range header to be parsed. :param on_update: an optional callable that is called every time a value on the :class:`~werkzeug.datastructures.ContentRange` object is changed. """ if value is None: return None try: units, rangedef = (value or '').strip().split(None, 1) except ValueError: return None if '/' not in rangedef: return None rng, length = rangedef.split('/', 1) if length == '*': length = None elif length.isdigit(): length = int(length) else: return None if rng == '*': return ContentRange(units, None, None, length, on_update=on_update) elif '-' not in rng: return None start, stop = rng.split('-', 1) try: start = int(start) stop = int(stop) + 1 except ValueError: return None if is_byte_range_valid(start, stop, length): return ContentRange(units, start, stop, length, on_update=on_update) def quote_etag(etag, weak=False): """Quote an etag. :param etag: the etag to quote. :param weak: set to `True` to tag it "weak". """ if '"' in etag: raise ValueError('invalid etag') etag = '"%s"' % etag if weak: etag = 'w/' + etag return etag def unquote_etag(etag): """Unquote a single etag: >>> unquote_etag('w/"bar"') ('bar', True) >>> unquote_etag('"bar"') ('bar', False) :param etag: the etag identifier to unquote. :return: a ``(etag, weak)`` tuple. """ if not etag: return None, None etag = etag.strip() weak = False if etag[:2] in ('w/', 'W/'): weak = True etag = etag[2:] if etag[:1] == etag[-1:] == '"': etag = etag[1:-1] return etag, weak def parse_etags(value): """Parse an etag header. :param value: the tag header to parse :return: an :class:`~werkzeug.datastructures.ETags` object. """ if not value: return ETags() strong = [] weak = [] end = len(value) pos = 0 while pos < end: match = _etag_re.match(value, pos) if match is None: break is_weak, quoted, raw = match.groups() if raw == '*': return ETags(star_tag=True) elif quoted: raw = quoted if is_weak: weak.append(raw) else: strong.append(raw) pos = match.end() return ETags(strong, weak) def generate_etag(data): """Generate an etag for some data.""" return md5(data).hexdigest() def parse_date(value): """Parse one of the following date formats into a datetime object: .. sourcecode:: text Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format If parsing fails the return value is `None`. :param value: a string with a supported date format. :return: a :class:`datetime.datetime` object. """ if value: t = parsedate_tz(value.strip()) if t is not None: try: year = t[0] # unfortunately that function does not tell us if two digit # years were part of the string, or if they were prefixed # with two zeroes. So what we do is to assume that 69-99 # refer to 1900, and everything below to 2000 if year >= 0 and year <= 68: year += 2000 elif year >= 69 and year <= 99: year += 1900 return datetime(*((year,) + t[1:7])) - \ timedelta(seconds=t[-1] or 0) except (ValueError, OverflowError): return None def _dump_date(d, delim): """Used for `http_date` and `cookie_date`.""" if d is None: d = gmtime() elif isinstance(d, datetime): d = d.utctimetuple() elif isinstance(d, (integer_types, float)): d = gmtime(d) return '%s, %02d%s%s%s%s %02d:%02d:%02d GMT' % ( ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')[d.tm_wday], d.tm_mday, delim, ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')[d.tm_mon - 1], delim, str(d.tm_year), d.tm_hour, d.tm_min, d.tm_sec ) def cookie_date(expires=None): """Formats the time to ensure compatibility with Netscape's cookie standard. Accepts a floating point number expressed in seconds since the epoch in, a datetime object or a timetuple. All times in UTC. The :func:`parse_date` function can be used to parse such a date. Outputs a string in the format ``Wdy, DD-Mon-YYYY HH:MM:SS GMT``. :param expires: If provided that date is used, otherwise the current. """ return _dump_date(expires, '-') def http_date(timestamp=None): """Formats the time to match the RFC1123 date format. Accepts a floating point number expressed in seconds since the epoch in, a datetime object or a timetuple. All times in UTC. The :func:`parse_date` function can be used to parse such a date. Outputs a string in the format ``Wdy, DD Mon YYYY HH:MM:SS GMT``. :param timestamp: If provided that date is used, otherwise the current. """ return _dump_date(timestamp, ' ') def is_resource_modified(environ, etag=None, data=None, last_modified=None): """Convenience method for conditional requests. :param environ: the WSGI environment of the request to be checked. :param etag: the etag for the response for comparison. :param data: or alternatively the data of the response to automatically generate an etag using :func:`generate_etag`. :param last_modified: an optional date of the last modification. :return: `True` if the resource was modified, otherwise `False`. """ if etag is None and data is not None: etag = generate_etag(data) elif data is not None: raise TypeError('both data and etag given') if environ['REQUEST_METHOD'] not in ('GET', 'HEAD'): return False unmodified = False if isinstance(last_modified, string_types): last_modified = parse_date(last_modified) # ensure that microsecond is zero because the HTTP spec does not transmit # that either and we might have some false positives. See issue #39 if last_modified is not None: last_modified = last_modified.replace(microsecond=0) modified_since = parse_date(environ.get('HTTP_IF_MODIFIED_SINCE')) if modified_since and last_modified and last_modified <= modified_since: unmodified = True if etag: if_none_match = parse_etags(environ.get('HTTP_IF_NONE_MATCH')) if if_none_match: unmodified = if_none_match.contains_raw(etag) return not unmodified def remove_entity_headers(headers, allowed=('expires', 'content-location')): """Remove all entity headers from a list or :class:`Headers` object. This operation works in-place. `Expires` and `Content-Location` headers are by default not removed. The reason for this is :rfc:`2616` section 10.3.5 which specifies some entity headers that should be sent. .. versionchanged:: 0.5 added `allowed` parameter. :param headers: a list or :class:`Headers` object. :param allowed: a list of headers that should still be allowed even though they are entity headers. """ allowed = set(x.lower() for x in allowed) headers[:] = [(key, value) for key, value in headers if not is_entity_header(key) or key.lower() in allowed] def remove_hop_by_hop_headers(headers): """Remove all HTTP/1.1 "Hop-by-Hop" headers from a list or :class:`Headers` object. This operation works in-place. .. versionadded:: 0.5 :param headers: a list or :class:`Headers` object. """ headers[:] = [(key, value) for key, value in headers if not is_hop_by_hop_header(key)] def is_entity_header(header): """Check if a header is an entity header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an entity header, `False` otherwise. """ return header.lower() in _entity_headers def is_hop_by_hop_header(header): """Check if a header is an HTTP/1.1 "Hop-by-Hop" header. .. versionadded:: 0.5 :param header: the header to test. :return: `True` if it's an entity header, `False` otherwise. """ return header.lower() in _hop_by_hop_headers def parse_cookie(header, charset='utf-8', errors='replace', cls=None): """Parse a cookie. Either from a string or WSGI environ. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a :exc:`HTTPUnicodeError` is raised. .. versionchanged:: 0.5 This function now returns a :class:`TypeConversionDict` instead of a regular dict. The `cls` parameter was added. :param header: the header to be used to parse the cookie. Alternatively this can be a WSGI environment. :param charset: the charset for the cookie values. :param errors: the error behavior for the charset decoding. :param cls: an optional dict class to use. If this is not specified or `None` the default :class:`TypeConversionDict` is used. """ if isinstance(header, dict): header = header.get('HTTP_COOKIE', '') elif header is None: header = '' # If the value is an unicode string it's mangled through latin1. This # is done because on PEP 3333 on Python 3 all headers are assumed latin1 # which however is incorrect for cookies, which are sent in page encoding. # As a result we if isinstance(header, text_type): header = header.encode('latin1', 'replace') if cls is None: cls = TypeConversionDict def _parse_pairs(): for key, val in _cookie_parse_impl(header): key = to_unicode(key, charset, errors, allow_none_charset=True) val = to_unicode(val, charset, errors, allow_none_charset=True) yield try_coerce_native(key), val return cls(_parse_pairs()) def dump_cookie(key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False, charset='utf-8', sync_expires=True): """Creates a new Set-Cookie header without the ``Set-Cookie`` prefix The parameters are the same as in the cookie Morsel object in the Python standard library but it accepts unicode data, too. On Python 3 the return value of this function will be a unicode string, on Python 2 it will be a native string. In both cases the return value is usually restricted to ascii as the vast majority of values are properly escaped, but that is no guarantee. If a unicode string is returned it's tunneled through latin1 as required by PEP 3333. The return value is not ASCII safe if the key contains unicode characters. This is technically against the specification but happens in the wild. It's strongly recommended to not use non-ASCII values for the keys. :param max_age: should be a number of seconds, or `None` (default) if the cookie should last only as long as the client's browser session. Additionally `timedelta` objects are accepted, too. :param expires: should be a `datetime` object or unix timestamp. :param path: limits the cookie to a given path, per default it will span the whole domain. :param domain: Use this if you want to set a cross-domain cookie. For example, ``domain=".example.com"`` will set a cookie that is readable by the domain ``www.example.com``, ``foo.example.com`` etc. Otherwise, a cookie will only be readable by the domain that set it. :param secure: The cookie will only be available via HTTPS :param httponly: disallow JavaScript to access the cookie. This is an extension to the cookie standard and probably not supported by all browsers. :param charset: the encoding for unicode values. :param sync_expires: automatically set expires if max_age is defined but expires not. """ key = to_bytes(key, charset) value = to_bytes(value, charset) if path is not None: path = iri_to_uri(path, charset) domain = _make_cookie_domain(domain) if isinstance(max_age, timedelta): max_age = (max_age.days * 60 * 60 * 24) + max_age.seconds if expires is not None: if not isinstance(expires, string_types): expires = cookie_date(expires) elif max_age is not None and sync_expires: expires = to_bytes(cookie_date(time() + max_age)) buf = [key + b'=' + _cookie_quote(value)] # XXX: In theory all of these parameters that are not marked with `None` # should be quoted. Because stdlib did not quote it before I did not # want to introduce quoting there now. for k, v, q in ((b'Domain', domain, True), (b'Expires', expires, False,), (b'Max-Age', max_age, False), (b'Secure', secure, None), (b'HttpOnly', httponly, None), (b'Path', path, False)): if q is None: if v: buf.append(k) continue if v is None: continue tmp = bytearray(k) if not isinstance(v, (bytes, bytearray)): v = to_bytes(text_type(v), charset) if q: v = _cookie_quote(v) tmp += b'=' + v buf.append(bytes(tmp)) # The return value will be an incorrectly encoded latin1 header on # Python 3 for consistency with the headers object and a bytestring # on Python 2 because that's how the API makes more sense. rv = b'; '.join(buf) if not PY2: rv = rv.decode('latin1') return rv def is_byte_range_valid(start, stop, length): """Checks if a given byte content range is valid for the given length. .. versionadded:: 0.7 """ if (start is None) != (stop is None): return False elif start is None: return length is None or length >= 0 elif length is None: return 0 <= start < stop elif start >= stop: return False return 0 <= start < length # circular dependency fun from werkzeug.datastructures import Accept, HeaderSet, ETags, Authorization, \ WWWAuthenticate, TypeConversionDict, IfRange, Range, ContentRange, \ RequestCacheControl # DEPRECATED # backwards compatible imports from werkzeug.datastructures import ( # noqa MIMEAccept, CharsetAccept, LanguageAccept, Headers ) from werkzeug.urls import iri_to_uri
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 1014, 272, 32202, 94, 339, 22798, 12477, 543, 282, 22219, 402, 15841, 626, 1720, 22798, 370, 7962, 543, 272, 3101, 666, 14, 221, 17536, 402, 314, 3992, 436, 3423, 2741, 701, 642, 859, 787, 272, 1202, 701, 314, 17995, 12, 1325, 2985, 787, 2997, 641, 3932, 5705, 12, 4634, 12, 24002, 340, 272, 314, 1177, 436, 1056, 2251, 787, 440, 1202, 14, 339, 961, 25858, 2005, 402, 314, 1655, 3101, 13345, 1567, 4534, 402, 9279, 12, 2005, 1163, 272, 15841, 4066, 465, 5494, 7252, 787, 22751, 315, 314, 658, 17719, 14, 1208, 64, 272, 859, 14, 2378, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 199, 504, 900, 492, 900, 12, 486, 8180, 199, 893, 26, 272, 687, 3031, 14, 1208, 492, 2198, 602, 63, 3903, 199, 2590, 3545, 26, 221, 327, 11942, 26, 949, 8486, 272, 687, 3031, 14, 7535, 492, 2198, 602, 63, 3903, 199, 893, 26, 272, 687, 4011, 18, 492, 2198, 63, 1014, 63, 513, 465, 485, 1122, 63, 513, 63, 1291, 199, 2590, 3545, 26, 221, 327, 11942, 26, 949, 8486, 272, 687, 4011, 14, 1069, 492, 2198, 63, 1014, 63, 513, 465, 485, 1122, 63, 513, 63, 1291, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 8337, 492, 6128, 21, 199, 646, 1300, 772, 199, 199, 504, 10380, 423, 4672, 492, 485, 5306, 63, 3513, 12, 485, 1875, 63, 5306, 63, 2261, 12, 971, 272, 485, 5306, 63, 1122, 63, 5472, 199, 504, 10380, 423, 5819, 492, 370, 63, 2975, 12, 10849, 12, 1318, 63, 466, 12, 971, 272, 1059, 63, 1313, 12, 862, 63, 14141, 63, 6106, 12, 370, 63, 2394, 12, 7843, 18, 12, 971, 272, 3000, 63, 1313, 421, 199, 63, 5306, 63, 6043, 275, 283, 10378, 17, 7, 199, 3, 367, 17531, 402, 298, 4603, 13, 1842, 401, 5423, 14, 1937, 3240, 2452, 959, 14, 19, 23379, 17, 12, 18, 93, 402, 7329, 1520, 11921, 199, 63, 5694, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 2344, 8, 9668, 327, 5898, 13, 1842, 12162, 4039, 13, 9575, 14925, 1598, 359, 12773, 83, 27031, 2807, 4519, 327, 730, 15, 10512, 1598, 7558, 7766, 971, 84, 3672, 27, 59, 971, 84, 3672, 420, 327, 28045, 355, 16697, 463, 327, 2725, 2222, 13, 13568, 4039, 13, 9575, 14925, 2116, 359, 12773, 83, 27031, 81, 1527, 12773, 83, 27031, 3672, 221, 327, 1526, 626, 3181, 1133, 1343, 543, 298, 81, 2, 355, 1204, 7861, 327, 503, 2116, 1894, 16045, 83, 27031, 29, 1527, 12773, 83, 27031, 3672, 327, 1526, 626, 365, 1655, 2419, 2951, 298, 81, 2, 355, 776, 1598, 776, 10, 8540, 327, 4697, 503, 1655, 2633, 288, 776, 9668, 327, 1284, 402, 5898, 13, 1842, 288, 7558, 7766, 971, 84, 3672, 27, 59, 971, 84, 3672, 81, 29, 420, 327, 5401, 365, 282, 298, 81, 2, 2725, 1598, 14749, 68, 10, 15840, 3134, 68, 19544, 9, 755, 327, 1894, 585, 12162, 4039, 13, 25510, 1598, 359, 62, 12, 3672, 463, 327, 298, 3435, 2, 4729, 1862, 26, 3963, 1704, 470, 31, 288, 24836, 10473, 327, 4729, 1862, 787, 2716, 267, 21281, 295, 14, 16075, 9, 199, 63, 1418, 63, 6574, 275, 9522, 19232, 3, 22074, 6, 16804, 16341, 14, 11371, 28114, 2, 586, 14452, 28116, 23459, 92, 94, 358, 199, 63, 11304, 63, 264, 275, 295, 14, 2014, 8, 82, 21731, 55, 87, 12978, 5547, 5169, 2, 17140, 2924, 92, 17140, 430, 15840, 83, 10, 4202, 83, 10, 92, 4, 5942, 199, 63, 14242, 63, 1291, 63, 6574, 275, 663, 360, 342, 16137, 32, 12, 27, 3427, 15313, 8607, 31, 7622, 971, 84, 358, 199, 63, 9888, 63, 875, 63, 264, 275, 519, 4065, 4735, 22996, 3672, 5169, 20942, 4735, 22996, 3672, 3342, 4507, 199, 63, 1422, 63, 1291, 63, 20082, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 7, 3779, 83, 10, 4042, 83, 92, 16045, 83, 27031, 29, 18096, 83, 10, 5169, 9529, 83, 10, 4042, 83, 23629, 27031, 23763, 5547, 60, 83, 10223, 450, 272, 6110, 9888, 63, 875, 63, 264, 12, 485, 9888, 63, 875, 63, 264, 9, 199, 9, 199, 63, 1422, 63, 1291, 63, 928, 63, 7626, 63, 466, 275, 295, 14, 2014, 8, 82, 30989, 83, 10, 7059, 27, 4202, 83, 11896, 779, 27031, 7272, 83, 4856, 19544, 358, 199, 199, 63, 4502, 63, 2139, 275, 9522, 779, 272, 283, 3306, 297, 283, 1317, 13, 2991, 297, 283, 1317, 13, 3671, 297, 283, 1317, 13, 1267, 297, 272, 283, 1317, 13, 1985, 297, 283, 1317, 13, 1064, 21, 297, 283, 1317, 13, 1842, 297, 283, 1317, 13, 466, 297, 272, 283, 12342, 297, 283, 2019, 13, 5540, 7, 199, 566, 199, 63, 13376, 63, 991, 63, 13376, 63, 2139, 275, 9522, 779, 272, 283, 2105, 297, 283, 3250, 13, 9631, 297, 283, 3280, 13, 13975, 297, 272, 283, 3280, 13, 15846, 297, 283, 266, 297, 283, 21606, 297, 283, 9609, 13, 2991, 297, 272, 283, 9375, 7, 199, 566, 421, 199, 2856, 63, 6305, 63, 15639, 275, 469, 272, 2948, 26, 259, 283, 24055, 297, 272, 14313, 26, 259, 283, 10167, 316, 2165, 475, 4574, 297, 272, 12996, 26, 259, 283, 9589, 297, 272, 1926, 26, 259, 283, 3593, 297, 272, 1784, 26, 259, 283, 10502, 297, 272, 19328, 26, 259, 283, 1945, 7203, 297, 272, 29202, 26, 259, 283, 6932, 6529, 390, 1905, 17064, 297, 272, 14785, 26, 259, 283, 1944, 6646, 297, 272, 24005, 26, 259, 283, 9637, 6646, 297, 272, 26761, 26, 259, 283, 18192, 6646, 297, 272, 31533, 26, 259, 283, 3947, 9795, 297, 272, 32584, 26, 259, 283, 1469, 8051, 297, 4519, 327, 1937, 7329, 650, 11182, 272, 9601, 26, 259, 283, 8433, 8802, 2370, 297, 272, 19660, 26, 259, 283, 20774, 3492, 11433, 590, 297, 272, 11485, 26, 259, 283, 3601, 297, 272, 25989, 26, 259, 283, 9295, 5439, 297, 272, 20398, 26, 259, 283, 1763, 22016, 297, 272, 650, 1717, 26, 259, 283, 6119, 12373, 297, 272, 26959, 26 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 1014, 272, 32202, 94, 339, 22798, 12477, 543, 282, 22219, 402, 15841, 626, 1720, 22798, 370, 7962, 543, 272, 3101, 666, 14, 221, 17536, 402, 314, 3992, 436, 3423, 2741, 701, 642, 859, 787, 272, 1202, 701, 314, 17995, 12, 1325, 2985, 787, 2997, 641, 3932, 5705, 12, 4634, 12, 24002, 340, 272, 314, 1177, 436, 1056, 2251, 787, 440, 1202, 14, 339, 961, 25858, 2005, 402, 314, 1655, 3101, 13345, 1567, 4534, 402, 9279, 12, 2005, 1163, 272, 15841, 4066, 465, 5494, 7252, 787, 22751, 315, 314, 658, 17719, 14, 1208, 64, 272, 859, 14, 2378, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 295, 199, 504, 900, 492, 900, 12, 486, 8180, 199, 893, 26, 272, 687, 3031, 14, 1208, 492, 2198, 602, 63, 3903, 199, 2590, 3545, 26, 221, 327, 11942, 26, 949, 8486, 272, 687, 3031, 14, 7535, 492, 2198, 602, 63, 3903, 199, 893, 26, 272, 687, 4011, 18, 492, 2198, 63, 1014, 63, 513, 465, 485, 1122, 63, 513, 63, 1291, 199, 2590, 3545, 26, 221, 327, 11942, 26, 949, 8486, 272, 687, 4011, 14, 1069, 492, 2198, 63, 1014, 63, 513, 465, 485, 1122, 63, 513, 63, 1291, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 8337, 492, 6128, 21, 199, 646, 1300, 772, 199, 199, 504, 10380, 423, 4672, 492, 485, 5306, 63, 3513, 12, 485, 1875, 63, 5306, 63, 2261, 12, 971, 272, 485, 5306, 63, 1122, 63, 5472, 199, 504, 10380, 423, 5819, 492, 370, 63, 2975, 12, 10849, 12, 1318, 63, 466, 12, 971, 272, 1059, 63, 1313, 12, 862, 63, 14141, 63, 6106, 12, 370, 63, 2394, 12, 7843, 18, 12, 971, 272, 3000, 63, 1313, 421, 199, 63, 5306, 63, 6043, 275, 283, 10378, 17, 7, 199, 3, 367, 17531, 402, 298, 4603, 13, 1842, 401, 5423, 14, 1937, 3240, 2452, 959, 14, 19, 23379, 17, 12, 18, 93, 402, 7329, 1520, 11921, 199, 63, 5694, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 2344, 8, 9668, 327, 5898, 13, 1842, 12162, 4039, 13, 9575, 14925, 1598, 359, 12773, 83, 27031, 2807, 4519, 327, 730, 15, 10512, 1598, 7558, 7766, 971, 84, 3672, 27, 59, 971, 84, 3672, 420, 327, 28045, 355, 16697, 463, 327, 2725, 2222, 13, 13568, 4039, 13, 9575, 14925, 2116, 359, 12773, 83, 27031, 81, 1527, 12773, 83, 27031, 3672, 221, 327, 1526, 626, 3181, 1133, 1343, 543, 298, 81, 2, 355, 1204, 7861, 327, 503, 2116, 1894, 16045, 83, 27031, 29, 1527, 12773, 83, 27031, 3672, 327, 1526, 626, 365, 1655, 2419, 2951, 298, 81, 2, 355, 776, 1598, 776, 10, 8540, 327, 4697, 503, 1655, 2633, 288, 776, 9668, 327, 1284, 402, 5898, 13, 1842, 288, 7558, 7766, 971, 84, 3672, 27, 59, 971, 84, 3672, 81, 29, 420, 327, 5401, 365, 282, 298, 81, 2, 2725, 1598, 14749, 68, 10, 15840, 3134, 68, 19544, 9, 755, 327, 1894, 585, 12162, 4039, 13, 25510, 1598, 359, 62, 12, 3672, 463, 327, 298, 3435, 2, 4729, 1862, 26, 3963, 1704, 470, 31, 288, 24836, 10473, 327, 4729, 1862, 787, 2716, 267, 21281, 295, 14, 16075, 9, 199, 63, 1418, 63, 6574, 275, 9522, 19232, 3, 22074, 6, 16804, 16341, 14, 11371, 28114, 2, 586, 14452, 28116, 23459, 92, 94, 358, 199, 63, 11304, 63, 264, 275, 295, 14, 2014, 8, 82, 21731, 55, 87, 12978, 5547, 5169, 2, 17140, 2924, 92, 17140, 430, 15840, 83, 10, 4202, 83, 10, 92, 4, 5942, 199, 63, 14242, 63, 1291, 63, 6574, 275, 663, 360, 342, 16137, 32, 12, 27, 3427, 15313, 8607, 31, 7622, 971, 84, 358, 199, 63, 9888, 63, 875, 63, 264, 275, 519, 4065, 4735, 22996, 3672, 5169, 20942, 4735, 22996, 3672, 3342, 4507, 199, 63, 1422, 63, 1291, 63, 20082, 63, 264, 275, 295, 14, 2014, 8, 272, 519, 7, 3779, 83, 10, 4042, 83, 92, 16045, 83, 27031, 29, 18096, 83, 10, 5169, 9529, 83, 10, 4042, 83, 23629, 27031, 23763, 5547, 60, 83, 10223, 450, 272, 6110, 9888, 63, 875, 63, 264, 12, 485, 9888, 63, 875, 63, 264, 9, 199, 9, 199, 63, 1422, 63, 1291, 63, 928, 63, 7626, 63, 466, 275, 295, 14, 2014, 8, 82, 30989, 83, 10, 7059, 27, 4202, 83, 11896, 779, 27031, 7272, 83, 4856, 19544, 358, 199, 199, 63, 4502, 63, 2139, 275, 9522, 779, 272, 283, 3306, 297, 283, 1317, 13, 2991, 297, 283, 1317, 13, 3671, 297, 283, 1317, 13, 1267, 297, 272, 283, 1317, 13, 1985, 297, 283, 1317, 13, 1064, 21, 297, 283, 1317, 13, 1842, 297, 283, 1317, 13, 466, 297, 272, 283, 12342, 297, 283, 2019, 13, 5540, 7, 199, 566, 199, 63, 13376, 63, 991, 63, 13376, 63, 2139, 275, 9522, 779, 272, 283, 2105, 297, 283, 3250, 13, 9631, 297, 283, 3280, 13, 13975, 297, 272, 283, 3280, 13, 15846, 297, 283, 266, 297, 283, 21606, 297, 283, 9609, 13, 2991, 297, 272, 283, 9375, 7, 199, 566, 421, 199, 2856, 63, 6305, 63, 15639, 275, 469, 272, 2948, 26, 259, 283, 24055, 297, 272, 14313, 26, 259, 283, 10167, 316, 2165, 475, 4574, 297, 272, 12996, 26, 259, 283, 9589, 297, 272, 1926, 26, 259, 283, 3593, 297, 272, 1784, 26, 259, 283, 10502, 297, 272, 19328, 26, 259, 283, 1945, 7203, 297, 272, 29202, 26, 259, 283, 6932, 6529, 390, 1905, 17064, 297, 272, 14785, 26, 259, 283, 1944, 6646, 297, 272, 24005, 26, 259, 283, 9637, 6646, 297, 272, 26761, 26, 259, 283, 18192, 6646, 297, 272, 31533, 26, 259, 283, 3947, 9795, 297, 272, 32584, 26, 259, 283, 1469, 8051, 297, 4519, 327, 1937, 7329, 650, 11182, 272, 9601, 26, 259, 283, 8433, 8802, 2370, 297, 272, 19660, 26, 259, 283, 20774, 3492, 11433, 590, 297, 272, 11485, 26, 259, 283, 3601, 297, 272,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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 ]
kdheepak89/RTDT
RTDT/transit.py
1
13035
from __future__ import print_function from google.transit import gtfs_realtime_pb2 import requests import pandas as pd from io import BytesIO import zipfile import os import os.path import datetime import math UTC_OFFSET = int(os.getenv('OFFSET', 7)) DEFAULT_LOCATION = {u'lat': 39.7433814, u'lng': -104.98910989999999} def get_gtfs_data(force=False): url = 'http://www.rtd-denver.com/GoogleFeeder/google_transit_Apr16_Runboard.zip' headers_file = 'google_feeder_headers.txt' last_modified = requests.head(url).headers['Date'] rerequest = False if not os.path.isfile(headers_file): rerequest = True else: with open(headers_file) as f: f_line = f.read() if last_modified not in f_line: print("File are not the same, submit rerequest") if force: rerequest=True else: print("File unchanged!") if not os.path.isfile('stops.txt') or not os.path.isfile('trips.txt'): rerequest = True print("Files missing") if rerequest: print("Re-requesting data") request = requests.get(url) z = zipfile.ZipFile(BytesIO(request.content)) z.extractall() with open(headers_file, 'w') as f: print(last_modified, file=f) return z def convert_df_to_list(df): # bus20_east_list = [str(i) for i in bus20_east_df['trip_id'].tolist()] # bus20_west_list = [str(i) for i in bus20_west_df['trip_id'].tolist()] return([str(i) for i in df['trip_id'].tolist()]) def get_real_time_data_request_response(header=False): if header: r = requests.head('http://www.rtd-denver.com/google_sync/TripUpdate.pb', auth=(os.getenv('RTD_USERNAME'), os.getenv('RTD_PASSWORD'))) return(r.headers) else: r = requests.get('http://www.rtd-denver.com/google_sync/TripUpdate.pb', auth=(os.getenv('RTD_USERNAME'), os.getenv('RTD_PASSWORD'))) if r.ok: return(r.content) else: return None def get_entities(bus_list): feed = gtfs_realtime_pb2.FeedMessage() content = get_real_time_data_request_response() feed.ParseFromString(content) list_entities = [] for entity in feed.entity: if entity.trip_update.trip.trip_id in bus_list: list_entities.append(entity) print("Getting entities") print(list_entities) return(list_entities) def get_markers_for_list_entities(list_entities, stops_df, current_location=DEFAULT_LOCATION, trips_df=None): if trips_df is None: trips_df = pd.read_csv('trips.txt') marker = [] for entity in list_entities: stop_time_update = entity.trip_update.stop_time_update[0] delay = stop_time_update.departure.delay uncertainty = stop_time_update.departure.uncertainty dt = datetime.datetime.fromtimestamp(stop_time_update.departure.time) dt = dt - datetime.timedelta(hours=UTC_OFFSET) departure_time = dt.strftime('%H:%M') closest_stop_time = 0 closest_stop_name = '' trip_id = entity.trip_update.trip.trip_id route_id, route_name = get_bus_name(trip_id, trips_df) lat, lon, stop_name = get_location_of_stop_time_update(stop_time_update) marker.append((lat, lon, stop_name, departure_time, delay, uncertainty, closest_stop_time, closest_stop_name, route_id, route_name, trip_id)) return marker def get_location_of_stop_time_update(stop_time_update): stops_df = pd.read_csv('stops.txt') lat = stops_df[stops_df['stop_id']==int(stop_time_update.stop_id)]['stop_lat'].iloc[0] lon = stops_df[stops_df['stop_id']==int(stop_time_update.stop_id)]['stop_lon'].iloc[0] stop_name = stops_df[stops_df['stop_id']==int(stop_time_update.stop_id)]['stop_name'].iloc[0].replace('[ X Stop ]', '') return lat, lon, stop_name def get_stop_location_list(stop_time_update): list_stop_location = [] for stop_time in stop_time_update: lat, lon, stop_name = get_location_of_stop_time_update(stop_time) arrival_time_dt = datetime.datetime.fromtimestamp(stop_time.arrival.time) - datetime.timedelta(hours=UTC_OFFSET) arrival_time = arrival_time_dt.strftime('%H:%M') if stop_time.arrival.delay != 0 or stop_time.arrival.uncertainty !=0: arrival_time = arrival_time + '\nwith a delay of {} with uncertainty {}' departure_time_dt = datetime.datetime.fromtimestamp(stop_time.departure.time) - datetime.timedelta(hours=UTC_OFFSET) departure_time = departure_time_dt.strftime('%H:%M') if stop_time.departure.delay != 0 or stop_time.departure.uncertainty !=0: departure_time = departure_time + '\nwith a delay of {} with uncertainty {}' list_stop_location.append({'lat': lat, 'lng': lon, 'stop_name': stop_name, 'departure_time': departure_time, 'arrival_time': arrival_time}) return list_stop_location def get_closest_stop_time(closest_stop_id, entity): for stop_time_update in entity.trip_update.stop_time_update: if int(stop_time_update.stop_id) == int(closest_stop_id): dt = datetime.datetime.fromtimestamp(stop_time_update.departure.time) dt = dt - datetime.timedelta(hours=UTC_OFFSET) departure_time = dt.strftime('%H:%M') return(departure_time) def get_stop_name(stop_id, stops_df): return(stops_df.loc[stops_df['stop_id'] == 10277]['stop_name'].values[0]) def find_closest_stop(stops_df, latlon, stop_id_list): lat = latlon[0] lon = latlon[1] stops_df = stops_df[stops_df['stop_id'].isin(stop_id_list)] stops_df['minimum_distance'] = (stops_df['stop_lat'] - lat)**2 + (stops_df['stop_lon'] - lon)**2 closest_stop_id = stops_df.loc[stops_df['minimum_distance'].argmin()]['stop_id'] return closest_stop_id def get_bus_name(trip_id, trips_df): return(trips_df[trips_df['trip_id'] == int(trip_id)]['route_id'].values[0], trips_df[trips_df['trip_id'] == int(trip_id)]['trip_headsign'].values[0]) def get_stop_id_list(entity): stop_id_list = [] for sq in entity.trip_update.stop_time_update: stop_id_list.append(int(sq.stop_id)) return stop_id_list def get_bus_list(trips_df): trips_df['unique_route_id'] = trips_df['route_id']+': '+trips_df['trip_headsign'] bl = trips_df['unique_route_id'].unique() return(bl.tolist()) def get_location_of_routes(l): routePaths = {} for entity in l: trip_id = entity.trip_update.trip.trip_id routePaths[trip_id] = get_stop_location_list(entity.trip_update.stop_time_update) return routePaths def get_all_current_position_markers(route, current_location=DEFAULT_LOCATION): stops_df = pd.read_csv('stops.txt') l = get_currently_active_trips(route) print("Inside get all current position markers") print(l) markers = {route: get_markers_for_list_entities(l, stops_df, current_location)} routePaths = get_location_of_routes(l) data = {'markers': markers, 'routePaths': routePaths } return(data) def parse_route_name(route): route_id = route.split(':')[0].replace('Route ', '').strip(' ') trip_headsign = route.split(':')[1].strip(' ') return route_id, trip_headsign def get_trip_id(route, trips_df): dt = datetime.datetime.now() dt = dt - datetime.timedelta(hours=4) dt.isoweekday() saturday = dt.isoweekday() == 6 sunday = dt.isoweekday() == 7 if saturday: trips_df = trips_df[trips_df['service_id'] == 'SA'] elif sunday: trips_df = trips_df[trips_df['service_id'] == 'SU'] else: # weekday: trips_df = trips_df[trips_df['service_id'] == 'WK'] trips_df['unique_route_id'] = 'Route ' + trips_df['route_id']+': '+trips_df['trip_headsign'] route_id, trip_headsign = parse_route_name(route) trips_df = trips_df[trips_df['route_id'] == route_id] trips_df = trips_df[trips_df['trip_headsign'] == trip_headsign] return trips_df['trip_id'].tolist() def get_currently_active_trips(route): trips_df = pd.read_csv('trips.txt') total_trip_list = [str(item) for item in get_trip_id(route, trips_df)] print("total trip list is ") print(total_trip_list) return get_entities(total_trip_list) def get_route_name(trip_id): df = pd.read_csv('./trips.txt') route_df = df[df['trip_id'] == int(trip_id)] return(str(route_df['route_id'].values[0]) + ': ' + route_df['trip_headsign'].values[0]) def get_route_data(trip_id): return({ 'stop_time_update': get_stop_time_update(trip_id), 'route_name': get_route_name(trip_id), }) def get_stop_time_update(trip_id): feed = gtfs_realtime_pb2.FeedMessage() content = get_real_time_data_request_response() feed.ParseFromString(content) list_entities = [] realtime_entity_list = feed.entity for trip in realtime_entity_list: if trip.trip_update.trip.trip_id == str(trip_id): return([stop_time_update_to_dict(stu) for stu in trip.trip_update.stop_time_update]) def stop_time_update_to_dict(stu): lat, lon, stop_name = get_location_of_stop_time_update(stu) return({ 'location': [lat, lon], 'stop_name': stop_name, 'stop_sequence': stu.stop_sequence, 'arrival': { 'time': time_convert(stu.arrival.time), 'uncertainty': stu.arrival.uncertainty, 'delay': stu.arrival.delay }, 'departure': { 'time': time_convert(stu.departure.time), 'uncertainty': stu.departure.uncertainty, 'delay': stu.departure.delay }, 'schedule_relationship': 'SCHEDULED' if stu.schedule_relationship==0 else 'UNKNOWN' }) def time_convert(t): dt = datetime.datetime.fromtimestamp(t) dt = dt - datetime.timedelta(hours=UTC_OFFSET) departure_time = dt.strftime('%H:%M') return(departure_time) def get_trip_ids(route_id, trip_headsign): trips_df = pd.read_csv("./trips.txt") route_df = trips_df[(trips_df['route_id'] == str(route_id)) & (trips_df['trip_headsign'] == trip_headsign)] feed = gtfs_realtime_pb2.FeedMessage() content = get_real_time_data_request_response() feed.ParseFromString(content) list_entities = [] realtime_entity_list = feed.entity current_routes = [] for trip in realtime_entity_list: if any(route_df['trip_id'] == int(trip.trip_update.trip.trip_id)): lat, lon, stop_name = get_location_of_stop_time_update(trip.trip_update.stop_time_update[0]) current_routes.append({ 'trip_name': route_id + ": " + trip_headsign, 'trip_id': int(trip.trip_update.trip.trip_id), 'location': [lat, lon], 'current_location': stop_name, 'expected_departure': time_convert(trip.trip_update.stop_time_update[0].departure.time) }) return(current_routes) def distance_on_unit_sphere(x, lat2, long2): lat1 = x['stop_lat'] long1 = x['stop_lon'] # Convert latitude and longitude to # spherical coordinates in radians. degrees_to_radians = math.pi/180.0 # phi = 90 - latitude phi1 = (90.0 - lat1)*degrees_to_radians phi2 = (90.0 - lat2)*degrees_to_radians # theta = longitude theta1 = long1*degrees_to_radians theta2 = long2*degrees_to_radians # Compute spherical distance from spherical coordinates. # For two locations in spherical coordinates # (1, theta, phi) and (1, theta', phi') # cosine( arc length ) = # sin phi sin phi' cos(theta-theta') + cos phi cos phi' # distance = rho * arc length cos = (math.sin(phi1)*math.sin(phi2)*math.cos(theta1 - theta2) + math.cos(phi1)*math.cos(phi2)) arc = math.acos( cos ) # Remember to multiply arc by the radius of the earth # in your favorite set of units to get length. return 3959 * arc def list_of_closest_buses(lat, lng): trips_df = pd.read_csv('./trips.txt') stop_df = pd.read_csv('./stops.txt') stop_df['proximity'] = stop_df.apply(distance_on_unit_sphere, args=(lat,lng), axis=1) stop_df = stop_df.sort_values(by='proximity') stop_times_df = pd.read_csv('./stop_times.txt') unique_bus_names = [] i = 0 while len(unique_bus_names) < 5: build_bus_name_list(unique_bus_names, stop_df, stop_times_df, trips_df, i) i = i+1 return(unique_bus_names) def build_bus_name_list(unique_bus_names, stop_df, stop_times_df, trips_df, i): stop_id = stop_df.iloc[i]['stop_id'] def match_bus_name(x): route_id, route_name = get_bus_name(x['trip_id'], trips_df) return(route_id + ": " + route_name) for item in stop_times_df[stop_times_df['stop_id'] == stop_id].apply(match_bus_name, axis=1).unique(): if item not in unique_bus_names: unique_bus_names.append(item)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 6233, 14, 3936, 2221, 492, 16484, 2319, 63, 3093, 521, 63, 3317, 18, 199, 646, 4145, 199, 646, 10634, 465, 6454, 199, 504, 5890, 492, 11808, 199, 646, 10392, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 2197, 199, 646, 3473, 199, 199, 11288, 63, 14839, 275, 1109, 8, 736, 14, 12959, 360, 14839, 297, 1520, 430, 199, 3472, 63, 16575, 275, 469, 85, 7, 4452, 356, 10551, 14, 1342, 13744, 1079, 12, 399, 7, 23829, 356, 446, 6785, 14, 30924, 709, 2905, 5008, 5637, 93, 199, 199, 318, 664, 63, 3308, 2319, 63, 576, 8, 3990, 29, 797, 304, 272, 1166, 275, 283, 1014, 921, 1544, 14, 29048, 13, 848, 422, 14, 957, 15, 13266, 28042, 424, 15, 3098, 63, 3936, 2221, 63, 33, 2700, 975, 63, 2540, 3576, 14, 3065, 7, 272, 2323, 63, 493, 275, 283, 3098, 63, 11195, 424, 63, 2139, 14, 2424, 7, 339, 2061, 63, 5540, 275, 4145, 14, 2993, 8, 633, 680, 2139, 459, 2506, 418, 272, 295, 1069, 275, 756, 339, 340, 440, 747, 14, 515, 14, 6292, 8, 2139, 63, 493, 304, 267, 295, 1069, 275, 715, 272, 587, 26, 267, 543, 1551, 8, 2139, 63, 493, 9, 465, 289, 26, 288, 289, 63, 604, 275, 289, 14, 739, 342, 288, 340, 2061, 63, 5540, 440, 315, 289, 63, 604, 26, 355, 870, 480, 1173, 787, 440, 314, 2011, 12, 11482, 295, 1069, 531, 355, 340, 3542, 26, 490, 295, 1069, 29, 549, 288, 587, 26, 355, 870, 480, 1173, 14874, 9124, 355, 340, 440, 747, 14, 515, 14, 6292, 360, 270, 1483, 14, 2424, 358, 503, 440, 747, 14, 515, 14, 6292, 360, 599, 1190, 14, 2424, 735, 490, 295, 1069, 275, 715, 490, 870, 480, 5535, 4124, 531, 339, 340, 295, 1069, 26, 267, 870, 480, 497, 13, 1069, 316, 666, 531, 267, 1056, 275, 4145, 14, 362, 8, 633, 9, 267, 1315, 275, 10392, 14, 15016, 8, 15466, 8, 1069, 14, 1317, 430, 267, 1315, 14, 5005, 452, 342, 267, 543, 1551, 8, 2139, 63, 493, 12, 283, 87, 358, 465, 289, 26, 288, 870, 8, 2019, 63, 5540, 12, 570, 29, 70, 9, 267, 372, 1315, 326, 199, 318, 3957, 63, 1587, 63, 475, 63, 513, 8, 1587, 304, 339, 327, 10414, 1165, 63, 14346, 63, 513, 275, 359, 495, 8, 73, 9, 367, 284, 315, 10414, 1165, 63, 14346, 63, 1587, 459, 7254, 63, 344, 2278, 13633, 5106, 272, 327, 10414, 1165, 63, 19082, 63, 513, 275, 359, 495, 8, 73, 9, 367, 284, 315, 10414, 1165, 63, 19082, 63, 1587, 459, 7254, 63, 344, 2278, 13633, 5106, 272, 372, 779, 495, 8, 73, 9, 367, 284, 315, 4051, 459, 7254, 63, 344, 2278, 13633, 9383, 199, 199, 318, 664, 63, 3093, 63, 521, 63, 576, 63, 1069, 63, 1310, 8, 1291, 29, 797, 304, 272, 340, 1406, 26, 267, 519, 275, 4145, 14, 2993, 360, 1014, 921, 1544, 14, 29048, 13, 848, 422, 14, 957, 15, 3098, 63, 5186, 15, 32220, 4152, 14, 3317, 297, 1790, 2687, 736, 14, 12959, 360, 11876, 36, 63, 11958, 659, 747, 14, 12959, 360, 11876, 36, 63, 9032, 7058, 267, 372, 8, 82, 14, 2139, 9, 272, 587, 26, 267, 519, 275, 4145, 14, 362, 360, 1014, 921, 1544, 14, 29048, 13, 848, 422, 14, 957, 15, 3098, 63, 5186, 15, 32220, 4152, 14, 3317, 297, 1790, 2687, 736, 14, 12959, 360, 11876, 36, 63, 11958, 659, 747, 14, 12959, 360, 11876, 36, 63, 9032, 7058, 267, 340, 519, 14, 745, 26, 288, 372, 8, 82, 14, 1317, 9, 267, 587, 26, 288, 372, 488, 199, 199, 318, 664, 63, 8327, 8, 5610, 63, 513, 304, 339, 4733, 275, 16484, 2319, 63, 3093, 521, 63, 3317, 18, 14, 7658, 2209, 342, 272, 1564, 275, 664, 63, 3093, 63, 521, 63, 576, 63, 1069, 63, 1310, 342, 272, 4733, 14, 28685, 8, 1317, 9, 272, 769, 63, 8327, 275, 942, 339, 367, 4642, 315, 4733, 14, 4502, 26, 267, 340, 4642, 14, 7254, 63, 873, 14, 7254, 14, 7254, 63, 344, 315, 10414, 63, 513, 26, 288, 769, 63, 8327, 14, 740, 8, 4502, 9, 2378, 870, 480, 28277, 9045, 531, 272, 870, 8, 513, 63, 8327, 9, 272, 372, 8, 513, 63, 8327, 9, 199, 199, 318, 664, 63, 16835, 63, 509, 63, 513, 63, 8327, 8, 513, 63, 8327, 12, 20922, 63, 1587, 12, 1453, 63, 1985, 29, 3472, 63, 16575, 12, 3229, 1190, 63, 1587, 29, 403, 304, 272, 340, 3229, 1190, 63, 1587, 365, 488, 26, 267, 3229, 1190, 63, 1587, 275, 6454, 14, 739, 63, 4737, 360, 599, 1190, 14, 2424, 358, 339, 3608, 275, 942, 272, 367, 4642, 315, 769, 63, 8327, 26, 267, 3631, 63, 521, 63, 873, 275, 4642, 14, 7254, 63, 873, 14, 2379, 63, 521, 63, 873, 59, 16, 61, 267, 7339, 275, 3631, 63, 521, 63, 873, 14, 27532, 608, 14, 5814, 267, 30043, 369, 275, 3631, 63, 521, 63, 873, 14, 27532, 608, 14, 31794, 877, 369, 267, 4487, 275, 2197, 14, 2083, 14, 18531, 8, 2379, 63, 521, 63, 873, 14, 27532, 608, 14, 521, 9, 267, 4487, 275, 4487, 446, 2197, 14, 7473, 8, 8419, 29, 11288, 63, 14839, 9, 267, 21124, 608, 63, 521, 275, 4487, 14, 6205, 3508, 40, 2689, 45, 358, 398, 18284, 63, 2379, 63, 521, 275, 378, 267, 18284, 63, 2379, 63, 354, 275, 2125, 398, 18038, 63, 344, 275, 4642, 14, 7254, 63, 873, 14, 7254, 14, 7254, 63, 344, 267, 7475, 63, 344, 12, 7475, 63, 354, 275, 664, 63, 5610, 63, 354, 8, 7254, 63, 344, 12, 3229, 1190, 63, 1587, 9, 398, 8396, 12, 6132, 12, 3631, 63, 354, 275, 664, 63, 1985, 63, 1618, 63, 2379, 63, 521, 63, 873, 8, 2379, 63, 521, 63, 873, 9, 398, 3608, 14, 740, 1332, 4452, 12, 6132, 12, 3631, 63, 354, 12, 21124, 608, 63, 521, 12, 7339, 12, 30043, 369, 12, 18284, 63, 2379, 63, 521, 12, 18284, 63, 2379, 63, 354, 12, 7475, 63, 344, 12, 7475, 63, 354, 12, 18038, 63, 344, 430, 339, 372, 3608, 199 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 6233, 14, 3936, 2221, 492, 16484, 2319, 63, 3093, 521, 63, 3317, 18, 199, 646, 4145, 199, 646, 10634, 465, 6454, 199, 504, 5890, 492, 11808, 199, 646, 10392, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 2197, 199, 646, 3473, 199, 199, 11288, 63, 14839, 275, 1109, 8, 736, 14, 12959, 360, 14839, 297, 1520, 430, 199, 3472, 63, 16575, 275, 469, 85, 7, 4452, 356, 10551, 14, 1342, 13744, 1079, 12, 399, 7, 23829, 356, 446, 6785, 14, 30924, 709, 2905, 5008, 5637, 93, 199, 199, 318, 664, 63, 3308, 2319, 63, 576, 8, 3990, 29, 797, 304, 272, 1166, 275, 283, 1014, 921, 1544, 14, 29048, 13, 848, 422, 14, 957, 15, 13266, 28042, 424, 15, 3098, 63, 3936, 2221, 63, 33, 2700, 975, 63, 2540, 3576, 14, 3065, 7, 272, 2323, 63, 493, 275, 283, 3098, 63, 11195, 424, 63, 2139, 14, 2424, 7, 339, 2061, 63, 5540, 275, 4145, 14, 2993, 8, 633, 680, 2139, 459, 2506, 418, 272, 295, 1069, 275, 756, 339, 340, 440, 747, 14, 515, 14, 6292, 8, 2139, 63, 493, 304, 267, 295, 1069, 275, 715, 272, 587, 26, 267, 543, 1551, 8, 2139, 63, 493, 9, 465, 289, 26, 288, 289, 63, 604, 275, 289, 14, 739, 342, 288, 340, 2061, 63, 5540, 440, 315, 289, 63, 604, 26, 355, 870, 480, 1173, 787, 440, 314, 2011, 12, 11482, 295, 1069, 531, 355, 340, 3542, 26, 490, 295, 1069, 29, 549, 288, 587, 26, 355, 870, 480, 1173, 14874, 9124, 355, 340, 440, 747, 14, 515, 14, 6292, 360, 270, 1483, 14, 2424, 358, 503, 440, 747, 14, 515, 14, 6292, 360, 599, 1190, 14, 2424, 735, 490, 295, 1069, 275, 715, 490, 870, 480, 5535, 4124, 531, 339, 340, 295, 1069, 26, 267, 870, 480, 497, 13, 1069, 316, 666, 531, 267, 1056, 275, 4145, 14, 362, 8, 633, 9, 267, 1315, 275, 10392, 14, 15016, 8, 15466, 8, 1069, 14, 1317, 430, 267, 1315, 14, 5005, 452, 342, 267, 543, 1551, 8, 2139, 63, 493, 12, 283, 87, 358, 465, 289, 26, 288, 870, 8, 2019, 63, 5540, 12, 570, 29, 70, 9, 267, 372, 1315, 326, 199, 318, 3957, 63, 1587, 63, 475, 63, 513, 8, 1587, 304, 339, 327, 10414, 1165, 63, 14346, 63, 513, 275, 359, 495, 8, 73, 9, 367, 284, 315, 10414, 1165, 63, 14346, 63, 1587, 459, 7254, 63, 344, 2278, 13633, 5106, 272, 327, 10414, 1165, 63, 19082, 63, 513, 275, 359, 495, 8, 73, 9, 367, 284, 315, 10414, 1165, 63, 19082, 63, 1587, 459, 7254, 63, 344, 2278, 13633, 5106, 272, 372, 779, 495, 8, 73, 9, 367, 284, 315, 4051, 459, 7254, 63, 344, 2278, 13633, 9383, 199, 199, 318, 664, 63, 3093, 63, 521, 63, 576, 63, 1069, 63, 1310, 8, 1291, 29, 797, 304, 272, 340, 1406, 26, 267, 519, 275, 4145, 14, 2993, 360, 1014, 921, 1544, 14, 29048, 13, 848, 422, 14, 957, 15, 3098, 63, 5186, 15, 32220, 4152, 14, 3317, 297, 1790, 2687, 736, 14, 12959, 360, 11876, 36, 63, 11958, 659, 747, 14, 12959, 360, 11876, 36, 63, 9032, 7058, 267, 372, 8, 82, 14, 2139, 9, 272, 587, 26, 267, 519, 275, 4145, 14, 362, 360, 1014, 921, 1544, 14, 29048, 13, 848, 422, 14, 957, 15, 3098, 63, 5186, 15, 32220, 4152, 14, 3317, 297, 1790, 2687, 736, 14, 12959, 360, 11876, 36, 63, 11958, 659, 747, 14, 12959, 360, 11876, 36, 63, 9032, 7058, 267, 340, 519, 14, 745, 26, 288, 372, 8, 82, 14, 1317, 9, 267, 587, 26, 288, 372, 488, 199, 199, 318, 664, 63, 8327, 8, 5610, 63, 513, 304, 339, 4733, 275, 16484, 2319, 63, 3093, 521, 63, 3317, 18, 14, 7658, 2209, 342, 272, 1564, 275, 664, 63, 3093, 63, 521, 63, 576, 63, 1069, 63, 1310, 342, 272, 4733, 14, 28685, 8, 1317, 9, 272, 769, 63, 8327, 275, 942, 339, 367, 4642, 315, 4733, 14, 4502, 26, 267, 340, 4642, 14, 7254, 63, 873, 14, 7254, 14, 7254, 63, 344, 315, 10414, 63, 513, 26, 288, 769, 63, 8327, 14, 740, 8, 4502, 9, 2378, 870, 480, 28277, 9045, 531, 272, 870, 8, 513, 63, 8327, 9, 272, 372, 8, 513, 63, 8327, 9, 199, 199, 318, 664, 63, 16835, 63, 509, 63, 513, 63, 8327, 8, 513, 63, 8327, 12, 20922, 63, 1587, 12, 1453, 63, 1985, 29, 3472, 63, 16575, 12, 3229, 1190, 63, 1587, 29, 403, 304, 272, 340, 3229, 1190, 63, 1587, 365, 488, 26, 267, 3229, 1190, 63, 1587, 275, 6454, 14, 739, 63, 4737, 360, 599, 1190, 14, 2424, 358, 339, 3608, 275, 942, 272, 367, 4642, 315, 769, 63, 8327, 26, 267, 3631, 63, 521, 63, 873, 275, 4642, 14, 7254, 63, 873, 14, 2379, 63, 521, 63, 873, 59, 16, 61, 267, 7339, 275, 3631, 63, 521, 63, 873, 14, 27532, 608, 14, 5814, 267, 30043, 369, 275, 3631, 63, 521, 63, 873, 14, 27532, 608, 14, 31794, 877, 369, 267, 4487, 275, 2197, 14, 2083, 14, 18531, 8, 2379, 63, 521, 63, 873, 14, 27532, 608, 14, 521, 9, 267, 4487, 275, 4487, 446, 2197, 14, 7473, 8, 8419, 29, 11288, 63, 14839, 9, 267, 21124, 608, 63, 521, 275, 4487, 14, 6205, 3508, 40, 2689, 45, 358, 398, 18284, 63, 2379, 63, 521, 275, 378, 267, 18284, 63, 2379, 63, 354, 275, 2125, 398, 18038, 63, 344, 275, 4642, 14, 7254, 63, 873, 14, 7254, 14, 7254, 63, 344, 267, 7475, 63, 344, 12, 7475, 63, 354, 275, 664, 63, 5610, 63, 354, 8, 7254, 63, 344, 12, 3229, 1190, 63, 1587, 9, 398, 8396, 12, 6132, 12, 3631, 63, 354, 275, 664, 63, 1985, 63, 1618, 63, 2379, 63, 521, 63, 873, 8, 2379, 63, 521, 63, 873, 9, 398, 3608, 14, 740, 1332, 4452, 12, 6132, 12, 3631, 63, 354, 12, 21124, 608, 63, 521, 12, 7339, 12, 30043, 369, 12, 18284, 63, 2379, 63, 521, 12, 18284, 63, 2379, 63, 354, 12, 7475, 63, 344, 12, 7475, 63, 354, 12, 18038, 63, 344, 430, 339, 372, 3608, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
40223108/w18
static/Brython3.1.3-20150514-095342/Lib/warnings.py
752
13825
"""Python part of the warnings subsystem.""" # Note: function level imports should *not* be used # in this module as it may cause import lock deadlock. # See bug 683658. import linecache import sys __all__ = ["warn", "showwarning", "formatwarning", "filterwarnings", "resetwarnings", "catch_warnings"] def showwarning(message, category, filename, lineno, file=None, line=None): """Hook to write a warning to a file; replace if you like.""" if file is None: file = sys.stderr try: file.write(formatwarning(message, category, filename, lineno, line)) except IOError: pass # the file (probably stderr) is invalid - this warning gets lost. def formatwarning(message, category, filename, lineno, line=None): """Function to format a warning the standard way.""" s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message) line = linecache.getline(filename, lineno) if line is None else line if line: line = line.strip() s += " %s\n" % line return s def filterwarnings(action, message="", category=Warning, module="", lineno=0, append=False): """Insert an entry into the list of warnings filters (at the front). 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'message' -- a regex that the warning message must match 'category' -- a class that the warning must be a subclass of 'module' -- a regex that the module name must match 'lineno' -- an integer line number, 0 matches all warnings 'append' -- if true, append to the list of filters """ import re assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) assert isinstance(message, str), "message must be a string" assert isinstance(category, type), "category must be a class" assert issubclass(category, Warning), "category must be a Warning subclass" assert isinstance(module, str), "module must be a string" assert isinstance(lineno, int) and lineno >= 0, \ "lineno must be an int >= 0" item = (action, re.compile(message, re.I), category, re.compile(module), lineno) if append: filters.append(item) else: filters.insert(0, item) def simplefilter(action, category=Warning, lineno=0, append=False): """Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'category' -- a class that the warning must be a subclass of 'lineno' -- an integer line number, 0 matches all warnings 'append' -- if true, append to the list of filters """ assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) assert isinstance(lineno, int) and lineno >= 0, \ "lineno must be an int >= 0" item = (action, None, category, None, lineno) if append: filters.append(item) else: filters.insert(0, item) def resetwarnings(): """Clear the list of warning filters, so that no filters are active.""" filters[:] = [] class _OptionError(Exception): """Exception used by option processing helpers.""" pass # Helper to process -W options passed via sys.warnoptions def _processoptions(args): for arg in args: try: _setoption(arg) except _OptionError as msg: print("Invalid -W option ignored:", msg, file=sys.stderr) # Helper for _processoptions() def _setoption(arg): import re parts = arg.split(':') if len(parts) > 5: raise _OptionError("too many fields (max 5): %r" % (arg,)) while len(parts) < 5: parts.append('') action, message, category, module, lineno = [s.strip() for s in parts] action = _getaction(action) message = re.escape(message) category = _getcategory(category) module = re.escape(module) if module: module = module + '$' if lineno: try: lineno = int(lineno) if lineno < 0: raise ValueError except (ValueError, OverflowError): raise _OptionError("invalid lineno %r" % (lineno,)) else: lineno = 0 filterwarnings(action, message, category, module, lineno) # Helper for _setoption() def _getaction(action): if not action: return "default" if action == "all": return "always" # Alias for a in ('default', 'always', 'ignore', 'module', 'once', 'error'): if a.startswith(action): return a raise _OptionError("invalid action: %r" % (action,)) # Helper for _setoption() def _getcategory(category): import re if not category: return Warning if re.match("^[a-zA-Z0-9_]+$", category): try: cat = eval(category) except NameError: raise _OptionError("unknown warning category: %r" % (category,)) else: i = category.rfind(".") module = category[:i] klass = category[i+1:] try: m = __import__(module, None, None, [klass]) except ImportError: raise _OptionError("invalid module name: %r" % (module,)) try: cat = getattr(m, klass) except AttributeError: raise _OptionError("unknown warning category: %r" % (category,)) if not issubclass(cat, Warning): raise _OptionError("invalid warning category: %r" % (category,)) return cat # Code typically replaced by _warnings def warn(message, category=None, stacklevel=1): """Issue a warning, or maybe ignore it or raise an exception.""" # Check if message is already a Warning object if isinstance(message, Warning): category = message.__class__ # Check category argument if category is None: category = UserWarning assert issubclass(category, Warning) # Get context information try: caller = sys._getframe(stacklevel) except ValueError: globals = sys.__dict__ lineno = 1 else: globals = caller.f_globals lineno = caller.f_lineno if '__name__' in globals: module = globals['__name__'] else: module = "<string>" filename = globals.get('__file__') if filename: fnl = filename.lower() if fnl.endswith((".pyc", ".pyo")): filename = filename[:-1] else: if module == "__main__": try: filename = sys.argv[0] except AttributeError: # embedded interpreters don't have sys.argv, see bug #839151 filename = '__main__' if not filename: filename = module registry = globals.setdefault("__warningregistry__", {}) warn_explicit(message, category, filename, lineno, module, registry, globals) def warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None): lineno = int(lineno) if module is None: module = filename or "<unknown>" if module[-3:].lower() == ".py": module = module[:-3] # XXX What about leading pathname? if registry is None: registry = {} if isinstance(message, Warning): text = str(message) category = message.__class__ else: text = message message = category(message) key = (text, category, lineno) # Quick test for common case if registry.get(key): return # Search the filters for item in filters: action, msg, cat, mod, ln = item if ((msg is None or msg.match(text)) and issubclass(category, cat) and (mod is None or mod.match(module)) and (ln == 0 or lineno == ln)): break else: action = defaultaction # Early exit actions if action == "ignore": registry[key] = 1 return # Prime the linecache for formatting, in case the # "file" is actually in a zipfile or something. linecache.getlines(filename, module_globals) if action == "error": raise message # Other actions if action == "once": registry[key] = 1 oncekey = (text, category) if onceregistry.get(oncekey): return onceregistry[oncekey] = 1 elif action == "always": pass elif action == "module": registry[key] = 1 altkey = (text, category, 0) if registry.get(altkey): return registry[altkey] = 1 elif action == "default": registry[key] = 1 else: # Unrecognized actions are errors raise RuntimeError( "Unrecognized action (%r) in warnings.filters:\n %s" % (action, item)) if not callable(showwarning): raise TypeError("warnings.showwarning() must be set to a " "function or method") # Print message and context showwarning(message, category, filename, lineno) class WarningMessage(object): """Holds the result of a single showwarning() call.""" _WARNING_DETAILS = ("message", "category", "filename", "lineno", "file", "line") def __init__(self, message, category, filename, lineno, file=None, line=None): local_values = locals() for attr in self._WARNING_DETAILS: setattr(self, attr, local_values[attr]) self._category_name = category.__name__ if category else None def __str__(self): return ("{message : %r, category : %r, filename : %r, lineno : %s, " "line : %r}" % (self.message, self._category_name, self.filename, self.lineno, self.line)) class catch_warnings(object): """A context manager that copies and restores the warnings filter upon exiting the context. The 'record' argument specifies whether warnings should be captured by a custom implementation of warnings.showwarning() and be appended to a list returned by the context manager. Otherwise None is returned by the context manager. The objects appended to the list are arguments whose attributes mirror the arguments to showwarning(). The 'module' argument is to specify an alternative module to the module named 'warnings' and imported under that name. This argument is only useful when testing the warnings module itself. """ def __init__(self, *, record=False, module=None): """Specify whether to record warnings and if an alternative module should be used other than sys.modules['warnings']. For compatibility with Python 3.0, please consider all arguments to be keyword-only. """ self._record = record self._module = sys.modules['warnings'] if module is None else module self._entered = False def __repr__(self): args = [] if self._record: args.append("record=True") if self._module is not sys.modules['warnings']: args.append("module=%r" % self._module) name = type(self).__name__ return "%s(%s)" % (name, ", ".join(args)) def __enter__(self): if self._entered: raise RuntimeError("Cannot enter %r twice" % self) self._entered = True self._filters = self._module.filters self._module.filters = self._filters[:] self._showwarning = self._module.showwarning if self._record: log = [] def showwarning(*args, **kwargs): log.append(WarningMessage(*args, **kwargs)) self._module.showwarning = showwarning return log else: return None def __exit__(self, *exc_info): if not self._entered: raise RuntimeError("Cannot exit %r without entering first" % self) self._module.filters = self._filters self._module.showwarning = self._showwarning # filters contains a sequence of filter 5-tuples # The components of the 5-tuple are: # - an action: error, ignore, always, default, module, or once # - a compiled regex that must match the warning message # - a class representing the warning category # - a compiled regex that must match the module that is being warned # - a line number for the line being warning, or 0 to mean any line # If either if the compiled regexs are None, match anything. _warnings_defaults = False try: from _warnings import (filters, _defaultaction, _onceregistry, warn, warn_explicit) defaultaction = _defaultaction onceregistry = _onceregistry _warnings_defaults = True except ImportError: filters = [] defaultaction = "default" onceregistry = {} # Module initialization _processoptions(sys.warnoptions) if not _warnings_defaults: silence = [ImportWarning, PendingDeprecationWarning] silence.append(DeprecationWarning) for cls in silence: simplefilter("ignore", category=cls) bytes_warning = sys.flags.bytes_warning if bytes_warning > 1: bytes_action = "error" elif bytes_warning: bytes_action = "default" else: bytes_action = "ignore" simplefilter(bytes_action, category=BytesWarning, append=1) # resource usage warnings are enabled by default in pydebug mode if hasattr(sys, 'gettotalrefcount'): resource_action = "always" else: resource_action = "ignore" simplefilter(resource_action, category=ResourceWarning, append=1) del _warnings_defaults
gpl-3.0
[ 624, 4718, 1777, 402, 314, 3598, 1007, 2253, 1041, 199, 199, 3, 3390, 26, 805, 2166, 8925, 1077, 627, 1397, 10, 506, 1202, 199, 3, 315, 642, 859, 465, 652, 1443, 7675, 492, 4650, 12314, 831, 14, 199, 3, 1666, 6519, 10851, 1344, 2010, 14, 199, 646, 26026, 199, 646, 984, 199, 199, 363, 452, 363, 275, 2097, 4050, 401, 298, 29109, 401, 298, 908, 3764, 401, 298, 23945, 401, 1779, 298, 3958, 5451, 401, 298, 9341, 63, 5451, 937, 421, 199, 318, 930, 25268, 8, 1188, 12, 4637, 12, 1788, 12, 5874, 12, 570, 29, 403, 12, 1004, 29, 403, 304, 272, 408, 8481, 370, 2218, 282, 5721, 370, 282, 570, 27, 3350, 340, 1265, 2839, 1041, 272, 340, 570, 365, 488, 26, 267, 570, 275, 984, 14, 3083, 272, 862, 26, 267, 570, 14, 952, 8, 908, 3764, 8, 1188, 12, 4637, 12, 1788, 12, 5874, 12, 1004, 430, 272, 871, 5925, 26, 267, 986, 327, 314, 570, 334, 6101, 6665, 4635, 9, 365, 3866, 446, 642, 5721, 7545, 14669, 14, 199, 199, 318, 1475, 3764, 8, 1188, 12, 4637, 12, 1788, 12, 5874, 12, 1004, 29, 403, 304, 272, 408, 3481, 370, 1475, 282, 5721, 314, 4465, 4340, 1041, 272, 308, 275, 221, 2071, 83, 2689, 83, 26, 450, 83, 26, 450, 83, 60, 78, 2, 450, 334, 1501, 12, 5874, 12, 4637, 855, 354, 3108, 1245, 9, 272, 1004, 275, 26026, 14, 362, 604, 8, 1501, 12, 5874, 9, 340, 1004, 365, 488, 587, 1004, 272, 340, 1004, 26, 267, 1004, 275, 1004, 14, 1913, 342, 267, 308, 847, 298, 221, 450, 83, 60, 78, 2, 450, 1004, 272, 372, 308, 199, 199, 318, 2457, 5451, 8, 1287, 12, 1245, 8772, 4637, 29, 3849, 12, 859, 8772, 5874, 29, 16, 12, 673, 5666, 29, 797, 304, 272, 408, 9971, 376, 2397, 1901, 314, 769, 402, 3598, 4766, 334, 292, 314, 13738, 680, 339, 283, 1287, 7, 1553, 1373, 402, 298, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 355, 503, 298, 5089, 2, 272, 283, 1188, 7, 1553, 282, 5163, 626, 314, 5721, 1245, 1471, 1336, 272, 283, 3710, 7, 1553, 282, 1021, 626, 314, 5721, 1471, 506, 282, 5516, 402, 272, 283, 578, 7, 1553, 282, 5163, 626, 314, 859, 536, 1471, 1336, 272, 283, 3469, 7, 1553, 376, 3000, 1004, 1329, 12, 378, 4450, 1006, 3598, 272, 283, 740, 7, 1553, 340, 2549, 12, 5666, 370, 314, 769, 402, 4766, 272, 408, 272, 492, 295, 272, 702, 1595, 315, 1689, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 1993, 298, 5089, 1288, 298, 3197, 1595, 26, 450, 82, 2, 450, 334, 1287, 4258, 272, 702, 1228, 8, 1188, 12, 620, 395, 298, 1188, 1471, 506, 282, 1059, 2, 272, 702, 1228, 8, 3710, 12, 730, 395, 298, 3710, 1471, 506, 282, 1021, 2, 272, 702, 11602, 8, 3710, 12, 15902, 395, 298, 3710, 1471, 506, 282, 15902, 5516, 2, 272, 702, 1228, 8, 578, 12, 620, 395, 298, 578, 1471, 506, 282, 1059, 2, 272, 702, 1228, 8, 3469, 12, 1109, 9, 436, 5874, 2356, 378, 12, 971, 1779, 298, 3469, 1471, 506, 376, 1109, 2356, 378, 2, 272, 1242, 275, 334, 1287, 12, 295, 14, 2014, 8, 1188, 12, 295, 14, 41, 395, 4637, 12, 288, 295, 14, 2014, 8, 578, 395, 5874, 9, 272, 340, 5666, 26, 267, 4766, 14, 740, 8, 1053, 9, 272, 587, 26, 267, 4766, 14, 3176, 8, 16, 12, 1242, 9, 199, 199, 318, 3486, 1541, 8, 1287, 12, 4637, 29, 3849, 12, 5874, 29, 16, 12, 5666, 29, 797, 304, 272, 408, 9971, 282, 3486, 2397, 1901, 314, 769, 402, 3598, 4766, 334, 292, 314, 13738, 680, 339, 437, 3486, 2457, 4450, 1006, 4621, 436, 3788, 14, 272, 283, 1287, 7, 1553, 1373, 402, 298, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 355, 503, 298, 5089, 2, 272, 283, 3710, 7, 1553, 282, 1021, 626, 314, 5721, 1471, 506, 282, 5516, 402, 272, 283, 3469, 7, 1553, 376, 3000, 1004, 1329, 12, 378, 4450, 1006, 3598, 272, 283, 740, 7, 1553, 340, 2549, 12, 5666, 370, 314, 769, 402, 4766, 272, 408, 272, 702, 1595, 315, 1689, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 1993, 298, 5089, 1288, 298, 3197, 1595, 26, 450, 82, 2, 450, 334, 1287, 4258, 272, 702, 1228, 8, 3469, 12, 1109, 9, 436, 5874, 2356, 378, 12, 971, 1779, 298, 3469, 1471, 506, 376, 1109, 2356, 378, 2, 272, 1242, 275, 334, 1287, 12, 488, 12, 4637, 12, 488, 12, 5874, 9, 272, 340, 5666, 26, 267, 4766, 14, 740, 8, 1053, 9, 272, 587, 26, 267, 4766, 14, 3176, 8, 16, 12, 1242, 9, 199, 199, 318, 5305, 5451, 837, 272, 408, 9721, 314, 769, 402, 5721, 4766, 12, 880, 626, 949, 4766, 787, 4702, 1041, 272, 4766, 5873, 275, 942, 199, 199, 533, 485, 16546, 8, 1726, 304, 272, 408, 1726, 1202, 701, 945, 6661, 10897, 1041, 272, 986, 199, 199, 3, 11642, 370, 2112, 446, 55, 1511, 3032, 4799, 984, 14, 4050, 1419, 199, 318, 485, 1412, 1419, 8, 589, 304, 272, 367, 1680, 315, 1249, 26, 267, 862, 26, 288, 485, 409, 1422, 8, 1273, 9, 267, 871, 485, 16546, 465, 1499, 26, 288, 870, 480, 3364, 446, 55, 945, 5525, 6783, 1499, 12, 570, 29, 1274, 14, 3083, 9, 199, 199, 3, 11642, 367, 485, 1412, 1419, 342, 199, 318, 485, 409, 1422, 8, 1273, 304, 272, 492, 295, 272, 4184, 275, 1680, 14, 1294, 11633, 272, 340, 822, 8, 4181, 9, 690, 959, 26, 267, 746, 485, 16546, 480, 7354, 5002, 1504, 334, 988, 959, 304, 450, 82, 2, 450, 334, 1273, 4641, 272, 1830, 822, 8, 4181, 9, 665, 959, 26, 267, 4184, 14, 740, 8355, 272, 1595, 12, 1245, 12, 4637, 12, 859, 12, 5874, 275, 359, 83, 14, 1913, 342, 1740, 367, 308, 315, 4184, 61, 272, 1595, 275, 485, 362, 1287, 8, 1287, 9, 272, 1245, 275, 295, 14, 3765, 8, 1188, 9, 272, 4637, 275, 485, 362, 3710 ]
[ 4718, 1777, 402, 314, 3598, 1007, 2253, 1041, 199, 199, 3, 3390, 26, 805, 2166, 8925, 1077, 627, 1397, 10, 506, 1202, 199, 3, 315, 642, 859, 465, 652, 1443, 7675, 492, 4650, 12314, 831, 14, 199, 3, 1666, 6519, 10851, 1344, 2010, 14, 199, 646, 26026, 199, 646, 984, 199, 199, 363, 452, 363, 275, 2097, 4050, 401, 298, 29109, 401, 298, 908, 3764, 401, 298, 23945, 401, 1779, 298, 3958, 5451, 401, 298, 9341, 63, 5451, 937, 421, 199, 318, 930, 25268, 8, 1188, 12, 4637, 12, 1788, 12, 5874, 12, 570, 29, 403, 12, 1004, 29, 403, 304, 272, 408, 8481, 370, 2218, 282, 5721, 370, 282, 570, 27, 3350, 340, 1265, 2839, 1041, 272, 340, 570, 365, 488, 26, 267, 570, 275, 984, 14, 3083, 272, 862, 26, 267, 570, 14, 952, 8, 908, 3764, 8, 1188, 12, 4637, 12, 1788, 12, 5874, 12, 1004, 430, 272, 871, 5925, 26, 267, 986, 327, 314, 570, 334, 6101, 6665, 4635, 9, 365, 3866, 446, 642, 5721, 7545, 14669, 14, 199, 199, 318, 1475, 3764, 8, 1188, 12, 4637, 12, 1788, 12, 5874, 12, 1004, 29, 403, 304, 272, 408, 3481, 370, 1475, 282, 5721, 314, 4465, 4340, 1041, 272, 308, 275, 221, 2071, 83, 2689, 83, 26, 450, 83, 26, 450, 83, 60, 78, 2, 450, 334, 1501, 12, 5874, 12, 4637, 855, 354, 3108, 1245, 9, 272, 1004, 275, 26026, 14, 362, 604, 8, 1501, 12, 5874, 9, 340, 1004, 365, 488, 587, 1004, 272, 340, 1004, 26, 267, 1004, 275, 1004, 14, 1913, 342, 267, 308, 847, 298, 221, 450, 83, 60, 78, 2, 450, 1004, 272, 372, 308, 199, 199, 318, 2457, 5451, 8, 1287, 12, 1245, 8772, 4637, 29, 3849, 12, 859, 8772, 5874, 29, 16, 12, 673, 5666, 29, 797, 304, 272, 408, 9971, 376, 2397, 1901, 314, 769, 402, 3598, 4766, 334, 292, 314, 13738, 680, 339, 283, 1287, 7, 1553, 1373, 402, 298, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 355, 503, 298, 5089, 2, 272, 283, 1188, 7, 1553, 282, 5163, 626, 314, 5721, 1245, 1471, 1336, 272, 283, 3710, 7, 1553, 282, 1021, 626, 314, 5721, 1471, 506, 282, 5516, 402, 272, 283, 578, 7, 1553, 282, 5163, 626, 314, 859, 536, 1471, 1336, 272, 283, 3469, 7, 1553, 376, 3000, 1004, 1329, 12, 378, 4450, 1006, 3598, 272, 283, 740, 7, 1553, 340, 2549, 12, 5666, 370, 314, 769, 402, 4766, 272, 408, 272, 492, 295, 272, 702, 1595, 315, 1689, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 1993, 298, 5089, 1288, 298, 3197, 1595, 26, 450, 82, 2, 450, 334, 1287, 4258, 272, 702, 1228, 8, 1188, 12, 620, 395, 298, 1188, 1471, 506, 282, 1059, 2, 272, 702, 1228, 8, 3710, 12, 730, 395, 298, 3710, 1471, 506, 282, 1021, 2, 272, 702, 11602, 8, 3710, 12, 15902, 395, 298, 3710, 1471, 506, 282, 15902, 5516, 2, 272, 702, 1228, 8, 578, 12, 620, 395, 298, 578, 1471, 506, 282, 1059, 2, 272, 702, 1228, 8, 3469, 12, 1109, 9, 436, 5874, 2356, 378, 12, 971, 1779, 298, 3469, 1471, 506, 376, 1109, 2356, 378, 2, 272, 1242, 275, 334, 1287, 12, 295, 14, 2014, 8, 1188, 12, 295, 14, 41, 395, 4637, 12, 288, 295, 14, 2014, 8, 578, 395, 5874, 9, 272, 340, 5666, 26, 267, 4766, 14, 740, 8, 1053, 9, 272, 587, 26, 267, 4766, 14, 3176, 8, 16, 12, 1242, 9, 199, 199, 318, 3486, 1541, 8, 1287, 12, 4637, 29, 3849, 12, 5874, 29, 16, 12, 5666, 29, 797, 304, 272, 408, 9971, 282, 3486, 2397, 1901, 314, 769, 402, 3598, 4766, 334, 292, 314, 13738, 680, 339, 437, 3486, 2457, 4450, 1006, 4621, 436, 3788, 14, 272, 283, 1287, 7, 1553, 1373, 402, 298, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 355, 503, 298, 5089, 2, 272, 283, 3710, 7, 1553, 282, 1021, 626, 314, 5721, 1471, 506, 282, 5516, 402, 272, 283, 3469, 7, 1553, 376, 3000, 1004, 1329, 12, 378, 4450, 1006, 3598, 272, 283, 740, 7, 1553, 340, 2549, 12, 5666, 370, 314, 769, 402, 4766, 272, 408, 272, 702, 1595, 315, 1689, 705, 401, 298, 4247, 401, 298, 9223, 401, 298, 885, 401, 298, 578, 401, 1993, 298, 5089, 1288, 298, 3197, 1595, 26, 450, 82, 2, 450, 334, 1287, 4258, 272, 702, 1228, 8, 3469, 12, 1109, 9, 436, 5874, 2356, 378, 12, 971, 1779, 298, 3469, 1471, 506, 376, 1109, 2356, 378, 2, 272, 1242, 275, 334, 1287, 12, 488, 12, 4637, 12, 488, 12, 5874, 9, 272, 340, 5666, 26, 267, 4766, 14, 740, 8, 1053, 9, 272, 587, 26, 267, 4766, 14, 3176, 8, 16, 12, 1242, 9, 199, 199, 318, 5305, 5451, 837, 272, 408, 9721, 314, 769, 402, 5721, 4766, 12, 880, 626, 949, 4766, 787, 4702, 1041, 272, 4766, 5873, 275, 942, 199, 199, 533, 485, 16546, 8, 1726, 304, 272, 408, 1726, 1202, 701, 945, 6661, 10897, 1041, 272, 986, 199, 199, 3, 11642, 370, 2112, 446, 55, 1511, 3032, 4799, 984, 14, 4050, 1419, 199, 318, 485, 1412, 1419, 8, 589, 304, 272, 367, 1680, 315, 1249, 26, 267, 862, 26, 288, 485, 409, 1422, 8, 1273, 9, 267, 871, 485, 16546, 465, 1499, 26, 288, 870, 480, 3364, 446, 55, 945, 5525, 6783, 1499, 12, 570, 29, 1274, 14, 3083, 9, 199, 199, 3, 11642, 367, 485, 1412, 1419, 342, 199, 318, 485, 409, 1422, 8, 1273, 304, 272, 492, 295, 272, 4184, 275, 1680, 14, 1294, 11633, 272, 340, 822, 8, 4181, 9, 690, 959, 26, 267, 746, 485, 16546, 480, 7354, 5002, 1504, 334, 988, 959, 304, 450, 82, 2, 450, 334, 1273, 4641, 272, 1830, 822, 8, 4181, 9, 665, 959, 26, 267, 4184, 14, 740, 8355, 272, 1595, 12, 1245, 12, 4637, 12, 859, 12, 5874, 275, 359, 83, 14, 1913, 342, 1740, 367, 308, 315, 4184, 61, 272, 1595, 275, 485, 362, 1287, 8, 1287, 9, 272, 1245, 275, 295, 14, 3765, 8, 1188, 9, 272, 4637, 275, 485, 362, 3710, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
longman694/youtube-dl
youtube_dl/extractor/noz.py
64
3665
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urllib_parse_unquote, compat_xpath, ) from ..utils import ( int_or_none, find_xpath_attr, xpath_text, update_url_query, ) class NozIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?noz\.de/video/(?P<id>[0-9]+)/' _TESTS = [{ 'url': 'http://www.noz.de/video/25151/32-Deutschland-gewinnt-Badminton-Lnderspiel-in-Melle', 'info_dict': { 'id': '25151', 'ext': 'mp4', 'duration': 215, 'title': '3:2 - Deutschland gewinnt Badminton-Länderspiel in Melle', 'description': 'Vor rund 370 Zuschauern gewinnt die deutsche Badminton-Nationalmannschaft am Donnerstag ein EM-Vorbereitungsspiel gegen Frankreich in Melle. Video Moritz Frankenberg.', 'thumbnail': r're:^http://.*\.jpg', }, }] def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) description = self._og_search_description(webpage) edge_url = self._html_search_regex( r'<script\s+(?:type="text/javascript"\s+)?src="(.*?/videojs_.*?)"', webpage, 'edge URL') edge_content = self._download_webpage(edge_url, 'meta configuration') config_url_encoded = self._search_regex( r'so\.addVariable\("config_url","[^,]*,(.*?)"', edge_content, 'config URL' ) config_url = compat_urllib_parse_unquote(config_url_encoded) doc = self._download_xml(config_url, 'video configuration') title = xpath_text(doc, './/title') thumbnail = xpath_text(doc, './/article/thumbnail/url') duration = int_or_none(xpath_text( doc, './/article/movie/file/duration')) formats = [] for qnode in doc.findall(compat_xpath('.//article/movie/file/qualities/qual')): http_url_ele = find_xpath_attr( qnode, './html_urls/video_url', 'format', 'video/mp4') http_url = http_url_ele.text if http_url_ele is not None else None if http_url: formats.append({ 'url': http_url, 'format_name': xpath_text(qnode, './name'), 'format_id': '%s-%s' % ('http', xpath_text(qnode, './id')), 'height': int_or_none(xpath_text(qnode, './height')), 'width': int_or_none(xpath_text(qnode, './width')), 'tbr': int_or_none(xpath_text(qnode, './bitrate'), scale=1000), }) else: f4m_url = xpath_text(qnode, 'url_hd2') if f4m_url: formats.extend(self._extract_f4m_formats( update_url_query(f4m_url, {'hdcore': '3.4.0'}), video_id, f4m_id='hds', fatal=False)) m3u8_url_ele = find_xpath_attr( qnode, './html_urls/video_url', 'format', 'application/vnd.apple.mpegurl') m3u8_url = m3u8_url_ele.text if m3u8_url_ele is not None else None if m3u8_url: formats.extend(self._extract_m3u8_formats( m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) self._sort_formats(formats) return { 'id': video_id, 'formats': formats, 'title': title, 'duration': duration, 'description': description, 'thumbnail': thumbnail, }
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 63, 12240, 12, 272, 8434, 63, 8006, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 2342, 63, 8006, 63, 962, 12, 272, 14462, 63, 505, 12, 272, 1678, 63, 633, 63, 1131, 12, 199, 9, 421, 199, 533, 3091, 90, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 889, 90, 4537, 271, 15, 3722, 9448, 48, 28, 344, 9514, 16, 13, 25, 24598, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 889, 90, 14, 271, 15, 3722, 15, 821, 12768, 15, 708, 13, 872, 14608, 335, 9688, 13, 303, 2676, 343, 13, 5725, 77, 442, 265, 13, 8940, 424, 8721, 352, 13, 262, 13, 45, 352, 274, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 821, 12768, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 5553, 356, 28436, 12, 288, 283, 1213, 356, 283, 19, 26, 18, 446, 1487, 14608, 335, 9688, 2312, 2676, 343, 8857, 77, 442, 265, 13, 44, 13733, 78, 424, 8721, 352, 315, 603, 352, 274, 297, 288, 283, 1802, 356, 283, 54, 269, 519, 725, 650, 2760, 3107, 527, 335, 3844, 27569, 2312, 2676, 343, 18833, 477, 14608, 595, 8857, 77, 442, 265, 13, 46, 6279, 1237, 561, 9518, 856, 8140, 7529, 1372, 270, 643, 325, 262, 26512, 13, 54, 269, 1235, 264, 390, 10335, 385, 1038, 352, 2312, 2268, 11007, 264, 1158, 315, 603, 352, 274, 14, 15709, 603, 269, 23751, 481, 1312, 917, 14630, 3130, 288, 283, 8311, 356, 519, 3984, 23497, 1014, 921, 24736, 8476, 297, 267, 1660, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 9, 398, 6275, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 1579, 60, 83, 11, 5169, 466, 628, 505, 15, 9554, 3212, 83, 19544, 2164, 628, 17140, 15, 3722, 3596, 63, 6697, 32691, 288, 9248, 12, 283, 5173, 2851, 358, 267, 6275, 63, 1317, 275, 291, 423, 4249, 63, 12022, 8, 5173, 63, 633, 12, 283, 2024, 2897, 358, 398, 1101, 63, 633, 63, 8167, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 1159, 79, 4537, 525, 2773, 60, 480, 888, 63, 633, 2266, 4735, 12, 3672, 12803, 6697, 32691, 288, 6275, 63, 1317, 12, 283, 888, 2851, 7, 267, 776, 267, 1101, 63, 633, 275, 8434, 63, 4078, 63, 1122, 63, 12240, 8, 888, 63, 633, 63, 8167, 9, 398, 1382, 275, 291, 423, 4249, 63, 1652, 8, 888, 63, 633, 12, 283, 3722, 2897, 358, 267, 2538, 275, 14462, 63, 505, 8, 1301, 12, 1987, 501, 1213, 358, 267, 10062, 275, 14462, 63, 505, 8, 1301, 12, 1987, 501, 6934, 15, 8311, 15, 633, 358, 267, 7373, 275, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 288, 1382, 12, 1987, 501, 6934, 15, 10888, 15, 493, 15, 5553, 1333, 267, 6752, 275, 942, 267, 367, 1894, 932, 315, 1382, 14, 6452, 8, 5819, 63, 8006, 29995, 6934, 15, 10888, 15, 493, 15, 537, 12107, 15, 537, 8109, 288, 1455, 63, 633, 63, 8081, 275, 2342, 63, 8006, 63, 962, 8, 355, 1894, 932, 12, 21526, 1360, 63, 3603, 15, 3722, 63, 633, 297, 283, 908, 297, 283, 3722, 15, 311, 20, 358, 288, 1455, 63, 633, 275, 1455, 63, 633, 63, 8081, 14, 505, 340, 1455, 63, 633, 63, 8081, 365, 440, 488, 587, 488, 288, 340, 1455, 63, 633, 26, 355, 6752, 14, 740, 2561, 490, 283, 633, 356, 1455, 63, 633, 12, 490, 283, 908, 63, 354, 356, 14462, 63, 505, 8, 81, 932, 12, 21526, 354, 659, 490, 283, 908, 63, 344, 356, 1543, 83, 3295, 83, 7, 450, 661, 1014, 297, 14462, 63, 505, 8, 81, 932, 12, 21526, 344, 3855, 490, 283, 3333, 356, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 81, 932, 12, 21526, 3333, 3855, 490, 283, 2063, 356, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 81, 932, 12, 21526, 2063, 3855, 490, 283, 84, 3289, 356, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 81, 932, 12, 21526, 24484, 659, 4666, 29, 5279, 395, 355, 3828, 288, 587, 26, 355, 289, 20, 77, 63, 633, 275, 14462, 63, 505, 8, 81, 932, 12, 283, 633, 63, 7952, 18, 358, 355, 340, 289, 20, 77, 63, 633, 26, 490, 6752, 14, 2880, 8, 277, 423, 5005, 63, 70, 20, 77, 63, 6321, 8, 717, 1678, 63, 633, 63, 1131, 8, 70, 20, 77, 63, 633, 12, 791, 7952, 1018, 356, 283, 19, 14, 20, 14, 16, 1604, 717, 3991, 63, 344, 12, 289, 20, 77, 63, 344, 534, 72, 795, 297, 14294, 29, 797, 430, 355, 333, 19, 85, 24, 63, 633, 63, 8081, 275, 2342, 63, 8006, 63, 962, 8, 490, 1894, 932, 12, 21526, 1360, 63, 3603, 15, 3722, 63, 633, 297, 490, 283, 908, 297, 283, 3578, 15, 26379, 14, 12820, 14, 16801, 633, 358, 355, 333, 19, 85, 24, 63, 633, 275, 333, 19, 85, 24, 63, 633, 63, 8081, 14, 505, 340, 333, 19, 85, 24, 63, 633, 63, 8081, 365, 440, 488, 587, 488, 355, 340, 333, 19, 85, 24, 63, 633, 26, 490, 6752, 14, 2880, 8, 277, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 717, 333, 19, 85, 24, 63, 633, 12, 3991, 63, 344, 12, 283, 311, 20, 297, 283, 77, 19, 85, 24, 63, 6106, 297, 717, 333, 19, 85, 24, 63, 344, 534, 30252, 297, 14294, 29, 797, 430, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 63, 12240, 12, 272, 8434, 63, 8006, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 2342, 63, 8006, 63, 962, 12, 272, 14462, 63, 505, 12, 272, 1678, 63, 633, 63, 1131, 12, 199, 9, 421, 199, 533, 3091, 90, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 889, 90, 4537, 271, 15, 3722, 9448, 48, 28, 344, 9514, 16, 13, 25, 24598, 7, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 889, 90, 14, 271, 15, 3722, 15, 821, 12768, 15, 708, 13, 872, 14608, 335, 9688, 13, 303, 2676, 343, 13, 5725, 77, 442, 265, 13, 8940, 424, 8721, 352, 13, 262, 13, 45, 352, 274, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 821, 12768, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 5553, 356, 28436, 12, 288, 283, 1213, 356, 283, 19, 26, 18, 446, 1487, 14608, 335, 9688, 2312, 2676, 343, 8857, 77, 442, 265, 13, 44, 13733, 78, 424, 8721, 352, 315, 603, 352, 274, 297, 288, 283, 1802, 356, 283, 54, 269, 519, 725, 650, 2760, 3107, 527, 335, 3844, 27569, 2312, 2676, 343, 18833, 477, 14608, 595, 8857, 77, 442, 265, 13, 46, 6279, 1237, 561, 9518, 856, 8140, 7529, 1372, 270, 643, 325, 262, 26512, 13, 54, 269, 1235, 264, 390, 10335, 385, 1038, 352, 2312, 2268, 11007, 264, 1158, 315, 603, 352, 274, 14, 15709, 603, 269, 23751, 481, 1312, 917, 14630, 3130, 288, 283, 8311, 356, 519, 3984, 23497, 1014, 921, 24736, 8476, 297, 267, 1660, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 9, 398, 6275, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 1579, 60, 83, 11, 5169, 466, 628, 505, 15, 9554, 3212, 83, 19544, 2164, 628, 17140, 15, 3722, 3596, 63, 6697, 32691, 288, 9248, 12, 283, 5173, 2851, 358, 267, 6275, 63, 1317, 275, 291, 423, 4249, 63, 12022, 8, 5173, 63, 633, 12, 283, 2024, 2897, 358, 398, 1101, 63, 633, 63, 8167, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 1159, 79, 4537, 525, 2773, 60, 480, 888, 63, 633, 2266, 4735, 12, 3672, 12803, 6697, 32691, 288, 6275, 63, 1317, 12, 283, 888, 2851, 7, 267, 776, 267, 1101, 63, 633, 275, 8434, 63, 4078, 63, 1122, 63, 12240, 8, 888, 63, 633, 63, 8167, 9, 398, 1382, 275, 291, 423, 4249, 63, 1652, 8, 888, 63, 633, 12, 283, 3722, 2897, 358, 267, 2538, 275, 14462, 63, 505, 8, 1301, 12, 1987, 501, 1213, 358, 267, 10062, 275, 14462, 63, 505, 8, 1301, 12, 1987, 501, 6934, 15, 8311, 15, 633, 358, 267, 7373, 275, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 288, 1382, 12, 1987, 501, 6934, 15, 10888, 15, 493, 15, 5553, 1333, 267, 6752, 275, 942, 267, 367, 1894, 932, 315, 1382, 14, 6452, 8, 5819, 63, 8006, 29995, 6934, 15, 10888, 15, 493, 15, 537, 12107, 15, 537, 8109, 288, 1455, 63, 633, 63, 8081, 275, 2342, 63, 8006, 63, 962, 8, 355, 1894, 932, 12, 21526, 1360, 63, 3603, 15, 3722, 63, 633, 297, 283, 908, 297, 283, 3722, 15, 311, 20, 358, 288, 1455, 63, 633, 275, 1455, 63, 633, 63, 8081, 14, 505, 340, 1455, 63, 633, 63, 8081, 365, 440, 488, 587, 488, 288, 340, 1455, 63, 633, 26, 355, 6752, 14, 740, 2561, 490, 283, 633, 356, 1455, 63, 633, 12, 490, 283, 908, 63, 354, 356, 14462, 63, 505, 8, 81, 932, 12, 21526, 354, 659, 490, 283, 908, 63, 344, 356, 1543, 83, 3295, 83, 7, 450, 661, 1014, 297, 14462, 63, 505, 8, 81, 932, 12, 21526, 344, 3855, 490, 283, 3333, 356, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 81, 932, 12, 21526, 3333, 3855, 490, 283, 2063, 356, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 81, 932, 12, 21526, 2063, 3855, 490, 283, 84, 3289, 356, 1109, 63, 269, 63, 3592, 8, 8006, 63, 505, 8, 81, 932, 12, 21526, 24484, 659, 4666, 29, 5279, 395, 355, 3828, 288, 587, 26, 355, 289, 20, 77, 63, 633, 275, 14462, 63, 505, 8, 81, 932, 12, 283, 633, 63, 7952, 18, 358, 355, 340, 289, 20, 77, 63, 633, 26, 490, 6752, 14, 2880, 8, 277, 423, 5005, 63, 70, 20, 77, 63, 6321, 8, 717, 1678, 63, 633, 63, 1131, 8, 70, 20, 77, 63, 633, 12, 791, 7952, 1018, 356, 283, 19, 14, 20, 14, 16, 1604, 717, 3991, 63, 344, 12, 289, 20, 77, 63, 344, 534, 72, 795, 297, 14294, 29, 797, 430, 355, 333, 19, 85, 24, 63, 633, 63, 8081, 275, 2342, 63, 8006, 63, 962, 8, 490, 1894, 932, 12, 21526, 1360, 63, 3603, 15, 3722, 63, 633, 297, 490, 283, 908, 297, 283, 3578, 15, 26379, 14, 12820, 14, 16801, 633, 358, 355, 333, 19, 85, 24, 63, 633, 275, 333, 19, 85, 24, 63, 633, 63, 8081, 14, 505, 340, 333, 19, 85, 24, 63, 633, 63, 8081, 365, 440, 488, 587, 488, 355, 340, 333, 19, 85, 24, 63, 633, 26, 490, 6752, 14, 2880, 8, 277, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 717, 333, 19, 85, 24, 63, 633, 12, 3991, 63, 344, 12, 283, 311, 20, 297, 283, 77, 19, 85, 24, 63, 6106, 297, 717, 333, 19, 85, 24, 63, 344, 534, 30252, 297, 14294, 29, 797, 430, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 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, 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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 ]
d3trax/asuswrt-merlin
release/src/router/samba-3.5.8/source3/stf/pythoncheck.py
82
1720
#! /usr/bin/python # Comfychair test cases for Samba python extensions # Copyright (C) 2003 by Tim Potter <tpot@samba.org> # # 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/>. """These tests are run by Samba's "make check".""" import sys, comfychair class ImportTest(comfychair.TestCase): """Check that all modules can be imported without error.""" def runtest(self): python_modules = ['spoolss', 'lsa', 'samr', 'winbind', 'winreg', 'srvsvc', 'tdb', 'smb', 'tdbpack'] for m in python_modules: try: __import__('samba.%s' % m) except ImportError, msg: self.log(str(msg)) self.fail('error importing %s module' % m) tests = [ImportTest] if __name__ == '__main__': # Some magic to repend build directory to python path so we see the # objects we have built and not previously installed stuff. from distutils.util import get_platform from os import getcwd sys.path.insert(0, '%s/build/lib.%s-%s' % (getcwd(), get_platform(), sys.version[0:3])) comfychair.main(tests)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 199, 199, 3, 5429, 1399, 335, 8387, 511, 5560, 367, 428, 14310, 2366, 5478, 199, 199, 3, 1898, 334, 35, 9, 13004, 701, 26244, 510, 357, 351, 665, 683, 357, 32, 21693, 14, 1308, 30, 199, 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 20676, 2295, 787, 1255, 701, 428, 14310, 1159, 298, 1875, 1104, 2, 1041, 199, 199, 646, 984, 12, 2414, 1399, 335, 8387, 199, 199, 533, 3161, 774, 8, 957, 1399, 335, 8387, 14, 1746, 304, 272, 408, 1799, 626, 1006, 4621, 883, 506, 8439, 1928, 1125, 1041, 272, 347, 1255, 396, 8, 277, 304, 267, 2366, 63, 3112, 275, 788, 83, 2293, 385, 297, 283, 31288, 297, 283, 21660, 82, 297, 283, 2676, 3409, 297, 283, 15658, 297, 2079, 283, 15165, 10599, 297, 283, 84, 697, 297, 283, 23323, 297, 283, 84, 697, 1389, 418, 267, 367, 333, 315, 2366, 63, 3112, 26, 288, 862, 26, 355, 636, 646, 19734, 21693, 4111, 83, 7, 450, 333, 9, 288, 871, 3545, 12, 1499, 26, 355, 291, 14, 793, 8, 495, 8, 1328, 430, 355, 291, 14, 1633, 360, 705, 16306, 450, 83, 859, 7, 450, 333, 9, 199, 199, 2219, 275, 359, 6295, 774, 61, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 6601, 10628, 370, 1833, 500, 1900, 2082, 370, 2366, 931, 880, 781, 1937, 314, 272, 327, 2251, 781, 1172, 6137, 436, 440, 10889, 4903, 8292, 14, 272, 687, 7065, 14, 1974, 492, 664, 63, 3246, 272, 687, 747, 492, 664, 6525, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 1543, 83, 15, 1506, 15, 773, 4111, 83, 3295, 83, 7, 450, 490, 334, 9458, 1062, 664, 63, 3246, 1062, 984, 14, 1023, 59, 16, 26, 19, 2459, 339, 2414, 1399, 335, 8387, 14, 973, 8, 2219, 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 ]
[ 1182, 2647, 15, 1393, 15, 1548, 199, 199, 3, 5429, 1399, 335, 8387, 511, 5560, 367, 428, 14310, 2366, 5478, 199, 199, 3, 1898, 334, 35, 9, 13004, 701, 26244, 510, 357, 351, 665, 683, 357, 32, 21693, 14, 1308, 30, 199, 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 20676, 2295, 787, 1255, 701, 428, 14310, 1159, 298, 1875, 1104, 2, 1041, 199, 199, 646, 984, 12, 2414, 1399, 335, 8387, 199, 199, 533, 3161, 774, 8, 957, 1399, 335, 8387, 14, 1746, 304, 272, 408, 1799, 626, 1006, 4621, 883, 506, 8439, 1928, 1125, 1041, 272, 347, 1255, 396, 8, 277, 304, 267, 2366, 63, 3112, 275, 788, 83, 2293, 385, 297, 283, 31288, 297, 283, 21660, 82, 297, 283, 2676, 3409, 297, 283, 15658, 297, 2079, 283, 15165, 10599, 297, 283, 84, 697, 297, 283, 23323, 297, 283, 84, 697, 1389, 418, 267, 367, 333, 315, 2366, 63, 3112, 26, 288, 862, 26, 355, 636, 646, 19734, 21693, 4111, 83, 7, 450, 333, 9, 288, 871, 3545, 12, 1499, 26, 355, 291, 14, 793, 8, 495, 8, 1328, 430, 355, 291, 14, 1633, 360, 705, 16306, 450, 83, 859, 7, 450, 333, 9, 199, 199, 2219, 275, 359, 6295, 774, 61, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 327, 6601, 10628, 370, 1833, 500, 1900, 2082, 370, 2366, 931, 880, 781, 1937, 314, 272, 327, 2251, 781, 1172, 6137, 436, 440, 10889, 4903, 8292, 14, 272, 687, 7065, 14, 1974, 492, 664, 63, 3246, 272, 687, 747, 492, 664, 6525, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 1543, 83, 15, 1506, 15, 773, 4111, 83, 3295, 83, 7, 450, 490, 334, 9458, 1062, 664, 63, 3246, 1062, 984, 14, 1023, 59, 16, 26, 19, 2459, 339, 2414, 1399, 335, 8387, 14, 973, 8, 2219, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pmaigutyak/mp-shop
wishlist/models.py
1
2022
from django.conf import settings from django.db import models from django.utils.translation import ugettext_lazy as _ from wishlist import exceptions class WishListItem(models.Model): user = models.ForeignKey( settings.AUTH_USER_MODEL, related_name='wishlist_items', verbose_name=_('Owner'), on_delete=models.CASCADE) product = models.ForeignKey( 'products.Product', verbose_name=_('Product'), on_delete=models.CASCADE) date_created = models.DateTimeField( _('Date created'), auto_now_add=True, editable=False) def __str__(self): return str(self.product) class Meta: unique_together = ['user', 'product'] verbose_name = _('Wish list item') verbose_name_plural = _('Wish list items') class WishList(object): def __init__(self, user): self._user = user @property def _items(self): if not self._user.is_authenticated: raise exceptions.UserIsNotAuthenticated() if not hasattr(self, '_items_cache'): self._items_cache = { i.product_id: i for i in self._user.wishlist_items.all().select_related('product') } return self._items_cache def add(self, product): if product.id in self._items: raise exceptions.ProductAlreadyAdded() item = self._user.wishlist_items.create(product=product) self._items_cache[product.id] = item def remove(self, product_id): if product_id not in self._items: raise exceptions.ItemDoesNotExists() self._items[product_id].delete() del self._items[product_id] def has_product(self, product_id): if not self._user.is_authenticated: return False return product_id in self._items def __iter__(self): return iter(self._items.values()) def __len__(self): if self._user.is_authenticated: return len(self._items) return 0
isc
[ 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 13809, 513, 492, 4967, 421, 199, 533, 644, 2453, 24229, 8, 992, 14, 1685, 304, 339, 922, 275, 1709, 14, 3190, 8, 267, 2202, 14, 5580, 63, 3791, 63, 11429, 12, 4048, 63, 354, 534, 87, 2453, 513, 63, 1744, 297, 267, 3376, 63, 354, 12397, 14919, 659, 641, 63, 1807, 29, 992, 14, 10855, 9, 339, 3336, 275, 1709, 14, 3190, 8, 267, 283, 13336, 14, 5884, 297, 3376, 63, 354, 12397, 5884, 659, 267, 641, 63, 1807, 29, 992, 14, 10855, 9, 339, 1434, 63, 3966, 275, 1709, 14, 4626, 8, 267, 4018, 2506, 2737, 659, 2599, 63, 2131, 63, 525, 29, 549, 12, 14783, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 2558, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 788, 751, 297, 283, 2558, 418, 267, 3376, 63, 354, 275, 4018, 55, 2453, 769, 1242, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 55, 2453, 769, 2974, 358, 421, 199, 533, 644, 2453, 1296, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 922, 304, 267, 291, 423, 751, 275, 922, 339, 768, 1829, 272, 347, 485, 1744, 8, 277, 304, 398, 340, 440, 291, 423, 751, 14, 374, 63, 12177, 26, 288, 746, 4967, 14, 1899, 1831, 1763, 30871, 342, 398, 340, 440, 2688, 8, 277, 12, 2513, 1744, 63, 1637, 735, 288, 291, 423, 1744, 63, 1637, 275, 469, 355, 284, 14, 2558, 63, 344, 26, 284, 367, 284, 315, 355, 291, 423, 751, 14, 87, 2453, 513, 63, 1744, 14, 452, 1252, 2416, 63, 2407, 360, 2558, 358, 288, 789, 398, 372, 291, 423, 1744, 63, 1637, 339, 347, 1050, 8, 277, 12, 3336, 304, 398, 340, 3336, 14, 344, 315, 291, 423, 1744, 26, 288, 746, 4967, 14, 5884, 16760, 20201, 342, 398, 1242, 275, 291, 423, 751, 14, 87, 2453, 513, 63, 1744, 14, 981, 8, 2558, 29, 2558, 9, 398, 291, 423, 1744, 63, 1637, 59, 2558, 14, 344, 61, 275, 1242, 339, 347, 2813, 8, 277, 12, 3336, 63, 344, 304, 398, 340, 3336, 63, 344, 440, 315, 291, 423, 1744, 26, 288, 746, 4967, 14, 2081, 7193, 7965, 342, 398, 291, 423, 1744, 59, 2558, 63, 344, 1055, 1807, 342, 398, 2150, 291, 423, 1744, 59, 2558, 63, 344, 61, 339, 347, 965, 63, 2558, 8, 277, 12, 3336, 63, 344, 304, 398, 340, 440, 291, 423, 751, 14, 374, 63, 12177, 26, 288, 372, 756, 398, 372, 3336, 63, 344, 315, 291, 423, 1744, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 1744, 14, 1459, 1012, 339, 347, 636, 552, 721, 277, 304, 398, 340, 291, 423, 751, 14, 374, 63, 12177, 26, 288, 372, 822, 8, 277, 423, 1744, 9, 398, 372, 378, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 13809, 513, 492, 4967, 421, 199, 533, 644, 2453, 24229, 8, 992, 14, 1685, 304, 339, 922, 275, 1709, 14, 3190, 8, 267, 2202, 14, 5580, 63, 3791, 63, 11429, 12, 4048, 63, 354, 534, 87, 2453, 513, 63, 1744, 297, 267, 3376, 63, 354, 12397, 14919, 659, 641, 63, 1807, 29, 992, 14, 10855, 9, 339, 3336, 275, 1709, 14, 3190, 8, 267, 283, 13336, 14, 5884, 297, 3376, 63, 354, 12397, 5884, 659, 267, 641, 63, 1807, 29, 992, 14, 10855, 9, 339, 1434, 63, 3966, 275, 1709, 14, 4626, 8, 267, 4018, 2506, 2737, 659, 2599, 63, 2131, 63, 525, 29, 549, 12, 14783, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 620, 8, 277, 14, 2558, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 788, 751, 297, 283, 2558, 418, 267, 3376, 63, 354, 275, 4018, 55, 2453, 769, 1242, 358, 267, 3376, 63, 354, 63, 10019, 275, 4018, 55, 2453, 769, 2974, 358, 421, 199, 533, 644, 2453, 1296, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 922, 304, 267, 291, 423, 751, 275, 922, 339, 768, 1829, 272, 347, 485, 1744, 8, 277, 304, 398, 340, 440, 291, 423, 751, 14, 374, 63, 12177, 26, 288, 746, 4967, 14, 1899, 1831, 1763, 30871, 342, 398, 340, 440, 2688, 8, 277, 12, 2513, 1744, 63, 1637, 735, 288, 291, 423, 1744, 63, 1637, 275, 469, 355, 284, 14, 2558, 63, 344, 26, 284, 367, 284, 315, 355, 291, 423, 751, 14, 87, 2453, 513, 63, 1744, 14, 452, 1252, 2416, 63, 2407, 360, 2558, 358, 288, 789, 398, 372, 291, 423, 1744, 63, 1637, 339, 347, 1050, 8, 277, 12, 3336, 304, 398, 340, 3336, 14, 344, 315, 291, 423, 1744, 26, 288, 746, 4967, 14, 5884, 16760, 20201, 342, 398, 1242, 275, 291, 423, 751, 14, 87, 2453, 513, 63, 1744, 14, 981, 8, 2558, 29, 2558, 9, 398, 291, 423, 1744, 63, 1637, 59, 2558, 14, 344, 61, 275, 1242, 339, 347, 2813, 8, 277, 12, 3336, 63, 344, 304, 398, 340, 3336, 63, 344, 440, 315, 291, 423, 1744, 26, 288, 746, 4967, 14, 2081, 7193, 7965, 342, 398, 291, 423, 1744, 59, 2558, 63, 344, 1055, 1807, 342, 398, 2150, 291, 423, 1744, 59, 2558, 63, 344, 61, 339, 347, 965, 63, 2558, 8, 277, 12, 3336, 63, 344, 304, 398, 340, 440, 291, 423, 751, 14, 374, 63, 12177, 26, 288, 372, 756, 398, 372, 3336, 63, 344, 315, 291, 423, 1744, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 1744, 14, 1459, 1012, 339, 347, 636, 552, 721, 277, 304, 398, 340, 291, 423, 751, 14, 374, 63, 12177, 26, 288, 372, 822, 8, 277, 423, 1744, 9, 398, 372, 378, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
CyanogenMod/android_external_chromium_org
tools/perf/benchmarks/thread_times.py
8
2093
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from telemetry import test from benchmarks import silk_flags from measurements import thread_times import page_sets class ThreadTimesKeySilkCases(test.Test): """Measures timeline metrics while performing smoothness action on key silk cases.""" test = thread_times.ThreadTimes page_set = page_sets.KeySilkCasesPageSet options = {"report_silk_results": True} class ThreadTimesFastPathKeySilkCases(test.Test): """Measures timeline metrics while performing smoothness action on key silk cases using bleeding edge rendering fast paths.""" tag = 'fast_path' test = thread_times.ThreadTimes page_set = page_sets.KeySilkCasesPageSet options = {"report_silk_results": True} def CustomizeBrowserOptions(self, options): silk_flags.CustomizeBrowserOptionsForFastPath(options) class LegacySilkBenchmark(ThreadTimesKeySilkCases): """Same as thread_times.key_silk_cases but with the old name.""" @classmethod def GetName(cls): return "silk.key_silk_cases" class ThreadTimesFastPathMobileSites(test.Test): """Measures timeline metrics while performing smoothness action on key mobile sites labeled with fast-path tag. http://www.chromium.org/developers/design-documents/rendering-benchmarks""" test = thread_times.ThreadTimes page_set = page_sets.KeyMobileSitesPageSet options = {'page_label_filter' : 'fastpath'} class ThreadTimesCompositorCases(test.Test): """Measures timeline metrics while performing smoothness action on tough compositor cases. http://www.chromium.org/developers/design-documents/rendering-benchmarks""" test = thread_times.ThreadTimes page_set = page_sets.ToughCompositorCasesPageSet @test.Enabled('android') class ThreadTimesPolymer(test.Test): """Measures timeline metrics while performing smoothness action on Polymer cases.""" test = thread_times.ThreadTimes page_set = page_sets.PolymerPageSet options = { 'report_silk_results': True }
bsd-3-clause
[ 3, 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 504, 17298, 492, 511, 199, 199, 504, 12338, 83, 492, 24968, 75, 63, 2469, 199, 504, 32619, 492, 2462, 63, 4508, 199, 646, 2034, 63, 2193, 421, 199, 533, 11086, 17687, 1197, 51, 382, 75, 1538, 83, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 790, 24968, 75, 523, 5560, 1041, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 1197, 51, 382, 75, 1538, 83, 3276, 1084, 523, 1511, 275, 2420, 3070, 63, 20329, 75, 63, 2604, 582, 715, 93, 421, 199, 533, 11086, 17687, 16976, 2042, 1197, 51, 382, 75, 1538, 83, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 790, 24968, 75, 523, 5560, 1808, 29603, 379, 316, 6275, 14066, 7377, 3792, 1041, 523, 1947, 275, 283, 7015, 63, 515, 7, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 1197, 51, 382, 75, 1538, 83, 3276, 1084, 523, 1511, 275, 2420, 3070, 63, 20329, 75, 63, 2604, 582, 715, 93, 523, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 24968, 75, 63, 2469, 14, 7223, 794, 11930, 4558, 1858, 16976, 2042, 8, 1419, 9, 421, 199, 533, 26251, 51, 382, 75, 18644, 8, 4436, 17687, 1197, 51, 382, 75, 1538, 83, 304, 523, 408, 8479, 465, 2462, 63, 4508, 14, 498, 63, 20329, 75, 63, 9403, 1325, 543, 314, 2269, 536, 1041, 523, 768, 3744, 523, 347, 2372, 985, 8, 1886, 304, 272, 372, 298, 20329, 75, 14, 498, 63, 20329, 75, 63, 9403, 2, 421, 199, 533, 11086, 17687, 16976, 2042, 27245, 51, 4033, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 523, 790, 21305, 15424, 23677, 543, 7377, 13, 515, 1947, 14, 523, 1455, 921, 1544, 14, 13211, 14, 1308, 15, 23826, 15, 14748, 13, 12233, 15, 28228, 13, 11861, 83, 624, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 1197, 27245, 51, 4033, 3276, 1084, 523, 1511, 275, 791, 1606, 63, 1302, 63, 1541, 7, 520, 283, 7015, 515, 936, 421, 199, 533, 11086, 17687, 16273, 2221, 269, 1538, 83, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 523, 370, 3080, 11395, 2221, 269, 5560, 14, 523, 1455, 921, 1544, 14, 13211, 14, 1308, 15, 23826, 15, 14748, 13, 12233, 15, 28228, 13, 11861, 83, 624, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 52, 4937, 16273, 2221, 269, 1538, 83, 3276, 1084, 421, 199, 32, 396, 14, 6589, 360, 6238, 358, 199, 533, 11086, 17687, 12747, 2626, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 523, 16869, 2626, 5560, 1041, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 12747, 2626, 3276, 1084, 523, 1511, 275, 469, 283, 3070, 63, 20329, 75, 63, 2604, 356, 715, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 504, 17298, 492, 511, 199, 199, 504, 12338, 83, 492, 24968, 75, 63, 2469, 199, 504, 32619, 492, 2462, 63, 4508, 199, 646, 2034, 63, 2193, 421, 199, 533, 11086, 17687, 1197, 51, 382, 75, 1538, 83, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 790, 24968, 75, 523, 5560, 1041, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 1197, 51, 382, 75, 1538, 83, 3276, 1084, 523, 1511, 275, 2420, 3070, 63, 20329, 75, 63, 2604, 582, 715, 93, 421, 199, 533, 11086, 17687, 16976, 2042, 1197, 51, 382, 75, 1538, 83, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 790, 24968, 75, 523, 5560, 1808, 29603, 379, 316, 6275, 14066, 7377, 3792, 1041, 523, 1947, 275, 283, 7015, 63, 515, 7, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 1197, 51, 382, 75, 1538, 83, 3276, 1084, 523, 1511, 275, 2420, 3070, 63, 20329, 75, 63, 2604, 582, 715, 93, 523, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 24968, 75, 63, 2469, 14, 7223, 794, 11930, 4558, 1858, 16976, 2042, 8, 1419, 9, 421, 199, 533, 26251, 51, 382, 75, 18644, 8, 4436, 17687, 1197, 51, 382, 75, 1538, 83, 304, 523, 408, 8479, 465, 2462, 63, 4508, 14, 498, 63, 20329, 75, 63, 9403, 1325, 543, 314, 2269, 536, 1041, 523, 768, 3744, 523, 347, 2372, 985, 8, 1886, 304, 272, 372, 298, 20329, 75, 14, 498, 63, 20329, 75, 63, 9403, 2, 421, 199, 533, 11086, 17687, 16976, 2042, 27245, 51, 4033, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 523, 790, 21305, 15424, 23677, 543, 7377, 13, 515, 1947, 14, 523, 1455, 921, 1544, 14, 13211, 14, 1308, 15, 23826, 15, 14748, 13, 12233, 15, 28228, 13, 11861, 83, 624, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 1197, 27245, 51, 4033, 3276, 1084, 523, 1511, 275, 791, 1606, 63, 1302, 63, 1541, 7, 520, 283, 7015, 515, 936, 421, 199, 533, 11086, 17687, 16273, 2221, 269, 1538, 83, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 523, 370, 3080, 11395, 2221, 269, 5560, 14, 523, 1455, 921, 1544, 14, 13211, 14, 1308, 15, 23826, 15, 14748, 13, 12233, 15, 28228, 13, 11861, 83, 624, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 52, 4937, 16273, 2221, 269, 1538, 83, 3276, 1084, 421, 199, 32, 396, 14, 6589, 360, 6238, 358, 199, 533, 11086, 17687, 12747, 2626, 8, 396, 14, 774, 304, 523, 408, 1352, 305, 1482, 20780, 7186, 1830, 19203, 19608, 4171, 1595, 641, 523, 16869, 2626, 5560, 1041, 523, 511, 275, 2462, 63, 4508, 14, 4436, 17687, 523, 2034, 63, 409, 275, 2034, 63, 2193, 14, 12747, 2626, 3276, 1084, 523, 1511, 275, 469, 283, 3070, 63, 20329, 75, 63, 2604, 356, 715, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yyjiang/scikit-learn
examples/linear_model/plot_ols_3d.py
350
2040
#!/usr/bin/python # -*- coding: utf-8 -*- """ ========================================================= Sparsity Example: Fitting only features 1 and 2 ========================================================= Features 1 and 2 of the diabetes-dataset are fitted and plotted below. It illustrates that although feature 2 has a strong coefficient on the full model, it does not give us much regarding `y` when compared to just feature 1 """ print(__doc__) # Code source: Gaël Varoquaux # Modified for documentation by Jaques Grobler # License: BSD 3 clause import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D from sklearn import datasets, linear_model diabetes = datasets.load_diabetes() indices = (0, 1) X_train = diabetes.data[:-20, indices] X_test = diabetes.data[-20:, indices] y_train = diabetes.target[:-20] y_test = diabetes.target[-20:] ols = linear_model.LinearRegression() ols.fit(X_train, y_train) ############################################################################### # Plot the figure def plot_figs(fig_num, elev, azim, X_train, clf): fig = plt.figure(fig_num, figsize=(4, 3)) plt.clf() ax = Axes3D(fig, elev=elev, azim=azim) ax.scatter(X_train[:, 0], X_train[:, 1], y_train, c='k', marker='+') ax.plot_surface(np.array([[-.1, -.1], [.15, .15]]), np.array([[-.1, .15], [-.1, .15]]), clf.predict(np.array([[-.1, -.1, .15, .15], [-.1, .15, -.1, .15]]).T ).reshape((2, 2)), alpha=.5) ax.set_xlabel('X_1') ax.set_ylabel('X_2') ax.set_zlabel('Y') ax.w_xaxis.set_ticklabels([]) ax.w_yaxis.set_ticklabels([]) ax.w_zaxis.set_ticklabels([]) #Generate the three different figures from different views elev = 43.5 azim = -110 plot_figs(1, elev, azim, X_train, ols) elev = -.5 azim = 0 plot_figs(2, elev, azim, X_train, ols) elev = -.5 azim = 90 plot_figs(3, elev, azim, X_train, ols) plt.show()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 12813, 15495, 199, 51, 462, 3677, 5679, 26, 25971, 1337, 1454, 4534, 413, 221, 436, 499, 199, 12813, 15495, 199, 199, 10807, 413, 436, 499, 402, 314, 487, 26290, 13, 5214, 787, 26093, 436, 199, 2798, 471, 5084, 14, 2779, 22907, 11409, 2335, 626, 22160, 3878, 499, 199, 1989, 282, 16925, 9421, 641, 314, 2615, 1402, 12, 652, 1630, 440, 199, 26035, 2739, 8298, 12602, 658, 89, 64, 1380, 13524, 370, 2951, 3878, 413, 199, 199, 624, 199, 1361, 3460, 1301, 3368, 421, 199, 3, 5495, 1350, 26, 9647, 128, 105, 76, 21084, 79, 392, 10962, 199, 3, 22016, 367, 3794, 701, 1603, 65, 19658, 598, 293, 830, 82, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 437, 12908, 19, 36, 199, 199, 504, 6357, 492, 13148, 12, 7798, 63, 1238, 199, 199, 328, 26290, 275, 13148, 14, 912, 63, 328, 26290, 342, 199, 4108, 275, 334, 16, 12, 413, 9, 199, 199, 56, 63, 2834, 275, 487, 26290, 14, 576, 4439, 1165, 12, 4918, 61, 199, 56, 63, 396, 275, 487, 26290, 14, 576, 1988, 1165, 11941, 4918, 61, 199, 89, 63, 2834, 275, 487, 26290, 14, 1375, 4439, 1165, 61, 199, 89, 63, 396, 275, 487, 26290, 14, 1375, 1988, 1165, 2938, 199, 199, 1446, 275, 7798, 63, 1238, 14, 10608, 13013, 342, 199, 1446, 14, 3269, 8, 56, 63, 2834, 12, 612, 63, 2834, 9, 421, 199, 11490, 199, 3, 14794, 314, 9658, 199, 318, 5137, 63, 5513, 8, 592, 63, 1507, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 6975, 304, 272, 6085, 275, 4488, 14, 8941, 8, 592, 63, 1507, 12, 6085, 890, 2687, 20, 12, 650, 430, 272, 4488, 14, 9694, 342, 272, 2185, 275, 437, 12908, 19, 36, 8, 592, 12, 325, 6972, 29, 24083, 12, 24978, 1017, 29, 4651, 1017, 9, 339, 2185, 14, 13512, 8, 56, 63, 2834, 3981, 378, 467, 1323, 63, 2834, 3981, 413, 467, 612, 63, 2834, 12, 286, 534, 75, 297, 3608, 534, 13854, 272, 2185, 14, 2798, 63, 10992, 8, 1590, 14, 1144, 22844, 14, 17, 12, 3568, 17, 467, 26496, 1046, 12, 1275, 1046, 13925, 490, 980, 14, 1144, 22844, 14, 17, 12, 1275, 1046, 467, 5243, 14, 17, 12, 1275, 1046, 13925, 490, 6975, 14, 6892, 8, 1590, 14, 1144, 22844, 14, 17, 12, 3568, 17, 12, 1275, 1046, 12, 1275, 1046, 467, 5101, 5243, 14, 17, 12, 1275, 1046, 12, 3568, 17, 12, 1275, 1046, 3934, 14, 52, 1816, 7092, 5217, 1332, 18, 12, 499, 1826, 490, 5131, 15856, 21, 9, 272, 2185, 14, 409, 63, 14168, 360, 56, 63, 17, 358, 272, 2185, 14, 409, 63, 13849, 360, 56, 63, 18, 358, 272, 2185, 14, 409, 63, 90, 1302, 360, 57, 358, 272, 2185, 14, 87, 63, 21854, 14, 409, 63, 27435, 4157, 272, 2185, 14, 87, 63, 23876, 14, 409, 63, 27435, 4157, 272, 2185, 14, 87, 63, 90, 3127, 14, 409, 63, 27435, 4157, 199, 199, 3, 6864, 314, 7795, 3365, 6085, 1482, 687, 3365, 6858, 199, 24083, 275, 11851, 14, 21, 199, 4651, 1017, 275, 446, 6019, 199, 2798, 63, 5513, 8, 17, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 312, 478, 9, 199, 199, 24083, 275, 3568, 21, 199, 4651, 1017, 275, 378, 199, 2798, 63, 5513, 8, 18, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 312, 478, 9, 199, 199, 24083, 275, 3568, 21, 199, 4651, 1017, 275, 9137, 199, 2798, 63, 5513, 8, 19, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 312, 478, 9, 199, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 12813, 15495, 199, 51, 462, 3677, 5679, 26, 25971, 1337, 1454, 4534, 413, 221, 436, 499, 199, 12813, 15495, 199, 199, 10807, 413, 436, 499, 402, 314, 487, 26290, 13, 5214, 787, 26093, 436, 199, 2798, 471, 5084, 14, 2779, 22907, 11409, 2335, 626, 22160, 3878, 499, 199, 1989, 282, 16925, 9421, 641, 314, 2615, 1402, 12, 652, 1630, 440, 199, 26035, 2739, 8298, 12602, 658, 89, 64, 1380, 13524, 370, 2951, 3878, 413, 199, 199, 624, 199, 1361, 3460, 1301, 3368, 421, 199, 3, 5495, 1350, 26, 9647, 128, 105, 76, 21084, 79, 392, 10962, 199, 3, 22016, 367, 3794, 701, 1603, 65, 19658, 598, 293, 830, 82, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 22513, 63, 3557, 75, 1405, 14, 311, 1653, 19, 68, 492, 437, 12908, 19, 36, 199, 199, 504, 6357, 492, 13148, 12, 7798, 63, 1238, 199, 199, 328, 26290, 275, 13148, 14, 912, 63, 328, 26290, 342, 199, 4108, 275, 334, 16, 12, 413, 9, 199, 199, 56, 63, 2834, 275, 487, 26290, 14, 576, 4439, 1165, 12, 4918, 61, 199, 56, 63, 396, 275, 487, 26290, 14, 576, 1988, 1165, 11941, 4918, 61, 199, 89, 63, 2834, 275, 487, 26290, 14, 1375, 4439, 1165, 61, 199, 89, 63, 396, 275, 487, 26290, 14, 1375, 1988, 1165, 2938, 199, 199, 1446, 275, 7798, 63, 1238, 14, 10608, 13013, 342, 199, 1446, 14, 3269, 8, 56, 63, 2834, 12, 612, 63, 2834, 9, 421, 199, 11490, 199, 3, 14794, 314, 9658, 199, 318, 5137, 63, 5513, 8, 592, 63, 1507, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 6975, 304, 272, 6085, 275, 4488, 14, 8941, 8, 592, 63, 1507, 12, 6085, 890, 2687, 20, 12, 650, 430, 272, 4488, 14, 9694, 342, 272, 2185, 275, 437, 12908, 19, 36, 8, 592, 12, 325, 6972, 29, 24083, 12, 24978, 1017, 29, 4651, 1017, 9, 339, 2185, 14, 13512, 8, 56, 63, 2834, 3981, 378, 467, 1323, 63, 2834, 3981, 413, 467, 612, 63, 2834, 12, 286, 534, 75, 297, 3608, 534, 13854, 272, 2185, 14, 2798, 63, 10992, 8, 1590, 14, 1144, 22844, 14, 17, 12, 3568, 17, 467, 26496, 1046, 12, 1275, 1046, 13925, 490, 980, 14, 1144, 22844, 14, 17, 12, 1275, 1046, 467, 5243, 14, 17, 12, 1275, 1046, 13925, 490, 6975, 14, 6892, 8, 1590, 14, 1144, 22844, 14, 17, 12, 3568, 17, 12, 1275, 1046, 12, 1275, 1046, 467, 5101, 5243, 14, 17, 12, 1275, 1046, 12, 3568, 17, 12, 1275, 1046, 3934, 14, 52, 1816, 7092, 5217, 1332, 18, 12, 499, 1826, 490, 5131, 15856, 21, 9, 272, 2185, 14, 409, 63, 14168, 360, 56, 63, 17, 358, 272, 2185, 14, 409, 63, 13849, 360, 56, 63, 18, 358, 272, 2185, 14, 409, 63, 90, 1302, 360, 57, 358, 272, 2185, 14, 87, 63, 21854, 14, 409, 63, 27435, 4157, 272, 2185, 14, 87, 63, 23876, 14, 409, 63, 27435, 4157, 272, 2185, 14, 87, 63, 90, 3127, 14, 409, 63, 27435, 4157, 199, 199, 3, 6864, 314, 7795, 3365, 6085, 1482, 687, 3365, 6858, 199, 24083, 275, 11851, 14, 21, 199, 4651, 1017, 275, 446, 6019, 199, 2798, 63, 5513, 8, 17, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 312, 478, 9, 199, 199, 24083, 275, 3568, 21, 199, 4651, 1017, 275, 378, 199, 2798, 63, 5513, 8, 18, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 312, 478, 9, 199, 199, 24083, 275, 3568, 21, 199, 4651, 1017, 275, 9137, 199, 2798, 63, 5513, 8, 19, 12, 325, 6972, 12, 24978, 1017, 12, 1323, 63, 2834, 12, 312, 478, 9, 199, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
joseihf/coding-events
web/forms/event_form.py
3
7889
# -*- coding: utf-8 -*- from django import forms from django_countries.fields import countries from api.models import Event from api.models.events import EventTheme, EventAudience class AddEventForm(forms.ModelForm): email_errors = { 'required': u'Please enter a valid email, so we can contact you in case of questions.', 'invalid': u'Can you please check if this is a valid email address?', } user_email = forms.EmailField(required=True, label='Your contact email', widget=forms.EmailInput(attrs={"class": "form-control"}), error_messages = email_errors, ) class Meta: model = Event fields = ['title', 'organizer', 'description', 'geoposition', 'location', 'country', 'start_date', 'end_date', 'event_url', 'contact_person', 'audience', 'theme', 'picture', 'tags', 'user_email', ] widgets = { 'title': forms.TextInput(attrs={"class": "form-control", "placeholder": "How do you call this event?"}), 'organizer': forms.TextInput(attrs={"class": "form-control", "placeholder": "Who is organizing this event?"}), 'description': forms.Textarea(attrs={"class": "form-control", "placeholder": "Tell us a bit about your event."}), 'location': forms.TextInput(attrs={"id": "autocomplete", "class": "form-control", "placeholder": "Where will the event be taking place?", }), 'start_date': forms.TextInput(attrs={"id": "id_datepicker_start", "class": "form-control", "autocomplete": "off", "placeholder": "When does it start?"}), 'end_date': forms.TextInput(attrs={"id": "id_datepicker_end", "class": "form-control", "autocomplete": "off", "placeholder": "When does it end?"}), 'event_url': forms.TextInput(attrs={"class": "form-control", "placeholder": "Do you have a website with more information?"}), 'contact_person': forms.TextInput(attrs={"class": "form-control", "placeholder": "Would you like to display a contact email?"}), 'audience': forms.CheckboxSelectMultiple(), 'theme': forms.CheckboxSelectMultiple(), 'tags': forms.TextInput(attrs={"class": "form-control", "placeholder": "example: Python, Django, Slovenia"}), } labels = { 'title': 'Event title', 'organizer': 'Organizer(s)', 'description': 'Description', 'location': 'Location', 'country': 'Country', 'start_date': 'Start date', 'end_date': 'End date', 'event_url': 'Website', 'contact_person': 'Contact', 'picture': 'Image', 'audience': 'Audience', 'theme': 'Theme', 'tags': 'Tags', } help_texts = { 'start_date': "Example: YYYY/MM/DD h:m", 'end_date': "Example: YYYY/MM/DD h:m", 'audience': "Who is the event for?", 'theme': "Which aspect of coding will your event cover?", 'picture': 'Larger images will be resized to 256 x 512 pixels. Maximum upload size is 256 x 1024.', } error_messages = { 'title': { 'required': u'Please enter a title for your event.', 'invalid': u'Can you please check if this is a valid title?', }, 'organizer': { 'required': u'Please enter an organizer.', 'invalid': u'Can you please check if this is a valid organizer?', }, 'description': { 'required': u'Please write a short description of what the event is about.', 'invalid': u'Please check if the description only contains regular text.', }, 'geoposition': { 'invalid': u'Please enter valid coordinates.' }, 'location': { 'required': u'Please enter a location.', 'invalid': u'Please check your event\'s location', }, 'country': { 'required': u'The event\'s location should be in Europe.', 'invalid': u'Make sure the event country is written in English.', }, 'start_date': { 'required': u'Please enter a valid date and time (example: 2014-10-22 18:00).', 'invalid': u'This doesn\'t seem like a valid date and time. Can you check, please?', }, 'end_date': { 'required': u'Please enter a valid date and time (example: 2014-10-22 20:00).', 'invalid': u'This doesn\'t seem like a valid date and time. Can you check, please?', }, 'event_url': { 'invalid': u'Please enter a valid web address starting with http://', }, 'contact_person': { 'invalid': u'Please enter a valid email address.', }, 'picture': { 'invalid': u'Make sure this is a valid image.', }, 'audience': { 'required': u'If unsure, choose Other and provide more information in the description.', 'invalid': u'Choose one or more of the provided choices.', }, 'theme': { 'required': u'If unsure, choose Other and provide more information in the description.', 'invalid': u'Choose one or more of the provided choices.', }, 'tags': { 'required': u'Please type in some tags to categorize the event', 'invalid': u'Please enter tags in plain text, separated by commas.', }, } def clean(self): cleaned_data = super(AddEventForm, self).clean() start_date = cleaned_data.get('start_date') end_date = cleaned_data.get('end_date') if start_date and end_date and end_date < start_date: msg = u'End date should be greater than start date.' self._errors['end_date'] = self.error_class([msg]) # Set contact_person e-mail in Event model ('user_email' is used to update the User model) cleaned_data['contact_person'] = cleaned_data.get('user_email', '') return cleaned_data def __init__(self, *args, **kwargs): super(AddEventForm, self).__init__(*args, **kwargs) class SearchEventForm(forms.Form): countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[0]) countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[1]) # XK is temp code for Kosovo; remove from COUNTRIES_OVERRIDE when # Kosovo gets its own ISO code and is added to django-countries if not 'Kosovo' in list(dict(countries._countries).values()): countries._countries.append((u'XK', u'Kosovo')) q = forms.CharField( required=False, widget=forms.TextInput(attrs={'placeholder': 'Search for event name or tag', 'class': 'form-control'}) ) past = forms.ChoiceField( label='Include past events', required=False, choices=(('yes', 'yes'),('no', 'no')), widget=forms.RadioSelect(attrs={'class': 'search-form-element'}), ) country = forms.ChoiceField( label='Select country', required=False, widget=forms.Select(attrs={'class': 'search-form-element'}), choices=countries ) theme = forms.ModelMultipleChoiceField( queryset=EventTheme.objects.all(), label='Theme', required=False, widget=forms.CheckboxSelectMultiple(attrs={'class': 'search-form-element'}), ) audience = forms.ModelMultipleChoiceField( queryset=EventAudience.objects.all(), label='Audience', required=False, widget=forms.CheckboxSelectMultiple(attrs={'class': 'search-form-element'}), ) def __init__(self, *args, **kwargs): country_code = kwargs.pop('country_code', None) past_events = kwargs.pop('past_events') search_query = kwargs.pop('search', None) theme = kwargs.pop('theme', None) audience = kwargs.pop('audience', None) super(SearchEventForm, self).__init__(*args, **kwargs) if country_code: self.fields['country'].initial = country_code self.fields['past'].initial = past_events if search_query: self.fields['q'].initial = search_query if theme: self.fields['theme'].initial = theme if audience: self.fields['audience'].initial = audience
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 492, 4513, 199, 504, 1639, 63, 23598, 14, 955, 492, 26013, 199, 504, 2986, 14, 992, 492, 6763, 199, 504, 2986, 14, 992, 14, 4368, 492, 6763, 16849, 12, 6763, 33, 22830, 421, 199, 533, 2654, 2390, 2821, 8, 3351, 14, 15937, 304, 421, 198, 2123, 63, 2550, 275, 469, 507, 198, 3984, 1087, 356, 399, 7, 8254, 9509, 282, 1686, 3031, 12, 880, 781, 883, 8966, 1265, 315, 1930, 402, 23071, 3130, 507, 198, 7, 3197, 356, 399, 7, 6049, 1265, 8749, 1104, 340, 642, 365, 282, 1686, 3031, 2287, 7044, 686, 198, 93, 199, 198, 751, 63, 2123, 275, 4513, 14, 16577, 8, 2427, 29, 549, 12, 22680, 221, 1768, 534, 14398, 8966, 3031, 297, 22680, 221, 3938, 29, 3351, 14, 7035, 3205, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 5593, 22680, 221, 1125, 63, 3431, 275, 3031, 63, 2550, 12, 22680, 198, 9, 421, 198, 533, 6288, 26, 507, 198, 1238, 275, 6763, 507, 198, 955, 275, 788, 1213, 297, 686, 3515, 283, 19916, 1793, 297, 686, 3515, 283, 1802, 297, 686, 3515, 283, 303, 27826, 1588, 297, 686, 3515, 283, 1985, 297, 686, 3515, 283, 6063, 297, 686, 3515, 283, 928, 63, 602, 297, 686, 3515, 283, 500, 63, 602, 297, 686, 3515, 283, 1430, 63, 633, 297, 686, 3515, 283, 7811, 63, 5484, 297, 686, 3515, 283, 23577, 4894, 297, 686, 3515, 283, 7915, 297, 686, 3515, 283, 12538, 297, 686, 3515, 283, 2969, 297, 686, 3515, 283, 751, 63, 2123, 297, 686, 3515, 1622, 2742, 198, 8583, 275, 469, 686, 198, 1133, 5776, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1871, 12788, 198, 198, 2, 6199, 582, 298, 18335, 886, 1265, 1240, 642, 1566, 31, 5593, 686, 198, 7, 19916, 1793, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1871, 12788, 1057, 198, 2, 6199, 582, 298, 55, 526, 365, 20765, 9147, 642, 1566, 31, 5593, 686, 198, 5121, 397, 4802, 356, 4513, 14, 1872, 6789, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 32542, 298, 6199, 582, 298, 52, 1697, 2739, 282, 4546, 3595, 2195, 1566, 2122, 8688, 686, 198, 7, 1985, 356, 4513, 14, 18362, 8, 3288, 8871, 344, 582, 298, 29695, 401, 298, 533, 582, 298, 964, 13, 2785, 401, 1585, 15530, 298, 6199, 582, 298, 26493, 911, 314, 1566, 506, 16466, 4192, 15583, 9998, 686, 198, 1159, 84, 580, 63, 602, 356, 4513, 14, 18362, 8, 3288, 8871, 344, 582, 298, 344, 63, 602, 4510, 281, 63, 928, 401, 298, 533, 582, 298, 964, 13, 2785, 401, 1585, 32542, 298, 29695, 582, 298, 1997, 401, 1585, 32542, 298, 6199, 582, 298, 11423, 1630, 652, 1343, 31, 5593, 686, 198, 7, 500, 63, 602, 356, 4513, 14, 18362, 8, 3288, 8871, 344, 582, 298, 344, 63, 602, 4510, 281, 63, 500, 401, 298, 533, 582, 298, 964, 13, 2785, 401, 1585, 15530, 298, 29695, 582, 298, 1997, 401, 298, 6199, 582, 298, 11423, 1630, 652, 1284, 31, 5593, 686, 198, 7, 1430, 63, 633, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 27503, 298, 6199, 582, 298, 2585, 1265, 1172, 282, 10691, 543, 1655, 2556, 31, 5593, 686, 198, 7, 7811, 63, 5484, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 2476, 260, 298, 6199, 582, 298, 55, 3857, 1265, 2839, 370, 2929, 282, 8966, 3031, 31, 5593, 686, 198, 7, 23577, 4894, 356, 4513, 14, 26366, 32331, 1062, 686, 198, 1133, 426, 278, 356, 4513, 14, 26366, 32331, 1062, 686, 198, 1133, 7391, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 17388, 298, 6199, 582, 298, 2694, 26, 2018, 12, 5634, 12, 428, 320, 1856, 4674, 5593, 507, 198, 93, 2742, 198, 3512, 275, 469, 686, 198, 1133, 5776, 356, 283, 2390, 2538, 297, 686, 198, 7, 19916, 1793, 356, 283, 11014, 290, 1793, 8, 83, 3196, 686, 198, 5121, 397, 4802, 356, 283, 5831, 297, 686, 198, 7, 1985, 356, 283, 6592, 297, 686, 198, 7, 6063, 356, 283, 17393, 297, 686, 198, 1159, 84, 580, 63, 602, 356, 283, 3162, 1434, 297, 686, 198, 7, 500, 63, 602, 356, 283, 3005, 1434, 297, 686, 198, 7, 1430, 63, 633, 356, 283, 26354, 297, 686, 198, 7, 7811, 63, 5484, 356, 283, 14499, 297, 686, 198, 7, 12538, 356, 283, 3491, 297, 686, 198, 7, 23577, 4894, 356, 283, 33, 22830, 297, 686, 198, 1133, 426, 278, 356, 283, 16849, 297, 686, 198, 1133, 7391, 356, 283, 9440, 297, 507, 198, 93, 2742, 198, 3437, 63, 19517, 275, 469, 686, 198, 1159, 84, 580, 63, 602, 356, 298, 9846, 26, 31946, 15, 3218, 15, 5745, 394, 26, 77, 401, 15075, 283, 500, 63, 602, 356, 298, 9846, 26, 31946, 15, 3218, 15, 5745, 394, 26, 77, 401, 15075, 283, 23577, 4894, 356, 298, 55, 526, 365, 314, 1566, 367, 15583, 15075, 283, 7915, 356, 298, 31619, 17435, 402, 2803, 911, 2195, 1566, 8486, 15583, 15075, 283, 12538, 356, 283, 44, 285, 836, 5935, 911, 506, 295, 15308, 370, 7633, 671, 10574, 11094, 14, 14212, 5802, 1568, 365, 7633, 671, 6619, 3130, 507, 198, 93, 2742, 198, 705, 63, 3431, 275, 469, 686, 198, 1133, 5776, 356, 469, 1585, 198, 3984, 1087, 356, 399, 7, 8254, 9509, 282, 2538, 367, 2195, 1566, 3130, 1585, 198, 7, 3197, 356, 399, 7, 6049, 1265, 8749, 1104, 340, 642, 365, 282, 1686, 2538, 7044, 686, 198, 1386, 686, 198, 7, 19916, 1793, 356, 469, 1585, 198, 3984, 1087, 356, 399, 7, 8254, 9509, 376, 20765, 1793, 3130, 1585, 198, 7, 3197, 356, 399, 7, 6049, 1265, 8749, 1104, 340, 642, 365, 282, 1686, 20765, 1793, 7044, 686, 198, 1386, 686, 198, 5121, 397, 4802, 356, 469, 1585, 198, 3984, 1087, 356, 399, 7, 8254, 2218, 282, 3974, 1369, 402, 4052, 314, 1566, 365, 3595, 3130, 1585, 198, 7, 3197, 356, 399, 7, 8254, 1104, 340, 314, 1369, 1454, 3509, 5578, 1318, 3130, 686, 198, 1386, 686, 198 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 492, 4513, 199, 504, 1639, 63, 23598, 14, 955, 492, 26013, 199, 504, 2986, 14, 992, 492, 6763, 199, 504, 2986, 14, 992, 14, 4368, 492, 6763, 16849, 12, 6763, 33, 22830, 421, 199, 533, 2654, 2390, 2821, 8, 3351, 14, 15937, 304, 421, 198, 2123, 63, 2550, 275, 469, 507, 198, 3984, 1087, 356, 399, 7, 8254, 9509, 282, 1686, 3031, 12, 880, 781, 883, 8966, 1265, 315, 1930, 402, 23071, 3130, 507, 198, 7, 3197, 356, 399, 7, 6049, 1265, 8749, 1104, 340, 642, 365, 282, 1686, 3031, 2287, 7044, 686, 198, 93, 199, 198, 751, 63, 2123, 275, 4513, 14, 16577, 8, 2427, 29, 549, 12, 22680, 221, 1768, 534, 14398, 8966, 3031, 297, 22680, 221, 3938, 29, 3351, 14, 7035, 3205, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 5593, 22680, 221, 1125, 63, 3431, 275, 3031, 63, 2550, 12, 22680, 198, 9, 421, 198, 533, 6288, 26, 507, 198, 1238, 275, 6763, 507, 198, 955, 275, 788, 1213, 297, 686, 3515, 283, 19916, 1793, 297, 686, 3515, 283, 1802, 297, 686, 3515, 283, 303, 27826, 1588, 297, 686, 3515, 283, 1985, 297, 686, 3515, 283, 6063, 297, 686, 3515, 283, 928, 63, 602, 297, 686, 3515, 283, 500, 63, 602, 297, 686, 3515, 283, 1430, 63, 633, 297, 686, 3515, 283, 7811, 63, 5484, 297, 686, 3515, 283, 23577, 4894, 297, 686, 3515, 283, 7915, 297, 686, 3515, 283, 12538, 297, 686, 3515, 283, 2969, 297, 686, 3515, 283, 751, 63, 2123, 297, 686, 3515, 1622, 2742, 198, 8583, 275, 469, 686, 198, 1133, 5776, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1871, 12788, 198, 198, 2, 6199, 582, 298, 18335, 886, 1265, 1240, 642, 1566, 31, 5593, 686, 198, 7, 19916, 1793, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1871, 12788, 1057, 198, 2, 6199, 582, 298, 55, 526, 365, 20765, 9147, 642, 1566, 31, 5593, 686, 198, 5121, 397, 4802, 356, 4513, 14, 1872, 6789, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 32542, 298, 6199, 582, 298, 52, 1697, 2739, 282, 4546, 3595, 2195, 1566, 2122, 8688, 686, 198, 7, 1985, 356, 4513, 14, 18362, 8, 3288, 8871, 344, 582, 298, 29695, 401, 298, 533, 582, 298, 964, 13, 2785, 401, 1585, 15530, 298, 6199, 582, 298, 26493, 911, 314, 1566, 506, 16466, 4192, 15583, 9998, 686, 198, 1159, 84, 580, 63, 602, 356, 4513, 14, 18362, 8, 3288, 8871, 344, 582, 298, 344, 63, 602, 4510, 281, 63, 928, 401, 298, 533, 582, 298, 964, 13, 2785, 401, 1585, 32542, 298, 29695, 582, 298, 1997, 401, 1585, 32542, 298, 6199, 582, 298, 11423, 1630, 652, 1343, 31, 5593, 686, 198, 7, 500, 63, 602, 356, 4513, 14, 18362, 8, 3288, 8871, 344, 582, 298, 344, 63, 602, 4510, 281, 63, 500, 401, 298, 533, 582, 298, 964, 13, 2785, 401, 1585, 15530, 298, 29695, 582, 298, 1997, 401, 298, 6199, 582, 298, 11423, 1630, 652, 1284, 31, 5593, 686, 198, 7, 1430, 63, 633, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 27503, 298, 6199, 582, 298, 2585, 1265, 1172, 282, 10691, 543, 1655, 2556, 31, 5593, 686, 198, 7, 7811, 63, 5484, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 2476, 260, 298, 6199, 582, 298, 55, 3857, 1265, 2839, 370, 2929, 282, 8966, 3031, 31, 5593, 686, 198, 7, 23577, 4894, 356, 4513, 14, 26366, 32331, 1062, 686, 198, 1133, 426, 278, 356, 4513, 14, 26366, 32331, 1062, 686, 198, 1133, 7391, 356, 4513, 14, 18362, 8, 3288, 8871, 533, 582, 298, 964, 13, 2785, 401, 1585, 17388, 298, 6199, 582, 298, 2694, 26, 2018, 12, 5634, 12, 428, 320, 1856, 4674, 5593, 507, 198, 93, 2742, 198, 3512, 275, 469, 686, 198, 1133, 5776, 356, 283, 2390, 2538, 297, 686, 198, 7, 19916, 1793, 356, 283, 11014, 290, 1793, 8, 83, 3196, 686, 198, 5121, 397, 4802, 356, 283, 5831, 297, 686, 198, 7, 1985, 356, 283, 6592, 297, 686, 198, 7, 6063, 356, 283, 17393, 297, 686, 198, 1159, 84, 580, 63, 602, 356, 283, 3162, 1434, 297, 686, 198, 7, 500, 63, 602, 356, 283, 3005, 1434, 297, 686, 198, 7, 1430, 63, 633, 356, 283, 26354, 297, 686, 198, 7, 7811, 63, 5484, 356, 283, 14499, 297, 686, 198, 7, 12538, 356, 283, 3491, 297, 686, 198, 7, 23577, 4894, 356, 283, 33, 22830, 297, 686, 198, 1133, 426, 278, 356, 283, 16849, 297, 686, 198, 1133, 7391, 356, 283, 9440, 297, 507, 198, 93, 2742, 198, 3437, 63, 19517, 275, 469, 686, 198, 1159, 84, 580, 63, 602, 356, 298, 9846, 26, 31946, 15, 3218, 15, 5745, 394, 26, 77, 401, 15075, 283, 500, 63, 602, 356, 298, 9846, 26, 31946, 15, 3218, 15, 5745, 394, 26, 77, 401, 15075, 283, 23577, 4894, 356, 298, 55, 526, 365, 314, 1566, 367, 15583, 15075, 283, 7915, 356, 298, 31619, 17435, 402, 2803, 911, 2195, 1566, 8486, 15583, 15075, 283, 12538, 356, 283, 44, 285, 836, 5935, 911, 506, 295, 15308, 370, 7633, 671, 10574, 11094, 14, 14212, 5802, 1568, 365, 7633, 671, 6619, 3130, 507, 198, 93, 2742, 198, 705, 63, 3431, 275, 469, 686, 198, 1133, 5776, 356, 469, 1585, 198, 3984, 1087, 356, 399, 7, 8254, 9509, 282, 2538, 367, 2195, 1566, 3130, 1585, 198, 7, 3197, 356, 399, 7, 6049, 1265, 8749, 1104, 340, 642, 365, 282, 1686, 2538, 7044, 686, 198, 1386, 686, 198, 7, 19916, 1793, 356, 469, 1585, 198, 3984, 1087, 356, 399, 7, 8254, 9509, 376, 20765, 1793, 3130, 1585, 198, 7, 3197, 356, 399, 7, 6049, 1265, 8749, 1104, 340, 642, 365, 282, 1686, 20765, 1793, 7044, 686, 198, 1386, 686, 198, 5121, 397, 4802, 356, 469, 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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 ]
Gnomjolnir/CoAPthon
plugtest_resources.py
4
5907
# coding=utf-8 import logging import threading import time import datetime from coapthon import defines from coapthon.resources.resource import Resource __author__ = 'Giacomo Tanganelli' logger = logging.getLogger(__name__) class TestResource(Resource): def __init__(self, name="TestResource", coap_server=None): super(TestResource, self).__init__(name, coap_server, visible=True, observable=False, allow_children=True) self.payload = "Test Resource" self.resource_type = "Type1" self.maximum_size_estimated = len(self.payload) def render_GET(self, request): return self def render_PUT(self, request): for option in request.options: if option.number == defines.OptionRegistry.CONTENT_TYPE.number: self.payload = (option.value, request.payload) return self self.payload = request.payload return self def render_POST(self, request): res = TestResource() res.location_query = request.uri_query for option in request.options: if option.number == defines.OptionRegistry.CONTENT_TYPE.number: res.payload = {option.value: request.payload} return res res.payload = request.payload return res def render_DELETE(self, request): return True class SeparateResource(Resource): def __init__(self, name="Separate", coap_server=None): super(SeparateResource, self).__init__(name, coap_server, visible=True, observable=False, allow_children=False) self.payload = "Separate Resource" self.interface_type = "separate" self.add_content_type("text/plain") def render_GET(self, request): return self, self.render_GET_separate def render_GET_separate(self, request): time.sleep(5) return self class ObservableResource(Resource): def __init__(self, name="Obs", coap_server=None): super(ObservableResource, self).__init__(name, coap_server, visible=True, observable=True, allow_children=False) self.payload = "Observable Resource" self.period = 5 self.update(True) def render_GET(self, request): return self def render_POST(self, request): self.payload = request.payload return self def update(self, first=False): self.payload = "Observable Resource" if not self._coap_server.stopped.isSet(): timer = threading.Timer(self.period, self.update) timer.setDaemon(True) timer.start() if not first and self._coap_server is not None: logger.debug("Periodic Update") self._coap_server.notify(self) self.observe_count += 1 class LargeResource(Resource): def __init__(self, name="Large", coap_server=None): super(LargeResource, self).__init__(name, coap_server, visible=True, observable=False, allow_children=False) # 2000 bytes self.payload = """"Me sabbee plenty"—grunted Queequeg, puffing away at his pipe and sitting up in bed. "You gettee in," he added, motioning to me with his tomahawk, and throwing the clothes to one side. He really did this in not only a civil but a really kind and charitable way. I stood looking at him a moment. For all his tattooings he was on the whole a clean, comely looking cannibal. What's all this fuss I have been making about, thought I to myself—the man's a human being just as I am: he has just as much reason to fear me, as I have to be afraid of him. Better sleep with a sober cannibal than a drunken Christian. "Landlord," said I, "tell him to stash his tomahawk there, or pipe, or whatever you call it; tell him to stop smoking, in short, and I will turn in with him. But I don't fancy having a man smoking in bed with me. It's dangerous. Besides, I ain't insured." This being told to Queequeg, he at once complied, and again politely motioned me to get into bed—rolling over to one side as much as to say—"I won't touch a leg of ye." "Good night, landlord," said I, "you may go." I turned in, and never slept better in my life. Upon waking next morning about daylight, I found Queequeg's arm thrown over me in the most loving and affectionate manner. You had almost thought I had been his wife. The counterpane was of patchwork, full of odd little parti-coloured squares and triangles; and this arm of his tattooed all over with an interminable Cretan labyrinth of a figure, no two parts of which were of one precise shade—owing I suppose to his keeping his arm at sea unmethodically in sun and shade, his shirt sleeves irregularly rolled up at various times—this same arm of his, I say, looked for all the world like a strip of that same patchwork quilt. Indeed, partly lying on it as the arm did when I first awoke, I could hardly tell it from the quilt, they so blended their hues together; and it was only by the sense of weight and pressure that I could tell that Queequeg was hugging""" def render_GET(self, request): return self class LargeUpdateResource(Resource): def __init__(self, name="Large", coap_server=None): super(LargeUpdateResource, self).__init__(name, coap_server, visible=True, observable=False, allow_children=False) self.payload = "" def render_GET(self, request): return self def render_PUT(self, request): self.payload = request.payload return self class LongResource(Resource): def __init__(self, name="Large", coap_server=None): super(LongResource, self).__init__(name, coap_server, visible=True, observable=False, allow_children=False) self.payload = "" def render_GET(self, request): time.sleep(5) return self
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 646, 2050, 199, 646, 5796, 199, 646, 900, 199, 199, 646, 2197, 199, 199, 504, 512, 439, 898, 492, 7890, 199, 504, 512, 439, 898, 14, 4435, 14, 1927, 492, 7337, 199, 199, 363, 2502, 363, 275, 283, 39, 4674, 331, 573, 377, 621, 4822, 317, 7, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1379, 4031, 8, 4031, 304, 272, 347, 636, 826, 721, 277, 12, 536, 628, 774, 4031, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 774, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 797, 12, 2040, 63, 3223, 29, 549, 9, 267, 291, 14, 4749, 275, 298, 774, 7337, 2, 267, 291, 14, 1927, 63, 466, 275, 298, 804, 17, 2, 267, 291, 14, 11555, 63, 890, 63, 597, 12754, 275, 822, 8, 277, 14, 4749, 9, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 372, 291, 339, 347, 3795, 63, 4013, 8, 277, 12, 1056, 304, 267, 367, 945, 315, 1056, 14, 1419, 26, 288, 340, 945, 14, 1955, 508, 7890, 14, 2602, 10899, 14, 9663, 63, 2711, 14, 1955, 26, 355, 291, 14, 4749, 275, 334, 1422, 14, 585, 12, 1056, 14, 4749, 9, 355, 372, 291, 267, 291, 14, 4749, 275, 1056, 14, 4749, 267, 372, 291, 339, 347, 3795, 63, 4030, 8, 277, 12, 1056, 304, 267, 522, 275, 1379, 4031, 342, 267, 522, 14, 1985, 63, 1131, 275, 1056, 14, 2302, 63, 1131, 267, 367, 945, 315, 1056, 14, 1419, 26, 288, 340, 945, 14, 1955, 508, 7890, 14, 2602, 10899, 14, 9663, 63, 2711, 14, 1955, 26, 355, 522, 14, 4749, 275, 469, 1422, 14, 585, 26, 1056, 14, 4749, 93, 355, 372, 522, 398, 522, 14, 4749, 275, 1056, 14, 4749, 267, 372, 522, 339, 347, 3795, 63, 7014, 8, 277, 12, 1056, 304, 267, 372, 715, 421, 199, 533, 27504, 323, 4031, 8, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 536, 628, 12653, 323, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 12653, 323, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 797, 12, 2040, 63, 3223, 29, 797, 9, 267, 291, 14, 4749, 275, 298, 12653, 323, 7337, 2, 267, 291, 14, 3266, 63, 466, 275, 298, 24904, 2, 267, 291, 14, 525, 63, 1317, 63, 466, 480, 505, 15, 6104, 531, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 372, 291, 12, 291, 14, 3352, 63, 2970, 63, 24904, 339, 347, 3795, 63, 2970, 63, 24904, 8, 277, 12, 1056, 304, 267, 900, 14, 4532, 8, 21, 9, 267, 372, 291, 421, 199, 533, 17985, 29454, 4031, 8, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 536, 628, 31004, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 11394, 29454, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 549, 12, 2040, 63, 3223, 29, 797, 9, 267, 291, 14, 4749, 275, 298, 11394, 29454, 7337, 2, 267, 291, 14, 5191, 275, 959, 267, 291, 14, 873, 8, 549, 9, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 372, 291, 339, 347, 3795, 63, 4030, 8, 277, 12, 1056, 304, 267, 291, 14, 4749, 275, 1056, 14, 4749, 267, 372, 291, 339, 347, 1678, 8, 277, 12, 1642, 29, 797, 304, 267, 291, 14, 4749, 275, 298, 11394, 29454, 7337, 2, 267, 340, 440, 291, 423, 331, 439, 63, 1000, 14, 14661, 14, 374, 1084, 837, 953, 9715, 275, 5796, 14, 7929, 8, 277, 14, 5191, 12, 291, 14, 873, 9, 288, 9715, 14, 409, 20555, 8, 549, 9, 288, 9715, 14, 928, 342, 953, 340, 440, 1642, 436, 291, 423, 331, 439, 63, 1000, 365, 440, 488, 26, 355, 2512, 14, 1757, 480, 2623, 11273, 6162, 531, 355, 291, 423, 331, 439, 63, 1000, 14, 6814, 8, 277, 9, 355, 291, 14, 2873, 4909, 63, 835, 847, 413, 421, 199, 533, 29095, 4031, 8, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 536, 628, 17149, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 17149, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 797, 12, 2040, 63, 3223, 29, 797, 9, 267, 327, 12293, 2783, 267, 291, 14, 4749, 275, 408, 2, 1352, 308, 12198, 1024, 299, 12518, 89, 2, 20292, 71, 1065, 471, 1413, 11281, 544, 71, 12, 299, 3043, 316, 13437, 737, 17049, 5200, 436, 13867, 1337, 1536, 315, 30739, 14, 199, 2, 5556, 664, 15557, 315, 4589, 946, 3483, 12, 25134, 316, 370, 562, 543, 17049, 370, 391, 2411, 14947, 12, 436, 7978, 316, 314, 2463, 273, 397, 370, 1373, 5366, 14, 5311, 7710, 8103, 642, 199, 262, 440, 1454, 282, 286, 1003, 382, 1325, 282, 7710, 4928, 436, 1495, 390, 461, 4340, 14, 473, 410, 23521, 10023, 737, 26457, 282, 12427, 14, 2104, 1006, 17049, 307, 292, 7354, 780, 199, 426, 1990, 641, 314, 8852, 282, 3633, 12, 11492, 590, 10023, 883, 78, 1892, 279, 14, 14791, 1159, 1006, 642, 15632, 385, 473, 1172, 2757, 10663, 3595, 12, 32463, 473, 370, 199, 1662, 277, 20292, 1589, 2169, 1159, 282, 11779, 3769, 2951, 465, 473, 8140, 26, 946, 965, 2951, 465, 8298, 4499, 370, 1964, 285, 562, 12, 465, 473, 1172, 370, 506, 15871, 24204, 402, 26457, 14, 199, 24472, 351, 9435, 543, 282, 880, 605, 883, 78, 1892, 279, 2419, 282, 366, 1065, 917, 2799, 18824, 5653, 14, 199, 2, 44, 460, 76, 2181, 4589, 25097, 473, 12, 298, 9974, 26457, 370, 410, 1119, 17049, 370, 391, 2411, 14947, 2337, 12, 503, 5200, 12, 503, 15685, 1265, 1240, 652, 27, 11480, 26457, 370, 3631, 308, 573, 17443, 12, 199, 262, 3974, 12, 436, 473, 911, 7485, 315, 543, 26457, 14, 11017, 473, 2793, 1133, 27571, 9445, 282, 2169, 308, 573, 17443, 315, 30739, 543, 562, 14, 2779, 1159, 366, 21480, 14, 6423 ]
[ 2803, 29, 1624, 13, 24, 199, 646, 2050, 199, 646, 5796, 199, 646, 900, 199, 199, 646, 2197, 199, 199, 504, 512, 439, 898, 492, 7890, 199, 504, 512, 439, 898, 14, 4435, 14, 1927, 492, 7337, 199, 199, 363, 2502, 363, 275, 283, 39, 4674, 331, 573, 377, 621, 4822, 317, 7, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1379, 4031, 8, 4031, 304, 272, 347, 636, 826, 721, 277, 12, 536, 628, 774, 4031, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 774, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 797, 12, 2040, 63, 3223, 29, 549, 9, 267, 291, 14, 4749, 275, 298, 774, 7337, 2, 267, 291, 14, 1927, 63, 466, 275, 298, 804, 17, 2, 267, 291, 14, 11555, 63, 890, 63, 597, 12754, 275, 822, 8, 277, 14, 4749, 9, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 372, 291, 339, 347, 3795, 63, 4013, 8, 277, 12, 1056, 304, 267, 367, 945, 315, 1056, 14, 1419, 26, 288, 340, 945, 14, 1955, 508, 7890, 14, 2602, 10899, 14, 9663, 63, 2711, 14, 1955, 26, 355, 291, 14, 4749, 275, 334, 1422, 14, 585, 12, 1056, 14, 4749, 9, 355, 372, 291, 267, 291, 14, 4749, 275, 1056, 14, 4749, 267, 372, 291, 339, 347, 3795, 63, 4030, 8, 277, 12, 1056, 304, 267, 522, 275, 1379, 4031, 342, 267, 522, 14, 1985, 63, 1131, 275, 1056, 14, 2302, 63, 1131, 267, 367, 945, 315, 1056, 14, 1419, 26, 288, 340, 945, 14, 1955, 508, 7890, 14, 2602, 10899, 14, 9663, 63, 2711, 14, 1955, 26, 355, 522, 14, 4749, 275, 469, 1422, 14, 585, 26, 1056, 14, 4749, 93, 355, 372, 522, 398, 522, 14, 4749, 275, 1056, 14, 4749, 267, 372, 522, 339, 347, 3795, 63, 7014, 8, 277, 12, 1056, 304, 267, 372, 715, 421, 199, 533, 27504, 323, 4031, 8, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 536, 628, 12653, 323, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 12653, 323, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 797, 12, 2040, 63, 3223, 29, 797, 9, 267, 291, 14, 4749, 275, 298, 12653, 323, 7337, 2, 267, 291, 14, 3266, 63, 466, 275, 298, 24904, 2, 267, 291, 14, 525, 63, 1317, 63, 466, 480, 505, 15, 6104, 531, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 372, 291, 12, 291, 14, 3352, 63, 2970, 63, 24904, 339, 347, 3795, 63, 2970, 63, 24904, 8, 277, 12, 1056, 304, 267, 900, 14, 4532, 8, 21, 9, 267, 372, 291, 421, 199, 533, 17985, 29454, 4031, 8, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 536, 628, 31004, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 11394, 29454, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 549, 12, 2040, 63, 3223, 29, 797, 9, 267, 291, 14, 4749, 275, 298, 11394, 29454, 7337, 2, 267, 291, 14, 5191, 275, 959, 267, 291, 14, 873, 8, 549, 9, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 372, 291, 339, 347, 3795, 63, 4030, 8, 277, 12, 1056, 304, 267, 291, 14, 4749, 275, 1056, 14, 4749, 267, 372, 291, 339, 347, 1678, 8, 277, 12, 1642, 29, 797, 304, 267, 291, 14, 4749, 275, 298, 11394, 29454, 7337, 2, 267, 340, 440, 291, 423, 331, 439, 63, 1000, 14, 14661, 14, 374, 1084, 837, 953, 9715, 275, 5796, 14, 7929, 8, 277, 14, 5191, 12, 291, 14, 873, 9, 288, 9715, 14, 409, 20555, 8, 549, 9, 288, 9715, 14, 928, 342, 953, 340, 440, 1642, 436, 291, 423, 331, 439, 63, 1000, 365, 440, 488, 26, 355, 2512, 14, 1757, 480, 2623, 11273, 6162, 531, 355, 291, 423, 331, 439, 63, 1000, 14, 6814, 8, 277, 9, 355, 291, 14, 2873, 4909, 63, 835, 847, 413, 421, 199, 533, 29095, 4031, 8, 4031, 304, 339, 347, 636, 826, 721, 277, 12, 536, 628, 17149, 401, 512, 439, 63, 1000, 29, 403, 304, 267, 1613, 8, 17149, 4031, 12, 291, 2843, 826, 721, 354, 12, 512, 439, 63, 1000, 12, 8917, 29, 549, 12, 2607, 29454, 29, 797, 12, 2040, 63, 3223, 29, 797, 9, 267, 327, 12293, 2783, 267, 291, 14, 4749, 275, 408, 2, 1352, 308, 12198, 1024, 299, 12518, 89, 2, 20292, 71, 1065, 471, 1413, 11281, 544, 71, 12, 299, 3043, 316, 13437, 737, 17049, 5200, 436, 13867, 1337, 1536, 315, 30739, 14, 199, 2, 5556, 664, 15557, 315, 4589, 946, 3483, 12, 25134, 316, 370, 562, 543, 17049, 370, 391, 2411, 14947, 12, 436, 7978, 316, 314, 2463, 273, 397, 370, 1373, 5366, 14, 5311, 7710, 8103, 642, 199, 262, 440, 1454, 282, 286, 1003, 382, 1325, 282, 7710, 4928, 436, 1495, 390, 461, 4340, 14, 473, 410, 23521, 10023, 737, 26457, 282, 12427, 14, 2104, 1006, 17049, 307, 292, 7354, 780, 199, 426, 1990, 641, 314, 8852, 282, 3633, 12, 11492, 590, 10023, 883, 78, 1892, 279, 14, 14791, 1159, 1006, 642, 15632, 385, 473, 1172, 2757, 10663, 3595, 12, 32463, 473, 370, 199, 1662, 277, 20292, 1589, 2169, 1159, 282, 11779, 3769, 2951, 465, 473, 8140, 26, 946, 965, 2951, 465, 8298, 4499, 370, 1964, 285, 562, 12, 465, 473, 1172, 370, 506, 15871, 24204, 402, 26457, 14, 199, 24472, 351, 9435, 543, 282, 880, 605, 883, 78, 1892, 279, 2419, 282, 366, 1065, 917, 2799, 18824, 5653, 14, 199, 2, 44, 460, 76, 2181, 4589, 25097, 473, 12, 298, 9974, 26457, 370, 410, 1119, 17049, 370, 391, 2411, 14947, 2337, 12, 503, 5200, 12, 503, 15685, 1265, 1240, 652, 27, 11480, 26457, 370, 3631, 308, 573, 17443, 12, 199, 262, 3974, 12, 436, 473, 911, 7485, 315, 543, 26457, 14, 11017, 473, 2793, 1133, 27571, 9445, 282, 2169, 308, 573, 17443, 315, 30739, 543, 562, 14, 2779, 1159, 366, 21480, 14, 6423, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jsfan/flask-dance
setup.py
1
2079
# coding=utf-8 from __future__ import unicode_literals import re from setuptools import setup, Command, find_packages class PyTest(Command): user_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): import sys,subprocess errno = subprocess.call([sys.executable, 'runtests.py']) raise SystemExit(errno) def is_requirement(line): line = line.strip() # Skip blank lines, comments, and editable installs return not ( line == '' or line.startswith('--') or line.startswith('-r') or line.startswith('#') or line.startswith('-e') or line.startswith('git+') ) def get_requirements(path): with open(path) as f: lines = f.readlines() return [l.strip() for l in lines if is_requirement(l)] version = '' with open('flask_dance/__init__.py', 'r') as fd: version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: raise RuntimeError('Cannot find version information') setup( name="Flask-Dance", version=version, description="Doing the OAuth dance with style using Flask, requests, and oauthlib", long_description=open('README.rst').read(), author="David Baumgold", author_email="david@davidbaumgold.com", url="https://github.com/singingwolfboy/flask-dance", packages=find_packages(), install_requires=get_requirements("requirements.txt"), tests_require=get_requirements("dev-requirements.txt"), extras_require={ 'sqla': ['sqlalchemy', 'sqlalchemy-utils'], 'signals': ['blinker'], }, cmdclass = {'test': PyTest}, license='MIT', classifiers=( 'License :: OSI Approved :: MIT License', 'Framework :: Flask', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', ), zip_safe=False, )
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 504, 9116, 492, 3272, 12, 5817, 12, 2342, 63, 5154, 421, 199, 533, 1611, 774, 8, 3110, 304, 272, 922, 63, 1419, 275, 942, 272, 347, 8265, 63, 1419, 8, 277, 304, 267, 986, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 986, 339, 347, 1255, 8, 277, 304, 267, 492, 984, 12, 5781, 267, 7554, 275, 3873, 14, 1250, 779, 1274, 14, 5904, 12, 283, 1065, 2219, 14, 647, 1105, 267, 746, 14838, 8, 7931, 9, 421, 199, 318, 365, 63, 12434, 8, 604, 304, 272, 1004, 275, 1004, 14, 1913, 342, 272, 327, 8232, 4596, 2385, 12, 6786, 12, 436, 14783, 25801, 272, 372, 440, 334, 267, 1004, 508, 2125, 503, 267, 1004, 14, 2460, 4517, 358, 503, 267, 1004, 14, 2460, 3654, 82, 358, 503, 267, 1004, 14, 2460, 7863, 358, 503, 267, 1004, 14, 2460, 3654, 69, 358, 503, 267, 1004, 14, 2460, 360, 3187, 13854, 272, 776, 421, 199, 318, 664, 63, 7538, 8, 515, 304, 272, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 2385, 275, 289, 14, 9684, 342, 272, 372, 359, 76, 14, 1913, 342, 367, 634, 315, 2385, 340, 365, 63, 12434, 8, 76, 1874, 421, 199, 1023, 275, 2125, 199, 1045, 1551, 360, 15720, 63, 20327, 22128, 826, 4343, 647, 297, 283, 82, 358, 465, 6111, 26, 272, 1015, 275, 295, 14, 1733, 8, 82, 4289, 363, 1023, 363, 60, 83, 23440, 83, 23033, 3985, 937, 7059, 3985, 937, 10, 2788, 3985, 23793, 717, 6111, 14, 739, 1062, 295, 14, 16661, 680, 923, 8, 17, 9, 199, 199, 692, 440, 1015, 26, 272, 746, 6064, 360, 6612, 2342, 1015, 2556, 358, 421, 199, 2758, 8, 272, 536, 628, 14182, 13, 36, 554, 401, 272, 1015, 29, 1023, 12, 272, 1369, 628, 2585, 316, 314, 11715, 366, 554, 543, 3449, 1808, 16704, 12, 4145, 12, 436, 9725, 773, 401, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 1959, 739, 1062, 272, 4132, 628, 36, 17204, 699, 65, 453, 23628, 401, 272, 4132, 63, 2123, 628, 983, 5017, 32, 983, 5017, 2470, 453, 23628, 14, 957, 401, 272, 1166, 628, 2859, 921, 5031, 14, 957, 15, 1044, 316, 28070, 656, 89, 15, 15720, 13, 20327, 401, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 3907, 63, 6537, 29, 362, 63, 7538, 480, 7538, 14, 2424, 1288, 272, 2295, 63, 4365, 29, 362, 63, 7538, 480, 2374, 13, 7538, 14, 2424, 1288, 272, 13751, 63, 4365, 3126, 267, 283, 3526, 416, 356, 788, 14536, 297, 283, 14536, 13, 1208, 995, 267, 283, 10458, 356, 788, 66, 20311, 995, 272, 1660, 272, 2088, 533, 275, 791, 396, 356, 1611, 774, 1386, 272, 4190, 534, 13965, 297, 272, 19137, 2687, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 267, 283, 16442, 3800, 16704, 297, 267, 283, 11411, 8466, 3800, 2018, 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, 272, 2318, 272, 3482, 63, 3489, 29, 797, 12, 199, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 504, 9116, 492, 3272, 12, 5817, 12, 2342, 63, 5154, 421, 199, 533, 1611, 774, 8, 3110, 304, 272, 922, 63, 1419, 275, 942, 272, 347, 8265, 63, 1419, 8, 277, 304, 267, 986, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 986, 339, 347, 1255, 8, 277, 304, 267, 492, 984, 12, 5781, 267, 7554, 275, 3873, 14, 1250, 779, 1274, 14, 5904, 12, 283, 1065, 2219, 14, 647, 1105, 267, 746, 14838, 8, 7931, 9, 421, 199, 318, 365, 63, 12434, 8, 604, 304, 272, 1004, 275, 1004, 14, 1913, 342, 272, 327, 8232, 4596, 2385, 12, 6786, 12, 436, 14783, 25801, 272, 372, 440, 334, 267, 1004, 508, 2125, 503, 267, 1004, 14, 2460, 4517, 358, 503, 267, 1004, 14, 2460, 3654, 82, 358, 503, 267, 1004, 14, 2460, 7863, 358, 503, 267, 1004, 14, 2460, 3654, 69, 358, 503, 267, 1004, 14, 2460, 360, 3187, 13854, 272, 776, 421, 199, 318, 664, 63, 7538, 8, 515, 304, 272, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 2385, 275, 289, 14, 9684, 342, 272, 372, 359, 76, 14, 1913, 342, 367, 634, 315, 2385, 340, 365, 63, 12434, 8, 76, 1874, 421, 199, 1023, 275, 2125, 199, 1045, 1551, 360, 15720, 63, 20327, 22128, 826, 4343, 647, 297, 283, 82, 358, 465, 6111, 26, 272, 1015, 275, 295, 14, 1733, 8, 82, 4289, 363, 1023, 363, 60, 83, 23440, 83, 23033, 3985, 937, 7059, 3985, 937, 10, 2788, 3985, 23793, 717, 6111, 14, 739, 1062, 295, 14, 16661, 680, 923, 8, 17, 9, 199, 199, 692, 440, 1015, 26, 272, 746, 6064, 360, 6612, 2342, 1015, 2556, 358, 421, 199, 2758, 8, 272, 536, 628, 14182, 13, 36, 554, 401, 272, 1015, 29, 1023, 12, 272, 1369, 628, 2585, 316, 314, 11715, 366, 554, 543, 3449, 1808, 16704, 12, 4145, 12, 436, 9725, 773, 401, 272, 1846, 63, 1802, 29, 1490, 360, 18195, 14, 8332, 1959, 739, 1062, 272, 4132, 628, 36, 17204, 699, 65, 453, 23628, 401, 272, 4132, 63, 2123, 628, 983, 5017, 32, 983, 5017, 2470, 453, 23628, 14, 957, 401, 272, 1166, 628, 2859, 921, 5031, 14, 957, 15, 1044, 316, 28070, 656, 89, 15, 15720, 13, 20327, 401, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 3907, 63, 6537, 29, 362, 63, 7538, 480, 7538, 14, 2424, 1288, 272, 2295, 63, 4365, 29, 362, 63, 7538, 480, 2374, 13, 7538, 14, 2424, 1288, 272, 13751, 63, 4365, 3126, 267, 283, 3526, 416, 356, 788, 14536, 297, 283, 14536, 13, 1208, 995, 267, 283, 10458, 356, 788, 66, 20311, 995, 272, 1660, 272, 2088, 533, 275, 791, 396, 356, 1611, 774, 1386, 272, 4190, 534, 13965, 297, 272, 19137, 2687, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 267, 283, 16442, 3800, 16704, 297, 267, 283, 11411, 8466, 3800, 2018, 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, 272, 2318, 272, 3482, 63, 3489, 29, 797, 12, 199, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Jozhogg/iris
lib/iris/tests/unit/fileformats/grib/load_convert/test_translate_phenomenon.py
1
2806
# (C) British Crown Copyright 2014, Met Office # # This file is part of Iris. # # Iris 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. # # Iris 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 Iris. If not, see <http://www.gnu.org/licenses/>. """ Tests for function :func:`iris.fileformats.grib._load_convert.translate_phenomenon`. """ from __future__ import (absolute_import, division, print_function) # import iris tests first so that some things can be initialised # before importing anything else. import iris.tests as tests from copy import deepcopy from iris.coords import DimCoord from iris.unit import Unit from iris.fileformats.grib._load_convert import Probability from iris.fileformats.grib.grib_phenom_translation import _GribToCfDataClass from iris.fileformats.grib._load_convert import translate_phenomenon class Test_probability(tests.IrisTest): def setUp(self): # Patch inner call to return a given phenomenon type. target_module = 'iris.fileformats.grib._load_convert' self.phenom_lookup_patch = self.patch( target_module + '.itranslation.grib2_phenom_to_cf_info', return_value=_GribToCfDataClass('air_temperature', '', 'K', None)) # Construct dummy call arguments self.probability = Probability('<prob_type>', 22.0) self.metadata = {'aux_coords_and_dims': []} def test_basic(self): result = translate_phenomenon(self.metadata, None, None, None, probability=self.probability) # Check metadata. thresh_coord = DimCoord([22.0], standard_name='air_temperature', long_name='', units='K') self.assertEqual(self.metadata, { 'standard_name': None, 'long_name': 'probability_of_air_temperature_<prob_type>', 'units': Unit(1), 'aux_coords_and_dims': [(thresh_coord, None)]}) def test_no_phenomenon(self): original_metadata = deepcopy(self.metadata) self.phenom_lookup_patch.return_value = None result = translate_phenomenon(self.metadata, None, None, None, probability=self.probability) self.assertEqual(self.metadata, original_metadata) if __name__ == '__main__': tests.main()
lgpl-3.0
[ 3, 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 6927, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 473, 5719, 14, 199, 3, 199, 3, 473, 5719, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 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, 473, 5719, 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, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 473, 5719, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 2925, 367, 805, 199, 26, 1532, 1705, 11885, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 14, 5275, 63, 17579, 1377, 2865, 2313, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 199, 3, 492, 12192, 2295, 1642, 880, 626, 2005, 7645, 883, 506, 2536, 9096, 199, 3, 2544, 16306, 7003, 587, 14, 199, 646, 12192, 14, 2219, 465, 2295, 199, 199, 504, 1331, 492, 14800, 199, 199, 504, 12192, 14, 8032, 492, 577, 1017, 14957, 199, 504, 12192, 14, 3248, 492, 12008, 199, 504, 12192, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 492, 22770, 3616, 199, 504, 12192, 14, 493, 6321, 14, 7928, 66, 14, 7928, 66, 63, 17579, 676, 63, 6893, 492, 485, 39, 30759, 1378, 24304, 1451, 2543, 199, 199, 504, 12192, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 492, 9028, 63, 17579, 1377, 2865, 421, 199, 533, 1379, 63, 17210, 8, 2219, 14, 41, 5719, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 327, 19292, 6506, 1240, 370, 372, 282, 1627, 3945, 287, 1377, 2865, 730, 14, 267, 1347, 63, 578, 275, 283, 11885, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 7, 267, 291, 14, 17579, 676, 63, 3892, 63, 2068, 275, 291, 14, 2068, 8, 288, 1347, 63, 578, 435, 1987, 390, 1320, 2212, 14, 7928, 66, 18, 63, 17579, 676, 63, 475, 63, 2177, 63, 815, 297, 288, 372, 63, 585, 3699, 39, 30759, 1378, 24304, 1451, 2543, 360, 8387, 63, 12954, 297, 3260, 283, 43, 297, 488, 430, 267, 327, 9215, 7283, 1240, 2368, 267, 291, 14, 17210, 275, 22770, 3616, 4827, 6101, 63, 466, 4206, 6928, 14, 16, 9, 267, 291, 14, 2343, 275, 791, 10962, 63, 8032, 63, 460, 63, 5380, 356, 23455, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 754, 275, 9028, 63, 17579, 1377, 2865, 8, 277, 14, 2343, 12, 488, 12, 488, 12, 488, 12, 4228, 12224, 29, 277, 14, 17210, 9, 267, 327, 2670, 3341, 14, 267, 16126, 63, 7988, 275, 577, 1017, 14957, 779, 1081, 14, 16, 467, 1816, 4465, 63, 354, 534, 8387, 63, 12954, 297, 1816, 1846, 63, 354, 4581, 6204, 534, 43, 358, 267, 291, 14, 629, 8, 277, 14, 2343, 12, 469, 288, 283, 6807, 63, 354, 356, 488, 12, 288, 283, 2809, 63, 354, 356, 283, 17210, 63, 1618, 63, 8387, 63, 12954, 27718, 6101, 63, 466, 4206, 288, 283, 5260, 356, 12008, 8, 17, 395, 288, 283, 10962, 63, 8032, 63, 460, 63, 5380, 356, 3842, 14898, 63, 7988, 12, 488, 1874, 1552, 339, 347, 511, 63, 889, 63, 17579, 1377, 2865, 8, 277, 304, 267, 3379, 63, 2343, 275, 14800, 8, 277, 14, 2343, 9, 267, 291, 14, 17579, 676, 63, 3892, 63, 2068, 14, 1107, 63, 585, 275, 488, 267, 754, 275, 9028, 63, 17579, 1377, 2865, 8, 277, 14, 2343, 12, 488, 12, 488, 12, 488, 12, 4228, 12224, 29, 277, 14, 17210, 9, 267, 291, 14, 629, 8, 277, 14, 2343, 12, 3379, 63, 2343, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2295, 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 ]
[ 334, 35, 9, 699, 322, 23184, 445, 18406, 1898, 6927, 12, 10072, 593, 11286, 301, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 473, 5719, 14, 199, 3, 199, 3, 473, 5719, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 199, 3, 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, 473, 5719, 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, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 473, 5719, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 2925, 367, 805, 199, 26, 1532, 1705, 11885, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 14, 5275, 63, 17579, 1377, 2865, 2313, 199, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 199, 3, 492, 12192, 2295, 1642, 880, 626, 2005, 7645, 883, 506, 2536, 9096, 199, 3, 2544, 16306, 7003, 587, 14, 199, 646, 12192, 14, 2219, 465, 2295, 199, 199, 504, 1331, 492, 14800, 199, 199, 504, 12192, 14, 8032, 492, 577, 1017, 14957, 199, 504, 12192, 14, 3248, 492, 12008, 199, 504, 12192, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 492, 22770, 3616, 199, 504, 12192, 14, 493, 6321, 14, 7928, 66, 14, 7928, 66, 63, 17579, 676, 63, 6893, 492, 485, 39, 30759, 1378, 24304, 1451, 2543, 199, 199, 504, 12192, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 492, 9028, 63, 17579, 1377, 2865, 421, 199, 533, 1379, 63, 17210, 8, 2219, 14, 41, 5719, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 327, 19292, 6506, 1240, 370, 372, 282, 1627, 3945, 287, 1377, 2865, 730, 14, 267, 1347, 63, 578, 275, 283, 11885, 14, 493, 6321, 14, 7928, 66, 423, 912, 63, 3916, 7, 267, 291, 14, 17579, 676, 63, 3892, 63, 2068, 275, 291, 14, 2068, 8, 288, 1347, 63, 578, 435, 1987, 390, 1320, 2212, 14, 7928, 66, 18, 63, 17579, 676, 63, 475, 63, 2177, 63, 815, 297, 288, 372, 63, 585, 3699, 39, 30759, 1378, 24304, 1451, 2543, 360, 8387, 63, 12954, 297, 3260, 283, 43, 297, 488, 430, 267, 327, 9215, 7283, 1240, 2368, 267, 291, 14, 17210, 275, 22770, 3616, 4827, 6101, 63, 466, 4206, 6928, 14, 16, 9, 267, 291, 14, 2343, 275, 791, 10962, 63, 8032, 63, 460, 63, 5380, 356, 23455, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 754, 275, 9028, 63, 17579, 1377, 2865, 8, 277, 14, 2343, 12, 488, 12, 488, 12, 488, 12, 4228, 12224, 29, 277, 14, 17210, 9, 267, 327, 2670, 3341, 14, 267, 16126, 63, 7988, 275, 577, 1017, 14957, 779, 1081, 14, 16, 467, 1816, 4465, 63, 354, 534, 8387, 63, 12954, 297, 1816, 1846, 63, 354, 4581, 6204, 534, 43, 358, 267, 291, 14, 629, 8, 277, 14, 2343, 12, 469, 288, 283, 6807, 63, 354, 356, 488, 12, 288, 283, 2809, 63, 354, 356, 283, 17210, 63, 1618, 63, 8387, 63, 12954, 27718, 6101, 63, 466, 4206, 288, 283, 5260, 356, 12008, 8, 17, 395, 288, 283, 10962, 63, 8032, 63, 460, 63, 5380, 356, 3842, 14898, 63, 7988, 12, 488, 1874, 1552, 339, 347, 511, 63, 889, 63, 17579, 1377, 2865, 8, 277, 304, 267, 3379, 63, 2343, 275, 14800, 8, 277, 14, 2343, 9, 267, 291, 14, 17579, 676, 63, 3892, 63, 2068, 14, 1107, 63, 585, 275, 488, 267, 754, 275, 9028, 63, 17579, 1377, 2865, 8, 277, 14, 2343, 12, 488, 12, 488, 12, 488, 12, 4228, 12224, 29, 277, 14, 17210, 9, 267, 291, 14, 629, 8, 277, 14, 2343, 12, 3379, 63, 2343, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2295, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MobleyLab/SAMPL6
host_guest/Analysis/Scripts/analyze_sampling.py
1
116143
#!/usr/bin/env python # ============================================================================= # GLOBAL IMPORTS # ============================================================================= import collections import copy import itertools import json import math import os import numpy as np import pandas as pd import scipy as sp import seaborn as sns from matplotlib import pyplot as plt from pkganalysis.stats import mean_confidence_interval from pkganalysis.sampling import (SamplingSubmission, YankSamplingAnalysis, YANK_N_ITERATIONS, DG_KEY, DDG_KEY, export_dictionary) from pkganalysis.submission import (load_submissions) # ============================================================================= # CONSTANTS # ============================================================================= YANK_METHOD_PAPER_NAME = 'OpenMM/HREX' # Paths to input data. SAMPLING_SUBMISSIONS_DIR_PATH = '../SubmissionsDoNotUpload/975/' YANK_ANALYSIS_DIR_PATH = 'YankAnalysis/Sampling/' SAMPLING_ANALYSIS_DIR_PATH = '../SAMPLing/' SAMPLING_DATA_DIR_PATH = os.path.join(SAMPLING_ANALYSIS_DIR_PATH, 'Data') SAMPLING_PLOT_DIR_PATH = os.path.join(SAMPLING_ANALYSIS_DIR_PATH, 'Plots') SAMPLING_PAPER_DIR_PATH = os.path.join(SAMPLING_ANALYSIS_DIR_PATH, 'PaperImages') # All system ids. SYSTEM_IDS = [ 'CB8-G3-0', 'CB8-G3-1', 'CB8-G3-2', 'CB8-G3-3', 'CB8-G3-4', 'OA-G3-0', 'OA-G3-1', 'OA-G3-2', 'OA-G3-3', 'OA-G3-4', 'OA-G6-0', 'OA-G6-1', 'OA-G6-2', 'OA-G6-3', 'OA-G6-4' ] # Kelly's colors for maximum contrast. # "gray95", "gray13", "gold2", "plum4", "darkorange1", "lightskyblue2", "firebrick", "burlywood3", "gray51", "springgreen4", "lightpink2", "deepskyblue4", "lightsalmon2", "mediumpurple4", "orange", "maroon", "yellow3", "brown4", "yellow4", "sienna4", "chocolate", "gray19" KELLY_COLORS = ['#F2F3F4', '#222222', '#F3C300', '#875692', '#F38400', '#A1CAF1', '#BE0032', '#C2B280', '#848482', '#008856', '#E68FAC', '#0067A5', '#F99379', '#604E97', '#F6A600', '#B3446C', '#DCD300', '#882D17', '#8DB600', '#654522', '#E25822', '#2B3D26'] TAB10_COLORS = sns.color_palette('tab10') # Index of Kelly's colors associated to each submission. SUBMISSION_COLORS = { 'AMBER/APR': 'dodgerblue',#KELLY_COLORS[11], 'OpenMM/REVO': 'gold', #KELLY_COLORS[7], 'OpenMM/SOMD': KELLY_COLORS[4], 'GROMACS/EE': 'darkviolet', #KELLY_COLORS[3], 'GROMACS/EE-fullequil': 'hotpink', #KELLY_COLORS[10], YANK_METHOD_PAPER_NAME: '#4ECC41', #'limegreen', #KELLY_COLORS[9], 'GROMACS/NS-DS/SB-long': KELLY_COLORS[6], 'GROMACS/NS-DS/SB': KELLY_COLORS[1], 'GROMACS/NS-Jarz-F': TAB10_COLORS[0], 'GROMACS/NS-Jarz-R': TAB10_COLORS[1], 'GROMACS/NS-Gauss-F': TAB10_COLORS[2], 'GROMACS/NS-Gauss-R': TAB10_COLORS[4], 'NAMD/BAR': 'saddlebrown' } SUBMISSION_LINE_STYLES = { 'AMBER/APR': '--', 'OpenMM/REVO': '-', 'OpenMM/SOMD': '-', 'GROMACS/EE': '-', 'GROMACS/EE-fullequil': '-', YANK_METHOD_PAPER_NAME: '-', 'GROMACS/NS-DS/SB-long': '-', 'GROMACS/NS-DS/SB': '-', 'GROMACS/NS-Jarz-F': '-', 'GROMACS/NS-Jarz-R': '-', 'GROMACS/NS-Gauss-F': '-', 'GROMACS/NS-Gauss-R': '-', 'NAMD/BAR': '--', } N_ENERGY_EVALUATIONS_SCALE = 1e6 # ============================================================================= # UTILITY FUNCTIONS # ============================================================================= def reduce_to_first_significant_digit(quantity, uncertainty): """Truncate a quantity to the first significant digit of its uncertainty.""" first_significant_digit = math.floor(math.log10(abs(uncertainty))) quantity = round(quantity, -first_significant_digit) uncertainty = round(uncertainty, -first_significant_digit) return quantity, uncertainty def load_yank_analysis(): """Load the YANK analysis in a single dataframe.""" yank_free_energies = {} for system_id in SYSTEM_IDS: file_path = os.path.join(YANK_ANALYSIS_DIR_PATH, 'yank-{}.json'.format(system_id)) with open(file_path, 'r') as f: yank_free_energies[system_id] = json.load(f) return yank_free_energies def fit_efficiency(mean_data, find_best_fit=True): """Compute the efficiency by fitting the model and using only the asymptotic data. We fit using the simulation percentage as the independent value because it is less prone to overflowing during fitting. We then return the efficiency in units of (kcal/mol)**2/n_energy_evaluations. """ from scipy.optimize import curve_fit def model(x, log_efficiency): return np.exp(log_efficiency) / x vars = mean_data['std'].values**2 cost = mean_data['Simulation percentage'].values # cost = mean_data['N energy evaluations'].values / 1e7 if find_best_fit: # Find fit with best error up to discarding 70% of calculation. max_discarded = math.floor(0.5*len(cost)) else: # Use all the data. max_discarded = 1 # Fit. fits = [] for n_discarded in range(max_discarded): cost_fit = cost[n_discarded:] vars_fit = vars[n_discarded:] fit = curve_fit(model, cost_fit, vars_fit, p0=[0.0]) fits.append((np.exp(fit[0]), fit[1])) # Find the fit with the minimum error. n_discarded = fits.index(min(fits, key=lambda x: x[1])) # Convert efficiency / simulation_percentage to efficiency / n_energy_evaluations efficiency = fits[n_discarded][0][0] / 100 * mean_data['N energy evaluations'].values[-1] # efficiency = fits[n_discarded][0][0] * 1e7 return efficiency, n_discarded def export_submissions(submissions, reference_free_energies): """Export the submission data to CSV and JSON format.""" for submission in submissions: exported_data = {} # Export data of the 5 independent replicates. for system_id in sorted(submission.data['System ID'].unique()): system_id_data = submission.data[submission.data['System ID'] == system_id] exported_data[system_id] = collections.OrderedDict([ ('DG', system_id_data[DG_KEY].values.tolist()), ('dDG', system_id_data[DDG_KEY].values.tolist()), ('cpu_times', system_id_data['CPU time [s]'].values.tolist()), ('n_energy_evaluations', system_id_data['N energy evaluations'].values.tolist()), ]) # Export data of mean trajectory and confidence intervals. mean_free_energies = submission.mean_free_energies() for system_name in mean_free_energies['System name'].unique(): system_name_data = mean_free_energies[mean_free_energies['System name'] == system_name] # Obtain free energies and bias. free_energies = system_name_data[DG_KEY].values free_energies_ci = system_name_data['$\Delta$G CI'].values reference_diff = free_energies - reference_free_energies.loc[system_name, '$\Delta$G [kcal/mol]'] exported_data[system_name + '-mean'] = collections.OrderedDict([ ('DG', free_energies.tolist()), ('DG_CI', free_energies_ci.tolist()), ('reference_difference', reference_diff.tolist()), ('n_energy_evaluations', system_name_data['N energy evaluations'].values.tolist()), ]) # Export. file_base_path = os.path.join(SAMPLING_DATA_DIR_PATH, submission.receipt_id) export_dictionary(exported_data, file_base_path) # ============================================================================= # PLOTTING FUNCTIONS # ============================================================================= def plot_mean_free_energy(mean_data, ax, x='Simulation percentage', color_mean=None, color_ci=None, zorder=None, start=None, stride=1, scale_n_energy_evaluations=True, plot_ci=True, **plot_kwargs): """Plot mean trajectory with confidence intervals.""" ci_key = '$\Delta$G CI' if start is None: # Discard the first datapoint which are 0.0 (i.e. no estimate). start = np.nonzero(mean_data[DG_KEY].values)[0][0] if x == 'N energy evaluations' and scale_n_energy_evaluations: # Plot in millions of energy evaluations. scale = N_ENERGY_EVALUATIONS_SCALE else: scale = 1 x = mean_data[x].values[start::stride] / scale mean_dg = mean_data[DG_KEY].values[start::stride] sem_dg = mean_data[ci_key].values[start::stride] # Plot mean trajectory confidence intervals. if plot_ci: ax.fill_between(x, mean_dg + sem_dg, mean_dg - sem_dg, alpha=0.15, color=color_ci, zorder=zorder) # Plot the mean free energy trajectory. if zorder is not None: # Push the CI shaded area in the background so that the trajectories are always visible. zorder += 20 ax.plot(x, mean_dg, color=color_mean, alpha=1.0, zorder=zorder, **plot_kwargs) return ax def plot_mean_data(mean_data, axes, color=None, ls=None, label=None, x='N energy evaluations', zorder=None, plot_std=True, plot_bias=True, plot_ci=True): """Plot free energy, variance and bias as a function of the cost in three different axes.""" # Do not plot the part of data without index. first_nonzero_idx = np.nonzero(mean_data[DG_KEY].values)[0][0] # If the x-axis is the number of energy/force evaluations, plot it in units of millions. if x == 'N energy evaluations': scale = N_ENERGY_EVALUATIONS_SCALE else: scale = 1 # Plot the submission mean trajectory with CI. plot_mean_free_energy(mean_data, x=x, ax=axes[0], color_mean=color, color_ci=color, ls=ls, zorder=zorder, start=first_nonzero_idx, label=label, plot_ci=plot_ci) # Plot standard deviation of the trajectories. if plot_std: axes[1].plot(mean_data[x].values[first_nonzero_idx:] / scale, mean_data['std'].values[first_nonzero_idx:], color=color, alpha=0.8, ls=ls, zorder=zorder, label=label) if plot_bias: axes[2].plot(mean_data[x].values[first_nonzero_idx:] / scale, mean_data['bias'].values[first_nonzero_idx:], color=color, alpha=0.8, ls=ls, zorder=zorder, label=label) def align_yaxis(ax1, v1, ax2, v2): """Adjust ax2 ylimit so that v2 in in the twin ax2 is aligned to v1 in ax1. From https://stackoverflow.com/questions/10481990/matplotlib-axis-with-two-scales-shared-origin . """ _, y1 = ax1.transData.transform((0, v1)) _, y2 = ax2.transData.transform((0, v2)) inv = ax2.transData.inverted() _, dy = inv.transform((0, 0)) - inv.transform((0, y1-y2)) miny, maxy = ax2.get_ylim() ax2.set_ylim(miny+dy, maxy+dy) # ============================================================================= # FIGURE 1 - SAMPLING CHALLENGE OVERVIEW # ============================================================================= def plot_example_bias_variance(yank_analysis, type='mixed', cost='generic', max_n_eval_percentage=1.0, mixed_proportion=0.5, model_free_energy=None, plot_experimental_value=False): """Free energy trajectories used to visualize bias and variance on the plots. This is used to illustrate how bias and uncertainty are intended in the paper. Parameters ---------- type : str, optional Can be 'single' (plot only CB8-G3-1), 'all' (plot all system IDs of CB8-G3), 'mean' (plot mean trajectory and uncertainties), and 'mixed (first part is all system IDs and second part is mean trajectory and uncertainties). cost : str, optional Can be 'generic' (no label on x-axis) or 'neval' (x-axis in number of energy evaluations). mixed_proportion : float, optional The proportion of all System IDs and mean trajectories in mixed-type plots. """ # sns.set_context('paper', font_scale=1.6) sns.set_style('white') sns.set_context('paper', font_scale=1.0) # Load the data n_iterations = 40000 cb8_data = yank_analysis.get_free_energies_from_iteration(n_iterations, system_name='CB8-G3', mean_trajectory=False) cb8_data_mean = yank_analysis.get_free_energies_from_iteration(n_iterations, system_name='CB8-G3', mean_trajectory=True) max_n_eval = max(cb8_data_mean['N energy evaluations']) max_n_eval_scaled = int(max_n_eval / N_ENERGY_EVALUATIONS_SCALE) max_displayed_n_eval = next(x for x in cb8_data_mean['N energy evaluations'] if x >= max_n_eval * max_n_eval_percentage) max_displayed_n_eval_scaled = int(max_displayed_n_eval / N_ENERGY_EVALUATIONS_SCALE) # Determine the asymptotic free energy if not given. if model_free_energy is None: model_free_energy = cb8_data_mean[DG_KEY].values[-1] # Scale the number of energy evaluations. cb8_data.loc[:,'N energy evaluations'] /= N_ENERGY_EVALUATIONS_SCALE fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(2.5, 1.8)) if type == 'single': # Plot only CB8-G3-1. cb8_data_1 = cb8_data[cb8_data['System ID'] == 'CB8-G3-1'] sns.lineplot(data=cb8_data_1, x='N energy evaluations', y=DG_KEY, hue='System ID', palette='bright', ax=ax, alpha=0.6) elif type == 'all': # Plot the 5 replicates individual trajectories. sns.lineplot(data=cb8_data, x='N energy evaluations', y=DG_KEY, hue='System ID', palette='bright', ax=ax, alpha=0.6) elif type == 'mean': # Plot the submission mean trajectory with CI. plot_mean_free_energy(cb8_data_mean, x='N energy evaluations', ax=ax, color_mean='black', plot_ci=True, color_ci='black', scale_n_energy_evaluations=True) elif type == 'mixed': # Plot all System IDs for the first half and mean/uncertainty in second half. half_n_eval = max_displayed_n_eval_scaled * mixed_proportion cb8_data_first_half = cb8_data[cb8_data['N energy evaluations'] <= half_n_eval + max_n_eval_scaled / 100] sns.lineplot(data=cb8_data_first_half, x='N energy evaluations', y=DG_KEY, hue='System ID', palette='bright', ax=ax, alpha=0.6) cb8_data_second_half = cb8_data_mean[cb8_data_mean['N energy evaluations'] >= half_n_eval * N_ENERGY_EVALUATIONS_SCALE] plot_mean_free_energy(cb8_data_second_half, x='N energy evaluations', ax=ax, color_mean='black', plot_ci=True, color_ci=(0.3, 0.3, 0.3), scale_n_energy_evaluations=True, ls='--') try: ax.get_legend().remove() except AttributeError: pass # Set limits x_lim = (0, max_displayed_n_eval_scaled) ax.set_xlim(x_lim) y_lim = (-12.5, -10.5) ax.set_ylim(y_lim) # Plot model and experiment indication. Both values are not real data, just an example. model_free_energy = -10.75 final_prediction = cb8_data_mean[cb8_data_mean['N energy evaluations'] == max_displayed_n_eval][DG_KEY].values[0] ax.plot(x_lim, [model_free_energy]*2, color='gray', ls='--') ax.text(x_lim[-1]+(max_n_eval_scaled*max_n_eval_percentage)/100, model_free_energy, r'$\Delta$G$_{\theta}$') ax.text(x_lim[-1]+(max_n_eval_scaled*max_n_eval_percentage)/100, final_prediction - 0.13, r'$\overline{\Delta G}$') # Plot experimental value horizontal line only for generic plot. if plot_experimental_value: experiment_dg = -11.75 plt.plot(x_lim, [experiment_dg]*2, color='black') if cost == 'neval': ax.set_xlabel('N force/energy evaluations') else: ax.set_xlabel('Computational cost', labelpad=-5) ax.set_ylabel('$\Delta$G', labelpad=-5) ax.set_yticklabels([]) ax.set_xticklabels([]) plt.tight_layout(pad=0.1, rect=[0.0, 0.0, 0.90, 1.0]) # Save file. figure_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'Figure 1 - host-guest') os.makedirs(figure_dir_path, exist_ok=True) output_base_path = os.path.join(figure_dir_path, 'example_trajectories') plt.savefig(output_base_path + '.pdf') # ============================================================================= # FIGURE 2 - MEAN ERROR AND RELATIVE EFFICIENCY CARTOON # ============================================================================= def plot_mean_error_cartoon(): """Plot the cartoon used to explain mean error and relative efficiency. This is used as an example to clarify some gotchas with the difinition of efficiency. """ from mpl_toolkits.axes_grid1.inset_locator import inset_axes sns.set_context('paper') sns.set_style('white') def err_decay_func_square(decay_coeff, c): return decay_coeff / np.sqrt(c) def mean_error_square(decay_coeff, c_min, c_max): return 2 * decay_coeff * (np.sqrt(c_max) - np.sqrt(c_min)) / (c_max - c_min) def err_decay_func_B(decay_coeff, c): return decay_coeff / c**(5/6) def mean_error_B(decay_coeff, c_min, c_max): return 6 * decay_coeff * (c_max**(1/6) - c_min**(1/6)) / (c_max - c_min) decay_coeffs = { 'A': 1.0, 'B': 2.5, 'Z': 1.5, } c_ranges = collections.OrderedDict([ ("A'", np.arange(1, 4.5, 0.1)), ("A''", np.arange(3, 6, 0.1)), ("B", np.arange(2, 6.5, 0.1)), ("Z", np.arange(1, 6.5, 0.1)), ]) # Determine colors colors. colors = {m: 'C'+str(i) for i, m in enumerate(sorted(c_ranges))} # Plot the error trajectories. fig, ax = plt.subplots(figsize=(3.5, 2.6)) # method_names = ["B", "Z", "A'", "A''"] method_names = ["Z", "A'", "A''"] for method_name in method_names: color = colors[method_name] c_range = c_ranges[method_name] decay_coeff = decay_coeffs[method_name[0]] if method_name == 'B': err_decay_func = err_decay_func_B else: err_decay_func = err_decay_func_square err = err_decay_func(decay_coeff, c_range) # Plot error area. ax.plot(c_range, err, color=color, label=method_name, zorder=1) ax.fill_between(c_range, err, 0, color=color, alpha=0.5, zorder=0) # Add method label. c_method_label_idx = int(len(c_range) / 8) ax.text(c_range[c_method_label_idx], err[c_method_label_idx]+0.01, method_name, fontsize=12) if method_name[0] == 'A': # Plot mean error. c_min, c_max = min(c_range), max(c_range) mean_err = mean_error_square(decay_coeff, c_min, c_max) # Start mean error horizontal line from the error curve. c_mean = (decay_coeff / mean_err)**2 ax.plot([0, c_mean], [mean_err, mean_err], color='black', ls='--', alpha=0.8, zorder=1) # Add label mean error. # ax.text(1.05, mean_err+0.025, '$\mathbb{E}[RMSE_{' + method_name + '}]$', fontsize=9) ax.text(-0.3, mean_err+0.025, '$\mathbb{E}[RMSE_{' + method_name + '}]$', fontsize=9) # Add c_min/max labels. ax.text(c_min-0.4, -0.1, 'c$_{min,' + method_name + '}$', fontsize=9) ax.text(c_max-0.4, -0.1, 'c$_{max,' + method_name + '}$', fontsize=9) # Configure axes. ax.set_xlim(1, 6.4) ax.set_ylim(0, 2) ax.set_xticklabels([]) ax.set_yticklabels([]) ax.set_ylabel('$RMSE(\Delta G)$') ax.set_xlabel('computational cost') # Pull axes labels closest to axes. ax.tick_params(axis='x', which='major', pad=2.0) ax.yaxis.set_label_coords(0.0, 0.65) # Plot the relative efficiencies in an inset plot. ax_ins = inset_axes(ax, width='100%', height='100%', bbox_to_anchor=[145, 115, 90, 50]) # Compute relative efficiencies with respect to Z. relative_efficiencies = collections.OrderedDict() for method_name in [name for name in method_names if name != 'Z']: c_min, c_max = min(c_ranges[method_name]), max(c_ranges[method_name]) if method_name == 'B': mean_error_func = mean_error_B else: mean_error_func = mean_error_square mean_err_method = mean_error_func(decay_coeffs[method_name[0]], c_min, c_max) mean_err_Z = mean_error_square(decay_coeffs['Z'], c_min, c_max) relative_efficiencies[method_name] = -np.log(mean_err_method/mean_err_Z) # Plot horizontal bar plot with all efficiencies. labels, rel_effs = zip(*relative_efficiencies.items()) bar_colors = [colors[m] for m in labels] labels = [l + '/Z' for l in labels] # labels = ['$e_{err,' + str(l) + '/Z}$' for l in labels] ax_ins.barh(y=labels, width=rel_effs, color=bar_colors, alpha=0.85) ax_ins.set_title('relative efficiency', pad=2.5) # plt.tight_layout(rect=[0.0, 0.0, 1.0, 1.0]) plt.tight_layout(rect=[0.1, 0.0, 1.0, 1.0]) # Pull axes labels closest to axes. ax_ins.set_xticks([0.0]) ax_ins.grid(axis='x') ax_ins.tick_params(axis='x', which='major', pad=0.0) ax_ins.tick_params(axis='y', which='major', pad=0.0) output_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'Figure2-efficiency_cartoon') os.makedirs(output_dir_path, exist_ok=True) plt.savefig(os.path.join(output_dir_path, 'error_trajectories.pdf')) # ============================================================================= # FIGURE 3 - FREE ENERGY TRAJECTORIES # ============================================================================= def plot_submissions_trajectory(submissions, yank_analysis, axes, y_limits=None, plot_std=True, plot_bias=True, plot_bias_to_reference=False, system_names=None): """Plot free energy trajectories, std, and bias of the given submissions.""" if system_names is None: system_names = ['CB8-G3', 'OA-G3', 'OA-G6'] n_systems = len(system_names) max_n_energy_evaluations = {system_name: 0 for system_name in system_names} min_n_energy_evaluations = {system_name: np.inf for system_name in system_names} # Handle default arguments. if y_limits is None: # 3 by 3 matrix of y limits for the plots. y_limits = [[None for _ in range(n_systems)] for _ in range(n_systems)] # We need a 2D array of axes for the code to work even if we're not plotting std or bias. try: axes_shape = len(axes.shape) except AttributeError: axes = np.array([[axes]]) else: if axes_shape == 1: axes = np.array([axes]) # Build a dictionary mapping submissions and system names to their mean data. all_mean_data = {} for submission in submissions: # We always want to print in order all_mean_data[submission.paper_name] = {} mean_free_energies = submission.mean_free_energies() for system_name in system_names: # CB8-G3 calculations for GROMACS/EE did not converge. if submission.name == 'Expanded-ensemble/MBAR' and system_name == 'CB8-G3': continue # Add mean free energies for this system. system_mean_data = mean_free_energies[mean_free_energies['System name'] == system_name] n_energy_evaluations = system_mean_data['N energy evaluations'].values[-1] all_mean_data[submission.paper_name][system_name] = system_mean_data # Keep track of the maximum and minimum number of energy evaluations, # which will be used to determine how to truncate the plotted reference # data and determine the zorder of the trajectories respectively. max_n_energy_evaluations[system_name] = max(max_n_energy_evaluations[system_name], n_energy_evaluations) min_n_energy_evaluations[system_name] = min(min_n_energy_evaluations[system_name], n_energy_evaluations) # Add also reference YANK calculations if provided. if yank_analysis is not None: all_mean_data[YANK_METHOD_PAPER_NAME] = {} for system_name in system_names: system_mean_data = yank_analysis.get_free_energies_from_energy_evaluations( max_n_energy_evaluations[system_name], system_name=system_name, mean_trajectory=True) all_mean_data[YANK_METHOD_PAPER_NAME][system_name] = system_mean_data # Create a table mapping submissions and system name to the zorder used # to plot the free energy trajectory so that smaller shaded areas are on # top of bigger ones. # First find the average CI for all methods up to min_n_energy_evaluations. methods_cis = {name: {} for name in system_names} for method_name, method_mean_data in all_mean_data.items(): for system_name, system_mean_data in method_mean_data.items(): # Find index of all energy evaluations < min_n_energy_evaluations. n_energy_evaluations = system_mean_data['N energy evaluations'].values last_idx = np.searchsorted(n_energy_evaluations, min_n_energy_evaluations[system_name], side='right') cis = system_mean_data['$\Delta$G CI'].values[:last_idx] methods_cis[system_name][method_name] = np.mean(cis) # For each system, order methods from smallest CI (plot on top) to greatest CI (background). zorders = {name: {} for name in system_names} for system_name, system_cis in methods_cis.items(): ordered_methods = sorted(system_cis.keys(), key=lambda method_name: system_cis[method_name]) for zorder, method_name in enumerate(ordered_methods): zorders[system_name][method_name] = zorder # The columns are in order CB8-G3, OA-G3, and OA-G6. system_columns = {'CB8-G3': 0, 'OA-G3': 1, 'OA-G6': 2} # Plot submissions in alphabetical order to order he legend labels. for method_name in sorted(all_mean_data.keys()): submission_mean_data = all_mean_data[method_name] submission_color = SUBMISSION_COLORS[method_name] submission_ls = SUBMISSION_LINE_STYLES[method_name] # Plot free energy trajectories. for system_name, mean_data in submission_mean_data.items(): ax_idx = system_columns[system_name] # The OA prediction of the NS short protocol are the same of the long protocol submission file. if method_name == 'GROMACS/NS-DS/SB-long' and system_name != 'CB8-G3': # Just add the label. axes[0][ax_idx].plot([], color=submission_color, ls=submission_ls, label=method_name) continue # Update maximum number of energy evaluations. n_energy_evaluations = mean_data['N energy evaluations'].values[-1] max_n_energy_evaluations[system_name] = max(max_n_energy_evaluations[system_name], n_energy_evaluations) # Determine zorder and plot. zorder = zorders[system_name][method_name] plot_mean_data(mean_data, axes[:,ax_idx], color=submission_color, ls=submission_ls, zorder=zorder, label=method_name, plot_std=plot_std, plot_bias=plot_bias) # Fix labels. axes[0][0].set_ylabel('$\Delta$G [kcal/mol]') if plot_std: axes[1][0].set_ylabel('std($\Delta$G) [kcal/mol]') if plot_bias: axes[2][0].set_ylabel('bias [kcal/mol]') central_column_idx = int(len(axes[0])/2) axes[-1][central_column_idx].set_xlabel('number of energy/force evaluations [10$^6$]') # Fix axes limits. for ax_idx, system_name in enumerate(system_names): for row_idx in range(len(axes)): ax = axes[row_idx][ax_idx] # Set the x-axis limits. ax.set_xlim((0, max_n_energy_evaluations[system_name]/N_ENERGY_EVALUATIONS_SCALE)) # Keep the x-axis label only at the bottom row. if row_idx != len(axes)-1: ax.xaxis.set_ticklabels([]) y_lim = y_limits[row_idx][ax_idx] if y_lim is not None: ax.set_ylim(y_lim) # Set the system name in the title. axes[0][ax_idx].set_title(system_name) # Create a bias axis AFTER the ylim has been set. if yank_analysis is not None and plot_bias_to_reference: for ax_idx, (system_name, ax) in enumerate(zip(system_names, axes[0])): yank_full_mean_data = yank_analysis.get_system_free_energies(system_name, mean_trajectory=True) ref_free_energy = yank_full_mean_data[DG_KEY].values[-1] with sns.axes_style('white'): ax2 = ax.twinx() # Plot a vertical line to fix the scale. vertical_line = np.linspace(*ax.get_ylim()) - ref_free_energy ax2.plot([50] * len(vertical_line), vertical_line, alpha=0.0001) ax2.grid(alpha=0.5, linestyle='dashed', zorder=0) # We add the bias y-label only on the rightmost Axis. if ax_idx == n_systems - 1: ax2.set_ylabel('Bias to reference [kcal/mol]') # Set the 0 of the twin axis to the YANK reference free energy. align_yaxis(ax, ref_free_energy, ax2, 0.0) def plot_all_entries_trajectory(submissions, yank_analysis, zoomed=False): """Plot free energy trajectories, std, and bias of the challenge entries.""" sns.set_style('whitegrid') sns.set_context('paper') # Create a figure with 3 columns (one for each system) and 2 rows. # The first row contains the free energy trajectory and CI, the second # a plot of the estimator variance, and the third the bias to the # asymptotic value. if zoomed: figsize = (7.25, 7.0) # Without REVO else: figsize = (7.25, 7.0) # With REVO fig, axes = plt.subplots(nrows=3, ncols=3, figsize=figsize) # Optionally, remove REVO. if zoomed: submissions = [s for s in submissions if s.name not in ['WExploreRateRatio']] if zoomed: # Y-axis limits when REVO calculations are excluded. y_limits = [ [(-15, -10), (-9, -4), (-9, -4)], [(0, 2), (0, 0.8), (0, 0.8)], [(-3, 1), (-0.6, 0.6), (-0.6, 0.6)], ] else: # Y-axis limits when REVO calculations are included. y_limits = [ [(-17, -9), (-13, -5), (-13, -5)], [(0, 2), (0, 1.75), (0, 1.75)], [(-4, 4), (-0.6, 0.6), (-0.6, 0.6)], ] plot_submissions_trajectory(submissions, yank_analysis, axes, y_limits=y_limits) # Show/save figure. if zoomed: plt.tight_layout(h_pad=0.2, rect=[0.0, 0.00, 1.0, 0.92], w_pad=0.0) # Without REVO else: plt.tight_layout(h_pad=0.2, rect=[0.0, 0.00, 1.0, 0.92]) # With REVO # Plot legend. if zoomed: # bbox_to_anchor = (2.52, 1.55) # Without REVO. bbox_to_anchor = (2.4, 1.48) else: bbox_to_anchor = (2.4, 1.48) # With REVO. axes[0][1].legend(loc='upper right', bbox_to_anchor=bbox_to_anchor, fancybox=True, ncol=4) plt.subplots_adjust(wspace=0.35) # plt.show() if zoomed: file_name = 'Figure3-free_energy_trajectories_zoomed' else: file_name = 'Figure3-free_energy_trajectories' figure_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'Figure3-free_energy_trajectories') os.makedirs(figure_dir_path, exist_ok=True) output_base_path = os.path.join(figure_dir_path, file_name) plt.savefig(output_base_path + '.pdf') # plt.savefig(output_base_path + '.png', dpi=500) # ============================================================================= # FIGURE 4 - NONEQUILIBRIUM SWITCHING ESTIMATOR COMPARISON # ============================================================================= def plot_all_nonequilibrium_switching(submissions): """Plot free energy trajectories, std, and bias of the nonequilibrium-switching calculations.""" # Create a figure with 3 columns (one for each system) and 2 rows. # The first row contains the free energy trajectory and CI, the second # a plot of the estimator variance, and the third the bias to the # asymptotic value. figsize = (7.25, 3.5) fig, axes = plt.subplots(nrows=1, ncols=3, figsize=figsize) # Select nonequilibrium-switching calculations with estimators. submissions = [s for s in submissions if 'NS' in s.paper_name] # Y-axis limits. y_limits = [ [(-20, 5), (-40, 0), (-40, 0)] ] plot_submissions_trajectory(submissions, yank_analysis=None, axes=axes, y_limits=y_limits, plot_std=False, plot_bias=False) # Show/save figure. plt.tight_layout(pad=0.0, rect=[0.0, 0.00, 1.0, 0.85]) # Plot legend. legend = axes[0].legend(loc='upper left', bbox_to_anchor=(0.6, 1.3), fancybox=True, ncol=3) # Change legend labels to refer to estimator used rather than overall method ID. legend_labels_map = { 'GROMACS/NS-DS/SB-long': 'BAR-long', 'GROMACS/NS-DS/SB': 'BAR', 'GROMACS/NS-Jarz-F': 'Jarzynski-Forward', 'GROMACS/NS-Jarz-R': 'Jarzynski-Reverse', 'GROMACS/NS-Gauss-F': 'Gaussian-Forward', 'GROMACS/NS-Gauss-R': 'Gaussian-Reverse', } for text in legend.get_texts(): text.set_text(legend_labels_map[text.get_text()]) plt.subplots_adjust(wspace=0.35) # plt.show() figure_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'Figure4-nonequilibrium_comparison') os.makedirs(figure_dir_path, exist_ok=True) output_base_path = os.path.join(figure_dir_path, 'Figure4-nonequilibrium_comparison') plt.savefig(output_base_path + '.pdf') # plt.savefig(output_base_path + '.png', dpi=500) # ============================================================================= # FIGURE 5 - BAROSTAT AND RESTRAINT # ============================================================================= # Directories containing the volume information of YANK and GROMACS/EE. BAROSTAT_DATA_DIR_PATH = os.path.join('..', 'SAMPLing', 'Data', 'BarostatData') YANK_VOLUMES_DIR_PATH = os.path.join(BAROSTAT_DATA_DIR_PATH, 'YankVolumes') EE_VOLUMES_DIR_PATH = os.path.join(BAROSTAT_DATA_DIR_PATH, 'EEVolumes') def plot_volume_distributions(axes, plot_predicted=False): """Plot the volume distributions obtained with Monte Carlo and Berendsen barostat.""" import scipy.stats import scipy.integrate from simtk import unit # Load data. mc_volumes = collections.OrderedDict([ (1, np.load(os.path.join(YANK_VOLUMES_DIR_PATH, 'volumes_pressure100.npy'))), (100, np.load(os.path.join(YANK_VOLUMES_DIR_PATH, 'volumes_pressure10000.npy'))), ]) mc_volumes_hrex = collections.OrderedDict([ (1, np.load(os.path.join(YANK_VOLUMES_DIR_PATH, 'hrex_state_volumes_state0.npy'))), (58, np.load(os.path.join(YANK_VOLUMES_DIR_PATH, 'hrex_state_volumes_state58.npy'))), ]) b_volumes = collections.OrderedDict([ (1, np.load(os.path.join(EE_VOLUMES_DIR_PATH, '1atm_vanilla.npy'))), (100, np.load(os.path.join(EE_VOLUMES_DIR_PATH, '100atm_vanilla.npy'))), ]) b_volumes_ee = collections.OrderedDict([ (1, np.load(os.path.join(EE_VOLUMES_DIR_PATH, '1atm_expanded.npy'))), (100, np.load(os.path.join(EE_VOLUMES_DIR_PATH, '100atm_expanded.npy'))), ]) # Print some statistics for each distribution. for volume_trajectories, label in [(mc_volumes, 'MC-MD '), (mc_volumes_hrex, 'MC-HREX'), (b_volumes, 'BB-MD '), (b_volumes_ee, 'BB-EE ')]: for pressure, trajectory in volume_trajectories.items(): n = len(trajectory) t_stat = 2.326 # 98% CI mean = np.mean(trajectory) sem = scipy.stats.sem(trajectory) mean_ci = t_stat * sem var = np.var(trajectory, ddof=1) # Standard error of variance if volume is gaussianly distributed sev = var * np.sqrt(2 / (n-1)) var_ci = t_stat * sev skew = scipy.stats.skew(trajectory) # Standard error of skewness if volume is gaussianly distributed ses = np.sqrt( 6*n*(n-1) / ((n-2)*(n+1)*(n+3)) ) skew_ci = t_stat * ses print('{}-{} (n={}): mean={:.3f} +- {:.3f}nm^3\t\tvar={:.3f} +- {:.3f}\tskew={:.3f} +- {:.3f}'.format( pressure, label, n, mean, mean_ci, var, var_ci, skew, skew_ci)) # Plot the 1atm vs 100atm comparison. barostats = ['B', 'MC'] for ax, volume_trajectories, barostat in zip(axes, [b_volumes, mc_volumes], barostats): barostat += ',MD' barostat = 'MD' for pressure, trajectory in volume_trajectories.items(): label = '$\\rho_{{\mathrm{{{}}}}}$(V|{}atm)'.format(barostat, pressure) ax = sns.distplot(trajectory, label=label, hist=False, ax=ax) if plot_predicted: # Plot predicted distribution. beta = 1.0 / (unit.BOLTZMANN_CONSTANT_kB * 298.15*unit.kelvin) p1 = 1.0 * unit.atmosphere p2 = 100.0 * unit.atmosphere volumes = np.linspace(78.0, 82.0, num=200) fit = scipy.stats.norm # Fit the original distribution. original_pressure, new_pressure = list(volume_trajectories.keys()) original_trajectory = list(volume_trajectories.values())[0] fit_parameters = fit.fit(original_trajectory) # Find normalizing constant predicted distribution. predicted_distribution = lambda v: np.exp(-beta*(p2 - p1)*v*unit.nanometer**3) * fit.pdf([v], *fit_parameters) normalizing_factor = scipy.integrate.quad(predicted_distribution, volumes[0], volumes[-1])[0] predicted = np.array([predicted_distribution(v) / normalizing_factor for v in volumes]) # Set the scale. label = '$\\rho_{{\mathrm{{{}}}}}$(V|{}atm)$\cdot e^{{\\beta ({}atm - {}atm) V}}$'.format(barostat, original_pressure, new_pressure, original_pressure) ax.plot(volumes, predicted, ls='--', label=label) # ax.plot(volumes, [fit.pdf([v], *fit_parameters) for v in volumes], label='original') # Plot comparison MD vs expanded ensemble and HREX volumes. for ax_idx, (trajectory, label) in enumerate([ (b_volumes_ee[1], 'B,EE'), (mc_volumes_hrex[1], 'MC,HREX') ]): label = 'E' ax = axes[ax_idx] label = '$\\rho_{{\mathrm{{{}}}}}$(V|1atm)'.format(label) sns.distplot(trajectory, label=label, hist=False, ax=ax) # Set titles and configure axes. axes[0].set_title('Berendsen barostat volume distribution', pad=2.0) axes[1].set_title('Monte Carlo barostat volume distribution', pad=2.0) for ax_idx in range(len(axes)): axes[ax_idx].set_xlim((78.8, 81.2)) axes[ax_idx].set_ylim((0.0, 6.0)) axes[ax_idx].set_ylabel('density') axes[0].set_xlabel('', labelpad=0.3) axes[1].set_xlabel('Volume [nm^3]', labelpad=0.3) # Create single legend for both MC and B barostat axes. bbox_to_anchor = (-0.1, -0.15) axes[0].legend(fontsize='xx-small', loc='upper left', bbox_to_anchor=bbox_to_anchor, ncol=4, fancybox=True, labelspacing=0.7, handletextpad=0.4, columnspacing=1.1,) # axes[0].get_legend().remove() axes[1].get_legend().remove() plt.tight_layout(pad=0, rect=[0.0, 0.0, 1.0, 1.0]) # Directory with the restraint information. RESTRAINT_DATA_DIR_PATH = os.path.join('YankAnalysis', 'RestraintAnalysis') # The state index of the discharged state with LJ interactions intact. DISCHARGED_STATE = { 'CB8-G3': 25, 'OA-G3': 32, 'OA-G6': 29 } # The final free energy predictions without restraint unbiasing. BIASED_FREE_ENERGIES = { 'CB8-G3-0': -10.643, 'CB8-G3-1': -10.533, 'CB8-G3-2': -10.463, 'CB8-G3-3': None, # TODO: Run the biased analysis 'CB8-G3-4': -10.324, 'OA-G3-0': -5.476, 'OA-G3-1': -5.588, 'OA-G3-2': -5.486, 'OA-G3-3': -5.510, 'OA-G3-4': -5.497, 'OA-G6-0': -5.669, 'OA-G6-1': -5.665, 'OA-G6-2': -5.767, 'OA-G6-3': -5.737, 'OA-G6-4': -5.788, } def plot_restraint_distance_distribution(system_id, ax, kde=True, iteration_set=None): """Plot the distribution of restraint distances at bound, discharged, and decoupled states. Return the 99.99-percentile restraint radius that was used as a cutoff during analysis. """ n_iterations = YANK_N_ITERATIONS + 1 # Count also iteration 0. system_name = system_id[:-2] discharged_state_idx = DISCHARGED_STATE[system_name] # Load all distances cached during the analysis. cache_dir_path = os.path.join('pkganalysis', 'cache', system_id.replace('-', '')) cached_distances_file_path = os.path.join(cache_dir_path, 'restraint_distances_cache.npz') distances_kn = np.load(cached_distances_file_path)['arr_0'] # Distances are in nm but we plot in Angstrom. distances_kn *= 10 n_states = int(len(distances_kn) / n_iterations) # Use the same colors that are used in the water analysis figures. color_palette = sns.color_palette('viridis', n_colors=n_states) color_palette = [color_palette[i] for i in (0, discharged_state_idx, -1)] # Isolate distances in the bound, discharged (only LJ), and decoupled state. distances_kn_bound = distances_kn[:n_iterations] distances_kn_discharged = distances_kn[(discharged_state_idx-1)*n_iterations:discharged_state_idx*n_iterations] distances_kn_decoupled = distances_kn[(n_states-1)*n_iterations:] # Filter iterations. if iteration_set is not None: distances_kn_bound = distances_kn_bound[iteration_set] distances_kn_discharged = distances_kn_discharged[iteration_set] distances_kn_decoupled = distances_kn_decoupled[iteration_set] assert len(distances_kn_bound) == len(distances_kn_decoupled) # Plot the distributions. # sns.distplot(distances_kn, ax=ax, kde=True, label='all states') sns.distplot(distances_kn_bound, ax=ax, kde=kde, label='bound', color=color_palette[0]) sns.distplot(distances_kn_discharged, ax=ax, kde=kde, label='discharged', color=color_palette[1]) sns.distplot(distances_kn_decoupled, ax=ax, kde=kde, label='decoupled', color=color_palette[2]) # Plot the threshold used for analysis, computed as the # 99.99-percentile of all distances in the bound state. distance_cutoff = np.percentile(a=distances_kn_bound, q=99.99) limits = ax.get_ylim() ax.plot([distance_cutoff for _ in range(100)], np.linspace(limits[0], limits[1]/2, num=100), color='black') return distance_cutoff def plot_restraint_profile(system_id, ax, restraint_cutoff): """Plot the free energy as a function of the restraint cutoff.""" # Load the free energy profile for this system. restraint_profile_file_path = os.path.join(RESTRAINT_DATA_DIR_PATH, system_id.replace('-', '') + '.json') with open(restraint_profile_file_path, 'r') as f: free_energies_profile = json.load(f) # Reorder the free energies by increasing cutoff and convert str keys to floats. free_energies_profile = [(float(d), f) for d, f in free_energies_profile.items()] free_energies_profile = sorted(free_energies_profile, key=lambda x: x[0]) distance_cutoffs, free_energies = list(zip(*free_energies_profile)) f, df = list(zip(*free_energies)) # Convert string to floats. distance_cutoffs = [float(c) for c in distance_cutoffs] # Plot profile. ax.errorbar(x=distance_cutoffs, y=f, yerr=df, label='after reweighting') # Plot biased free energy biased_f = BIASED_FREE_ENERGIES[system_id] x = np.linspace(*ax.get_xlim()) ax.plot(x, [biased_f for _ in x], label='before reweighting') # Plot restraint distance cutoff. limits = ax.get_ylim() x = [restraint_cutoff for _ in range(100)] y = np.linspace(limits[0], limits[1], num=100) ax.plot(x, y, color='black') def plot_restraint_analysis(system_id, axes): """Plot distribution of restraint distances and free energy profile on two axes.""" # Histograms of restraint distances/energies. ax = axes[0] kde = True restraint_cutoff = plot_restraint_distance_distribution(system_id, ax, kde=kde) # Set restraint distance distribution lables and titles. ax.set_title('Restrained ligand-receptor distance', pad=2.0) if kde is False: ax.set_ylabel('Number of samples') else: ax.set_ylabel('density') ax.legend(loc='upper right', fontsize='x-small') ax.set_xlabel('Restrained distance [$\mathrm{\AA}$]', labelpad=0.3) # Free energy as a function of restraint distance. ax = axes[1] ax.set_title('$\Delta G$ as a function of restraint radius cutoff', pad=2.0 ) plot_restraint_profile(system_id, ax, restraint_cutoff) # Labels and legend. ax.set_xlabel('Restraint radius cutoff [$\mathrm{\AA}$]', labelpad=0.3) ax.set_ylabel('$\Delta G$ [kcal/mol]') ax.legend(fontsize='x-small') def plot_restraint_and_barostat_analysis(): """Plot the Figure showing info for the restraint and barostat analysis.""" import seaborn as sns from matplotlib import pyplot as plt sns.set_style('whitegrid') sns.set_context('paper', font_scale=1.0) # Create two columns, each of them share the x-axis. fig = plt.figure(figsize=(7.25, 4)) # Restraint distribution axes. ax1 = fig.add_subplot(221) ax2 = fig.add_subplot(223, sharex=ax1) barostat_axes = [ax1, ax2] # Volume distribution axes. ax3 = fig.add_subplot(222) ax4 = fig.add_subplot(224, sharex=ax3) restraint_axes = [ax3, ax4] # Plot barostat analysis. plot_volume_distributions(barostat_axes, plot_predicted=True) # Plot restraint analysis. system_id = 'OA-G3-0' plot_restraint_analysis(system_id, restraint_axes) # Configure axes. restraint_axes[0].set_xlim((0, 10.045)) restraint_axes[1].set_ylim((-7, -3.9)) for ax in restraint_axes + barostat_axes: ax.tick_params(axis='x', which='major', pad=0.1) ax.tick_params(axis='y', which='major', pad=0.1) plt.tight_layout(pad=0.3) # plt.show() output_file_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'Figure5-restraint_barostat', 'restraint_barostat.pdf') os.makedirs(os.path.dirname(output_file_path), exist_ok=True) plt.savefig(output_file_path) # ============================================================================= # FIGURE 6 - HREX INITIAL BIAS # ============================================================================= def plot_yank_system_bias(system_name, data_dir_paths, axes, shift_to_origin=True, plot_std=True): """Plot the YANK free energy trajectoies when discarding initial samples for a single system.""" color_palette = sns.color_palette('viridis', n_colors=len(data_dir_paths)+1) # Plot trajectories with truncated data. all_iterations = set() for data_idx, data_dir_path in enumerate(data_dir_paths): yank_analysis = YankSamplingAnalysis(data_dir_path) # In the YankAnalysis folder, each analysis starting from # iteration N is in the folder "iterN/". last_dir_name = os.path.basename(os.path.normpath(data_dir_path)) label = last_dir_name[4:] # First color is for the full data. color = color_palette[data_idx+1] # Collect all iterations that we'll plot for the full data. mean_data = yank_analysis.get_system_free_energies(system_name, mean_trajectory=True) all_iterations.update(mean_data['HREX iteration'].values.tolist()) # Simulate plotting starting from the origin. if shift_to_origin: mean_data['HREX iteration'] -= mean_data['HREX iteration'].values[0] plot_mean_data(mean_data, axes, x='HREX iteration', color=color, label=label, plot_std=plot_std, plot_bias=False, plot_ci=False) # Plot trajectory with full data. color = color_palette[0] # Plot an early iteration and all the iterations analyzed for the bias. yank_analysis = YankSamplingAnalysis(YANK_ANALYSIS_DIR_PATH) system_ids = [system_name + '-' + str(i) for i in range(5)] first_iteration = yank_analysis.get_system_iterations(system_ids[0])[2] iterations = [first_iteration] + sorted(all_iterations) mean_data = yank_analysis._get_free_energies_from_iterations( iterations, system_ids, mean_trajectory=True) # Simulate plotting starting from the origin. if shift_to_origin: mean_data['HREX iteration'] -= mean_data['HREX iteration'].values[0] # Simulate ploatting starting from the origin. plot_mean_data(mean_data, axes, x='HREX iteration', color=color, label='0', plot_std=plot_std, plot_bias=False, plot_ci=False) axes[0].set_title(system_name) def plot_yank_bias(plot_std=True, figure_dir_path=None): """Plot YANK free energy trajectories when discarding initial samples.""" # In the first column, plot the "unshifted" trajectory of CB8-G3, # with all sub-trajectories shifted to the origin. In the second # and third columns, plot the trajectories of CB8-G3 and OA-G3 # with all sub-trajectories shifted to the origin. what_to_plot = [ ('CB8-G3', False), # ('CB8-G3', True), ('OA-G3', False), # ('OA-G3', False), ('OA-G6', False), ] if plot_std: n_rows = 2 else: n_rows = 1 n_cols = len(what_to_plot) fig, axes = plt.subplots(nrows=n_rows, ncols=n_cols, figsize=(7.25, 4.0)) # The loops are based on a two dimensional array of axes. if n_rows == 1: axes = np.array([axes]) # Sort paths by how many samples they have. data_dir_paths = ['YankAnalysis/BiasAnalysis/iter{}/'.format(i) for i in [1000, 2000, 4000, 8000, 16000, 24000]] for column_idx, (system_name, shift_to_origin) in enumerate(what_to_plot): plot_yank_system_bias(system_name, data_dir_paths, axes[:,column_idx], shift_to_origin=shift_to_origin, plot_std=plot_std) title = system_name + ' (shifted)' if shift_to_origin else system_name axes[0,column_idx].set_title(title) # Fix axes limits and labels. ylimits = { 'CB8-G3': (-12.5, -10.5), 'OA-G3': (-8, -6), 'OA-G6': (-8, -6) } for column_idx, (system_name, _) in enumerate(what_to_plot): axes[0][column_idx].set_ylim(ylimits[system_name]) if plot_std: axes[1][column_idx].set_ylim((0, 0.6)) for row_idx, ax_idx in itertools.product(range(n_rows), range(n_cols)): # Control the number of ticks for the x axis. axes[row_idx][ax_idx].locator_params(axis='x', nbins=4) # Set x limits for number of iterations. axes[row_idx][ax_idx].set_xlim((0, YANK_N_ITERATIONS)) # Remove ticks labels that are shared with the last row. for row_idx, ax_idx in itertools.product(range(n_rows-1), range(n_cols)): axes[row_idx][ax_idx].set_xticklabels([]) # Set axes labels. axes[0][0].set_ylabel('$\Delta$G [kcal/mol]') if plot_std: axes[1][0].set_ylabel('std($\Delta$G) [kcal/mol]') # If there is an odd number of columns print x label only on the central one. if n_cols % 2 == 1: axes[-1][1].set_xlabel('HREX iteration') else: for ax in axes[-1]: ax.set_xlabel('HREX iteration') plt.tight_layout(h_pad=0.1, rect=[0.0, 0.00, 1.0, 0.91]) handles, labels = axes[0][0].get_legend_handles_labels() handles = [handles[-1]] + handles[:-1] labels = [labels[-1]] + labels[:-1] bbox_to_anchor = (0.4, 1.53) axes[0][0].legend(handles, labels, loc='upper left', bbox_to_anchor=bbox_to_anchor, title='number of discarded initial iterations', ncol=len(data_dir_paths)+1, fancybox=True, labelspacing=0.8, handletextpad=0.5, columnspacing=1.2, fontsize='small') # plt.show() if figure_dir_path is None: figure_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'Figure6-bias_hrex') os.makedirs(figure_dir_path, exist_ok=True) output_file_path = os.path.join(figure_dir_path, 'Figure6-bias_hrex') plt.savefig(output_file_path + '.pdf') # plt.savefig(output_file_path + '.png', dpi=600) # ============================================================================= # SUPPORTING INFORMATION - EXAMPLE OF HREX BIAS # ============================================================================= def simulate_correlation_samples(): """Simulation of bias from same initial configuration. There are 3 states as different harmonic oscillators, but all or almost all the samples come from the first (bound) state to simulate what happens when they don't decorrelate fast enough. The hypothesis is that most is that starting from the bound state causes the initial free energy to be artificially negative if the correlation times are long. The second (discharged) state is just a shifted harmonic oscillator (same free energy as bound state). The third (unbound) is shifted and has much higher entropy. """ from numpy.random import normal from pymbar import MBAR def harmonic_oscillator_free_energy(sigma): """Analytical expression for the free energy of a harmonic oscillator.""" #return - np.log(2 * np.pi * sigma**2) * 3.0 / 2.0 # 3D oscillator return - np.log(np.sqrt(2 * np.pi) * sigma) def harmonic_oscillator_potential(x, loc, std): """Compute potential of the given positions given location and standard deviation of the Gaussian distribution. Potentials are returned in units of kT. """ spring_constant = 1 / std**2 return spring_constant / 2.0 * (x - loc)**2 def print_free_energies(Deltaf_ij, dDeltaf_ij): mbar_str = ', '.join(['{:.4f} +- {:.4f}'.format(f, df) for f, df in zip(Deltaf_ij[:,0], dDeltaf_ij[:,0])]) print('MBAR :', mbar_str) analytical_str = ', '.join(['{:.4f} '.format(f) for f in analytical_Deltaf]) print('Analytical:', analytical_str) def compute_mbar_free_energy(all_samples, shifts, stds, analytical_f): n_states = len(all_samples) # u_kn[k,n] is the reduced potential energy n-th sample evaluated at state k. u_kn = np.empty(shape=(n_states, n_states*n_samples)) # Convert samples to potentials. for k in range(n_states): for sampled_k, samples in enumerate(all_samples): start = sampled_k * n_samples end = (sampled_k + 1) * n_samples u_kn[k,start:end] = harmonic_oscillator_potential(samples, loc=shifts[k], std=stds[k]) # Compute MBAR free energy. N_k = np.array([n_samples] * n_states) mbar = MBAR(u_kn, N_k=N_k, initial_f_k=analytical_f) Deltaf_ij, dDeltaf_ij, _ = mbar.getFreeEnergyDifferences() return Deltaf_ij, dDeltaf_ij # Determine standard deviation and shift of the harmonic distributions. n_samples = 5000000 stds = np.array([2.0, 2.0, 5.0]) shifts = np.array([0.0, 2.0, 2.0]) print('\nspring constants:', 1 / stds**2) # Compute analytical free energy. analytical_f = np.array([harmonic_oscillator_free_energy(s) for s in stds]) analytical_Deltaf = np.array([analytical_f[0] - analytical_f[i] for i in range(len(stds))]) # FIRST TEST. # Sample from all states and verify that MBAR free energy is correct. # ------------------------------------------------------------------- all_samples = [normal(loc=l, scale=s, size=n_samples) for l, s in zip(shifts, stds)] Deltaf_ij, dDeltaf_ij = compute_mbar_free_energy(all_samples, shifts, stds, analytical_f) print() print_free_energies(Deltaf_ij, dDeltaf_ij) # SECOND TEST. # Check if the bias is not due to lack of overlap. If we sample only the end states the estimate should be correct. # ----------------------------------------------------------------------------------------------------------------- for i in range(1, len(all_samples)): all_samples_bar = [all_samples[0], all_samples[i]] shifts_bar = [shifts[0], shifts[i]] stds_bar = [stds[0], stds[i]] analytical_f_bar = [analytical_f[0], analytical_f[i]] Deltaf_ij, dDeltaf_ij = compute_mbar_free_energy(all_samples_bar, shifts_bar, stds_bar, analytical_f_bar) print('\nBAR_{}0'.format(i)) print_free_energies(Deltaf_ij, dDeltaf_ij) # THIRD TEST. # Now sample from only the bound state to see how the free energy changes. # ------------------------------------------------------------------------ all_samples[1:] = [normal(loc=shifts[0], scale=stds[0], size=n_samples) for _ in range(len(stds)-1)] Deltaf_ij, dDeltaf_ij = compute_mbar_free_energy(all_samples, shifts, stds, analytical_f) print() print_free_energies(Deltaf_ij, dDeltaf_ij) # FOURTH TEST. # Now let the unbound state decorrelate fast (i.e. sample from its own distribution). # ----------------------------------------------------------------------------------- all_samples[-1] = normal(loc=shifts[-1], scale=stds[-1], size=n_samples) Deltaf_ij, dDeltaf_ij = compute_mbar_free_energy(all_samples, shifts, stds, analytical_f) print() print_free_energies(Deltaf_ij, dDeltaf_ij) # RESULT: SUCCESS!!! # ============================================================================= # SUPPORTING INFORMATION - COMPLEX/SOLVENT and ENTROPY/ENTHALPY DECOMPOSITION # ============================================================================= def _mean_data_decomposition(data): # Convert into a numpy array to take the mean. # Convert None (not supported by numpy) into nans. try: # This may fail if we have computed different iterations for each. data = np.array(data, dtype=np.float) except ValueError: data_lengths = [len(x) for x in data] print('Warning: Truncating data of shape {}'.format(data_lengths)) min_length = min(data_lengths) data = [x[:min_length] for x in data] data = np.array(data, dtype=np.float) # Compute std and mean along the trajectory ignoring NaNs. return np.nanmean(data, axis=0), np.nanstd(data, axis=0) def _plot_phase_decomposition(ax, phase_free_energies): # Shortcuts. data = phase_free_energies label = '$\Delta$G' # Plot each phase data on a separate axis to make the comparison on different order of magnitudes easier. # Receipt with three axes: https://matplotlib.org/3.1.0/gallery/ticks_and_spines/multiple_yaxis_with_spines.html phase_axes = { 'complex': ax.twinx(), 'solvent': ax.twinx() } phase_colors = { 'complex': 'C1', 'solvent': 'C0', } for ax_name in sorted(phase_axes): phase_axes[ax_name].set_ylabel(label + ' ' + ax_name + ' [kcal/mol]', color=phase_colors[ax_name]) phase_axes[ax_name].spines["right"].set_position(("axes", 1.2)) # Compute total free energy summing complex and solvent for all replicates. total_mean = [np.array(data['solvent'][i]) + np.array(data['complex'][i]) for i in range(5)] total_mean, total_std = _mean_data_decomposition(total_mean) # Compute and plot the phase free energy. for phase_name in ['complex', 'solvent']: color = phase_colors[phase_name] # Convert into a numpy array to take the mean. # Convert None (not supported by numpy) into nans. data[phase_name], std = _mean_data_decomposition(data[phase_name]) # Plot each phase data on a separate axis to make the comparison easier. phase_axes[phase_name].plot(data[phase_name], ls='-', color=color, label=label + ' ' + phase_name) # Plot uncertainties. phase_axes[phase_name].fill_between(x=list(range(len(std))), y1=data[phase_name]-std, y2=data[phase_name]+std, color=color, alpha=0.7) # Plot total free energy. # total = data['solvent'] + data['complex'] # ax.plot(total, color='black', label=label+' total') ax.plot(total_mean, color='black', label=label+' total') ax.fill_between(x=list(range(len(total_std))), y1=total_mean-total_std, y2=total_mean+total_std, color='black', alpha=0.7) ax.set_ylabel(label + ' total [kcal/mol]') ax.set_xlabel('simulation percentage') # Make the range of all y axes the same. ax.set_ylim((-21, -18)) phase_axes['complex'].set_ylim((-151.0, -148.0)) phase_axes['solvent'].set_ylim((129.0, 132.0)) def _plot_entropy_enthalpy_decomposition(ax, phase_free_energies, phase_enthalpy): # Analyze only the complex. phase_name = 'complex' # Plot each phase data on a separate axis to make the comparison on different order of magnitudes easier. # Receipt with three axes: https://matplotlib.org/3.1.0/gallery/ticks_and_spines/multiple_yaxis_with_spines.html axes = { '$\Delta$G': ax, '$\Delta$H': ax.twinx(), '-T$\Delta$S': ax.twinx(), } colors = { '$\Delta$G': 'black', '$\Delta$H': 'C1', '-T$\Delta$S': 'C0', } for ax_name in sorted(axes): axes[ax_name].set_ylabel(ax_name + ' ' + phase_name + ' [kcal/mol]', color=colors[ax_name]) axes[ax_name].spines["right"].set_position(("axes", 1.2)) # Variable used to propagate entropy decomposition. entropy_std = [] # Plot the total average free energy and enthalpy and for each phase. for data, label in [(phase_free_energies, '$\Delta$G'), (phase_enthalpy, '$\Delta$H')]: color = colors[label] # Convert into a numpy array to take the mean. # Convert None (not supported by numpy) into nans. data[phase_name], std = _mean_data_decomposition(data[phase_name]) ns_replica = np.arange(0.0, 40.0, 40/len(std)) # Plot each phase data on a separate axis to make the comparison easier. axes[label].plot(ns_replica, data[phase_name], ls='-', color=color, label=label+' '+phase_name) # Plot uncertainties. axes[label].fill_between(x=ns_replica, y1=data[phase_name]-std, y2=data[phase_name]+std, color=color, alpha=0.7) # Propagate uncertainty. if len(entropy_std) == 0: entropy_std = std**2 else: entropy_std += std**2 entropy_std = np.sqrt(entropy_std) # Plot also entropies. label = '-T$\Delta$S' color = colors[label] entropy = phase_free_energies[phase_name] - phase_enthalpy[phase_name] axes[label].plot(ns_replica, entropy, ls='-', color=color, label=label+' '+phase_name) # Plot uncertainties. axes[label].fill_between(x=ns_replica, y1=entropy-entropy_std, y2=entropy+entropy_std, color=color, alpha=0.7) ax.set_xlabel('ns/replica') def plot_decomposition(system_name, starting_iteration, type, output_file_path): """ Decomposition of the free energy trajectory in complex/solvent phase or entropy/enthalpy. Parameters ---------- type : str Can be 'entropy-enthalpy' or 'phase'. """ data_file_pattern = 'YankAnalysis/BiasAnalysis/iter{}/fe-decomposition-{}-{{}}.json'.format( starting_iteration, system_name) n_replicates = 5 phase_free_energies = {'complex': [[] for _ in range(n_replicates)], 'solvent': [[] for _ in range(n_replicates)]} phase_enthalpy = copy.deepcopy(phase_free_energies) for replicate_idx in range(n_replicates): # Read decomposition data. decomposition_data_file_path = data_file_pattern.format(replicate_idx) with open(decomposition_data_file_path, 'r') as f: decomposition_data = json.load(f) # Read free energy and enthalpy at each iteration. sorted_decomposition_data = sorted(decomposition_data, key=lambda x: int(x.split('-')[1])) for phase_iter in sorted_decomposition_data: decomposition = decomposition_data[phase_iter] phase_name, iteration = phase_iter.split('-') # Correct sign consistent with thermodynamic cycle. if phase_name == 'complex': sign = -1 else: sign = 1 corrected_free_energy = sign * (decomposition['DeltaF'] + decomposition['DeltaF_standard_state_correction']) phase_free_energies[phase_name][replicate_idx].append(corrected_free_energy) # Multiplication works only if enthalpy is not None. if decomposition['DeltaH'] is not None: decomposition['DeltaH'] *= sign phase_enthalpy[phase_name][replicate_idx].append(decomposition['DeltaH']) # Create figure. fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(7.25, 4.6)) if type == 'entropy-enthalpy': _plot_entropy_enthalpy_decomposition(ax, phase_free_energies, phase_enthalpy) else: _plot_phase_decomposition(ax, phase_free_energies) # # Plot total free energy. # total = data['solvent'] + data['complex'] # ax.plot(total, color=color, label=label) # totals.append(total) # Plot also entropies. # ax.plot(totals[0] - totals[1], color='blue', label='-T$\Delta$S') # ax.set_ylim((-20, -18)) # phase_axes['complex'].set_ylim((-153, -148)) # phase_axes['solvent'].set_ylim((128, 133)) # ax.set_ylim((-23, -18)) # phase_axes['complex'].set_ylim((30, 45)) # phase_axes['solvent'].set_ylim((-55, -40)) # ax.legend() plt.tight_layout() if output_file_path is not None: os.makedirs(os.path.dirname(output_file_path), exist_ok=True) plt.savefig(output_file_path) else: plt.show() # ============================================================================= # RELATIVE EFFICIENCY ANALYSIS # ============================================================================= def get_relative_efficiency_input(submission, yank_analysis, system_name): """Prepare the data to compute the mean relative efficiencies for this system.""" # For GROMACS/EE-fullquil we need to account for the extra equilibration # cost and shift all energy evaluation to the right. if submission.paper_name == 'GROMACS/EE-fullequil': mean_free_energies = submission.mean_free_energies() mean_data = mean_free_energies[mean_free_energies['System name'] == system_name] first_shifted = mean_data['N energy evaluations'].values[0] last_shifted = mean_data['N energy evaluations'].values[-1] calibration_cost = first_shifted*100/99 - last_shifted/99 else: calibration_cost = 0 # Isolate the data for the system. data_sub = submission.data[submission.data['System name'] == system_name] n_energy_evaluations = max(data_sub['N energy evaluations']) data_ref = yank_analysis.get_free_energies_from_energy_evaluations( n_energy_evaluations, system_name=system_name, mean_trajectory=False, start=calibration_cost) # Obtain the free energies for the submission. n_replicates = 5 free_energy_sub = np.empty(shape=(n_replicates, 100)) free_energy_ref = np.empty(shape=(n_replicates, 100)) for data, free_energy in [ (data_sub, free_energy_sub), (data_ref, free_energy_ref), ]: for i in range(n_replicates): system_id = system_name + '-' + str(i) system_id_data = data[data['System ID'] == system_id] free_energy[i] = system_id_data[DG_KEY].values # Discard the initial frames of REVO and GROMACS/EE that don't have predictions. from pkganalysis.efficiency import discard_initial_zeros free_energy_ref, free_energy_sub = discard_initial_zeros(free_energy_ref, free_energy_sub) # Determine the actual asymptotic free energy of YANK. asymptotic_free_energy_ref = yank_analysis.get_reference_free_energies()[system_name] return free_energy_ref, free_energy_sub, asymptotic_free_energy_ref def compute_all_relative_efficiencies( free_energy_A, free_energy_B, ci, n_bootstrap_samples, asymptotic_free_energy_A=None, asymptotic_free_energy_B=None ): from pkganalysis.efficiency import EfficiencyAnalysis analysis = EfficiencyAnalysis(free_energy_A, free_energy_B, asymptotic_free_energy_A, asymptotic_free_energy_B) std_rel_eff = analysis.compute_std_relative_efficiency( confidence_interval=ci, n_bootstrap_samples=n_bootstrap_samples) abs_bias_rel_eff = analysis.compute_abs_bias_relative_efficiency( confidence_interval=ci, n_bootstrap_samples=n_bootstrap_samples) rmse_rel_eff = analysis.compute_rmse_relative_efficiency( confidence_interval=ci, n_bootstrap_samples=n_bootstrap_samples) if ci is None: rel_eff = [std_rel_eff, abs_bias_rel_eff, rmse_rel_eff] return rel_eff else: rel_eff = [std_rel_eff[0], abs_bias_rel_eff[0], rmse_rel_eff[0]] cis = [std_rel_eff[1], abs_bias_rel_eff[1], rmse_rel_eff[1]] return rel_eff, cis def plot_relative_efficiencies(submissions, yank_analysis, ci=0.95, n_bootstrap_samples=1000, same_plot=False, step_cumulative=2): sns.set_style('whitegrid') sns.set_context('paper') statistic_names = ['std', 'absolute bias', 'RMSE'] # Create output directory. figure_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'SI_Figure-efficiencies') os.makedirs(figure_dir_path, exist_ok=True) # Check if we need all the efficiencies in the same plot or not. if same_plot: fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(7.25, 8)) # Keep track of data range by statistic. statistic_ranges = {name: [np.inf, 0] for name in statistic_names} # Keep track of n_energy_evaluations by column. max_n_energy_evaluations = [0 for _ in range(3)] for submission in submissions: if submission.paper_name in {'OpenMM/REVO'}: continue # if submission.paper_name in {'AMBER/APR', 'GROMACS/NS-DS/SB', 'GROMACS/NS-DS/SB-long', # 'NAMD/BAR', 'GROMACS/EE', 'GROMACS/EE-fullequil', 'OpenMM/SOMD'}: # continue print(submission.paper_name) system_names = submission.data['System name'].unique() # Create figure. if not same_plot: # For GROMACS/EE, there are no submissions for CB8-G3. if 'GROMACS/EE' in submission.paper_name: system_names = system_names[~(system_names == 'CB8-G3')] fig, axes = plt.subplots(nrows=3, ncols=len(system_names), figsize=(7.25, 8)) statistic_ranges = {name: [np.inf, 0] for name in statistic_names} for col_idx, system_name in enumerate(system_names): color = SUBMISSION_COLORS[submission.paper_name] # For GROMACS/EE, there are no submissions for CB8-G3. if 'GROMACS/EE' in submission.paper_name and system_name == 'CB8-G3': continue # For GROMACS/NS-DS/SB-long there are no new submissions for OAs. if 'GROMACS/NS-DS/SB-long' in submission.paper_name and system_name != 'CB8-G3': # Just add the label. axes[0][col_idx].plot([], color=color, label=submission.paper_name) continue # Get input for EfficiencyAnalysis. free_energy_ref, free_energy_sub, asymptotic_free_energy_ref = get_relative_efficiency_input( submission, yank_analysis, system_name) # Get the relative efficiencies. rel_eff = compute_all_relative_efficiencies( free_energy_ref, free_energy_sub, ci, n_bootstrap_samples, asymptotic_free_energy_A=asymptotic_free_energy_ref ) if ci is not None: rel_eff, cis = rel_eff # Unpack confidence intervals. # Use the same asymptotic free energies to compute the absolute bias # relative efficiency as a function of the simulation length. asymptotic_free_energy_sub = free_energy_sub.mean(axis=0)[-1] # # Print relative efficiencies. # print(system_name, ci) # if ci is not None: # for rel_eff, bounds in zip(rel_eff, cis): # print('\t', rel_eff, bounds.tolist()) # else: # for rel_eff in rel_eff: # print('\t', rel_eff) # Compute mean efficiencies as a function of the length of the simulation. n_costs = free_energy_ref.shape[1] n_rel_eff = int(n_costs / step_cumulative) relative_efficiencies = np.empty(shape=(3, n_rel_eff)) low_bounds = np.empty(shape=(3, n_rel_eff)) high_bounds = np.empty(shape=(3, n_rel_eff)) for i, c in enumerate(range(step_cumulative-1, n_costs, step_cumulative)): c1 = c + 1 rel_eff = compute_all_relative_efficiencies( free_energy_ref[:,:c1], free_energy_sub[:,:c1], ci, n_bootstrap_samples, asymptotic_free_energy_A=asymptotic_free_energy_ref, asymptotic_free_energy_B=asymptotic_free_energy_sub ) if ci is not None: rel_eff, cis = rel_eff # Unpack confidence intervals. # Update CI lower and upper bound. relative_efficiencies[:,i] = rel_eff if ci is not None: low_bounds[:,i] = [x[0] for x in cis] high_bounds[:,i] = [x[1] for x in cis] # Get number of energy evaluations. mean_data = submission.mean_free_energies(system_name=system_name) # Check how many initial iteration have been discarded. discarded_iterations = 100 - n_costs n_energy_evaluations = mean_data['N energy evaluations'].values[ discarded_iterations+1::step_cumulative] / 1e6 for row_idx, rel_eff in enumerate(relative_efficiencies): ax = axes[row_idx][col_idx] ax.plot(n_energy_evaluations, rel_eff, color=color, label=submission.paper_name) # Plot back line at 0. ax.plot(n_energy_evaluations, [0 for _ in n_energy_evaluations], color='black', ls='--') # Update data range. statistic_range = statistic_ranges[statistic_names[row_idx]] # if ci is None: # min_rel_eff = min(rel_eff) # max_rel_eff = max(rel_eff) # else: # min_rel_eff = min(*rel_eff, *low_bounds[row_idx]) # max_rel_eff = max(*rel_eff, *high_bounds[row_idx]) statistic_range[0] = min(statistic_range[0], min(rel_eff)) statistic_range[1] = max(statistic_range[1], max(rel_eff)) # Update x-axis range. if same_plot: max_n_energy_evaluations[col_idx] = max(max_n_energy_evaluations[col_idx], n_energy_evaluations[-1]) else: for row_idx in range(len(statistic_names)): axes[row_idx][col_idx].set_xlim((0, n_energy_evaluations[-1])) if ci is not None: # Plot confidence intervals. for row_idx, (low_bound_c, high_bound_c) in enumerate(zip(low_bounds, high_bounds)): ax = axes[row_idx][col_idx] ax.fill_between(n_energy_evaluations, low_bound_c, high_bound_c, alpha=0.35, color='gray') # We do this multiple times unnecessarily if same_plot is True, but the code is simpler. for col_idx, system_name in enumerate(system_names): axes[0][col_idx].set_title(system_name) for row_idx, statistic_name in enumerate(statistic_names): axes[row_idx][0].set_ylabel(statistic_name + ' rel eff') for col_idx in range(len(system_names)): if same_plot: extra_space = 0.1 else: # Make space for confidence intervals. extra_space = 1 ylimits = (statistic_ranges[statistic_name][0] - extra_space, statistic_ranges[statistic_name][1] + extra_space) axes[row_idx][col_idx].set_ylim(ylimits) axes[row_idx][col_idx].tick_params(axis='y', which='major', pad=0.1) axes[-1][1].set_xlabel('Number of force/energy evaluations [10$^6$]') # Set labels and axes limits. if not same_plot: fig.suptitle(submission.paper_name) output_file_base_name = 'releff-{}-{}'.format(submission.file_name, submission.receipt_id) output_file_base_path = os.path.join(figure_dir_path, output_file_base_name) plt.savefig(output_file_base_path + '.pdf') # plt.savefig(output_file_base_path + '.png', dpi=600) # plt.show() if same_plot: for row_idx in range(len(statistic_names)): for col_idx in range(len(system_names)): axes[row_idx][col_idx].set_xlim((0, max_n_energy_evaluations[col_idx])) axes[0][1].legend(loc='upper right', bbox_to_anchor=(2.0, 1.48), fancybox=True, ncol=3) output_file_base_path = os.path.join(figure_dir_path, 'relative-efficiencies') plt.savefig(output_file_base_path + '.pdf') # plt.savefig(output_file_base_path + '.png', dpi=600) # plt.show() def plot_absolute_efficiencies(submissions, yank_analysis, ci=0.95, n_bootstrap_samples=1000): sns.set_style('whitegrid') sns.set_context('paper') # Keep track of data range by statistic. statistic_names = ['std', 'absolute bias', 'RMSE'] # Keep track of maximum number of energy evaluations # to determine plotting range for YANK. system_names = ['CB8-G3', 'OA-G3', 'OA-G6'] max_n_energy_eval = {name: 0 for name in system_names} # Create figure. fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(7.25, 8)) for submission in submissions + [yank_analysis]: if 'REVO' in submission.paper_name: continue print(submission.paper_name) # Obtain std, bias, and RMSE of the 5 trajectories. # If this is a YANK analysis, we get it later specifically for the system. if not isinstance(submission, YankSamplingAnalysis): mean_free_energies = submission.mean_free_energies() color = SUBMISSION_COLORS[submission.paper_name] for col_idx, system_name in enumerate(system_names): # GROMACS/EE doesn't have submissions for CB8-G3. if 'GROMACS/EE' in submission.paper_name and system_name == 'CB8-G3': continue # For GROMACS/NS-DS/SB-long there are no new submissions for OAs. if 'GROMACS/NS-DS/SB-long' in submission.paper_name and 'OA' in system_name: # Just add the label. axes[0][col_idx].plot([], color=color, label=submission.paper_name) continue # Select the submission data for only this host-guest system. if isinstance(submission, YankSamplingAnalysis): line_style = '--' mean_data = submission.get_free_energies_from_energy_evaluations( max_n_energy_eval[system_name], system_name=system_name, mean_trajectory=True) else: line_style = '-' mean_data = mean_free_energies[mean_free_energies['System name'] == system_name] # Update maximum number of energy evaluations. n_energy_evaluations = mean_data['N energy evaluations'].values max_n_energy_eval[system_name] = max(max_n_energy_eval[system_name], n_energy_evaluations[-1]) # Discard initial computational costs for which there's no data. first_nonzero_idx = np.nonzero(mean_data[DG_KEY])[0][0] n_energy_evaluations = n_energy_evaluations[first_nonzero_idx:] # Compute cumulative total std, abs_bias, and RMSE. scale_energy_evaluations = 1e6 norm_factor = (n_energy_evaluations - n_energy_evaluations[0])[1:] / scale_energy_evaluations avg_std = sp.integrate.cumtrapz(mean_data['std'].values[first_nonzero_idx:]) / norm_factor avg_abs_bias = sp.integrate.cumtrapz(np.abs(mean_data['bias'].values[first_nonzero_idx:])) / norm_factor avg_rmse = sp.integrate.cumtrapz(mean_data['RMSE'].values[first_nonzero_idx:]) / norm_factor # Plot total statistics as a function of the energy evaluations. # Discard first energy evaluation as cumtrapz doesn't return a result for it. for row_idx, avg_stats in enumerate([avg_std, avg_abs_bias, avg_rmse]): ax = axes[row_idx, col_idx] ax.plot(n_energy_evaluations[1:] / scale_energy_evaluations, avg_stats, color=color, label=submission.paper_name, ls=line_style) # Set x axis. ax.set_xlim((0, n_energy_evaluations[-1] / scale_energy_evaluations)) # Set labels and axes limits. y_limits = { 'std': (0, 0.4), 'absolute bias': (0, 0.3), 'RMSE': (0, 0.4) } for col_idx, system_name in enumerate(system_names): axes[0][col_idx].set_title(system_name) # Set y limits (shared for each row). for row_idx, statistic_name in enumerate(statistic_names): axes[row_idx][col_idx].set_ylim(y_limits[statistic_name]) axes[row_idx][col_idx].tick_params(axis='y', which='major', pad=0.1) # # Remove shared ticks. # for row_idx in range(len(statistic_names)): # for col_idx in range(len(system_names)): # if col_idx > 0: # axes[row_idx][col_idx].set_yticklabels([]) # if row_idx < len(statistic_names)-1: # axes[row_idx][col_idx].set_xticklabels([]) for row_idx, statistic_name in enumerate(statistic_names): axes[row_idx][0].set_ylabel('mean ' + statistic_name + ' [kcal/mol]') axes[-1][1].set_xlabel('N energy evaluations [M]') axes[0][1].legend(loc='upper right', bbox_to_anchor=(2.0, 1.48), fancybox=True, ncol=3) figure_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'SI_Figure-efficiencies') os.makedirs(figure_dir_path, exist_ok=True) output_file_base_path = os.path.join(figure_dir_path, 'absolute-efficiencies') plt.savefig(output_file_base_path + '.pdf') # plt.savefig(output_file_base_path + '.png', dpi=600) # plt.show() def print_relative_efficiency_table( submissions, yank_analysis, ci=0.95, n_bootstrap_samples=100, print_bias_corrected=False ): """Create a table with standard deviation, absolute bias, and RMSE relative efficiency.""" methods = [] # Initialize the table to be converted into a Pandas dataframe. system_names = ['CB8-G3', 'OA-G3', 'OA-G6'] statistic_names = [r'$e_{\mathrm{std}}$', r'$e_{|\mathrm{bias}|}$', r'$e_{\mathrm{RMSD}}$'] column_names = ['\\makecell{$\Delta$ G \\\\ $[$kcal/mol$]$}', '\\makecell{n eval \\\\ $[$M$]$}'] + statistic_names # Add columns. efficiency_table = collections.OrderedDict() for system_name, column_name in itertools.product(system_names, column_names): efficiency_table[(system_name, column_name)] = [] for submission in submissions: # Collect method's names in the given order. methods.append(submission.paper_name) mean_free_energies = submission.mean_free_energies() for system_name in system_names: # CB8-G3 calculations for GROMACS/EE did not converge yet, and the # long protocol in CS-NS calculations have been run only on CB8-G3. if ((submission.name == 'Expanded-ensemble/MBAR' and system_name == 'CB8-G3') or (submission.paper_name == 'GROMACS/NS-DS/SB-long' and system_name != 'CB8-G3')): relative_efficiencies, relative_efficiencies_corrected = np.full((2, 3), fill_value=np.nan) dg = '' n_force_eval = '' else: # Get input for EfficiencyAnalysis. free_energy_ref, free_energy_sub, asymptotic_free_energy_ref = get_relative_efficiency_input( submission, yank_analysis, system_name) # Get the relative efficiencies. relative_efficiencies, cis = compute_all_relative_efficiencies( free_energy_ref, free_energy_sub, ci, n_bootstrap_samples, asymptotic_free_energy_A=asymptotic_free_energy_ref ) # Recompute relative efficiencies assuming that YANK converged. if print_bias_corrected: relative_efficiencies_corrected, cis_corrected = compute_all_relative_efficiencies( free_energy_ref, free_energy_sub, ci, n_bootstrap_samples) # Select the data for only this host-guest system. mean_data_sub = mean_free_energies[mean_free_energies['System name'] == system_name] # Get the final free energy and number of energy/force evaluations. dg = mean_data_sub[DG_KEY].values[-1] dg_CI = mean_data_sub['$\Delta$G CI'].values[-1] # Confidence interval. dg, dg_CI = reduce_to_first_significant_digit(dg, dg_CI) n_force_eval = mean_data_sub['N energy evaluations'].values[-1] # Convert to string format. dg = '{} $\\pm$ {}'.format(dg, dg_CI) n_force_eval = str(int(round(n_force_eval / 1e6))) # Add free energy and cost entries. efficiency_table[(system_name, column_names[0])].append(dg) efficiency_table[(system_name, column_names[1])].append(n_force_eval) # Add efficiency entries for the table. for statistic_idx, statistic_name in enumerate(statistic_names): # Gather the format arguments. rel_effs = [relative_efficiencies[statistic_idx], cis[statistic_idx][0], cis[statistic_idx][1]] if print_bias_corrected: rel_effs.append(relative_efficiencies_corrected[statistic_idx]) # Comment this if we don't want to print CIs for the corrected estimate. rel_effs.extend([cis_corrected[statistic_idx][0], cis_corrected[statistic_idx][1]]) # Print significant digits. efficiencies_format = [] for e_idx in range(0, len(rel_effs), 3): rel_eff, low_bound, high_bound = rel_effs[e_idx:e_idx+3] if high_bound - rel_eff < 0.1 or rel_eff - low_bound < 0.1: fmt = '{:2.2f}' else: fmt = '{:2.1f}' # Print lower and higher bound as sub and superscripts of the estimate. efficiencies_format.append(fmt + '$_{{\raisem{{2pt}}{{' + fmt + '}}}}^{{\mathstrut ' + fmt + '}}$') if np.isnan(rel_effs[0]): data_entry = '' # Standard deviation efficiency is not affected by the bias. elif print_bias_corrected and ('std' not in statistic_name): data_entry = efficiencies_format[0] + ' (' + efficiencies_format[1] + ')' data_entry = data_entry.format(*rel_effs) else: data_entry = efficiencies_format[0].format(*rel_effs[:3]) # Remove the minus sign from "-0". data_entry = data_entry.replace('-0.0', '0.0') data_entry = data_entry.replace('-0.00', '0.00') efficiency_table[(system_name, statistic_name)].append(data_entry) # Add row for reference calculation. methods.append(YANK_METHOD_PAPER_NAME) # Add free energy and cost entries. for system_name in system_names: yank_mean_data = yank_analysis.get_free_energies_from_iteration( YANK_N_ITERATIONS, system_name=system_name, mean_trajectory=True) dg = yank_mean_data[DG_KEY].values[-1] dg_CI = yank_mean_data['$\Delta$G CI'].values[-1] # Confidence interval. dg, dg_CI = reduce_to_first_significant_digit(dg, dg_CI) n_force_eval = yank_mean_data['N energy evaluations'].values[-1] n_force_eval = str(int(round(n_force_eval / 1e6))) efficiency_table[(system_name, column_names[0])].append('{} $\\pm$ {}'.format(dg, dg_CI)) efficiency_table[(system_name, column_names[1])].append(n_force_eval) # All efficiencies are relative to YANK so they're all 1. for system_name, statistic_name in itertools.product(system_names, statistic_names): efficiency_table[(system_name, statistic_name)].append('0.0') # Convert to Pandas Dataframe. efficiency_table = pd.DataFrame(efficiency_table) # Set the method's names as index column. efficiency_table = efficiency_table.assign(Method=methods) efficiency_table.set_index(keys='Method', inplace=True) # Print table. column_format = 'lccccc|ccccc|ccccc' efficiency_table_latex = efficiency_table.to_latex(column_format=column_format, multicolumn_format='c', escape=False) # Make header and reference method bold. textbf = lambda s: '\\textbf{' + s + '}' efficiency_table_latex = efficiency_table_latex.replace(YANK_METHOD_PAPER_NAME, textbf(YANK_METHOD_PAPER_NAME)) efficiency_table_latex = efficiency_table_latex.replace('Method', textbf('Method')) for system_name in system_names: efficiency_table_latex = efficiency_table_latex.replace(system_name, textbf(system_name)) for column_name in column_names: efficiency_table_latex = efficiency_table_latex.replace(column_name, textbf(column_name)) print(efficiency_table_latex) def print_nonequilibrium_relative_efficiencies(nonequilibrium_submissions): """Print relative efficiencies w.r.t. for the nonequilibrium estimators table.""" system_names = ['CB8-G3', 'OA-G3', 'OA-G6'] def _get_free_energy_array(submission, system_name, step=1, max_c=100, get_asymptotic=False): n_replicates = 5 system_data = submission.data[submission.data['System name'] == system_name] free_energy_array = np.empty(shape=(n_replicates, int(max_c/step))) for i in range(n_replicates): system_id = system_name + '-' + str(i) system_id_data = system_data[system_data['System ID'] == system_id] free_energy_array[i] = system_id_data[DG_KEY].values[:max_c:step] if get_asymptotic: mean_free_energies = submission.mean_free_energies() asymptotic = mean_free_energies[mean_free_energies['System name'] == system_name][DG_KEY].values[-1] return free_energy_array, asymptotic return free_energy_array # Use GROMACS/NS-DS/SB-long as reference method. reference_submission = [s for s in nonequilibrium_submissions if s.paper_name == 'GROMACS/NS-DS/SB-long'][0] # Also remove the other BAR submission. nonequilibrium_submissions = [s for s in nonequilibrium_submissions if 'GROMACS/NS-DS/SB' not in s.paper_name] # Get only the first 50 as the 1-directional estimators only have half the cost. free_energy_ref = {} asymptotic_ref = {} for system_name in system_names: DG, asympt = _get_free_energy_array(reference_submission, system_name, max_c=50, get_asymptotic=True) free_energy_ref[system_name] = DG asymptotic_ref[system_name] = asympt for submission in nonequilibrium_submissions: print(submission.paper_name, end='') for system_name in system_names: free_energy_sub = _get_free_energy_array(submission, system_name, step=2) rel_eff, cis = compute_all_relative_efficiencies( free_energy_ref[system_name], free_energy_sub, ci=0.95, n_bootstrap_samples=1000, asymptotic_free_energy_A=asymptotic_ref[system_name], asymptotic_free_energy_B=asymptotic_ref[system_name] ) for i, stat_name in enumerate(['std', 'bias', 'RMSE']): print(r' & {:.1f}$_{{\raisem{{2pt}}{{{:.1f}}}}}^{{\mathstrut {:.1f}}}$'.format(rel_eff[i], cis[i][0], cis[i][1]), end='') print(r' \\') def print_final_prediction_table(submissions, yank_analysis): """Plot the table containing the fina binding free energy predictions for all replicates.""" for submission in submissions + [yank_analysis]: # GROMACS/EE-fullequil predictions are identical to GROMACS/EE if submission.paper_name == 'GROMACS/EE-fullequil': continue if isinstance(submission, YankSamplingAnalysis): submission_data = yank_analysis.get_free_energies_from_iteration(final_iteration=YANK_N_ITERATIONS) else: submission_data = submission.data submission_data = submission_data[submission_data['Simulation percentage'] == 100] row_str = submission.paper_name + ' & ' submission_final_DGs = [] for system_id in submission_data['System ID'].unique(): # GROMACS/EE doesn't have predictions for CB8-G3, and the # GROMACS/NS-DS/SB-long protocol was applied only to CB8-G3. if (('GROMACS/EE' in submission.paper_name and 'CB8-G3' in system_id) or (submission.paper_name == 'GROMACS/NS-DS/SB-long' and 'OA' in system_id)): submission_final_DGs.append('') continue dg = submission_data.loc[submission_data['System ID'] == system_id, DG_KEY].values[0] ddg = submission_data.loc[submission_data['System ID'] == system_id, DDG_KEY].values[0] dg, ddg = reduce_to_first_significant_digit(dg, ddg) submission_final_DGs.append(r'{} $\pm$ {}'.format(dg, ddg)) row_str += ' & '.join(submission_final_DGs) + r' \\' print(row_str) # ============================================================================= # SUPPORTING INFORMATION - SINGLE TRAJECTORIES # ============================================================================= def plot_single_trajectories_figures(axes, system_data, system_mean_data, reference_system_mean_data=None, plot_errors=True, plot_methods_uncertainties=True): """Plot individual free energy trajectories and standard deviations for a single method and system.""" system_name = system_data['System name'].unique()[0] palette_mean = sns.color_palette('pastel') submission_mean_color = 'black' reference_mean_color = palette_mean[9] # Plot the method uncertainties of the single replicate trajectories. # First scale the number of energy evaluations. system_data.loc[:,'N energy evaluations'] /= N_ENERGY_EVALUATIONS_SCALE # Plot the 5 replicates individual trajectories. # First remove the initial predictions that are 0.0 (i.e. there is no estimate). ax = axes[0] system_data = system_data[system_data[DG_KEY] != 0.0] sns.lineplot(data=system_data, x='N energy evaluations', y=DG_KEY, hue='System ID', palette='bright', ax=ax, alpha=0.6) # Plot the submission mean trajectory with CI. plot_mean_free_energy(system_mean_data, x='N energy evaluations', ax=ax, color_mean=submission_mean_color, plot_ci=False, color_ci=submission_mean_color, label='Best estimate', scale_n_energy_evaluations=True) # Plot YANK mean trajectory with CI. if reference_system_mean_data is not None: plot_mean_free_energy(reference_system_mean_data, x='N energy evaluations', ax=ax, color_mean=reference_mean_color, plot_ci=False, color_ci=reference_mean_color, label='Reference estimate', scale_n_energy_evaluations=True) ax.set_title(system_name) # Add the y-label only on the leftmost Axis. if system_name != 'CB8-G3': ax.set_ylabel('') # Remove the legend for now, which will be added at the end after tighting up the plot. ax.get_legend().remove() # Create a bias axis. if reference_system_mean_data is not None: ref_free_energy = reference_free_energies.loc[system_name, DG_KEY] with sns.axes_style('white'): ax2 = ax.twinx() # Plot a vertical line to make the scale. vertical_line = np.linspace(*ax.get_ylim()) - ref_free_energy ax2.plot([50] * len(vertical_line), vertical_line, alpha=0.0001) ax2.grid(alpha=0.5, linestyle='dashed', zorder=0) # We add the bias y-label only on the rightmost Axis. if system_name == 'OA-G6': ax2.set_ylabel('Bias to reference [kcal/mol]') # Set the 0 of the twin axis to the YANK reference free energy. align_yaxis(ax, ref_free_energy, ax2, 0.0) if plot_errors: # The x-axis is shared between the 2 rows so we can plot the ticks only in the bottom one. ax.xaxis.set_ticklabels([]) ax.set_xlabel('') ax = axes[1] # REVO uses the mean of the 5 replicates to estimate the # uncertainty so it doesn't add information. if plot_methods_uncertainties: sns.lineplot(data=system_data, x='N energy evaluations', y=DDG_KEY, hue='System ID', palette='bright', ax=ax, alpha=0.6) # The legend is added later at the top. ax.get_legend().remove() # Plot the standard deviation of the free energy trajectories. # submission_std = system_mean_data['std'] submission_std = system_mean_data['unbiased_std'] # cost = system_mean_data['Simulation percentage'].values cost = system_mean_data['N energy evaluations'].values / N_ENERGY_EVALUATIONS_SCALE ax.plot(cost, submission_std, color=submission_mean_color) # Plot confidence interval around standard deviation. submission_std_low_ci = system_mean_data['unbiased_std_low_CI'].values submission_std_up_ci = system_mean_data['unbiased_std_up_CI'].values ax.fill_between(cost, submission_std_low_ci, submission_std_up_ci, alpha=0.35, color='gray') if reference_system_mean_data is not None: # reference_std = reference_system_mean_data['std'] reference_std = reference_system_mean_data['unbiased_std'] ax.plot(cost, reference_std, color=reference_mean_color) # Only the central plot shows the x-label. ax.set_xlabel('') # Add the y-label only on the leftmost Axis. if system_name != 'CB8-G3': ax.set_ylabel('') else: ax.set_ylabel('std($\Delta$G) [kcal/mol]') # Set x limits. for ax in axes: ax.set_xlim((0, max(system_data['N energy evaluations']))) def plot_all_single_trajectories_figures(submissions, yank_analysis, plot_errors=True, output_path_dir=None): """Individual plots for each method with the 5 individual free energy and uncertainty trajectories.""" sns.set_style('whitegrid') sns.set_context('paper') if output_path_dir is None: output_path_dir = os.path.join(SAMPLING_PAPER_DIR_PATH, 'SI_Figure-individual-trajectories/') os.makedirs(output_path_dir, exist_ok=True) # -------------------- # # Plot submission data # # -------------------- # # Remove nonequilibrium-switching calculations with single-direction estimators. submissions = [s for s in submissions if ('Jarz' not in s.paper_name and 'Gauss' not in s.paper_name)] for submission in submissions + [yank_analysis]: # CB8-G3 calculations for GROMACS/EE did not converge yet. if submission.name == 'Expanded-ensemble/MBAR': submission.data = submission.data[submission.data['System name'] != 'CB8-G3'] # REVO uses the mean of the 5 replicates to estimate the # uncertainty so it doesn't add information. if 'REVO' in submission.paper_name: plot_methods_uncertainties = False else: plot_methods_uncertainties = True if not isinstance(submission, YankSamplingAnalysis): mean_free_energies = submission.mean_free_energies() unique_system_names = submission.data['System name'].unique() else: unique_system_names = sorted(submission.system_names) # Create a figure with 3 axes (one for each system). n_systems = len(unique_system_names) if plot_errors: # The second row will plot the errors. fig, axes = plt.subplots(nrows=2, ncols=n_systems, figsize=(7.25, 4.8)) trajectory_axes = axes[0] else: fig, axes = plt.subplots(nrows=1, ncols=n_systems, figsize=(7.25, 2.4)) trajectory_axes = axes # Set figure title. fig.suptitle(submission.paper_name) # Determine range of data across systems. min_DG = np.inf max_DG = -np.inf min_dDG = np.inf max_dDG = -np.inf # for system_name in unique_system_names: for ax_idx, system_name in enumerate(unique_system_names): if isinstance(submission, YankSamplingAnalysis): data = submission.get_free_energies_from_iteration(final_iteration=YANK_N_ITERATIONS, system_name=system_name) mean_data = submission.get_free_energies_from_iteration(final_iteration=YANK_N_ITERATIONS, system_name=system_name, mean_trajectory=True) else: # Select the data for only this host-guest system. data = submission.data[submission.data['System name'] == system_name] mean_data = mean_free_energies[mean_free_energies['System name'] == system_name] plot_single_trajectories_figures(axes[:,ax_idx], data, mean_data, plot_errors=plot_errors, reference_system_mean_data=None, plot_methods_uncertainties=plot_methods_uncertainties) # Collect max and min data to determine axes range. min_DG = min(min_DG, min(data[DG_KEY]), min(mean_data[DG_KEY])) max_DG = max(max_DG, max(data[DG_KEY]), max(mean_data[DG_KEY])) min_dDG = min(min_dDG, min(data[DDG_KEY]), min(mean_data['std'])) max_dDG = max(max_dDG, max(data[DDG_KEY]), max(mean_data['std'])) # Set limits. for i in range(len(unique_system_names)): axes[0][i].set_ylim((min_DG, max_DG)) axes[1][i].set_ylim((min_dDG, max_dDG)) # Keep ticks only in external plots. axes[0][i].set_xticklabels([]) for i in range(1, len(unique_system_names)): axes[0][i].set_yticklabels([]) axes[1][i].set_yticklabels([]) # The x-label is shown only in the central plot. axes[-1][1].set_xlabel('N energy evaluations [10$^6$]') plt.tight_layout(pad=0.2, rect=[0.0, 0.0, 1.0, 0.85]) # Create legend. # The first handle/label is the legend title "System ID" so we get rid of it. handles, labels = trajectory_axes[0].get_legend_handles_labels() labels = ['replicate ' + str(i) for i in range(5)] + labels[6:] bbox_to_anchor = (-0.1, 1.35) trajectory_axes[0].legend(handles=handles[1:], labels=labels, loc='upper left', bbox_to_anchor=bbox_to_anchor, ncol=6, fancybox=True, labelspacing=0.8, handletextpad=0.5, columnspacing=1.2) # Save figure. output_file_name = 'replicates-{}-{}'.format(submission.file_name, submission.receipt_id) plt.savefig(os.path.join(output_path_dir, output_file_name + '.pdf')) # plt.savefig(os.path.join(output_path_dir, output_file_name + '.png'), dpi=300) # plt.show() # ============================================================================= # SUPPORTING INFORMATION - HREX/MBAR STATISTICAL INEFFICIENCY ANALYSIS # ============================================================================= def plot_hrex_stat_ineff_trajectories(): """Individual plots for HREX with the 5 individual free energy and uncertainty trajectories as a function of the statistical inefficiency.""" sns.set_context('paper') # Limits of y-axis (free energies, uncertainties) by system. y_limits = { 'CB8-G3': [(-14, -10), (0, 2)], 'OA-G3': [(-9, -5), (0, 1.5)], 'OA-G6': [(-9, -5), (0, 1.5)], } # Create output dir. output_path_dir = os.path.join(SAMPLING_PAPER_DIR_PATH, 'SI_Figure-statistical-inefficiency') os.makedirs(output_path_dir, exist_ok=True) # Read the data, which is organized by statistical inefficiency. # We'll then plot by system. yank_analysis_by_statineff = collections.OrderedDict() for stat_ineff in ['5', '10', '20', '50', '100', '200']: data_dir_path = os.path.join('YankAnalysis', 'CorrelationAnalysis', 'statineff-{}'.format(stat_ineff)) yank_analysis = YankSamplingAnalysis(data_dir_path) yank_analysis_by_statineff[stat_ineff] = yank_analysis # Plot by system. for system_name in ['CB8-G3', 'OA-G3', 'OA-G6']: fig, axes = plt.subplots(nrows=4, ncols=3, figsize=(7.25, 9.8)) # Set figure title. fig.suptitle('HREX uncertainty predictions as a function of\n' 'statistical inefficiency for {}'.format(system_name)) # for system_name in unique_system_names: for stat_ineff_idx, stat_ineff in enumerate(yank_analysis_by_statineff): yank_analysis = yank_analysis_by_statineff[stat_ineff] data = yank_analysis.get_free_energies_from_iteration(final_iteration=YANK_N_ITERATIONS, system_name=system_name) mean_data = yank_analysis.get_free_energies_from_iteration(final_iteration=YANK_N_ITERATIONS, system_name=system_name, mean_trajectory=True) # Plot on the correct axis. DG_row = 2*int(stat_ineff_idx / 3) col = stat_ineff_idx % 3 stat_ineff_axes = axes[DG_row:DG_row+2, col] plot_single_trajectories_figures(stat_ineff_axes, data, mean_data, plot_errors=True, reference_system_mean_data=None, plot_methods_uncertainties=True) # Set titles and limits. title = 'Statistical inefficiency: {} ps'.format(stat_ineff) if DG_row > 0: title = '\n' + title stat_ineff_axes[0].set_title(title, fontweight='bold') stat_ineff_axes[0].set_ylim(y_limits[system_name][0]) stat_ineff_axes[1].set_ylim(y_limits[system_name][1]) stat_ineff_axes[0].set_ylabel('$\Delta$G [kcal/mol]') stat_ineff_axes[1].set_ylabel('std($\Delta$G) [kcal/mol]') # Keep ticks only in external plots. for row_idx in range(axes.shape[0]): for col_idx in range(axes.shape[1]): if row_idx != len(axes[0]) - 1: axes[row_idx][col_idx].set_xticklabels([]) if col_idx != 0: axes[row_idx][col_idx].set_ylabel('') axes[row_idx][col_idx].set_yticklabels([]) # Set x label. axes[-1][1].set_xlabel('N energy evaluations [10$^6$]') plt.tight_layout(pad=0.0, rect=[0.0, 0.0, 1.0, 0.88]) # Create legend. # The first handle/label is the legend title "System ID" so we get rid of it. handles, labels = axes[0][0].get_legend_handles_labels() labels = ['replicate ' + str(i) for i in range(5)] + labels[6:] bbox_to_anchor = (0.05, 1.35) axes[0][0].legend(handles=handles[1:], labels=labels, loc='upper left', bbox_to_anchor=bbox_to_anchor, ncol=6, fancybox=True, labelspacing=0.8, handletextpad=0.5, columnspacing=1.2) # Save figure. output_file_name = 'statineff-{}'.format(system_name) plt.savefig(os.path.join(output_path_dir, output_file_name + '.pdf')) # plt.savefig(os.path.join(output_path_dir, output_file_name + '.png'), dpi=300) # plt.show() # ============================================================================= # MAIN # ============================================================================= if __name__ == '__main__': sns.set_style('whitegrid') sns.set_context('paper') # Read reference values. yank_analysis = YankSamplingAnalysis(YANK_ANALYSIS_DIR_PATH) # Obtain free energies and final reference values. mean_reference_free_energies = yank_analysis.get_free_energies_from_iteration(YANK_N_ITERATIONS, mean_trajectory=True) reference_free_energies = mean_reference_free_energies[mean_reference_free_energies['Simulation percentage'] == 100] reference_free_energies.set_index('System name', inplace=True) # Compute efficiency of reference. reference_efficiencies = {} for system_name in mean_reference_free_energies['System name'].unique(): mean_data = mean_reference_free_energies[mean_reference_free_energies ['System name'] == system_name] reference_efficiencies[system_name], n_discarded = fit_efficiency(mean_data) # Import user map. with open('../SubmissionsDoNotUpload/SAMPL6_user_map.csv', 'r') as f: user_map = pd.read_csv(f) # Load submissions data. We do OA and TEMOA together. all_submissions = load_submissions(SamplingSubmission, SAMPLING_SUBMISSIONS_DIR_PATH, user_map) # Remove AMBER/TI. all_submissions = [s for s in all_submissions if s.name not in ['Langevin/Virtual Bond/TI']] # Create an extra submission for GROMACS/EE where the full cost of equilibration has been taken into account. gromacs_ee_submission = copy.deepcopy([s for s in all_submissions if s.paper_name == 'GROMACS/EE'][0]) gromacs_ee_submission.paper_name = 'GROMACS/EE-fullequil' gromacs_ee_submission.file_name = 'EENVT-fullequil' data = gromacs_ee_submission.data # Shortcut. mean_free_energies = gromacs_ee_submission.mean_free_energies() for system_name in ['OA-G3', 'OA-G6']: mean_data = mean_free_energies[mean_free_energies['System name'] == system_name] first_nonzero_idx = np.nonzero(mean_data[DG_KEY].values)[0][0] full_equilibration_cost = mean_data['N energy evaluations'].values[first_nonzero_idx] * 4 for i in data[data['System name'] == system_name].index: data.at[i, 'N energy evaluations'] += full_equilibration_cost all_submissions.append(gromacs_ee_submission) # Sort the submissions to have all pot and tables in the same order. all_submissions = sorted(all_submissions, key=lambda s: s.paper_name) # Separate the main submissions from the data about nonequilibrium estimators. main_submissions = [s for s in all_submissions if not ('Jarz' in s.paper_name or 'Gauss' in s.paper_name)] noneq_submissions = [s for s in all_submissions if 'NS' in s.paper_name] # Export YANK analysis and submissions to CSV/JSON tables. yank_analysis.export(os.path.join(SAMPLING_DATA_DIR_PATH, 'reference_free_energies')) for s in main_submissions: file_base_path = os.path.join(SAMPLING_DATA_DIR_PATH, s.receipt_id + '-reference') yank_analysis.export_by_submission(file_base_path, s) export_submissions(all_submissions, reference_free_energies) # Create example trajectory for the figure describing the challenge process. plot_example_bias_variance(yank_analysis, max_n_eval_percentage=0.4, mixed_proportion=0.3) # Cartoon explaining mean error and relative efficiency. plot_mean_error_cartoon() # Create figure with free energy, standard deviation, and bias as a function of computational cost. plot_all_entries_trajectory(main_submissions, yank_analysis, zoomed=False) plot_all_entries_trajectory(main_submissions, yank_analysis, zoomed=True) # Create results and efficiency table. print_relative_efficiency_table(main_submissions, yank_analysis, print_bias_corrected=False) # Plot nonequilibrium-switching single-direction estimator. plot_all_nonequilibrium_switching(noneq_submissions) # Plot sensitivity analysis figure. plot_restraint_and_barostat_analysis() # Plot figure for HREX bias analysis. plot_yank_bias() # Supporting information # ---------------------- # Absolute/relative efficiency as a function of the computational cost. plot_relative_efficiencies(main_submissions, yank_analysis) plot_relative_efficiencies(main_submissions, yank_analysis, ci=None, same_plot=True) plot_absolute_efficiencies(main_submissions, yank_analysis) # Relative efficiency for uni/bi-directional estimators. print_nonequilibrium_relative_efficiencies(noneq_submissions) # Plot replicate predictions table. print_final_prediction_table(all_submissions, yank_analysis) # Plot individual trajectories. plot_all_single_trajectories_figures(all_submissions, yank_analysis) # Plot statistical inefficiency analysis. plot_hrex_stat_ineff_trajectories() # Supporting information for bias section. output_dir_path = os.path.join(SAMPLING_PAPER_DIR_PATH, 'SI_Figure-bias_hrex') plot_decomposition('CB8-G3', starting_iteration=5, type='phase', output_file_path=output_dir_path + '/free-energy-phase-decomposition.pdf')) plot_decomposition('CB8-G3', starting_iteration=5, type='entropy-enthalpy', output_file_path=output_dir_path + '/free-energy-entropy-decomposition.pdf')
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 26237, 199, 3, 598, 12667, 5025, 2596, 51, 199, 3, 26237, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 7975, 199, 646, 2022, 199, 646, 3473, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 7026, 465, 2249, 199, 646, 542, 371, 6161, 465, 308, 561, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 199, 504, 5496, 10466, 14, 3200, 492, 4615, 63, 13969, 63, 4284, 199, 504, 5496, 10466, 14, 17376, 492, 334, 12226, 8922, 2610, 2250, 12, 1488, 3580, 12226, 8922, 13182, 12, 3303, 1488, 15874, 63, 46, 63, 11084, 12969, 12, 577, 39, 63, 3078, 12, 577, 29173, 63, 3078, 12, 4843, 63, 9086, 9, 199, 504, 5496, 10466, 14, 12542, 492, 334, 912, 63, 29752, 9, 199, 199, 3, 26237, 199, 3, 21803, 1441, 51, 199, 3, 26237, 199, 199, 57, 15874, 63, 9977, 63, 48, 28773, 63, 2339, 275, 283, 4299, 3218, 15, 40, 907, 56, 7, 199, 199, 3, 6912, 83, 370, 1324, 666, 14, 199, 51, 7855, 1206, 63, 6348, 31978, 63, 3022, 63, 3243, 275, 20644, 2610, 2554, 2585, 1763, 10301, 15, 28947, 4805, 199, 57, 15874, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 275, 283, 57, 3580, 13182, 15, 12226, 8922, 4805, 199, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 275, 20644, 51, 7855, 316, 4805, 199, 51, 7855, 1206, 63, 3998, 63, 3022, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 12, 283, 1451, 358, 199, 51, 7855, 1206, 63, 2749, 1387, 63, 3022, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 12, 283, 48, 4555, 358, 199, 51, 7855, 1206, 63, 48, 28773, 63, 3022, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 12, 283, 48, 9804, 18882, 358, 199, 199, 3, 2900, 2656, 2762, 14, 199, 12711, 63, 20857, 275, 359, 272, 283, 9956, 24, 13, 39, 19, 13, 16, 297, 283, 9956, 24, 13, 39, 19, 13, 17, 297, 283, 9956, 24, 13, 39, 19, 13, 18, 297, 283, 9956, 24, 13, 39, 19, 13, 19, 297, 283, 9956, 24, 13, 39, 19, 13, 20, 297, 272, 283, 47, 33, 13, 39, 19, 13, 16, 297, 283, 47, 33, 13, 39, 19, 13, 17, 297, 283, 47, 33, 13, 39, 19, 13, 18, 297, 283, 47, 33, 13, 39, 19, 13, 19, 297, 283, 47, 33, 13, 39, 19, 13, 20, 297, 272, 283, 47, 33, 13, 39, 22, 13, 16, 297, 283, 47, 33, 13, 39, 22, 13, 17, 297, 283, 47, 33, 13, 39, 22, 13, 18, 297, 283, 47, 33, 13, 39, 22, 13, 19, 297, 283, 47, 33, 13, 39, 22, 13, 20, 7, 199, 61, 199, 199, 3, 1804, 29051, 1159, 9229, 367, 5696, 30347, 14, 199, 3, 5185, 298, 12150, 2720, 401, 221, 298, 12150, 969, 401, 221, 298, 23628, 18, 401, 257, 298, 1168, 453, 20, 401, 257, 298, 13625, 22683, 17, 401, 298, 4040, 12267, 6304, 18, 401, 298, 8935, 29541, 401, 298, 30735, 590, 22736, 19, 401, 298, 12150, 2869, 401, 298, 26008, 7731, 20, 401, 298, 4040, 26591, 18, 401, 298, 271, 8277, 10562, 6304, 20, 401, 298, 4040, 6327, 2106, 18, 401, 298, 3700, 1220, 300, 11045, 20, 401, 298, 22683, 401, 298, 4584, 79, 265, 401, 298, 14514, 19, 401, 298, 27133, 20, 401, 298, 14514, 20, 401, 298, 338, 287, 3540, 20, 401, 298, 2239, 331, 750, 401, 298, 12150, 1167, 2, 199, 2430, 4464, 57, 63, 25671, 275, 788, 3, 38, 18, 38, 19, 38, 20, 297, 3943, 9993, 1081, 297, 3943, 38, 19, 35, 5863, 297, 3943, 1555, 1367, 2942, 297, 3943, 38, 8188, 383, 297, 258, 3943, 33, 17, 3263, 38, 17, 297, 755, 3943, 6773, 30867, 297, 221, 3943, 35, 18, 34, 18520, 297, 257, 3943, 1349, 1349, 2564, 297, 3943, 31419, 1367, 297, 420, 3943, 37, 2333, 38, 1348, 297, 259, 3943, 30761, 33, 21, 297, 258, 3943, 38, 1020, 12015, 297, 420, 3943, 30320, 37, 2576, 297, 420, 3943, 38, 22, 33, 6683, 297, 3943, 34, 1082, 2466, 35, 297, 3943, 5196, 36, 5863, 297, 3943, 19119, 36, 1196, 297, 3943, 24, 2846, 6683, 297, 3943, 11157, 29915, 297, 3943, 37, 821, 10228, 297, 3943, 18, 34, 19, 36, 1479, 418, 199, 10129, 709, 63, 25671, 275, 308, 561, 14, 2326, 63, 16506, 360, 2902, 709, 358, 199, 3, 5499, 402, 1804, 29051, 1159, 9229, 4568, 370, 1924, 13071, 14, 199, 6348, 22320, 63, 25671, 275, 469, 272, 283, 1156, 12003, 15, 1282, 50, 356, 283, 68, 364, 836, 6304, 297, 3, 2430, 4464, 57, 63, 25671, 59, 845, 467, 272, 283, 4299, 3218, 15, 907, 10662, 356, 283, 23628, 297, 327, 2430, 4464, 57, 63, 25671, 59, 23, 467, 272, 283, 4299, 3218, 15, 4118, 5127, 356, 1804, 2901, 6084, 63, 25671, 59, 20, 467, 272, 283, 39, 3810, 1348, 51, 15, 8699, 356, 283, 13625, 32052, 2723, 297, 327, 2430, 4464, 57, 63, 25671, 59, 19, 467, 272, 283, 39, 3810, 1348, 51, 15, 8699, 13, 1893, 274, 392, 382, 356, 283, 8885, 26591, 297, 327, 2430, 4464, 57, 63, 25671, 59, 709, 467, 272, 1488, 15874, 63, 9977, 63, 48, 28773, 63, 2339, 26, 3943, 20, 37, 2571, 2953, 297, 17384, 18687, 7731, 297, 327, 2430, 4464, 57, 63, 25671, 59, 25, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 3177, 15, 12463, 13, 2809, 356, 1804, 2901, 6084, 63, 25671, 59, 22, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 3177, 15, 12463, 356, 1804, 2901, 6084, 63, 25671, 59, 17, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 12977, 90, 13, 38, 356, 17916, 709, 63, 25671, 59, 16, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 12977, 90, 13, 50, 356, 17916, 709, 63, 25671, 59, 17, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 39, 23822 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 26237, 199, 3, 598, 12667, 5025, 2596, 51, 199, 3, 26237, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 7975, 199, 646, 2022, 199, 646, 3473, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 7026, 465, 2249, 199, 646, 542, 371, 6161, 465, 308, 561, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 199, 504, 5496, 10466, 14, 3200, 492, 4615, 63, 13969, 63, 4284, 199, 504, 5496, 10466, 14, 17376, 492, 334, 12226, 8922, 2610, 2250, 12, 1488, 3580, 12226, 8922, 13182, 12, 3303, 1488, 15874, 63, 46, 63, 11084, 12969, 12, 577, 39, 63, 3078, 12, 577, 29173, 63, 3078, 12, 4843, 63, 9086, 9, 199, 504, 5496, 10466, 14, 12542, 492, 334, 912, 63, 29752, 9, 199, 199, 3, 26237, 199, 3, 21803, 1441, 51, 199, 3, 26237, 199, 199, 57, 15874, 63, 9977, 63, 48, 28773, 63, 2339, 275, 283, 4299, 3218, 15, 40, 907, 56, 7, 199, 199, 3, 6912, 83, 370, 1324, 666, 14, 199, 51, 7855, 1206, 63, 6348, 31978, 63, 3022, 63, 3243, 275, 20644, 2610, 2554, 2585, 1763, 10301, 15, 28947, 4805, 199, 57, 15874, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 275, 283, 57, 3580, 13182, 15, 12226, 8922, 4805, 199, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 275, 20644, 51, 7855, 316, 4805, 199, 51, 7855, 1206, 63, 3998, 63, 3022, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 12, 283, 1451, 358, 199, 51, 7855, 1206, 63, 2749, 1387, 63, 3022, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 12, 283, 48, 4555, 358, 199, 51, 7855, 1206, 63, 48, 28773, 63, 3022, 63, 3243, 275, 747, 14, 515, 14, 904, 8, 51, 7855, 1206, 63, 31158, 20238, 1311, 63, 3022, 63, 3243, 12, 283, 48, 9804, 18882, 358, 199, 199, 3, 2900, 2656, 2762, 14, 199, 12711, 63, 20857, 275, 359, 272, 283, 9956, 24, 13, 39, 19, 13, 16, 297, 283, 9956, 24, 13, 39, 19, 13, 17, 297, 283, 9956, 24, 13, 39, 19, 13, 18, 297, 283, 9956, 24, 13, 39, 19, 13, 19, 297, 283, 9956, 24, 13, 39, 19, 13, 20, 297, 272, 283, 47, 33, 13, 39, 19, 13, 16, 297, 283, 47, 33, 13, 39, 19, 13, 17, 297, 283, 47, 33, 13, 39, 19, 13, 18, 297, 283, 47, 33, 13, 39, 19, 13, 19, 297, 283, 47, 33, 13, 39, 19, 13, 20, 297, 272, 283, 47, 33, 13, 39, 22, 13, 16, 297, 283, 47, 33, 13, 39, 22, 13, 17, 297, 283, 47, 33, 13, 39, 22, 13, 18, 297, 283, 47, 33, 13, 39, 22, 13, 19, 297, 283, 47, 33, 13, 39, 22, 13, 20, 7, 199, 61, 199, 199, 3, 1804, 29051, 1159, 9229, 367, 5696, 30347, 14, 199, 3, 5185, 298, 12150, 2720, 401, 221, 298, 12150, 969, 401, 221, 298, 23628, 18, 401, 257, 298, 1168, 453, 20, 401, 257, 298, 13625, 22683, 17, 401, 298, 4040, 12267, 6304, 18, 401, 298, 8935, 29541, 401, 298, 30735, 590, 22736, 19, 401, 298, 12150, 2869, 401, 298, 26008, 7731, 20, 401, 298, 4040, 26591, 18, 401, 298, 271, 8277, 10562, 6304, 20, 401, 298, 4040, 6327, 2106, 18, 401, 298, 3700, 1220, 300, 11045, 20, 401, 298, 22683, 401, 298, 4584, 79, 265, 401, 298, 14514, 19, 401, 298, 27133, 20, 401, 298, 14514, 20, 401, 298, 338, 287, 3540, 20, 401, 298, 2239, 331, 750, 401, 298, 12150, 1167, 2, 199, 2430, 4464, 57, 63, 25671, 275, 788, 3, 38, 18, 38, 19, 38, 20, 297, 3943, 9993, 1081, 297, 3943, 38, 19, 35, 5863, 297, 3943, 1555, 1367, 2942, 297, 3943, 38, 8188, 383, 297, 258, 3943, 33, 17, 3263, 38, 17, 297, 755, 3943, 6773, 30867, 297, 221, 3943, 35, 18, 34, 18520, 297, 257, 3943, 1349, 1349, 2564, 297, 3943, 31419, 1367, 297, 420, 3943, 37, 2333, 38, 1348, 297, 259, 3943, 30761, 33, 21, 297, 258, 3943, 38, 1020, 12015, 297, 420, 3943, 30320, 37, 2576, 297, 420, 3943, 38, 22, 33, 6683, 297, 3943, 34, 1082, 2466, 35, 297, 3943, 5196, 36, 5863, 297, 3943, 19119, 36, 1196, 297, 3943, 24, 2846, 6683, 297, 3943, 11157, 29915, 297, 3943, 37, 821, 10228, 297, 3943, 18, 34, 19, 36, 1479, 418, 199, 10129, 709, 63, 25671, 275, 308, 561, 14, 2326, 63, 16506, 360, 2902, 709, 358, 199, 3, 5499, 402, 1804, 29051, 1159, 9229, 4568, 370, 1924, 13071, 14, 199, 6348, 22320, 63, 25671, 275, 469, 272, 283, 1156, 12003, 15, 1282, 50, 356, 283, 68, 364, 836, 6304, 297, 3, 2430, 4464, 57, 63, 25671, 59, 845, 467, 272, 283, 4299, 3218, 15, 907, 10662, 356, 283, 23628, 297, 327, 2430, 4464, 57, 63, 25671, 59, 23, 467, 272, 283, 4299, 3218, 15, 4118, 5127, 356, 1804, 2901, 6084, 63, 25671, 59, 20, 467, 272, 283, 39, 3810, 1348, 51, 15, 8699, 356, 283, 13625, 32052, 2723, 297, 327, 2430, 4464, 57, 63, 25671, 59, 19, 467, 272, 283, 39, 3810, 1348, 51, 15, 8699, 13, 1893, 274, 392, 382, 356, 283, 8885, 26591, 297, 327, 2430, 4464, 57, 63, 25671, 59, 709, 467, 272, 1488, 15874, 63, 9977, 63, 48, 28773, 63, 2339, 26, 3943, 20, 37, 2571, 2953, 297, 17384, 18687, 7731, 297, 327, 2430, 4464, 57, 63, 25671, 59, 25, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 3177, 15, 12463, 13, 2809, 356, 1804, 2901, 6084, 63, 25671, 59, 22, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 3177, 15, 12463, 356, 1804, 2901, 6084, 63, 25671, 59, 17, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 12977, 90, 13, 38, 356, 17916, 709, 63, 25671, 59, 16, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 12977, 90, 13, 50, 356, 17916, 709, 63, 25671, 59, 17, 467, 272, 283, 39, 3810, 1348, 51, 15, 2709, 13, 39, 23822, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
scorphus/thumbor
tests/metrics/test_logger_metrics.py
4
1137
#!/usr/bin/python # -*- coding: utf-8 -*- # thumbor imaging service # https://github.com/thumbor/thumbor/wiki # Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com from preggy import expect from thumbor.context import Context from thumbor.importer import Importer from thumbor.config import Config import thumbor.metrics from tests.base import TestCase class LoggerMetricsTestCase(TestCase): def get_context(self): conf = Config() conf.METRICS = "thumbor.metrics.logger_metrics" imp = Importer(conf) imp.import_modules() return Context(None, conf, imp) def test_should_initialize_metrics(self): expect(self.context.metrics).to_be_instance_of( thumbor.metrics.logger_metrics.Metrics ) def test_should_not_fail_on_use(self): expect(self.context.metrics.incr("test.count")).not_to_be_an_error() expect(self.context.metrics.incr("test.count", 2)).not_to_be_an_error() expect(self.context.metrics.timing("test.time", 100)).not_to_be_an_error()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 21541, 269, 18884, 1540, 2435, 199, 3, 4178, 921, 5031, 14, 957, 15, 16534, 269, 15, 16534, 269, 15, 6797, 199, 199, 3, 3909, 1334, 314, 10697, 4190, 26, 199, 3, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 199, 3, 1898, 334, 67, 9, 7760, 486, 320, 656, 14, 957, 21541, 269, 32, 3098, 2634, 14, 957, 199, 199, 504, 876, 26435, 492, 4282, 199, 199, 504, 21541, 269, 14, 1100, 492, 9470, 199, 504, 21541, 269, 14, 12138, 492, 8362, 3968, 199, 504, 21541, 269, 14, 888, 492, 4094, 199, 646, 21541, 269, 14, 6759, 199, 199, 504, 2295, 14, 1095, 492, 7640, 421, 199, 533, 15996, 17213, 1746, 8, 1746, 304, 272, 347, 664, 63, 1100, 8, 277, 304, 267, 3743, 275, 4094, 342, 267, 3743, 14, 30476, 275, 298, 16534, 269, 14, 6759, 14, 2921, 63, 6759, 2, 267, 1742, 275, 8362, 3968, 8, 2190, 9, 267, 1742, 14, 646, 63, 3112, 342, 267, 372, 9470, 8, 403, 12, 3743, 12, 1742, 9, 339, 347, 511, 63, 5626, 63, 8489, 63, 6759, 8, 277, 304, 267, 4282, 8, 277, 14, 1100, 14, 6759, 680, 475, 63, 1235, 63, 842, 63, 1618, 8, 288, 21541, 269, 14, 6759, 14, 2921, 63, 6759, 14, 17213, 267, 776, 339, 347, 511, 63, 5626, 63, 1397, 63, 1633, 63, 265, 63, 1180, 8, 277, 304, 267, 4282, 8, 277, 14, 1100, 14, 6759, 14, 19362, 480, 396, 14, 835, 21688, 1397, 63, 475, 63, 1235, 63, 290, 63, 705, 342, 267, 4282, 8, 277, 14, 1100, 14, 6759, 14, 19362, 480, 396, 14, 835, 401, 499, 4992, 1397, 63, 475, 63, 1235, 63, 290, 63, 705, 342, 267, 4282, 8, 277, 14, 1100, 14, 6759, 14, 14639, 480, 396, 14, 521, 401, 2948, 4992, 1397, 63, 475, 63, 1235, 63, 290, 63, 705, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 21541, 269, 18884, 1540, 2435, 199, 3, 4178, 921, 5031, 14, 957, 15, 16534, 269, 15, 16534, 269, 15, 6797, 199, 199, 3, 3909, 1334, 314, 10697, 4190, 26, 199, 3, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 199, 3, 1898, 334, 67, 9, 7760, 486, 320, 656, 14, 957, 21541, 269, 32, 3098, 2634, 14, 957, 199, 199, 504, 876, 26435, 492, 4282, 199, 199, 504, 21541, 269, 14, 1100, 492, 9470, 199, 504, 21541, 269, 14, 12138, 492, 8362, 3968, 199, 504, 21541, 269, 14, 888, 492, 4094, 199, 646, 21541, 269, 14, 6759, 199, 199, 504, 2295, 14, 1095, 492, 7640, 421, 199, 533, 15996, 17213, 1746, 8, 1746, 304, 272, 347, 664, 63, 1100, 8, 277, 304, 267, 3743, 275, 4094, 342, 267, 3743, 14, 30476, 275, 298, 16534, 269, 14, 6759, 14, 2921, 63, 6759, 2, 267, 1742, 275, 8362, 3968, 8, 2190, 9, 267, 1742, 14, 646, 63, 3112, 342, 267, 372, 9470, 8, 403, 12, 3743, 12, 1742, 9, 339, 347, 511, 63, 5626, 63, 8489, 63, 6759, 8, 277, 304, 267, 4282, 8, 277, 14, 1100, 14, 6759, 680, 475, 63, 1235, 63, 842, 63, 1618, 8, 288, 21541, 269, 14, 6759, 14, 2921, 63, 6759, 14, 17213, 267, 776, 339, 347, 511, 63, 5626, 63, 1397, 63, 1633, 63, 265, 63, 1180, 8, 277, 304, 267, 4282, 8, 277, 14, 1100, 14, 6759, 14, 19362, 480, 396, 14, 835, 21688, 1397, 63, 475, 63, 1235, 63, 290, 63, 705, 342, 267, 4282, 8, 277, 14, 1100, 14, 6759, 14, 19362, 480, 396, 14, 835, 401, 499, 4992, 1397, 63, 475, 63, 1235, 63, 290, 63, 705, 342, 267, 4282, 8, 277, 14, 1100, 14, 6759, 14, 14639, 480, 396, 14, 521, 401, 2948, 4992, 1397, 63, 475, 63, 1235, 63, 290, 63, 705, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
alexanderjfink/miner
library/maps/uscensus_old.py
1
3983
""" miner map for U.S. Census 2010 Minnesota database """ from miner import * class USCensus2010: description = 'Data from the 2010 Dicennial US Census.' homepage = 'http://www.census.gov' # Place all download functionality in here, should download files to a standard download directory # Should check whether args have been specified for download. In this case, we might have something like # $miner extract uscensus --state=mn -- in this case, grab census data only for MN def download(): ## SERIES OF PLACEHOLDERS TO FIX FOR FINAL PROJECT ## # PLACEHOLDER: Download SF1 datafiles # PLACEHOLDER: Download 2003 Access Database from US Census (2003 b/c mdbtools can deal only w/Access JET3, 4 # PLACEHOLDER: Test whether mdbtools is installed and works sys.exit() # Place all unpacking functionality here. Unpacking should involve: # unzipping files, # changing file names for consistency def unpack(): # PLACEHOLDER: Unzip SF1 datafiles # PLACEHOLDER: Create new database # PLACEHOLDER: Build tables based on guide database # rename .sf1 data files to .csv # consider replacing bash script w/python # run_script("rename 's/\.sf1$/\.csv/' *.sf1") sys.exit() # Place all installation functionality here. This involves: # pulling files and sending data to database api for insertion def install(self): ################################################################# # POPULATE DATA TABLES # # For this formulae, use all CSV files in downloaded sf1 folder # ################################################################# # open MySQL connection # open MySQL connection db = DBConnect() cnx = db.connect() # Create cursor cursor = cnx.cursor() # Create database if it isn't there already cursor.execute("DROP DATABASE IF EXISTS uscensus2010;") cursor.execute("CREATE DATABASE IF NOT EXISTS uscensus2010;") cursor.execute("USE uscensus2010;") cnx.commit() # sqlstr = """load data local infile '/Users/afink/Desktop/mn000012010.csv' into table SF1_00001 # columns terminated by ',' # optionally enclosed by '"' # escaped by '"' # lines terminated by '\n' # (FILEID, STUSAB, CHARITER, CIFSN, LOGRECNO, P0010001);""" # for each CSV file # match csv file name to table # generate load data local infile query # run sql query # PLACEHOLDER: if verbose, print results cursor = cnx.cursor() os.chdir("./tmp/mn2010.sf1/") for files in glob.glob("*.csv"): #GENERAL INSERT SQL add_csv_file = ('''INSERT INTO %(table_name)s VALUES (%(csv_row)s);''') # Open the CSV file and iterate it by row # Yes, this is slower than using a LOAD DATA LOCAL INFILE SQL query (at least I'm pretty sure it is), but I'm not convinced # that will work easily across all systems and it is not cross-database compatible with open(files, 'rb') as csvfile: spamreader = csv.reader(csvfile, delimiter=',', quoting=csv.QUOTE_MINIMAL) for row in spamreader: # basic detection of whether this should be treated as a string or not... csv_row = [] for r in row: csv_row.append(is_number(r)) # Insert CSV file information csv_info = { 'table_name': 'SF1_' + files[2:-8], 'csv_row': str(csv_row).strip('[]'), } query = add_csv_file % csv_info print query cursor.execute(query) # PLACEHOLDER: Add csv.next() or some feature to figure out what line we are on out of the total to build # a progress bar that can indicate how much is complete. # Make sure data is committed to the database # Waiting until end to commit means we don't get partial datasets inserted. cnx.commit() cursor.close() cnx.close()
gpl-2.0
[ 624, 221, 199, 827, 281, 2341, 367, 738, 14, 51, 14, 445, 8764, 527, 7129, 10195, 17775, 12041, 3050, 199, 624, 199, 199, 504, 1748, 281, 492, 627, 199, 199, 533, 738, 5153, 8764, 527, 6542, 26, 199, 198, 1802, 275, 283, 1451, 687, 314, 7129, 577, 530, 287, 78, 2380, 19635, 445, 8764, 527, 3530, 199, 198, 25539, 275, 283, 1014, 921, 1544, 14, 2497, 25253, 14, 16294, 7, 4388, 198, 3, 10902, 1006, 5235, 9330, 315, 2348, 12, 1077, 5235, 1584, 370, 282, 4465, 5235, 2082, 199, 198, 3, 7719, 1104, 3775, 1249, 1172, 2757, 2013, 367, 5235, 14, 1010, 642, 1930, 12, 781, 5594, 1172, 6020, 2839, 199, 198, 3, 2672, 827, 281, 5536, 399, 551, 8764, 527, 1553, 929, 29, 10344, 1553, 315, 642, 1930, 12, 18200, 286, 8764, 527, 666, 1454, 367, 603, 46, 199, 198, 318, 5235, 837, 507, 198, 309, 7017, 2563, 1634, 10092, 4121, 40, 5104, 3960, 2296, 7333, 2381, 24745, 21915, 925, 507, 198, 3, 10092, 4121, 40, 15744, 26, 17955, 29531, 17, 666, 1725, 507, 198, 3, 10092, 4121, 40, 15744, 26, 17955, 13004, 11003, 8692, 687, 19635, 445, 8764, 527, 334, 17919, 330, 15, 67, 333, 697, 2537, 883, 7962, 1454, 336, 15, 3946, 1603, 775, 19, 12, 841, 507, 198, 3, 10092, 4121, 40, 15744, 26, 1379, 3775, 333, 697, 2537, 365, 4903, 436, 5419, 507, 198, 1274, 14, 2224, 342, 4388, 198, 3, 10902, 1006, 7787, 316, 9330, 2348, 14, 31017, 316, 1077, 4572, 3344, 26, 9948, 198, 3, 257, 29379, 4073, 1584, 12, 199, 198, 3, 257, 13729, 570, 1561, 367, 17754, 199, 198, 318, 7787, 837, 507, 198, 3, 10092, 4121, 40, 15744, 26, 1910, 3065, 29531, 17, 666, 1725, 507, 198, 3, 10092, 4121, 40, 15744, 26, 2790, 892, 3050, 507, 198, 3, 10092, 4121, 40, 15744, 26, 6516, 6716, 4079, 641, 22885, 3050, 221, 9068, 198, 3, 11441, 1275, 7646, 17, 666, 1584, 370, 1275, 4737, 507, 198, 3, 11201, 15810, 20387, 2884, 336, 15, 1548, 507, 198, 3, 1255, 63, 1579, 480, 8165, 283, 83, 15, 4537, 7646, 17, 4, 15, 4537, 4737, 4805, 23588, 7646, 17, 531, 507, 198, 1274, 14, 2224, 342, 4388, 198, 3, 10902, 1006, 12096, 9330, 2348, 14, 961, 25613, 2310, 26, 199, 198, 3, 257, 10299, 316, 1584, 436, 10209, 666, 370, 3050, 2986, 367, 22470, 199, 198, 318, 3907, 8, 277, 304, 507, 198, 3060, 3, 507, 198, 3, 510, 1938, 1293, 1951, 7126, 377, 17041, 221, 24564, 1057, 198, 3, 507, 198, 3, 2104, 642, 1824, 348, 3624, 12, 675, 1006, 14689, 1584, 315, 13557, 13330, 17, 4922, 327, 507, 198, 3060, 3, 2742, 198, 3, 1551, 11200, 1950, 507, 198, 3, 1551, 11200, 1950, 507, 198, 697, 275, 6249, 8631, 342, 507, 198, 6413, 88, 275, 1592, 14, 2242, 342, 2742, 198, 3, 2790, 3920, 507, 198, 3937, 275, 286, 7343, 14, 3937, 342, 2742, 198, 3, 2790, 3050, 340, 652, 5712, 1133, 2337, 2575, 507, 198, 3937, 14, 2526, 480, 14764, 31705, 8036, 23875, 399, 551, 8764, 527, 6542, 15027, 507, 198, 3937, 14, 2526, 480, 8366, 31705, 8036, 2845, 23875, 399, 551, 8764, 527, 6542, 15027, 507, 198, 3937, 14, 2526, 480, 4701, 399, 551, 8764, 527, 6542, 15027, 507, 198, 6413, 88, 14, 3543, 342, 2742, 198, 3, 3875, 495, 275, 408, 912, 666, 2257, 14734, 1994, 12117, 15, 2756, 2292, 15, 20436, 15, 10344, 993, 713, 9523, 14, 4737, 7, 1901, 1817, 29531, 17, 63, 22417, 11083, 198, 3, 258, 4362, 15745, 701, 13647, 11083, 198, 3, 221, 198, 1422, 1183, 27828, 701, 14788, 11083, 198, 3, 221, 198, 13572, 701, 14788, 11083, 198, 3, 221, 198, 1278, 15745, 701, 1557, 78, 7, 507, 198, 3, 221, 198, 8, 3817, 998, 12, 4384, 1668, 1217, 12, 8518, 11084, 12, 445, 4656, 8199, 12, 5051, 9481, 2826, 12, 510, 383, 1960, 614, 2736, 624, 2742, 198, 3, 367, 1924, 14689, 570, 11083, 198, 3, 1336, 7392, 570, 536, 370, 1817, 507, 198, 3, 3550, 2248, 666, 2257, 14734, 1827, 507, 198, 3, 1255, 3875, 1827, 507, 198, 3, 10092, 4121, 40, 15744, 26, 221, 340, 3376, 12, 870, 2058, 2742, 198, 3937, 275, 286, 7343, 14, 3937, 342, 2742, 198, 736, 14, 8563, 28615, 2791, 15, 10344, 6542, 14, 7646, 17, 13589, 507, 198, 509, 1584, 315, 5739, 14, 6463, 480, 4856, 4737, 2349, 6319, 259, 327, 31548, 22542, 5385, 15075, 1050, 63, 4737, 63, 493, 275, 661, 891, 10258, 12872, 2818, 1224, 63, 354, 9, 83, 13992, 17753, 4737, 63, 1143, 9, 83, 2736, 12310, 686, 258, 15075, 327, 3232, 314, 14689, 570, 436, 13974, 652, 701, 1962, 15075, 327, 29715, 12, 642, 365, 26200, 2419, 1808, 282, 3412, 1554, 7126, 20639, 1621, 3817, 5385, 1827, 334, 292, 5210, 473, 6704, 7268, 3238, 652, 365, 395, 1325, 473, 6704, 440, 8260, 2855, 68, 15075, 327, 626, 911, 1736, 16174, 9371, 1006, 10460, 436, 652, 365, 440, 8059, 13, 4659, 9025, 15075, 543, 1551, 8, 1725, 12, 283, 4848, 358, 465, 7392, 493, 26, 686, 263, 14909, 5503, 275, 7392, 14, 5503, 8, 4737, 493, 12, 11172, 4009, 297, 18593, 29, 4737, 14, 18495, 63, 4896, 16980, 9, 686, 263, 367, 1962, 315, 14909, 5503, 26, 686, 258, 686, 258, 198, 198, 3, 5678, 15212, 402, 3775, 642, 1077, 506, 10184, 465, 282, 1059, 503, 440, 1396, 686, 3322, 7392, 63, 1143, 275, 942, 686, 3322, 367, 519, 315, 1962, 26, 686, 4483, 7392, 63, 1143, 14, 740, 8, 374, 63, 1955, 8, 82, 430, 258, 686, 463, 686, 3322, 327, 15496, 14689, 570, 2556, 686, 3322, 7392, 63, 815, 275, 469, 686, 4483, 283, 1224, 63, 354, 356, 283, 13107, 17, 8650, 435, 1584, 59, 18, 6809, 24, 467, 686, 4483, 283, 4737, 63, 1143, 356, 620, 8, 4737, 63, 1143, 680, 1913, 360, 8607, 659, 686, 3322, 789, 686, 3777, 686, 3322, 1827, 275, 1050, 63, 4737, 63, 493, 450, 7392, 63, 815, 686, 3777, 686, 3322, 870, 1827, 686, 3777, 686, 3322, 3920, 14, 2526, 8, 1131, 9, 686, 3777, 686, 3322, 327, 10092, 4121, 40, 15744, 26, 2654, 7392, 14, 2184, 342, 503, 2005, 3878, 370, 9658, 734, 4052, 1004 ]
[ 221, 199, 827, 281, 2341, 367, 738, 14, 51, 14, 445, 8764, 527, 7129, 10195, 17775, 12041, 3050, 199, 624, 199, 199, 504, 1748, 281, 492, 627, 199, 199, 533, 738, 5153, 8764, 527, 6542, 26, 199, 198, 1802, 275, 283, 1451, 687, 314, 7129, 577, 530, 287, 78, 2380, 19635, 445, 8764, 527, 3530, 199, 198, 25539, 275, 283, 1014, 921, 1544, 14, 2497, 25253, 14, 16294, 7, 4388, 198, 3, 10902, 1006, 5235, 9330, 315, 2348, 12, 1077, 5235, 1584, 370, 282, 4465, 5235, 2082, 199, 198, 3, 7719, 1104, 3775, 1249, 1172, 2757, 2013, 367, 5235, 14, 1010, 642, 1930, 12, 781, 5594, 1172, 6020, 2839, 199, 198, 3, 2672, 827, 281, 5536, 399, 551, 8764, 527, 1553, 929, 29, 10344, 1553, 315, 642, 1930, 12, 18200, 286, 8764, 527, 666, 1454, 367, 603, 46, 199, 198, 318, 5235, 837, 507, 198, 309, 7017, 2563, 1634, 10092, 4121, 40, 5104, 3960, 2296, 7333, 2381, 24745, 21915, 925, 507, 198, 3, 10092, 4121, 40, 15744, 26, 17955, 29531, 17, 666, 1725, 507, 198, 3, 10092, 4121, 40, 15744, 26, 17955, 13004, 11003, 8692, 687, 19635, 445, 8764, 527, 334, 17919, 330, 15, 67, 333, 697, 2537, 883, 7962, 1454, 336, 15, 3946, 1603, 775, 19, 12, 841, 507, 198, 3, 10092, 4121, 40, 15744, 26, 1379, 3775, 333, 697, 2537, 365, 4903, 436, 5419, 507, 198, 1274, 14, 2224, 342, 4388, 198, 3, 10902, 1006, 7787, 316, 9330, 2348, 14, 31017, 316, 1077, 4572, 3344, 26, 9948, 198, 3, 257, 29379, 4073, 1584, 12, 199, 198, 3, 257, 13729, 570, 1561, 367, 17754, 199, 198, 318, 7787, 837, 507, 198, 3, 10092, 4121, 40, 15744, 26, 1910, 3065, 29531, 17, 666, 1725, 507, 198, 3, 10092, 4121, 40, 15744, 26, 2790, 892, 3050, 507, 198, 3, 10092, 4121, 40, 15744, 26, 6516, 6716, 4079, 641, 22885, 3050, 221, 9068, 198, 3, 11441, 1275, 7646, 17, 666, 1584, 370, 1275, 4737, 507, 198, 3, 11201, 15810, 20387, 2884, 336, 15, 1548, 507, 198, 3, 1255, 63, 1579, 480, 8165, 283, 83, 15, 4537, 7646, 17, 4, 15, 4537, 4737, 4805, 23588, 7646, 17, 531, 507, 198, 1274, 14, 2224, 342, 4388, 198, 3, 10902, 1006, 12096, 9330, 2348, 14, 961, 25613, 2310, 26, 199, 198, 3, 257, 10299, 316, 1584, 436, 10209, 666, 370, 3050, 2986, 367, 22470, 199, 198, 318, 3907, 8, 277, 304, 507, 198, 3060, 3, 507, 198, 3, 510, 1938, 1293, 1951, 7126, 377, 17041, 221, 24564, 1057, 198, 3, 507, 198, 3, 2104, 642, 1824, 348, 3624, 12, 675, 1006, 14689, 1584, 315, 13557, 13330, 17, 4922, 327, 507, 198, 3060, 3, 2742, 198, 3, 1551, 11200, 1950, 507, 198, 3, 1551, 11200, 1950, 507, 198, 697, 275, 6249, 8631, 342, 507, 198, 6413, 88, 275, 1592, 14, 2242, 342, 2742, 198, 3, 2790, 3920, 507, 198, 3937, 275, 286, 7343, 14, 3937, 342, 2742, 198, 3, 2790, 3050, 340, 652, 5712, 1133, 2337, 2575, 507, 198, 3937, 14, 2526, 480, 14764, 31705, 8036, 23875, 399, 551, 8764, 527, 6542, 15027, 507, 198, 3937, 14, 2526, 480, 8366, 31705, 8036, 2845, 23875, 399, 551, 8764, 527, 6542, 15027, 507, 198, 3937, 14, 2526, 480, 4701, 399, 551, 8764, 527, 6542, 15027, 507, 198, 6413, 88, 14, 3543, 342, 2742, 198, 3, 3875, 495, 275, 408, 912, 666, 2257, 14734, 1994, 12117, 15, 2756, 2292, 15, 20436, 15, 10344, 993, 713, 9523, 14, 4737, 7, 1901, 1817, 29531, 17, 63, 22417, 11083, 198, 3, 258, 4362, 15745, 701, 13647, 11083, 198, 3, 221, 198, 1422, 1183, 27828, 701, 14788, 11083, 198, 3, 221, 198, 13572, 701, 14788, 11083, 198, 3, 221, 198, 1278, 15745, 701, 1557, 78, 7, 507, 198, 3, 221, 198, 8, 3817, 998, 12, 4384, 1668, 1217, 12, 8518, 11084, 12, 445, 4656, 8199, 12, 5051, 9481, 2826, 12, 510, 383, 1960, 614, 2736, 624, 2742, 198, 3, 367, 1924, 14689, 570, 11083, 198, 3, 1336, 7392, 570, 536, 370, 1817, 507, 198, 3, 3550, 2248, 666, 2257, 14734, 1827, 507, 198, 3, 1255, 3875, 1827, 507, 198, 3, 10092, 4121, 40, 15744, 26, 221, 340, 3376, 12, 870, 2058, 2742, 198, 3937, 275, 286, 7343, 14, 3937, 342, 2742, 198, 736, 14, 8563, 28615, 2791, 15, 10344, 6542, 14, 7646, 17, 13589, 507, 198, 509, 1584, 315, 5739, 14, 6463, 480, 4856, 4737, 2349, 6319, 259, 327, 31548, 22542, 5385, 15075, 1050, 63, 4737, 63, 493, 275, 661, 891, 10258, 12872, 2818, 1224, 63, 354, 9, 83, 13992, 17753, 4737, 63, 1143, 9, 83, 2736, 12310, 686, 258, 15075, 327, 3232, 314, 14689, 570, 436, 13974, 652, 701, 1962, 15075, 327, 29715, 12, 642, 365, 26200, 2419, 1808, 282, 3412, 1554, 7126, 20639, 1621, 3817, 5385, 1827, 334, 292, 5210, 473, 6704, 7268, 3238, 652, 365, 395, 1325, 473, 6704, 440, 8260, 2855, 68, 15075, 327, 626, 911, 1736, 16174, 9371, 1006, 10460, 436, 652, 365, 440, 8059, 13, 4659, 9025, 15075, 543, 1551, 8, 1725, 12, 283, 4848, 358, 465, 7392, 493, 26, 686, 263, 14909, 5503, 275, 7392, 14, 5503, 8, 4737, 493, 12, 11172, 4009, 297, 18593, 29, 4737, 14, 18495, 63, 4896, 16980, 9, 686, 263, 367, 1962, 315, 14909, 5503, 26, 686, 258, 686, 258, 198, 198, 3, 5678, 15212, 402, 3775, 642, 1077, 506, 10184, 465, 282, 1059, 503, 440, 1396, 686, 3322, 7392, 63, 1143, 275, 942, 686, 3322, 367, 519, 315, 1962, 26, 686, 4483, 7392, 63, 1143, 14, 740, 8, 374, 63, 1955, 8, 82, 430, 258, 686, 463, 686, 3322, 327, 15496, 14689, 570, 2556, 686, 3322, 7392, 63, 815, 275, 469, 686, 4483, 283, 1224, 63, 354, 356, 283, 13107, 17, 8650, 435, 1584, 59, 18, 6809, 24, 467, 686, 4483, 283, 4737, 63, 1143, 356, 620, 8, 4737, 63, 1143, 680, 1913, 360, 8607, 659, 686, 3322, 789, 686, 3777, 686, 3322, 1827, 275, 1050, 63, 4737, 63, 493, 450, 7392, 63, 815, 686, 3777, 686, 3322, 870, 1827, 686, 3777, 686, 3322, 3920, 14, 2526, 8, 1131, 9, 686, 3777, 686, 3322, 327, 10092, 4121, 40, 15744, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ssorgatem/pulsar
galaxy/tools/deps/resolvers/modules.py
1
6098
""" This file contains the outline of an implementation to load environment modules (http://modules.sourceforge.net/). This is a community contributed feature and the core Galaxy team does utilize it, hence support for it will be minimal. The Galaxy team eagerly welcomes community contribution and maintenance however. """ from os import environ, pathsep from os.path import exists, isdir, join from six import StringIO from subprocess import Popen, PIPE from ..resolvers import DependencyResolver, INDETERMINATE_DEPENDENCY, Dependency import logging log = logging.getLogger( __name__ ) DEFAULT_MODULECMD_PATH = "modulecmd" # Just check path DEFAULT_MODULE_PATH = '/usr/share/modules/modulefiles' DEFAULT_INDICATOR = '(default)' DEFAULT_MODULE_PREFETCH = "true" UNKNOWN_FIND_BY_MESSAGE = "ModuleDependencyResolver does not know how to find modules by [%s], find_by should be one of %s" class ModuleDependencyResolver(DependencyResolver): resolver_type = "modules" def __init__(self, dependency_manager, **kwds): self.versionless = _string_as_bool(kwds.get('versionless', 'false')) find_by = kwds.get('find_by', 'avail') prefetch = _string_as_bool(kwds.get('prefetch', DEFAULT_MODULE_PREFETCH)) self.modulecmd = kwds.get('modulecmd', DEFAULT_MODULECMD_PATH) if find_by == 'directory': modulepath = kwds.get('modulepath', self.__default_modulespath()) self.module_checker = DirectoryModuleChecker(self, modulepath, prefetch) elif find_by == 'avail': self.module_checker = AvailModuleChecker(self, prefetch) else: raise Exception(UNKNOWN_FIND_BY_MESSAGE % (find_by, ["avail", "directory"])) def __default_modulespath(self): if 'MODULEPATH' in environ: module_path = environ['MODULEPATH'] elif 'MODULESHOME' in environ: module_path = join(environ['MODULESHOME'], 'modulefiles') else: module_path = DEFAULT_MODULE_PATH return module_path def resolve( self, name, version, type, **kwds ): if type != "package": return INDETERMINATE_DEPENDENCY if self.__has_module(name, version): return ModuleDependency(self, name, version) elif self.versionless and self.__has_module(name, None): return ModuleDependency(self, name, None) return INDETERMINATE_DEPENDENCY def __has_module(self, name, version): return self.module_checker.has_module(name, version) class DirectoryModuleChecker(object): def __init__(self, module_dependency_resolver, modulepath, prefetch): self.module_dependency_resolver = module_dependency_resolver self.directories = modulepath.split(pathsep) if prefetch: log.warn("Created module dependency resolver with prefetch enabled, but directory module checker does not support this.") pass def has_module(self, module, version): has_module = False for directory in self.directories: module_directory = join(directory, module) has_module_directory = isdir( module_directory ) if not version: has_module = has_module_directory or exists(module_directory) # could be a bare modulefile else: modulefile = join( module_directory, version ) has_modulefile = exists( modulefile ) has_module = has_module_directory and has_modulefile if has_module: break return has_module class AvailModuleChecker(object): def __init__(self, module_dependency_resolver, prefetch): self.module_dependency_resolver = module_dependency_resolver if prefetch: prefetched_modules = [] for module in self.__modules(): prefetched_modules.append(module) else: prefetched_modules = None self.prefetched_modules = prefetched_modules def has_module(self, module, version): module_generator = self.prefetched_modules if module_generator is None: module_generator = self.__modules() for module_name, module_version in module_generator: names_match = module == module_name module_match = names_match and (version is None or module_version == version) if module_match: return True return False def __modules(self): raw_output = self.__module_avail_output().decode("utf-8") for line in StringIO(raw_output): line = line and line.strip() if not line or line.startswith("-"): continue line_modules = line.split() for module in line_modules: if module.endswith(DEFAULT_INDICATOR): module = module[0:-len(DEFAULT_INDICATOR)].strip() module_parts = module.split('/') module_version = None if len(module_parts) == 2: module_version = module_parts[1] module_name = module_parts[0] yield module_name, module_version def __module_avail_output(self): avail_command = [self.module_dependency_resolver.modulecmd, 'sh', 'avail'] return Popen(avail_command, stderr=PIPE).communicate()[1] class ModuleDependency(Dependency): def __init__(self, module_dependency_resolver, module_name, module_version=None): self.module_dependency_resolver = module_dependency_resolver self.module_name = module_name self.module_version = module_version def shell_commands(self, requirement): module_to_load = self.module_name if self.module_version: module_to_load = '%s/%s' % (self.module_name, self.module_version) command = 'eval `%s sh load %s`' % (self.module_dependency_resolver.modulecmd, module_to_load) return command def _string_as_bool( value ): return str( value ).lower() == "true" __all__ = ['ModuleDependencyResolver']
apache-2.0
[ 624, 199, 2765, 570, 3509, 314, 17964, 402, 376, 4514, 370, 2248, 3734, 4621, 199, 8, 1014, 921, 3112, 14, 22943, 14, 846, 15, 680, 199, 199, 2765, 365, 282, 23633, 406, 24855, 3878, 436, 314, 6170, 598, 15914, 8099, 1630, 7678, 13559, 199, 390, 12, 19407, 2291, 367, 652, 911, 506, 13460, 14, 710, 598, 15914, 8099, 21719, 590, 336, 14628, 83, 199, 9387, 406, 15980, 436, 21964, 13432, 14, 199, 624, 199, 504, 747, 492, 6160, 12, 931, 4127, 199, 504, 747, 14, 515, 492, 3495, 12, 26004, 12, 4263, 199, 504, 3816, 492, 5228, 199, 504, 3873, 492, 13995, 12, 22773, 199, 199, 504, 2508, 12640, 492, 22922, 12407, 12, 1621, 17442, 540, 4896, 1951, 63, 25743, 17059, 12, 22922, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 8, 636, 354, 363, 776, 199, 199, 3472, 63, 10001, 9744, 63, 3243, 275, 298, 578, 1760, 2, 221, 327, 13870, 1104, 931, 199, 3472, 63, 10001, 63, 3243, 275, 1994, 2647, 15, 6251, 15, 3112, 15, 578, 1725, 7, 199, 3472, 63, 23723, 6467, 275, 8189, 885, 3171, 199, 3472, 63, 10001, 63, 4225, 32097, 275, 298, 2052, 2, 199, 11588, 63, 27087, 63, 8285, 63, 8272, 275, 298, 2377, 14403, 12407, 1630, 440, 5715, 4212, 370, 2342, 4621, 701, 8978, 83, 467, 2342, 63, 991, 1077, 506, 1373, 402, 450, 83, 2, 421, 199, 533, 5673, 14403, 12407, 8, 14403, 12407, 304, 272, 15611, 63, 466, 275, 298, 3112, 2, 339, 347, 636, 826, 721, 277, 12, 5936, 63, 2609, 12, 1011, 10340, 304, 267, 291, 14, 1023, 2003, 275, 485, 875, 63, 305, 63, 2245, 8, 10340, 14, 362, 360, 1023, 2003, 297, 283, 3910, 1333, 267, 2342, 63, 991, 275, 16286, 14, 362, 360, 1623, 63, 991, 297, 283, 18961, 358, 267, 21544, 275, 485, 875, 63, 305, 63, 2245, 8, 10340, 14, 362, 360, 15576, 297, 6186, 63, 10001, 63, 4225, 32097, 430, 267, 291, 14, 578, 1760, 275, 16286, 14, 362, 360, 578, 1760, 297, 6186, 63, 10001, 9744, 63, 3243, 9, 267, 340, 2342, 63, 991, 508, 283, 3619, 356, 288, 859, 515, 275, 16286, 14, 362, 360, 578, 515, 297, 291, 855, 885, 63, 3112, 515, 1012, 288, 291, 14, 578, 63, 6743, 275, 15191, 2377, 3048, 8, 277, 12, 859, 515, 12, 21544, 9, 267, 916, 2342, 63, 991, 508, 283, 18961, 356, 288, 291, 14, 578, 63, 6743, 275, 16599, 1054, 2377, 3048, 8, 277, 12, 21544, 9, 267, 587, 26, 288, 746, 2186, 8, 11588, 63, 27087, 63, 8285, 63, 8272, 450, 334, 1623, 63, 991, 12, 2097, 18961, 401, 298, 3619, 13045, 339, 347, 636, 885, 63, 3112, 515, 8, 277, 304, 267, 340, 283, 10001, 3243, 7, 315, 6160, 26, 288, 859, 63, 515, 275, 6160, 459, 10001, 3243, 418, 267, 916, 283, 21194, 9524, 7, 315, 6160, 26, 288, 859, 63, 515, 275, 4263, 8, 2314, 459, 21194, 9524, 995, 283, 578, 1725, 358, 267, 587, 26, 288, 859, 63, 515, 275, 6186, 63, 10001, 63, 3243, 267, 372, 859, 63, 515, 339, 347, 7512, 8, 291, 12, 536, 12, 1015, 12, 730, 12, 1011, 10340, 3461, 267, 340, 730, 1137, 298, 2491, 582, 288, 372, 1621, 17442, 540, 4896, 1951, 63, 25743, 17059, 398, 340, 291, 855, 1989, 63, 578, 8, 354, 12, 1015, 304, 288, 372, 5673, 14403, 8, 277, 12, 536, 12, 1015, 9, 267, 916, 291, 14, 1023, 2003, 436, 291, 855, 1989, 63, 578, 8, 354, 12, 488, 304, 288, 372, 5673, 14403, 8, 277, 12, 536, 12, 488, 9, 398, 372, 1621, 17442, 540, 4896, 1951, 63, 25743, 17059, 339, 347, 636, 1989, 63, 578, 8, 277, 12, 536, 12, 1015, 304, 267, 372, 291, 14, 578, 63, 6743, 14, 1989, 63, 578, 8, 354, 12, 1015, 9, 421, 199, 533, 15191, 2377, 3048, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 859, 63, 8575, 63, 7717, 12, 859, 515, 12, 21544, 304, 267, 291, 14, 578, 63, 8575, 63, 7717, 275, 859, 63, 8575, 63, 7717, 267, 291, 14, 12629, 275, 859, 515, 14, 1294, 8, 17843, 9, 267, 340, 21544, 26, 288, 943, 14, 4050, 480, 10502, 859, 5936, 15611, 543, 21544, 5223, 12, 1325, 2082, 859, 7739, 1630, 440, 2291, 642, 2685, 288, 986, 339, 347, 965, 63, 578, 8, 277, 12, 859, 12, 1015, 304, 267, 965, 63, 578, 275, 756, 267, 367, 2082, 315, 291, 14, 12629, 26, 288, 859, 63, 3619, 275, 4263, 8, 3619, 12, 859, 9, 288, 965, 63, 578, 63, 3619, 275, 26004, 8, 859, 63, 3619, 776, 288, 340, 440, 1015, 26, 355, 965, 63, 578, 275, 965, 63, 578, 63, 3619, 503, 3495, 8, 578, 63, 3619, 9, 221, 327, 4293, 506, 282, 18753, 859, 493, 288, 587, 26, 355, 859, 493, 275, 4263, 8, 221, 859, 63, 3619, 12, 1015, 776, 355, 965, 63, 578, 493, 275, 3495, 8, 859, 493, 776, 355, 965, 63, 578, 275, 965, 63, 578, 63, 3619, 436, 965, 63, 578, 493, 288, 340, 965, 63, 578, 26, 355, 2059, 267, 372, 965, 63, 578, 421, 199, 533, 16599, 1054, 2377, 3048, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 859, 63, 8575, 63, 7717, 12, 21544, 304, 267, 291, 14, 578, 63, 8575, 63, 7717, 275, 859, 63, 8575, 63, 7717, 267, 340, 21544, 26, 288, 20491, 13534, 63, 3112, 275, 942, 288, 367, 859, 315, 291, 855, 3112, 837, 355, 20491, 13534, 63, 3112, 14, 740, 8, 578, 9, 267, 587, 26, 288, 20491, 13534, 63, 3112, 275, 488, 267, 291, 14, 13829, 13534, 63, 3112, 275, 20491, 13534, 63, 3112, 339, 347, 965, 63, 578, 8, 277, 12, 859, 12, 1015, 304, 267, 859, 63, 4679, 275, 291, 14, 13829, 13534, 63, 3112, 267, 340, 859, 63, 4679, 365, 488, 26, 288, 859, 63, 4679, 275, 291, 855, 3112, 342, 398, 367, 859, 63, 354, 12, 859, 63, 1023, 315, 859, 63, 4679, 26, 288, 1561, 63, 1431, 275, 859, 508, 859, 63, 354, 288, 859, 63, 1431, 275, 1561, 63, 1431, 436, 334, 1023, 365, 488, 503, 859, 63, 1023, 508, 1015, 9, 288, 340, 859 ]
[ 199, 2765, 570, 3509, 314, 17964, 402, 376, 4514, 370, 2248, 3734, 4621, 199, 8, 1014, 921, 3112, 14, 22943, 14, 846, 15, 680, 199, 199, 2765, 365, 282, 23633, 406, 24855, 3878, 436, 314, 6170, 598, 15914, 8099, 1630, 7678, 13559, 199, 390, 12, 19407, 2291, 367, 652, 911, 506, 13460, 14, 710, 598, 15914, 8099, 21719, 590, 336, 14628, 83, 199, 9387, 406, 15980, 436, 21964, 13432, 14, 199, 624, 199, 504, 747, 492, 6160, 12, 931, 4127, 199, 504, 747, 14, 515, 492, 3495, 12, 26004, 12, 4263, 199, 504, 3816, 492, 5228, 199, 504, 3873, 492, 13995, 12, 22773, 199, 199, 504, 2508, 12640, 492, 22922, 12407, 12, 1621, 17442, 540, 4896, 1951, 63, 25743, 17059, 12, 22922, 199, 199, 646, 2050, 199, 793, 275, 2050, 14, 5572, 8, 636, 354, 363, 776, 199, 199, 3472, 63, 10001, 9744, 63, 3243, 275, 298, 578, 1760, 2, 221, 327, 13870, 1104, 931, 199, 3472, 63, 10001, 63, 3243, 275, 1994, 2647, 15, 6251, 15, 3112, 15, 578, 1725, 7, 199, 3472, 63, 23723, 6467, 275, 8189, 885, 3171, 199, 3472, 63, 10001, 63, 4225, 32097, 275, 298, 2052, 2, 199, 11588, 63, 27087, 63, 8285, 63, 8272, 275, 298, 2377, 14403, 12407, 1630, 440, 5715, 4212, 370, 2342, 4621, 701, 8978, 83, 467, 2342, 63, 991, 1077, 506, 1373, 402, 450, 83, 2, 421, 199, 533, 5673, 14403, 12407, 8, 14403, 12407, 304, 272, 15611, 63, 466, 275, 298, 3112, 2, 339, 347, 636, 826, 721, 277, 12, 5936, 63, 2609, 12, 1011, 10340, 304, 267, 291, 14, 1023, 2003, 275, 485, 875, 63, 305, 63, 2245, 8, 10340, 14, 362, 360, 1023, 2003, 297, 283, 3910, 1333, 267, 2342, 63, 991, 275, 16286, 14, 362, 360, 1623, 63, 991, 297, 283, 18961, 358, 267, 21544, 275, 485, 875, 63, 305, 63, 2245, 8, 10340, 14, 362, 360, 15576, 297, 6186, 63, 10001, 63, 4225, 32097, 430, 267, 291, 14, 578, 1760, 275, 16286, 14, 362, 360, 578, 1760, 297, 6186, 63, 10001, 9744, 63, 3243, 9, 267, 340, 2342, 63, 991, 508, 283, 3619, 356, 288, 859, 515, 275, 16286, 14, 362, 360, 578, 515, 297, 291, 855, 885, 63, 3112, 515, 1012, 288, 291, 14, 578, 63, 6743, 275, 15191, 2377, 3048, 8, 277, 12, 859, 515, 12, 21544, 9, 267, 916, 2342, 63, 991, 508, 283, 18961, 356, 288, 291, 14, 578, 63, 6743, 275, 16599, 1054, 2377, 3048, 8, 277, 12, 21544, 9, 267, 587, 26, 288, 746, 2186, 8, 11588, 63, 27087, 63, 8285, 63, 8272, 450, 334, 1623, 63, 991, 12, 2097, 18961, 401, 298, 3619, 13045, 339, 347, 636, 885, 63, 3112, 515, 8, 277, 304, 267, 340, 283, 10001, 3243, 7, 315, 6160, 26, 288, 859, 63, 515, 275, 6160, 459, 10001, 3243, 418, 267, 916, 283, 21194, 9524, 7, 315, 6160, 26, 288, 859, 63, 515, 275, 4263, 8, 2314, 459, 21194, 9524, 995, 283, 578, 1725, 358, 267, 587, 26, 288, 859, 63, 515, 275, 6186, 63, 10001, 63, 3243, 267, 372, 859, 63, 515, 339, 347, 7512, 8, 291, 12, 536, 12, 1015, 12, 730, 12, 1011, 10340, 3461, 267, 340, 730, 1137, 298, 2491, 582, 288, 372, 1621, 17442, 540, 4896, 1951, 63, 25743, 17059, 398, 340, 291, 855, 1989, 63, 578, 8, 354, 12, 1015, 304, 288, 372, 5673, 14403, 8, 277, 12, 536, 12, 1015, 9, 267, 916, 291, 14, 1023, 2003, 436, 291, 855, 1989, 63, 578, 8, 354, 12, 488, 304, 288, 372, 5673, 14403, 8, 277, 12, 536, 12, 488, 9, 398, 372, 1621, 17442, 540, 4896, 1951, 63, 25743, 17059, 339, 347, 636, 1989, 63, 578, 8, 277, 12, 536, 12, 1015, 304, 267, 372, 291, 14, 578, 63, 6743, 14, 1989, 63, 578, 8, 354, 12, 1015, 9, 421, 199, 533, 15191, 2377, 3048, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 859, 63, 8575, 63, 7717, 12, 859, 515, 12, 21544, 304, 267, 291, 14, 578, 63, 8575, 63, 7717, 275, 859, 63, 8575, 63, 7717, 267, 291, 14, 12629, 275, 859, 515, 14, 1294, 8, 17843, 9, 267, 340, 21544, 26, 288, 943, 14, 4050, 480, 10502, 859, 5936, 15611, 543, 21544, 5223, 12, 1325, 2082, 859, 7739, 1630, 440, 2291, 642, 2685, 288, 986, 339, 347, 965, 63, 578, 8, 277, 12, 859, 12, 1015, 304, 267, 965, 63, 578, 275, 756, 267, 367, 2082, 315, 291, 14, 12629, 26, 288, 859, 63, 3619, 275, 4263, 8, 3619, 12, 859, 9, 288, 965, 63, 578, 63, 3619, 275, 26004, 8, 859, 63, 3619, 776, 288, 340, 440, 1015, 26, 355, 965, 63, 578, 275, 965, 63, 578, 63, 3619, 503, 3495, 8, 578, 63, 3619, 9, 221, 327, 4293, 506, 282, 18753, 859, 493, 288, 587, 26, 355, 859, 493, 275, 4263, 8, 221, 859, 63, 3619, 12, 1015, 776, 355, 965, 63, 578, 493, 275, 3495, 8, 859, 493, 776, 355, 965, 63, 578, 275, 965, 63, 578, 63, 3619, 436, 965, 63, 578, 493, 288, 340, 965, 63, 578, 26, 355, 2059, 267, 372, 965, 63, 578, 421, 199, 533, 16599, 1054, 2377, 3048, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 859, 63, 8575, 63, 7717, 12, 21544, 304, 267, 291, 14, 578, 63, 8575, 63, 7717, 275, 859, 63, 8575, 63, 7717, 267, 340, 21544, 26, 288, 20491, 13534, 63, 3112, 275, 942, 288, 367, 859, 315, 291, 855, 3112, 837, 355, 20491, 13534, 63, 3112, 14, 740, 8, 578, 9, 267, 587, 26, 288, 20491, 13534, 63, 3112, 275, 488, 267, 291, 14, 13829, 13534, 63, 3112, 275, 20491, 13534, 63, 3112, 339, 347, 965, 63, 578, 8, 277, 12, 859, 12, 1015, 304, 267, 859, 63, 4679, 275, 291, 14, 13829, 13534, 63, 3112, 267, 340, 859, 63, 4679, 365, 488, 26, 288, 859, 63, 4679, 275, 291, 855, 3112, 342, 398, 367, 859, 63, 354, 12, 859, 63, 1023, 315, 859, 63, 4679, 26, 288, 1561, 63, 1431, 275, 859, 508, 859, 63, 354, 288, 859, 63, 1431, 275, 1561, 63, 1431, 436, 334, 1023, 365, 488, 503, 859, 63, 1023, 508, 1015, 9, 288, 340, 859, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sdague/home-assistant
homeassistant/components/isy994/binary_sensor.py
9
18206
"""Support for ISY994 binary sensors.""" from datetime import timedelta from typing import Callable, Union from pyisy.constants import ( CMD_OFF, CMD_ON, ISY_VALUE_UNKNOWN, PROTO_INSTEON, PROTO_ZWAVE, ) from pyisy.nodes import Group, Node from homeassistant.components.binary_sensor import ( DEVICE_CLASS_BATTERY, DEVICE_CLASS_COLD, DEVICE_CLASS_HEAT, DEVICE_CLASS_LIGHT, DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOTION, DEVICE_CLASS_OPENING, DEVICE_CLASS_PROBLEM, DOMAIN as BINARY_SENSOR, BinarySensorEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.typing import HomeAssistantType from homeassistant.util import dt as dt_util from .const import ( _LOGGER, BINARY_SENSOR_DEVICE_TYPES_ISY, BINARY_SENSOR_DEVICE_TYPES_ZWAVE, DOMAIN as ISY994_DOMAIN, ISY994_NODES, ISY994_PROGRAMS, SUBNODE_CLIMATE_COOL, SUBNODE_CLIMATE_HEAT, SUBNODE_DUSK_DAWN, SUBNODE_HEARTBEAT, SUBNODE_LOW_BATTERY, SUBNODE_MOTION_DISABLED, SUBNODE_NEGATIVE, SUBNODE_TAMPER, TYPE_CATEGORY_CLIMATE, TYPE_INSTEON_MOTION, ) from .entity import ISYNodeEntity, ISYProgramEntity from .helpers import migrate_old_unique_ids DEVICE_PARENT_REQUIRED = [ DEVICE_CLASS_OPENING, DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOTION, ] async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[list], None], ) -> bool: """Set up the ISY994 binary sensor platform.""" devices = [] devices_by_address = {} child_nodes = [] hass_isy_data = hass.data[ISY994_DOMAIN][entry.entry_id] for node in hass_isy_data[ISY994_NODES][BINARY_SENSOR]: device_class, device_type = _detect_device_type_and_class(node) if node.protocol == PROTO_INSTEON: if node.parent_node is not None: # We'll process the Insteon child nodes last, to ensure all parent # nodes have been processed child_nodes.append((node, device_class, device_type)) continue device = ISYInsteonBinarySensorEntity(node, device_class) else: device = ISYBinarySensorEntity(node, device_class) devices.append(device) devices_by_address[node.address] = device # Handle some special child node cases for Insteon Devices for (node, device_class, device_type) in child_nodes: subnode_id = int(node.address.split(" ")[-1], 16) # Handle Insteon Thermostats if device_type.startswith(TYPE_CATEGORY_CLIMATE): if subnode_id == SUBNODE_CLIMATE_COOL: # Subnode 2 is the "Cool Control" sensor # It never reports its state until first use is # detected after an ISY Restart, so we assume it's off. # As soon as the ISY Event Stream connects if it has a # valid state, it will be set. device = ISYInsteonBinarySensorEntity(node, DEVICE_CLASS_COLD, False) devices.append(device) elif subnode_id == SUBNODE_CLIMATE_HEAT: # Subnode 3 is the "Heat Control" sensor device = ISYInsteonBinarySensorEntity(node, DEVICE_CLASS_HEAT, False) devices.append(device) continue if device_class in DEVICE_PARENT_REQUIRED: parent_device = devices_by_address.get(node.parent_node.address) if not parent_device: _LOGGER.error( "Node %s has a parent node %s, but no device " "was created for the parent. Skipping", node.address, node.parent_node, ) continue if device_class in (DEVICE_CLASS_OPENING, DEVICE_CLASS_MOISTURE): # These sensors use an optional "negative" subnode 2 to # snag all state changes if subnode_id == SUBNODE_NEGATIVE: parent_device.add_negative_node(node) elif subnode_id == SUBNODE_HEARTBEAT: # Subnode 4 is the heartbeat node, which we will # represent as a separate binary_sensor device = ISYBinarySensorHeartbeat(node, parent_device) parent_device.add_heartbeat_device(device) devices.append(device) continue if ( device_class == DEVICE_CLASS_MOTION and device_type is not None and any([device_type.startswith(t) for t in TYPE_INSTEON_MOTION]) ): # Special cases for Insteon Motion Sensors I & II: # Some subnodes never report status until activated, so # the initial state is forced "OFF"/"NORMAL" if the # parent device has a valid state. This is corrected # upon connection to the ISY event stream if subnode has a valid state. initial_state = None if parent_device.state is None else False if subnode_id == SUBNODE_DUSK_DAWN: # Subnode 2 is the Dusk/Dawn sensor device = ISYInsteonBinarySensorEntity(node, DEVICE_CLASS_LIGHT) devices.append(device) continue if subnode_id == SUBNODE_LOW_BATTERY: # Subnode 3 is the low battery node device = ISYInsteonBinarySensorEntity( node, DEVICE_CLASS_BATTERY, initial_state ) devices.append(device) continue if subnode_id in SUBNODE_TAMPER: # Tamper Sub-node for MS II. Sometimes reported as "A" sometimes # reported as "10", which translate from Hex to 10 and 16 resp. device = ISYInsteonBinarySensorEntity( node, DEVICE_CLASS_PROBLEM, initial_state ) devices.append(device) continue if subnode_id in SUBNODE_MOTION_DISABLED: # Motion Disabled Sub-node for MS II ("D" or "13") device = ISYInsteonBinarySensorEntity(node) devices.append(device) continue # We don't yet have any special logic for other sensor # types, so add the nodes as individual devices device = ISYBinarySensorEntity(node, device_class) devices.append(device) for name, status, _ in hass_isy_data[ISY994_PROGRAMS][BINARY_SENSOR]: devices.append(ISYBinarySensorProgramEntity(name, status)) await migrate_old_unique_ids(hass, BINARY_SENSOR, devices) async_add_entities(devices) def _detect_device_type_and_class(node: Union[Group, Node]) -> (str, str): try: device_type = node.type except AttributeError: # The type attribute didn't exist in the ISY's API response return (None, None) # Z-Wave Devices: if node.protocol == PROTO_ZWAVE: device_type = f"Z{node.zwave_props.category}" for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ZWAVE]: if ( node.zwave_props.category in BINARY_SENSOR_DEVICE_TYPES_ZWAVE[device_class] ): return device_class, device_type return (None, device_type) # Other devices (incl Insteon.) for device_class in [*BINARY_SENSOR_DEVICE_TYPES_ISY]: if any( [ device_type.startswith(t) for t in set(BINARY_SENSOR_DEVICE_TYPES_ISY[device_class]) ] ): return device_class, device_type return (None, device_type) class ISYBinarySensorEntity(ISYNodeEntity, BinarySensorEntity): """Representation of a basic ISY994 binary sensor device.""" def __init__(self, node, force_device_class=None, unknown_state=None) -> None: """Initialize the ISY994 binary sensor device.""" super().__init__(node) self._device_class = force_device_class @property def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on.""" if self._node.status == ISY_VALUE_UNKNOWN: return None return bool(self._node.status) @property def device_class(self) -> str: """Return the class of this device. This was discovered by parsing the device type code during init """ return self._device_class class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity): """Representation of an ISY994 Insteon binary sensor device. Often times, a single device is represented by multiple nodes in the ISY, allowing for different nuances in how those devices report their on and off events. This class turns those multiple nodes into a single Home Assistant entity and handles both ways that ISY binary sensors can work. """ def __init__(self, node, force_device_class=None, unknown_state=None) -> None: """Initialize the ISY994 binary sensor device.""" super().__init__(node, force_device_class) self._negative_node = None self._heartbeat_device = None if self._node.status == ISY_VALUE_UNKNOWN: self._computed_state = unknown_state self._status_was_unknown = True else: self._computed_state = bool(self._node.status) self._status_was_unknown = False async def async_added_to_hass(self) -> None: """Subscribe to the node and subnode event emitters.""" await super().async_added_to_hass() self._node.control_events.subscribe(self._positive_node_control_handler) if self._negative_node is not None: self._negative_node.control_events.subscribe( self._negative_node_control_handler ) def add_heartbeat_device(self, device) -> None: """Register a heartbeat device for this sensor. The heartbeat node beats on its own, but we can gain a little reliability by considering any node activity for this sensor to be a heartbeat as well. """ self._heartbeat_device = device def _heartbeat(self) -> None: """Send a heartbeat to our heartbeat device, if we have one.""" if self._heartbeat_device is not None: self._heartbeat_device.heartbeat() def add_negative_node(self, child) -> None: """Add a negative node to this binary sensor device. The negative node is a node that can receive the 'off' events for the sensor, depending on device configuration and type. """ self._negative_node = child if self._negative_node.status != ISY_VALUE_UNKNOWN: # If the negative node has a value, it means the negative node is # in use for this device. Next we need to check to see if the # negative and positive nodes disagree on the state (both ON or # both OFF). if self._negative_node.status == self._node.status: # The states disagree, therefore we cannot determine the state # of the sensor until we receive our first ON event. self._computed_state = None def _negative_node_control_handler(self, event: object) -> None: """Handle an "On" control event from the "negative" node.""" if event.control == CMD_ON: _LOGGER.debug( "Sensor %s turning Off via the Negative node sending a DON command", self.name, ) self._computed_state = False self.schedule_update_ha_state() self._heartbeat() def _positive_node_control_handler(self, event: object) -> None: """Handle On and Off control event coming from the primary node. Depending on device configuration, sometimes only On events will come to this node, with the negative node representing Off events """ if event.control == CMD_ON: _LOGGER.debug( "Sensor %s turning On via the Primary node sending a DON command", self.name, ) self._computed_state = True self.schedule_update_ha_state() self._heartbeat() if event.control == CMD_OFF: _LOGGER.debug( "Sensor %s turning Off via the Primary node sending a DOF command", self.name, ) self._computed_state = False self.schedule_update_ha_state() self._heartbeat() def on_update(self, event: object) -> None: """Primary node status updates. We MOSTLY ignore these updates, as we listen directly to the Control events on all nodes for this device. However, there is one edge case: If a leak sensor is unknown, due to a recent reboot of the ISY, the status will get updated to dry upon the first heartbeat. This status update is the only way that a leak sensor's status changes without an accompanying Control event, so we need to watch for it. """ if self._status_was_unknown and self._computed_state is None: self._computed_state = bool(self._node.status) self._status_was_unknown = False self.schedule_update_ha_state() self._heartbeat() @property def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on. Insteon leak sensors set their primary node to On when the state is DRY, not WET, so we invert the binary state if the user indicates that it is a moisture sensor. """ if self._computed_state is None: # Do this first so we don't invert None on moisture sensors return None if self.device_class == DEVICE_CLASS_MOISTURE: return not self._computed_state return self._computed_state class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity): """Representation of the battery state of an ISY994 sensor.""" def __init__(self, node, parent_device) -> None: """Initialize the ISY994 binary sensor device. Computed state is set to UNKNOWN unless the ISY provided a valid state. See notes above regarding ISY Sensor status on ISY restart. If a valid state is provided (either on or off), the computed state in HA is set to OFF (Normal). If the heartbeat is not received in 25 hours then the computed state is set to ON (Low Battery). """ super().__init__(node) self._parent_device = parent_device self._heartbeat_timer = None self._computed_state = None if self.state is None: self._computed_state = False async def async_added_to_hass(self) -> None: """Subscribe to the node and subnode event emitters.""" await super().async_added_to_hass() self._node.control_events.subscribe(self._heartbeat_node_control_handler) # Start the timer on bootup, so we can change from UNKNOWN to OFF self._restart_timer() def _heartbeat_node_control_handler(self, event: object) -> None: """Update the heartbeat timestamp when any ON/OFF event is sent. The ISY uses both DON and DOF commands (alternating) for a heartbeat. """ if event.control in [CMD_ON, CMD_OFF]: self.heartbeat() def heartbeat(self): """Mark the device as online, and restart the 25 hour timer. This gets called when the heartbeat node beats, but also when the parent sensor sends any events, as we can trust that to mean the device is online. This mitigates the risk of false positives due to a single missed heartbeat event. """ self._computed_state = False self._restart_timer() self.schedule_update_ha_state() def _restart_timer(self): """Restart the 25 hour timer.""" try: self._heartbeat_timer() self._heartbeat_timer = None except TypeError: # No heartbeat timer is active pass @callback def timer_elapsed(now) -> None: """Heartbeat missed; set state to ON to indicate dead battery.""" self._computed_state = True self._heartbeat_timer = None self.schedule_update_ha_state() point_in_time = dt_util.utcnow() + timedelta(hours=25) _LOGGER.debug( "Heartbeat timer starting. Now: %s Then: %s", dt_util.utcnow(), point_in_time, ) self._heartbeat_timer = async_track_point_in_utc_time( self.hass, timer_elapsed, point_in_time ) def on_update(self, event: object) -> None: """Ignore node status updates. We listen directly to the Control events for this device. """ @property def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on. Note: This method will return false if the current state is UNKNOWN which occurs after a restart until the first heartbeat or control parent control event is received. """ return bool(self._computed_state) @property def device_class(self) -> str: """Get the class of this device.""" return DEVICE_CLASS_BATTERY @property def device_state_attributes(self): """Get the state attributes for the device.""" attr = super().device_state_attributes attr["parent_entity_id"] = self._parent_device.entity_id return attr class ISYBinarySensorProgramEntity(ISYProgramEntity, BinarySensorEntity): """Representation of an ISY994 binary sensor program. This does not need all of the subnode logic in the device version of binary sensors. """ @property def is_on(self) -> bool: """Get whether the ISY994 binary sensor device is on.""" return bool(self._node.status)
apache-2.0
[ 624, 11532, 367, 2281, 57, 14966, 3366, 19678, 1041, 199, 504, 2197, 492, 6871, 199, 504, 14090, 492, 16975, 12, 15961, 199, 199, 504, 1134, 19765, 14, 5559, 492, 334, 272, 25548, 63, 7517, 12, 272, 25548, 63, 615, 12, 272, 2281, 57, 63, 7041, 63, 11588, 12, 272, 3611, 2566, 63, 7834, 37, 615, 12, 272, 3611, 2566, 63, 58, 32482, 12, 199, 9, 199, 504, 1134, 19765, 14, 2415, 492, 5611, 12, 5013, 199, 199, 504, 8846, 14, 4608, 14, 3008, 63, 8956, 492, 334, 272, 11643, 63, 6885, 63, 28839, 1157, 57, 12, 272, 11643, 63, 6885, 63, 3978, 36, 12, 272, 11643, 63, 6885, 63, 1645, 619, 12, 272, 11643, 63, 6885, 63, 21613, 12, 272, 11643, 63, 6885, 63, 2679, 6225, 3942, 12, 272, 11643, 63, 6885, 63, 27235, 1075, 12, 272, 11643, 63, 6885, 63, 9935, 1206, 12, 272, 11643, 63, 6885, 63, 30533, 25847, 12, 272, 15265, 465, 32698, 63, 24151, 12, 272, 14161, 10160, 7302, 12, 199, 9, 199, 504, 8846, 14, 888, 63, 3189, 492, 4094, 3900, 199, 504, 8846, 14, 1018, 492, 3233, 199, 504, 8846, 14, 7546, 14, 1430, 492, 5316, 63, 3885, 63, 1403, 63, 262, 63, 5834, 63, 521, 199, 504, 8846, 14, 7546, 14, 29747, 492, 29913, 804, 199, 504, 8846, 14, 1974, 492, 4487, 465, 4487, 63, 1974, 199, 199, 504, 1275, 1297, 492, 334, 272, 485, 10186, 12, 272, 32698, 63, 24151, 63, 10555, 63, 7893, 63, 1311, 57, 12, 272, 32698, 63, 24151, 63, 10555, 63, 7893, 63, 58, 32482, 12, 272, 15265, 465, 2281, 57, 14966, 63, 7378, 12, 272, 2281, 57, 14966, 63, 2826, 4448, 12, 272, 2281, 57, 14966, 63, 15605, 51, 12, 272, 7605, 8063, 63, 1981, 1469, 1951, 63, 1439, 2228, 12, 272, 7605, 8063, 63, 1981, 1469, 1951, 63, 1645, 619, 12, 272, 7605, 8063, 63, 36, 1668, 43, 63, 8980, 3705, 12, 272, 7605, 8063, 63, 1645, 2294, 6773, 619, 12, 272, 7605, 8063, 63, 5896, 63, 28839, 1157, 57, 12, 272, 7605, 8063, 63, 27235, 1075, 63, 16205, 12, 272, 7605, 8063, 63, 46, 23651, 12, 272, 7605, 8063, 63, 52, 1156, 4227, 12, 272, 11511, 63, 22690, 63, 1981, 1469, 1951, 12, 272, 11511, 63, 7834, 37, 615, 63, 27235, 1075, 12, 199, 9, 199, 504, 1275, 4502, 492, 2281, 57, 1716, 7302, 12, 2281, 57, 9184, 7302, 199, 504, 1275, 7546, 492, 12810, 63, 1753, 63, 3235, 63, 1580, 199, 199, 10555, 63, 20562, 63, 12496, 275, 359, 272, 11643, 63, 6885, 63, 9935, 1206, 12, 272, 11643, 63, 6885, 63, 2679, 6225, 3942, 12, 272, 11643, 63, 6885, 63, 27235, 1075, 12, 199, 61, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 272, 6298, 26, 29913, 804, 12, 272, 2397, 26, 4094, 3900, 12, 272, 5316, 63, 525, 63, 8327, 26, 16975, 9046, 513, 467, 488, 467, 199, 9, 1035, 2155, 26, 272, 408, 1084, 1536, 314, 2281, 57, 14966, 3366, 8778, 4298, 1041, 272, 7256, 275, 942, 272, 7256, 63, 991, 63, 1562, 275, 1052, 272, 1982, 63, 2415, 275, 942, 339, 6298, 63, 19765, 63, 576, 275, 6298, 14, 576, 59, 1311, 57, 14966, 63, 7378, 1527, 2373, 14, 2373, 63, 344, 61, 272, 367, 1031, 315, 6298, 63, 19765, 63, 576, 59, 1311, 57, 14966, 63, 2826, 4448, 1527, 13246, 63, 24151, 2189, 267, 2243, 63, 533, 12, 2243, 63, 466, 275, 485, 13552, 63, 1782, 63, 466, 63, 460, 63, 533, 8, 932, 9, 267, 340, 1031, 14, 3922, 508, 3611, 2566, 63, 7834, 37, 615, 26, 288, 340, 1031, 14, 1708, 63, 932, 365, 440, 488, 26, 355, 327, 2136, 7171, 2112, 314, 12062, 266, 265, 1982, 3380, 2061, 12, 370, 4868, 1006, 1676, 355, 327, 3380, 1172, 2757, 7686, 355, 1982, 63, 2415, 14, 740, 1332, 932, 12, 2243, 63, 533, 12, 2243, 63, 466, 430, 355, 1980, 288, 2243, 275, 2281, 57, 13962, 266, 265, 6636, 10160, 7302, 8, 932, 12, 2243, 63, 533, 9, 267, 587, 26, 288, 2243, 275, 2281, 57, 6636, 10160, 7302, 8, 932, 12, 2243, 63, 533, 9, 267, 7256, 14, 740, 8, 1782, 9, 267, 7256, 63, 991, 63, 1562, 59, 932, 14, 1562, 61, 275, 2243, 339, 327, 8690, 2005, 4539, 1982, 1031, 5560, 367, 12062, 266, 265, 12272, 83, 272, 367, 334, 932, 12, 2243, 63, 533, 12, 2243, 63, 466, 9, 315, 1982, 63, 2415, 26, 267, 1007, 932, 63, 344, 275, 1109, 8, 932, 14, 1562, 14, 1294, 480, 6099, 1988, 17, 467, 3193, 9, 267, 327, 8690, 12062, 266, 265, 377, 2523, 2786, 1956, 267, 340, 2243, 63, 466, 14, 2460, 8, 2711, 63, 22690, 63, 1981, 1469, 1951, 304, 288, 340, 1007, 932, 63, 344, 508, 7605, 8063, 63, 1981, 1469, 1951, 63, 1439, 2228, 26, 355, 327, 4804, 932, 499, 365, 314, 298, 967, 393, 8612, 2, 8778, 355, 327, 2779, 7078, 13924, 2399, 1174, 5133, 1642, 675, 365, 355, 327, 10501, 2410, 376, 2281, 57, 799, 928, 12, 880, 781, 5534, 652, 1159, 2331, 14, 355, 327, 3709, 18930, 465, 314, 2281, 57, 6763, 8271, 4907, 83, 340, 652, 965, 282, 355, 327, 1686, 1174, 12, 652, 911, 506, 663, 14, 355, 2243, 275, 2281, 57, 13962, 266, 265, 6636, 10160, 7302, 8, 932, 12, 11643, 63, 6885, 63, 3978, 36, 12, 756, 9, 355, 7256, 14, 740, 8, 1782, 9, 288, 916, 1007, 932, 63, 344, 508, 7605, 8063, 63, 1981, 1469, 1951, 63, 1645, 619, 26, 355, 327, 4804, 932, 650, 365, 314, 298, 30770, 8612, 2, 8778, 355, 2243, 275, 2281, 57, 13962, 266, 265, 6636, 10160, 7302, 8, 932, 12, 11643, 63, 6885, 63, 1645, 619, 12, 756, 9, 355, 7256, 14, 740, 8, 1782, 9, 288, 1980, 398, 340, 2243, 63, 533, 315, 11643, 63, 20562, 63, 12496, 26, 288, 1676, 63, 1782, 275, 7256, 63, 991, 63, 1562, 14, 362, 8, 932, 14, 1708, 63, 932, 14, 1562, 9, 288, 340, 440, 1676, 63, 1782, 26, 355, 485, 10186, 14, 705, 8, 490, 298, 1716, 450, 83, 965, 282, 1676, 1031, 450, 83, 12, 1325, 949, 2243, 298, 490, 298, 10274, 2737, 367, 314, 1676, 14, 8232 ]
[ 11532, 367, 2281, 57, 14966, 3366, 19678, 1041, 199, 504, 2197, 492, 6871, 199, 504, 14090, 492, 16975, 12, 15961, 199, 199, 504, 1134, 19765, 14, 5559, 492, 334, 272, 25548, 63, 7517, 12, 272, 25548, 63, 615, 12, 272, 2281, 57, 63, 7041, 63, 11588, 12, 272, 3611, 2566, 63, 7834, 37, 615, 12, 272, 3611, 2566, 63, 58, 32482, 12, 199, 9, 199, 504, 1134, 19765, 14, 2415, 492, 5611, 12, 5013, 199, 199, 504, 8846, 14, 4608, 14, 3008, 63, 8956, 492, 334, 272, 11643, 63, 6885, 63, 28839, 1157, 57, 12, 272, 11643, 63, 6885, 63, 3978, 36, 12, 272, 11643, 63, 6885, 63, 1645, 619, 12, 272, 11643, 63, 6885, 63, 21613, 12, 272, 11643, 63, 6885, 63, 2679, 6225, 3942, 12, 272, 11643, 63, 6885, 63, 27235, 1075, 12, 272, 11643, 63, 6885, 63, 9935, 1206, 12, 272, 11643, 63, 6885, 63, 30533, 25847, 12, 272, 15265, 465, 32698, 63, 24151, 12, 272, 14161, 10160, 7302, 12, 199, 9, 199, 504, 8846, 14, 888, 63, 3189, 492, 4094, 3900, 199, 504, 8846, 14, 1018, 492, 3233, 199, 504, 8846, 14, 7546, 14, 1430, 492, 5316, 63, 3885, 63, 1403, 63, 262, 63, 5834, 63, 521, 199, 504, 8846, 14, 7546, 14, 29747, 492, 29913, 804, 199, 504, 8846, 14, 1974, 492, 4487, 465, 4487, 63, 1974, 199, 199, 504, 1275, 1297, 492, 334, 272, 485, 10186, 12, 272, 32698, 63, 24151, 63, 10555, 63, 7893, 63, 1311, 57, 12, 272, 32698, 63, 24151, 63, 10555, 63, 7893, 63, 58, 32482, 12, 272, 15265, 465, 2281, 57, 14966, 63, 7378, 12, 272, 2281, 57, 14966, 63, 2826, 4448, 12, 272, 2281, 57, 14966, 63, 15605, 51, 12, 272, 7605, 8063, 63, 1981, 1469, 1951, 63, 1439, 2228, 12, 272, 7605, 8063, 63, 1981, 1469, 1951, 63, 1645, 619, 12, 272, 7605, 8063, 63, 36, 1668, 43, 63, 8980, 3705, 12, 272, 7605, 8063, 63, 1645, 2294, 6773, 619, 12, 272, 7605, 8063, 63, 5896, 63, 28839, 1157, 57, 12, 272, 7605, 8063, 63, 27235, 1075, 63, 16205, 12, 272, 7605, 8063, 63, 46, 23651, 12, 272, 7605, 8063, 63, 52, 1156, 4227, 12, 272, 11511, 63, 22690, 63, 1981, 1469, 1951, 12, 272, 11511, 63, 7834, 37, 615, 63, 27235, 1075, 12, 199, 9, 199, 504, 1275, 4502, 492, 2281, 57, 1716, 7302, 12, 2281, 57, 9184, 7302, 199, 504, 1275, 7546, 492, 12810, 63, 1753, 63, 3235, 63, 1580, 199, 199, 10555, 63, 20562, 63, 12496, 275, 359, 272, 11643, 63, 6885, 63, 9935, 1206, 12, 272, 11643, 63, 6885, 63, 2679, 6225, 3942, 12, 272, 11643, 63, 6885, 63, 27235, 1075, 12, 199, 61, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 272, 6298, 26, 29913, 804, 12, 272, 2397, 26, 4094, 3900, 12, 272, 5316, 63, 525, 63, 8327, 26, 16975, 9046, 513, 467, 488, 467, 199, 9, 1035, 2155, 26, 272, 408, 1084, 1536, 314, 2281, 57, 14966, 3366, 8778, 4298, 1041, 272, 7256, 275, 942, 272, 7256, 63, 991, 63, 1562, 275, 1052, 272, 1982, 63, 2415, 275, 942, 339, 6298, 63, 19765, 63, 576, 275, 6298, 14, 576, 59, 1311, 57, 14966, 63, 7378, 1527, 2373, 14, 2373, 63, 344, 61, 272, 367, 1031, 315, 6298, 63, 19765, 63, 576, 59, 1311, 57, 14966, 63, 2826, 4448, 1527, 13246, 63, 24151, 2189, 267, 2243, 63, 533, 12, 2243, 63, 466, 275, 485, 13552, 63, 1782, 63, 466, 63, 460, 63, 533, 8, 932, 9, 267, 340, 1031, 14, 3922, 508, 3611, 2566, 63, 7834, 37, 615, 26, 288, 340, 1031, 14, 1708, 63, 932, 365, 440, 488, 26, 355, 327, 2136, 7171, 2112, 314, 12062, 266, 265, 1982, 3380, 2061, 12, 370, 4868, 1006, 1676, 355, 327, 3380, 1172, 2757, 7686, 355, 1982, 63, 2415, 14, 740, 1332, 932, 12, 2243, 63, 533, 12, 2243, 63, 466, 430, 355, 1980, 288, 2243, 275, 2281, 57, 13962, 266, 265, 6636, 10160, 7302, 8, 932, 12, 2243, 63, 533, 9, 267, 587, 26, 288, 2243, 275, 2281, 57, 6636, 10160, 7302, 8, 932, 12, 2243, 63, 533, 9, 267, 7256, 14, 740, 8, 1782, 9, 267, 7256, 63, 991, 63, 1562, 59, 932, 14, 1562, 61, 275, 2243, 339, 327, 8690, 2005, 4539, 1982, 1031, 5560, 367, 12062, 266, 265, 12272, 83, 272, 367, 334, 932, 12, 2243, 63, 533, 12, 2243, 63, 466, 9, 315, 1982, 63, 2415, 26, 267, 1007, 932, 63, 344, 275, 1109, 8, 932, 14, 1562, 14, 1294, 480, 6099, 1988, 17, 467, 3193, 9, 267, 327, 8690, 12062, 266, 265, 377, 2523, 2786, 1956, 267, 340, 2243, 63, 466, 14, 2460, 8, 2711, 63, 22690, 63, 1981, 1469, 1951, 304, 288, 340, 1007, 932, 63, 344, 508, 7605, 8063, 63, 1981, 1469, 1951, 63, 1439, 2228, 26, 355, 327, 4804, 932, 499, 365, 314, 298, 967, 393, 8612, 2, 8778, 355, 327, 2779, 7078, 13924, 2399, 1174, 5133, 1642, 675, 365, 355, 327, 10501, 2410, 376, 2281, 57, 799, 928, 12, 880, 781, 5534, 652, 1159, 2331, 14, 355, 327, 3709, 18930, 465, 314, 2281, 57, 6763, 8271, 4907, 83, 340, 652, 965, 282, 355, 327, 1686, 1174, 12, 652, 911, 506, 663, 14, 355, 2243, 275, 2281, 57, 13962, 266, 265, 6636, 10160, 7302, 8, 932, 12, 11643, 63, 6885, 63, 3978, 36, 12, 756, 9, 355, 7256, 14, 740, 8, 1782, 9, 288, 916, 1007, 932, 63, 344, 508, 7605, 8063, 63, 1981, 1469, 1951, 63, 1645, 619, 26, 355, 327, 4804, 932, 650, 365, 314, 298, 30770, 8612, 2, 8778, 355, 2243, 275, 2281, 57, 13962, 266, 265, 6636, 10160, 7302, 8, 932, 12, 11643, 63, 6885, 63, 1645, 619, 12, 756, 9, 355, 7256, 14, 740, 8, 1782, 9, 288, 1980, 398, 340, 2243, 63, 533, 315, 11643, 63, 20562, 63, 12496, 26, 288, 1676, 63, 1782, 275, 7256, 63, 991, 63, 1562, 14, 362, 8, 932, 14, 1708, 63, 932, 14, 1562, 9, 288, 340, 440, 1676, 63, 1782, 26, 355, 485, 10186, 14, 705, 8, 490, 298, 1716, 450, 83, 965, 282, 1676, 1031, 450, 83, 12, 1325, 949, 2243, 298, 490, 298, 10274, 2737, 367, 314, 1676, 14, 8232, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mtdewulf/incubator-airflow
airflow/settings.py
13
4567
# -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import logging import os import sys from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker from airflow import configuration as conf class DummyStatsLogger(object): @classmethod def incr(cls, stat, count=1, rate=1): pass @classmethod def decr(cls, stat, count=1, rate=1): pass @classmethod def gauge(cls, stat, value, rate=1, delta=False): pass @classmethod def timing(cls, stat, dt): pass Stats = DummyStatsLogger if conf.getboolean('scheduler', 'statsd_on'): from statsd import StatsClient statsd = StatsClient( host=conf.get('scheduler', 'statsd_host'), port=conf.getint('scheduler', 'statsd_port'), prefix=conf.get('scheduler', 'statsd_prefix')) Stats = statsd else: Stats = DummyStatsLogger HEADER = """\ ____________ _____________ ____ |__( )_________ __/__ /________ __ ____ /| |_ /__ ___/_ /_ __ /_ __ \_ | /| / / ___ ___ | / _ / _ __/ _ / / /_/ /_ |/ |/ / _/_/ |_/_/ /_/ /_/ /_/ \____/____/|__/ """ BASE_LOG_URL = '/admin/airflow/log' AIRFLOW_HOME = os.path.expanduser(conf.get('core', 'AIRFLOW_HOME')) SQL_ALCHEMY_CONN = conf.get('core', 'SQL_ALCHEMY_CONN') LOGGING_LEVEL = logging.INFO DAGS_FOLDER = os.path.expanduser(conf.get('core', 'DAGS_FOLDER')) # the prefix to append to gunicorn worker processes after init GUNICORN_WORKER_READY_PREFIX = "[ready] " # can't move this to conf due to ConfigParser interpolation LOG_FORMAT = ( '[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s') LOG_FORMAT_WITH_PID = ( '[%(asctime)s] [%(process)d] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s') LOG_FORMAT_WITH_THREAD_NAME = ( '[%(asctime)s] {%(filename)s:%(lineno)d} %(threadName)s %(levelname)s - %(message)s') SIMPLE_LOG_FORMAT = '%(asctime)s %(levelname)s - %(message)s' def policy(task_instance): """ This policy setting allows altering task instances right before they are executed. It allows administrator to rewire some task parameters. Note that the ``TaskInstance`` object has an attribute ``task`` pointing to its related task object, that in turns has a reference to the DAG object. So you can use the attributes of all of these to define your policy. To define policy, add a ``airflow_local_settings`` module to your PYTHONPATH that defines this ``policy`` function. It receives a ``TaskInstance`` object and can alter it where needed. Here are a few examples of how this can be useful: * You could enforce a specific queue (say the ``spark`` queue) for tasks using the ``SparkOperator`` to make sure that these task instances get wired to the right workers * You could force all task instances running on an ``execution_date`` older than a week old to run in a ``backfill`` pool. * ... """ pass def configure_logging(log_format=LOG_FORMAT): logging.root.handlers = [] logging.basicConfig( format=log_format, stream=sys.stdout, level=LOGGING_LEVEL) engine = None Session = None def configure_orm(): global engine global Session engine_args = {} if 'sqlite' not in SQL_ALCHEMY_CONN: # Engine args not supported by sqlite engine_args['pool_size'] = conf.getint('core', 'SQL_ALCHEMY_POOL_SIZE') engine_args['pool_recycle'] = conf.getint('core', 'SQL_ALCHEMY_POOL_RECYCLE') engine = create_engine(SQL_ALCHEMY_CONN, **engine_args) Session = scoped_session( sessionmaker(autocommit=False, autoflush=False, bind=engine)) try: from airflow_local_settings import * logging.info("Loaded airflow_local_settings.") except: pass configure_logging() configure_orm()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 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, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 199, 504, 8335, 492, 1218, 63, 3908, 199, 504, 8335, 14, 1025, 492, 27582, 63, 1730, 12, 2351, 14367, 199, 199, 504, 16321, 492, 2897, 465, 3743, 421, 199, 533, 9762, 8257, 4455, 8, 785, 304, 339, 768, 3744, 272, 347, 315, 1556, 8, 1886, 12, 5672, 12, 2338, 29, 17, 12, 6634, 29, 17, 304, 267, 986, 339, 768, 3744, 272, 347, 477, 1556, 8, 1886, 12, 5672, 12, 2338, 29, 17, 12, 6634, 29, 17, 304, 267, 986, 339, 768, 3744, 272, 347, 486, 30949, 8, 1886, 12, 5672, 12, 574, 12, 6634, 29, 17, 12, 5762, 29, 797, 304, 267, 986, 339, 768, 3744, 272, 347, 20542, 8, 1886, 12, 5672, 12, 4487, 304, 267, 986, 199, 199, 8257, 275, 9762, 8257, 4455, 199, 199, 692, 3743, 14, 30356, 360, 8874, 297, 283, 3200, 68, 63, 265, 735, 272, 687, 5020, 68, 492, 29062, 3041, 272, 5020, 68, 275, 29062, 3041, 8, 267, 1591, 29, 2190, 14, 362, 360, 8874, 297, 283, 3200, 68, 63, 1102, 659, 267, 1844, 29, 2190, 14, 26627, 360, 8874, 297, 283, 3200, 68, 63, 719, 659, 267, 2403, 29, 2190, 14, 362, 360, 8874, 297, 283, 3200, 68, 63, 1861, 1333, 272, 29062, 275, 5020, 68, 199, 2836, 26, 272, 29062, 275, 9762, 8257, 4455, 421, 199, 7311, 275, 9638, 523, 636, 7785, 363, 755, 636, 7785, 8989, 199, 636, 363, 259, 1204, 721, 776, 7785, 63, 221, 636, 22128, 221, 1182, 7785, 420, 636, 199, 4741, 221, 1182, 92, 1204, 63, 221, 1182, 363, 221, 31111, 15607, 221, 1182, 63, 636, 221, 1182, 63, 221, 636, 971, 63, 1204, 1182, 92, 1182, 1182, 199, 8989, 221, 31111, 1204, 221, 1182, 485, 221, 1182, 257, 485, 221, 636, 15, 485, 221, 1182, 1182, 1182, 63, 15, 1182, 63, 1204, 15, 1204, 15, 1182, 199, 485, 15607, 15, 221, 1204, 63, 15607, 15, 221, 1182, 63, 15, 259, 1182, 63, 15, 259, 1182, 63, 15, 221, 971, 4741, 15, 4741, 15, 92, 363, 15, 199, 408, 199, 199, 5825, 63, 4947, 63, 2632, 275, 1994, 2113, 15, 15815, 15, 793, 7, 199, 33, 3927, 17114, 63, 9524, 275, 747, 14, 515, 14, 12131, 8, 2190, 14, 362, 360, 1018, 297, 283, 33, 3927, 17114, 63, 9524, 1333, 199, 4657, 63, 748, 1244, 2769, 57, 63, 17489, 275, 3743, 14, 362, 360, 1018, 297, 283, 4657, 63, 748, 1244, 2769, 57, 63, 17489, 358, 199, 27896, 63, 11817, 275, 2050, 14, 4531, 199, 28211, 51, 63, 19041, 275, 747, 14, 515, 14, 12131, 8, 2190, 14, 362, 360, 1018, 297, 283, 28211, 51, 63, 19041, 1333, 199, 199, 3, 314, 2403, 370, 5666, 370, 486, 29067, 7239, 10358, 2410, 4205, 199, 39, 11580, 32080, 63, 8406, 540, 63, 22579, 63, 6351, 275, 7369, 2179, 61, 298, 199, 199, 3, 883, 1133, 4057, 642, 370, 3743, 7037, 370, 14196, 14046, 199, 4947, 63, 4807, 275, 334, 272, 6730, 2840, 18331, 9, 83, 61, 469, 2840, 1501, 9, 83, 19648, 3469, 9, 68, 93, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 358, 199, 4947, 63, 4807, 63, 9139, 63, 16098, 275, 334, 272, 6730, 2840, 18331, 9, 83, 61, 359, 2840, 1412, 9, 68, 61, 469, 2840, 1501, 9, 83, 19648, 3469, 9, 68, 93, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 358, 199, 4947, 63, 4807, 63, 9139, 63, 16103, 63, 2339, 275, 334, 272, 6730, 2840, 18331, 9, 83, 61, 469, 2840, 1501, 9, 83, 19648, 3469, 9, 68, 93, 2818, 2671, 985, 9, 83, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 358, 199, 27548, 63, 4947, 63, 4807, 275, 9487, 18331, 9, 83, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 7, 421, 199, 318, 4592, 8, 1765, 63, 842, 304, 272, 408, 272, 961, 4592, 4260, 6127, 17355, 316, 2120, 4454, 2451, 2544, 2985, 272, 787, 7934, 14, 2779, 6127, 31056, 370, 295, 11239, 2005, 2120, 2633, 14, 339, 3390, 626, 314, 1124, 4476, 3244, 1040, 909, 965, 376, 2225, 1124, 1765, 1040, 20686, 272, 370, 2399, 4048, 2120, 909, 12, 626, 315, 25449, 965, 282, 3659, 370, 314, 19666, 272, 909, 14, 2002, 1265, 883, 675, 314, 3004, 402, 1006, 402, 3520, 370, 5627, 2195, 272, 4592, 14, 339, 4005, 5627, 4592, 12, 1050, 282, 1124, 15815, 63, 1832, 63, 1751, 1040, 859, 272, 370, 2195, 31176, 626, 7890, 642, 1124, 3185, 1040, 805, 14, 2779, 23192, 272, 282, 1124, 4476, 3244, 1040, 909, 436, 883, 17355, 652, 2382, 4346, 14, 339, 11842, 787, 282, 9284, 7251, 402, 4212, 642, 883, 506, 2997, 26, 339, 627, 2047, 4293, 15814, 282, 2488, 4126, 334, 19787, 314, 1124, 9852, 1040, 4126, 9, 267, 367, 6527, 1808, 314, 1124, 27110, 7961, 1040, 370, 1852, 3238, 626, 3520, 267, 2120, 4454, 664, 336, 16139, 370, 314, 2451, 14123, 272, 627, 2047, 4293, 3542, 1006, 2120, 4454, 3879, 641, 376, 267, 1124, 9416, 63, 602, 1040, 12731, 2419, 282, 8620, 2269, 370, 1255, 315, 282, 1124, 894, 4498, 1040, 267, 4203, 14, 272, 627, 2263, 272, 408 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 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, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 199, 504, 8335, 492, 1218, 63, 3908, 199, 504, 8335, 14, 1025, 492, 27582, 63, 1730, 12, 2351, 14367, 199, 199, 504, 16321, 492, 2897, 465, 3743, 421, 199, 533, 9762, 8257, 4455, 8, 785, 304, 339, 768, 3744, 272, 347, 315, 1556, 8, 1886, 12, 5672, 12, 2338, 29, 17, 12, 6634, 29, 17, 304, 267, 986, 339, 768, 3744, 272, 347, 477, 1556, 8, 1886, 12, 5672, 12, 2338, 29, 17, 12, 6634, 29, 17, 304, 267, 986, 339, 768, 3744, 272, 347, 486, 30949, 8, 1886, 12, 5672, 12, 574, 12, 6634, 29, 17, 12, 5762, 29, 797, 304, 267, 986, 339, 768, 3744, 272, 347, 20542, 8, 1886, 12, 5672, 12, 4487, 304, 267, 986, 199, 199, 8257, 275, 9762, 8257, 4455, 199, 199, 692, 3743, 14, 30356, 360, 8874, 297, 283, 3200, 68, 63, 265, 735, 272, 687, 5020, 68, 492, 29062, 3041, 272, 5020, 68, 275, 29062, 3041, 8, 267, 1591, 29, 2190, 14, 362, 360, 8874, 297, 283, 3200, 68, 63, 1102, 659, 267, 1844, 29, 2190, 14, 26627, 360, 8874, 297, 283, 3200, 68, 63, 719, 659, 267, 2403, 29, 2190, 14, 362, 360, 8874, 297, 283, 3200, 68, 63, 1861, 1333, 272, 29062, 275, 5020, 68, 199, 2836, 26, 272, 29062, 275, 9762, 8257, 4455, 421, 199, 7311, 275, 9638, 523, 636, 7785, 363, 755, 636, 7785, 8989, 199, 636, 363, 259, 1204, 721, 776, 7785, 63, 221, 636, 22128, 221, 1182, 7785, 420, 636, 199, 4741, 221, 1182, 92, 1204, 63, 221, 1182, 363, 221, 31111, 15607, 221, 1182, 63, 636, 221, 1182, 63, 221, 636, 971, 63, 1204, 1182, 92, 1182, 1182, 199, 8989, 221, 31111, 1204, 221, 1182, 485, 221, 1182, 257, 485, 221, 636, 15, 485, 221, 1182, 1182, 1182, 63, 15, 1182, 63, 1204, 15, 1204, 15, 1182, 199, 485, 15607, 15, 221, 1204, 63, 15607, 15, 221, 1182, 63, 15, 259, 1182, 63, 15, 259, 1182, 63, 15, 221, 971, 4741, 15, 4741, 15, 92, 363, 15, 199, 408, 199, 199, 5825, 63, 4947, 63, 2632, 275, 1994, 2113, 15, 15815, 15, 793, 7, 199, 33, 3927, 17114, 63, 9524, 275, 747, 14, 515, 14, 12131, 8, 2190, 14, 362, 360, 1018, 297, 283, 33, 3927, 17114, 63, 9524, 1333, 199, 4657, 63, 748, 1244, 2769, 57, 63, 17489, 275, 3743, 14, 362, 360, 1018, 297, 283, 4657, 63, 748, 1244, 2769, 57, 63, 17489, 358, 199, 27896, 63, 11817, 275, 2050, 14, 4531, 199, 28211, 51, 63, 19041, 275, 747, 14, 515, 14, 12131, 8, 2190, 14, 362, 360, 1018, 297, 283, 28211, 51, 63, 19041, 1333, 199, 199, 3, 314, 2403, 370, 5666, 370, 486, 29067, 7239, 10358, 2410, 4205, 199, 39, 11580, 32080, 63, 8406, 540, 63, 22579, 63, 6351, 275, 7369, 2179, 61, 298, 199, 199, 3, 883, 1133, 4057, 642, 370, 3743, 7037, 370, 14196, 14046, 199, 4947, 63, 4807, 275, 334, 272, 6730, 2840, 18331, 9, 83, 61, 469, 2840, 1501, 9, 83, 19648, 3469, 9, 68, 93, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 358, 199, 4947, 63, 4807, 63, 9139, 63, 16098, 275, 334, 272, 6730, 2840, 18331, 9, 83, 61, 359, 2840, 1412, 9, 68, 61, 469, 2840, 1501, 9, 83, 19648, 3469, 9, 68, 93, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 358, 199, 4947, 63, 4807, 63, 9139, 63, 16103, 63, 2339, 275, 334, 272, 6730, 2840, 18331, 9, 83, 61, 469, 2840, 1501, 9, 83, 19648, 3469, 9, 68, 93, 2818, 2671, 985, 9, 83, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 358, 199, 27548, 63, 4947, 63, 4807, 275, 9487, 18331, 9, 83, 2818, 20056, 9, 83, 446, 2818, 1188, 9, 83, 7, 421, 199, 318, 4592, 8, 1765, 63, 842, 304, 272, 408, 272, 961, 4592, 4260, 6127, 17355, 316, 2120, 4454, 2451, 2544, 2985, 272, 787, 7934, 14, 2779, 6127, 31056, 370, 295, 11239, 2005, 2120, 2633, 14, 339, 3390, 626, 314, 1124, 4476, 3244, 1040, 909, 965, 376, 2225, 1124, 1765, 1040, 20686, 272, 370, 2399, 4048, 2120, 909, 12, 626, 315, 25449, 965, 282, 3659, 370, 314, 19666, 272, 909, 14, 2002, 1265, 883, 675, 314, 3004, 402, 1006, 402, 3520, 370, 5627, 2195, 272, 4592, 14, 339, 4005, 5627, 4592, 12, 1050, 282, 1124, 15815, 63, 1832, 63, 1751, 1040, 859, 272, 370, 2195, 31176, 626, 7890, 642, 1124, 3185, 1040, 805, 14, 2779, 23192, 272, 282, 1124, 4476, 3244, 1040, 909, 436, 883, 17355, 652, 2382, 4346, 14, 339, 11842, 787, 282, 9284, 7251, 402, 4212, 642, 883, 506, 2997, 26, 339, 627, 2047, 4293, 15814, 282, 2488, 4126, 334, 19787, 314, 1124, 9852, 1040, 4126, 9, 267, 367, 6527, 1808, 314, 1124, 27110, 7961, 1040, 370, 1852, 3238, 626, 3520, 267, 2120, 4454, 664, 336, 16139, 370, 314, 2451, 14123, 272, 627, 2047, 4293, 3542, 1006, 2120, 4454, 3879, 641, 376, 267, 1124, 9416, 63, 602, 1040, 12731, 2419, 282, 8620, 2269, 370, 1255, 315, 282, 1124, 894, 4498, 1040, 267, 4203, 14, 272, 627, 2263, 272, 408, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
AuyaJackie/odoo
openerp/addons/base/module/wizard/base_module_configuration.py
447
2274
# -*- 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.osv import osv from openerp.tools.translate import _ class base_module_configuration(osv.osv_memory): _name = "base.module.configuration" def start(self, cr, uid, ids, context=None): todo_ids = self.pool.get('ir.actions.todo').search(cr, uid, ['|', ('type','=','recurring'), ('state', '=', 'open')]) if not todo_ids: # When there is no wizard todo it will display message data_obj = self.pool.get('ir.model.data') result = data_obj._get_id(cr, uid, 'base', 'view_base_module_configuration_form') view_id = data_obj.browse(cr, uid, result).res_id value = { 'name': _('System Configuration done'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'base.module.configuration', 'view_id': [view_id], 'type': 'ir.actions.act_window', 'target': 'new' } return value # Run the config wizards config_pool = self.pool.get('res.config') return config_pool.start(cr, uid, ids, context=context) base_module_configuration() # 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, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 1300, 63, 578, 63, 4758, 8, 4795, 14, 4795, 63, 4844, 304, 339, 485, 354, 275, 298, 1095, 14, 578, 14, 4758, 2, 339, 347, 1343, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 11386, 63, 1580, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 11396, 1959, 1733, 8, 1556, 12, 1747, 12, 288, 788, 26320, 661, 466, 1673, 29511, 6794, 5985, 659, 661, 929, 297, 6291, 283, 1490, 2023, 267, 340, 440, 11386, 63, 1580, 26, 288, 327, 3979, 2337, 365, 949, 12262, 11386, 652, 911, 2929, 1245, 288, 666, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 288, 754, 275, 666, 63, 1113, 423, 362, 63, 344, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 1345, 63, 1095, 63, 578, 63, 4758, 63, 964, 358, 288, 2455, 63, 344, 275, 666, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 754, 680, 470, 63, 344, 288, 574, 275, 469, 490, 283, 354, 356, 4018, 3989, 11595, 4224, 659, 15324, 283, 1345, 63, 466, 356, 283, 964, 297, 15324, 283, 1345, 63, 632, 356, 283, 964, 297, 15324, 283, 470, 63, 1238, 356, 283, 1095, 14, 578, 14, 4758, 297, 15324, 283, 1345, 63, 344, 356, 359, 1345, 63, 344, 467, 15324, 283, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 15324, 283, 1375, 356, 283, 1222, 7, 355, 789, 288, 372, 574, 267, 327, 3378, 314, 1101, 31067, 5596, 267, 1101, 63, 2293, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 888, 358, 267, 372, 1101, 63, 2293, 14, 928, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 199, 199, 1095, 63, 578, 63, 4758, 342, 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 ]
[ 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, 14, 4795, 492, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 1300, 63, 578, 63, 4758, 8, 4795, 14, 4795, 63, 4844, 304, 339, 485, 354, 275, 298, 1095, 14, 578, 14, 4758, 2, 339, 347, 1343, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 11386, 63, 1580, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 11396, 1959, 1733, 8, 1556, 12, 1747, 12, 288, 788, 26320, 661, 466, 1673, 29511, 6794, 5985, 659, 661, 929, 297, 6291, 283, 1490, 2023, 267, 340, 440, 11386, 63, 1580, 26, 288, 327, 3979, 2337, 365, 949, 12262, 11386, 652, 911, 2929, 1245, 288, 666, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 288, 754, 275, 666, 63, 1113, 423, 362, 63, 344, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 1345, 63, 1095, 63, 578, 63, 4758, 63, 964, 358, 288, 2455, 63, 344, 275, 666, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 754, 680, 470, 63, 344, 288, 574, 275, 469, 490, 283, 354, 356, 4018, 3989, 11595, 4224, 659, 15324, 283, 1345, 63, 466, 356, 283, 964, 297, 15324, 283, 1345, 63, 632, 356, 283, 964, 297, 15324, 283, 470, 63, 1238, 356, 283, 1095, 14, 578, 14, 4758, 297, 15324, 283, 1345, 63, 344, 356, 359, 1345, 63, 344, 467, 15324, 283, 466, 356, 283, 723, 14, 3723, 14, 2442, 63, 3806, 297, 15324, 283, 1375, 356, 283, 1222, 7, 355, 789, 288, 372, 574, 267, 327, 3378, 314, 1101, 31067, 5596, 267, 1101, 63, 2293, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 888, 358, 267, 372, 1101, 63, 2293, 14, 928, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 9, 199, 199, 1095, 63, 578, 63, 4758, 342, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dit/dit
dit/divergences/copy_mutual_information.py
1
2403
""" The copy mutual information, as defined by Kolchinsky & Corominas-Murtra. """ from .pmf import relative_entropy from ..utils import unitful __all__ = ( 'copy_mutual_information', ) def binary_kullback_leibler_divergence(p, q): """ Compute the binary Killback-Leibler divergence. Parameters ---------- p : float The first probability. q : float The second probability. Returns ------- dkl : float The binary Kullback-Leibler divergence. """ return relative_entropy([p, 1 - p], [q, 1 - q]) @unitful def specific_copy_mutual_information(p_Y_g_x, p_Y, x): """ Compute the specific copy mutual information. Roughly it is the portion of the specific mutual information which results from X = Y = x. Parameters ---------- p_Y_g_x : Distribution The probability p(Y|X=x). p_Y : Distribution The probability p(Y). x : event An event in the sample space of X, Y. Returns ------- Icopy : float The specific copy mutual information of x. """ py = p_Y[x] pygx = p_Y_g_x[x] if pygx > py: return binary_kullback_leibler_divergence(pygx, py) else: return 0 def copy_mutual_information(dist, X, Y, rv_mode=None): """ Computes the copy mutual information. Roughly, it is the portion of the mutual information which results from :math:`X = Y`. Parameters ---------- dist : Distribution The distribution of interest. X : iterable The indicies to consider as X. Y : iterable The indicies to consider as Y. rv_mode : str, None Specifies how to interpret ``crvs`` and ``rvs``. Valid options are: {'indices', 'names'}. If equal to 'indices', then the elements of ``crvs`` and ``rvs`` are interpreted as random variable indices. If equal to 'names', the the elements are interpreted as random varible names. If ``None``, then the value of ``self._rv_mode`` is consulted, which defaults to 'indices'. Returns ------- Icopy : float The copy mutual information of x. """ p_Y = dist.marginal(Y, rv_mode=rv_mode) marg, cdists = dist.condition_on(X, rvs=Y, rv_mode=rv_mode) return sum(marg[x] * specific_copy_mutual_information(cdist, p_Y, x) for x, cdist in zip(marg.outcomes, cdists))
bsd-3-clause
[ 624, 199, 1918, 1331, 8567, 1061, 2556, 12, 465, 3247, 701, 1804, 393, 335, 262, 12267, 1253, 7499, 676, 262, 305, 13, 45, 300, 1239, 14, 199, 624, 199, 199, 504, 1275, 31842, 492, 3847, 63, 10435, 199, 504, 2508, 1208, 492, 4137, 1893, 421, 199, 363, 452, 363, 275, 334, 272, 283, 1574, 63, 6552, 1061, 63, 11697, 297, 199, 9, 421, 199, 318, 3366, 63, 75, 979, 894, 63, 274, 7247, 82, 63, 32049, 8, 80, 12, 1894, 304, 272, 408, 272, 8354, 314, 3366, 1804, 778, 894, 13, 2553, 7247, 82, 487, 23803, 14, 339, 3897, 272, 4143, 272, 299, 520, 2069, 267, 710, 1642, 12224, 14, 272, 1894, 520, 2069, 267, 710, 3499, 12224, 14, 339, 1803, 272, 5514, 272, 366, 9503, 520, 2069, 267, 710, 3366, 1804, 979, 894, 13, 2553, 7247, 82, 487, 23803, 14, 272, 408, 272, 372, 3847, 63, 10435, 779, 80, 12, 413, 446, 299, 467, 359, 81, 12, 413, 446, 1894, 566, 421, 199, 32, 3248, 1893, 199, 318, 2488, 63, 1574, 63, 6552, 1061, 63, 11697, 8, 80, 63, 57, 63, 71, 63, 88, 12, 299, 63, 57, 12, 671, 304, 272, 408, 272, 8354, 314, 2488, 1331, 8567, 1061, 2556, 14, 820, 4937, 590, 652, 365, 314, 272, 18046, 402, 314, 2488, 8567, 1061, 2556, 1314, 2058, 687, 1323, 275, 1488, 275, 671, 14, 339, 3897, 272, 4143, 272, 299, 63, 57, 63, 71, 63, 88, 520, 11839, 267, 710, 12224, 299, 8, 57, 92, 56, 29, 88, 680, 272, 299, 63, 57, 520, 11839, 267, 710, 12224, 299, 8, 57, 680, 272, 671, 520, 1566, 267, 1626, 1566, 315, 314, 2690, 4601, 402, 1323, 12, 1488, 14, 339, 1803, 272, 5514, 272, 473, 1574, 520, 2069, 267, 710, 2488, 1331, 8567, 1061, 2556, 402, 671, 14, 272, 408, 272, 1134, 275, 299, 63, 57, 59, 88, 61, 272, 1134, 20777, 275, 299, 63, 57, 63, 71, 63, 88, 59, 88, 61, 272, 340, 1134, 20777, 690, 1134, 26, 267, 372, 3366, 63, 75, 979, 894, 63, 274, 7247, 82, 63, 32049, 8, 647, 20777, 12, 1134, 9, 272, 587, 26, 267, 372, 378, 421, 199, 318, 1331, 63, 6552, 1061, 63, 11697, 8, 2686, 12, 1323, 12, 1488, 12, 4336, 63, 632, 29, 403, 304, 272, 408, 272, 28040, 314, 1331, 8567, 1061, 2556, 14, 820, 4937, 590, 12, 652, 365, 314, 272, 18046, 402, 314, 8567, 1061, 2556, 1314, 2058, 687, 520, 3442, 1705, 56, 275, 1488, 2313, 339, 3897, 272, 4143, 272, 2917, 520, 11839, 267, 710, 4084, 402, 13518, 14, 272, 1323, 520, 6076, 267, 710, 2539, 2578, 370, 11201, 465, 1323, 14, 272, 1488, 520, 6076, 267, 710, 2539, 2578, 370, 11201, 465, 1488, 14, 272, 4336, 63, 632, 520, 620, 12, 488, 267, 11015, 4212, 370, 15579, 1124, 1556, 3122, 1040, 436, 1124, 23322, 4345, 4821, 1511, 787, 26, 267, 791, 4108, 297, 283, 1247, 936, 14, 982, 4472, 370, 283, 4108, 297, 2066, 314, 4008, 267, 402, 1124, 1556, 3122, 1040, 436, 1124, 23322, 1040, 787, 11922, 465, 2196, 1750, 4918, 14, 267, 982, 4472, 370, 283, 1247, 297, 314, 314, 4008, 787, 11922, 465, 2196, 267, 4172, 830, 1561, 14, 982, 1124, 403, 4542, 2066, 314, 574, 402, 1124, 277, 423, 6310, 63, 632, 1040, 365, 267, 13447, 30355, 12, 1314, 4243, 370, 283, 4108, 1370, 339, 1803, 272, 5514, 272, 473, 1574, 520, 2069, 267, 710, 1331, 8567, 1061, 2556, 402, 671, 14, 272, 408, 272, 299, 63, 57, 275, 2917, 14, 9650, 279, 8, 57, 12, 4336, 63, 632, 29, 6310, 63, 632, 9, 272, 333, 1273, 12, 286, 18552, 275, 2917, 14, 5394, 63, 265, 8, 56, 12, 519, 3122, 29, 57, 12, 4336, 63, 632, 29, 6310, 63, 632, 9, 272, 372, 3089, 8, 77, 1273, 59, 88, 61, 627, 2488, 63, 1574, 63, 6552, 1061, 63, 11697, 8, 67, 2686, 12, 299, 63, 57, 12, 671, 9, 367, 671, 12, 286, 2686, 315, 3482, 8, 77, 1273, 14, 17502, 83, 12, 286, 18552, 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 ]
[ 199, 1918, 1331, 8567, 1061, 2556, 12, 465, 3247, 701, 1804, 393, 335, 262, 12267, 1253, 7499, 676, 262, 305, 13, 45, 300, 1239, 14, 199, 624, 199, 199, 504, 1275, 31842, 492, 3847, 63, 10435, 199, 504, 2508, 1208, 492, 4137, 1893, 421, 199, 363, 452, 363, 275, 334, 272, 283, 1574, 63, 6552, 1061, 63, 11697, 297, 199, 9, 421, 199, 318, 3366, 63, 75, 979, 894, 63, 274, 7247, 82, 63, 32049, 8, 80, 12, 1894, 304, 272, 408, 272, 8354, 314, 3366, 1804, 778, 894, 13, 2553, 7247, 82, 487, 23803, 14, 339, 3897, 272, 4143, 272, 299, 520, 2069, 267, 710, 1642, 12224, 14, 272, 1894, 520, 2069, 267, 710, 3499, 12224, 14, 339, 1803, 272, 5514, 272, 366, 9503, 520, 2069, 267, 710, 3366, 1804, 979, 894, 13, 2553, 7247, 82, 487, 23803, 14, 272, 408, 272, 372, 3847, 63, 10435, 779, 80, 12, 413, 446, 299, 467, 359, 81, 12, 413, 446, 1894, 566, 421, 199, 32, 3248, 1893, 199, 318, 2488, 63, 1574, 63, 6552, 1061, 63, 11697, 8, 80, 63, 57, 63, 71, 63, 88, 12, 299, 63, 57, 12, 671, 304, 272, 408, 272, 8354, 314, 2488, 1331, 8567, 1061, 2556, 14, 820, 4937, 590, 652, 365, 314, 272, 18046, 402, 314, 2488, 8567, 1061, 2556, 1314, 2058, 687, 1323, 275, 1488, 275, 671, 14, 339, 3897, 272, 4143, 272, 299, 63, 57, 63, 71, 63, 88, 520, 11839, 267, 710, 12224, 299, 8, 57, 92, 56, 29, 88, 680, 272, 299, 63, 57, 520, 11839, 267, 710, 12224, 299, 8, 57, 680, 272, 671, 520, 1566, 267, 1626, 1566, 315, 314, 2690, 4601, 402, 1323, 12, 1488, 14, 339, 1803, 272, 5514, 272, 473, 1574, 520, 2069, 267, 710, 2488, 1331, 8567, 1061, 2556, 402, 671, 14, 272, 408, 272, 1134, 275, 299, 63, 57, 59, 88, 61, 272, 1134, 20777, 275, 299, 63, 57, 63, 71, 63, 88, 59, 88, 61, 272, 340, 1134, 20777, 690, 1134, 26, 267, 372, 3366, 63, 75, 979, 894, 63, 274, 7247, 82, 63, 32049, 8, 647, 20777, 12, 1134, 9, 272, 587, 26, 267, 372, 378, 421, 199, 318, 1331, 63, 6552, 1061, 63, 11697, 8, 2686, 12, 1323, 12, 1488, 12, 4336, 63, 632, 29, 403, 304, 272, 408, 272, 28040, 314, 1331, 8567, 1061, 2556, 14, 820, 4937, 590, 12, 652, 365, 314, 272, 18046, 402, 314, 8567, 1061, 2556, 1314, 2058, 687, 520, 3442, 1705, 56, 275, 1488, 2313, 339, 3897, 272, 4143, 272, 2917, 520, 11839, 267, 710, 4084, 402, 13518, 14, 272, 1323, 520, 6076, 267, 710, 2539, 2578, 370, 11201, 465, 1323, 14, 272, 1488, 520, 6076, 267, 710, 2539, 2578, 370, 11201, 465, 1488, 14, 272, 4336, 63, 632, 520, 620, 12, 488, 267, 11015, 4212, 370, 15579, 1124, 1556, 3122, 1040, 436, 1124, 23322, 4345, 4821, 1511, 787, 26, 267, 791, 4108, 297, 283, 1247, 936, 14, 982, 4472, 370, 283, 4108, 297, 2066, 314, 4008, 267, 402, 1124, 1556, 3122, 1040, 436, 1124, 23322, 1040, 787, 11922, 465, 2196, 1750, 4918, 14, 267, 982, 4472, 370, 283, 1247, 297, 314, 314, 4008, 787, 11922, 465, 2196, 267, 4172, 830, 1561, 14, 982, 1124, 403, 4542, 2066, 314, 574, 402, 1124, 277, 423, 6310, 63, 632, 1040, 365, 267, 13447, 30355, 12, 1314, 4243, 370, 283, 4108, 1370, 339, 1803, 272, 5514, 272, 473, 1574, 520, 2069, 267, 710, 1331, 8567, 1061, 2556, 402, 671, 14, 272, 408, 272, 299, 63, 57, 275, 2917, 14, 9650, 279, 8, 57, 12, 4336, 63, 632, 29, 6310, 63, 632, 9, 272, 333, 1273, 12, 286, 18552, 275, 2917, 14, 5394, 63, 265, 8, 56, 12, 519, 3122, 29, 57, 12, 4336, 63, 632, 29, 6310, 63, 632, 9, 272, 372, 3089, 8, 77, 1273, 59, 88, 61, 627, 2488, 63, 1574, 63, 6552, 1061, 63, 11697, 8, 67, 2686, 12, 299, 63, 57, 12, 671, 9, 367, 671, 12, 286, 2686, 315, 3482, 8, 77, 1273, 14, 17502, 83, 12, 286, 18552, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
crodrigues96/mtasa-blue
vendor/google-breakpad/src/tools/gyp/test/builddir/gyptest-default.py
185
2696
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Verify the settings that cause a set of programs to be created in a specific build directory, and that no intermediate built files get created outside of that build directory hierarchy even when referred to with deeply-nested ../../.. paths. """ import TestGyp # TODO(mmoss): Make only supports (theoretically) a single, global build # directory (through GYP_GENERATOR_FLAGS 'output_dir'), rather than # gyp-file-specific settings (e.g. the stuff in builddir.gypi) that the other # generators support, so this doesn't work yet for make. # TODO(mmoss) Make also has the issue that the top-level Makefile is written to # the "--depth" location, which is one level above 'src', but then this test # moves 'src' somewhere else, leaving the Makefile behind, so make can't find # its sources. I'm not sure if make is wrong for writing outside the current # directory, or if the test is wrong for assuming everything generated is under # the current directory. # Android, Ninja, and CMake do not support setting the build directory. test = TestGyp.TestGyp(formats=['!make', '!ninja', '!android', '!cmake']) test.run_gyp('prog1.gyp', '--depth=..', chdir='src') if test.format == 'msvs': if test.uses_msbuild: test.must_contain('src/prog1.vcxproj', '<OutDir>..\\builddir\\Default\\</OutDir>') else: test.must_contain('src/prog1.vcproj', 'OutputDirectory="..\\builddir\\Default\\"') test.relocate('src', 'relocate/src') test.subdir('relocate/builddir') # Make sure that all the built ../../etc. files only get put under builddir, # by making all of relocate read-only and then making only builddir writable. test.writable('relocate', False) test.writable('relocate/builddir', True) # Suppress the test infrastructure's setting SYMROOT on the command line. test.build('prog1.gyp', SYMROOT=None, chdir='relocate/src') expect1 = """\ Hello from prog1.c Hello from func1.c """ expect2 = """\ Hello from subdir2/prog2.c Hello from func2.c """ expect3 = """\ Hello from subdir2/subdir3/prog3.c Hello from func3.c """ expect4 = """\ Hello from subdir2/subdir3/subdir4/prog4.c Hello from func4.c """ expect5 = """\ Hello from subdir2/subdir3/subdir4/subdir5/prog5.c Hello from func5.c """ def run_builddir(prog, expect): dir = 'relocate/builddir/Default/' test.run(program=test.workpath(dir + prog), stdout=expect) run_builddir('prog1', expect1) run_builddir('prog2', expect2) run_builddir('prog3', expect3) run_builddir('prog4', expect4) run_builddir('prog5', expect5) test.pass_test()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 7496, 314, 2202, 626, 7675, 282, 663, 402, 18572, 370, 506, 2737, 315, 199, 65, 2488, 1900, 2082, 12, 436, 626, 949, 13197, 6137, 1584, 199, 362, 2737, 9682, 402, 626, 1900, 2082, 14446, 2755, 1380, 199, 1121, 7165, 370, 543, 13217, 590, 13, 6376, 24272, 5093, 703, 3792, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 3, 3254, 8, 77, 573, 385, 304, 4155, 1454, 5171, 334, 1589, 720, 17269, 9, 282, 2849, 12, 2288, 1900, 199, 3, 2082, 334, 8304, 25686, 63, 12795, 6467, 63, 4831, 283, 1199, 63, 694, 659, 7830, 2419, 199, 3, 4902, 13, 493, 13, 6100, 2202, 334, 69, 14, 71, 14, 314, 8292, 315, 1900, 694, 14, 4312, 1038, 9, 626, 314, 1163, 199, 3, 16952, 2291, 12, 880, 642, 3181, 1133, 1736, 5966, 367, 1852, 14, 199, 3, 3254, 8, 77, 573, 385, 9, 4155, 2597, 965, 314, 4976, 626, 314, 2746, 13, 1896, 20618, 365, 5313, 370, 199, 3, 314, 4320, 4631, 2, 2909, 12, 1314, 365, 1373, 2166, 3432, 283, 2164, 297, 1325, 2066, 642, 511, 199, 3, 14569, 283, 2164, 7, 23430, 587, 12, 23188, 314, 20618, 22172, 12, 880, 1852, 883, 1133, 2342, 199, 3, 2399, 5274, 14, 473, 6704, 440, 3238, 340, 1852, 365, 6835, 367, 3575, 9682, 314, 1453, 199, 3, 2082, 12, 503, 340, 314, 511, 365, 6835, 367, 18002, 8137, 4046, 365, 1334, 199, 3, 314, 1453, 2082, 14, 199, 3, 14694, 12, 653, 4135, 12, 436, 21355, 886, 440, 2291, 4260, 314, 1900, 2082, 14, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 1, 1875, 297, 14597, 8675, 297, 14597, 6238, 297, 14597, 16472, 1105, 199, 199, 396, 14, 1065, 63, 6179, 360, 6595, 17, 14, 6179, 297, 2850, 4631, 29, 703, 297, 13097, 534, 2164, 358, 199, 692, 511, 14, 908, 508, 283, 8338, 356, 523, 340, 511, 14, 5589, 63, 14087, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 88, 5468, 297, 489, 2650, 30654, 30, 703, 1103, 21728, 1103, 2698, 1103, 1108, 30654, 5971, 523, 587, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 5468, 297, 489, 283, 2959, 6231, 628, 703, 1103, 21728, 1103, 2698, 1103, 9008, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 396, 14, 10622, 360, 18919, 15, 21728, 358, 199, 199, 3, 4155, 3238, 626, 1006, 314, 6137, 24272, 5093, 6839, 14, 1584, 1454, 664, 5324, 1334, 1900, 694, 12, 199, 3, 701, 10663, 1006, 402, 295, 6280, 1586, 13, 2118, 436, 2066, 10663, 1454, 1900, 694, 17267, 14, 199, 396, 14, 15053, 360, 18919, 297, 756, 9, 199, 396, 14, 15053, 360, 18919, 15, 21728, 297, 715, 9, 199, 199, 3, 26602, 314, 511, 28890, 6976, 1159, 4260, 10046, 45, 5441, 641, 314, 1414, 1004, 14, 199, 396, 14, 1506, 360, 6595, 17, 14, 6179, 297, 10046, 45, 5441, 29, 403, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 4921, 17, 275, 9638, 199, 6257, 687, 13205, 17, 14, 67, 199, 6257, 687, 2562, 17, 14, 67, 199, 624, 199, 199, 4921, 18, 275, 9638, 199, 6257, 687, 15488, 18, 15, 6595, 18, 14, 67, 199, 6257, 687, 2562, 18, 14, 67, 199, 624, 199, 199, 4921, 19, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 6595, 19, 14, 67, 199, 6257, 687, 2562, 19, 14, 67, 199, 624, 199, 199, 4921, 20, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 6595, 20, 14, 67, 199, 6257, 687, 2562, 20, 14, 67, 199, 624, 199, 199, 4921, 21, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 10622, 21, 15, 6595, 21, 14, 67, 199, 6257, 687, 2562, 21, 14, 67, 199, 624, 199, 199, 318, 1255, 63, 21728, 8, 6595, 12, 4282, 304, 523, 2935, 275, 283, 18919, 15, 21728, 15, 2698, 4805, 523, 511, 14, 1065, 8, 6815, 29, 396, 14, 800, 515, 8, 694, 435, 13205, 395, 3839, 29, 4921, 9, 199, 199, 1065, 63, 21728, 360, 6595, 17, 297, 4282, 17, 9, 199, 1065, 63, 21728, 360, 6595, 18, 297, 4282, 18, 9, 199, 1065, 63, 21728, 360, 6595, 19, 297, 4282, 19, 9, 199, 1065, 63, 21728, 360, 6595, 20, 297, 4282, 20, 9, 199, 1065, 63, 21728, 360, 6595, 21, 297, 4282, 21, 9, 199, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 7496, 314, 2202, 626, 7675, 282, 663, 402, 18572, 370, 506, 2737, 315, 199, 65, 2488, 1900, 2082, 12, 436, 626, 949, 13197, 6137, 1584, 199, 362, 2737, 9682, 402, 626, 1900, 2082, 14446, 2755, 1380, 199, 1121, 7165, 370, 543, 13217, 590, 13, 6376, 24272, 5093, 703, 3792, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 3, 3254, 8, 77, 573, 385, 304, 4155, 1454, 5171, 334, 1589, 720, 17269, 9, 282, 2849, 12, 2288, 1900, 199, 3, 2082, 334, 8304, 25686, 63, 12795, 6467, 63, 4831, 283, 1199, 63, 694, 659, 7830, 2419, 199, 3, 4902, 13, 493, 13, 6100, 2202, 334, 69, 14, 71, 14, 314, 8292, 315, 1900, 694, 14, 4312, 1038, 9, 626, 314, 1163, 199, 3, 16952, 2291, 12, 880, 642, 3181, 1133, 1736, 5966, 367, 1852, 14, 199, 3, 3254, 8, 77, 573, 385, 9, 4155, 2597, 965, 314, 4976, 626, 314, 2746, 13, 1896, 20618, 365, 5313, 370, 199, 3, 314, 4320, 4631, 2, 2909, 12, 1314, 365, 1373, 2166, 3432, 283, 2164, 297, 1325, 2066, 642, 511, 199, 3, 14569, 283, 2164, 7, 23430, 587, 12, 23188, 314, 20618, 22172, 12, 880, 1852, 883, 1133, 2342, 199, 3, 2399, 5274, 14, 473, 6704, 440, 3238, 340, 1852, 365, 6835, 367, 3575, 9682, 314, 1453, 199, 3, 2082, 12, 503, 340, 314, 511, 365, 6835, 367, 18002, 8137, 4046, 365, 1334, 199, 3, 314, 1453, 2082, 14, 199, 3, 14694, 12, 653, 4135, 12, 436, 21355, 886, 440, 2291, 4260, 314, 1900, 2082, 14, 199, 396, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 1, 1875, 297, 14597, 8675, 297, 14597, 6238, 297, 14597, 16472, 1105, 199, 199, 396, 14, 1065, 63, 6179, 360, 6595, 17, 14, 6179, 297, 2850, 4631, 29, 703, 297, 13097, 534, 2164, 358, 199, 692, 511, 14, 908, 508, 283, 8338, 356, 523, 340, 511, 14, 5589, 63, 14087, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 88, 5468, 297, 489, 2650, 30654, 30, 703, 1103, 21728, 1103, 2698, 1103, 1108, 30654, 5971, 523, 587, 26, 272, 511, 14, 7790, 63, 7747, 360, 2164, 15, 6595, 17, 14, 6737, 5468, 297, 489, 283, 2959, 6231, 628, 703, 1103, 21728, 1103, 2698, 1103, 9008, 199, 199, 396, 14, 18919, 360, 2164, 297, 283, 18919, 15, 2164, 358, 199, 199, 396, 14, 10622, 360, 18919, 15, 21728, 358, 199, 199, 3, 4155, 3238, 626, 1006, 314, 6137, 24272, 5093, 6839, 14, 1584, 1454, 664, 5324, 1334, 1900, 694, 12, 199, 3, 701, 10663, 1006, 402, 295, 6280, 1586, 13, 2118, 436, 2066, 10663, 1454, 1900, 694, 17267, 14, 199, 396, 14, 15053, 360, 18919, 297, 756, 9, 199, 396, 14, 15053, 360, 18919, 15, 21728, 297, 715, 9, 199, 199, 3, 26602, 314, 511, 28890, 6976, 1159, 4260, 10046, 45, 5441, 641, 314, 1414, 1004, 14, 199, 396, 14, 1506, 360, 6595, 17, 14, 6179, 297, 10046, 45, 5441, 29, 403, 12, 13097, 534, 18919, 15, 2164, 358, 199, 199, 4921, 17, 275, 9638, 199, 6257, 687, 13205, 17, 14, 67, 199, 6257, 687, 2562, 17, 14, 67, 199, 624, 199, 199, 4921, 18, 275, 9638, 199, 6257, 687, 15488, 18, 15, 6595, 18, 14, 67, 199, 6257, 687, 2562, 18, 14, 67, 199, 624, 199, 199, 4921, 19, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 6595, 19, 14, 67, 199, 6257, 687, 2562, 19, 14, 67, 199, 624, 199, 199, 4921, 20, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 6595, 20, 14, 67, 199, 6257, 687, 2562, 20, 14, 67, 199, 624, 199, 199, 4921, 21, 275, 9638, 199, 6257, 687, 15488, 18, 15, 10622, 19, 15, 10622, 20, 15, 10622, 21, 15, 6595, 21, 14, 67, 199, 6257, 687, 2562, 21, 14, 67, 199, 624, 199, 199, 318, 1255, 63, 21728, 8, 6595, 12, 4282, 304, 523, 2935, 275, 283, 18919, 15, 21728, 15, 2698, 4805, 523, 511, 14, 1065, 8, 6815, 29, 396, 14, 800, 515, 8, 694, 435, 13205, 395, 3839, 29, 4921, 9, 199, 199, 1065, 63, 21728, 360, 6595, 17, 297, 4282, 17, 9, 199, 1065, 63, 21728, 360, 6595, 18, 297, 4282, 18, 9, 199, 1065, 63, 21728, 360, 6595, 19, 297, 4282, 19, 9, 199, 1065, 63, 21728, 360, 6595, 20, 297, 4282, 20, 9, 199, 1065, 63, 21728, 360, 6595, 21, 297, 4282, 21, 9, 199, 199, 396, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
sulaweyo/torrentflux-b4rt-php7
html/bin/clients/mainline/BitTorrent/configfile.py
6
17671
# The contents of this file are subject to the BitTorrent Open Source License # Version 1.1 (the License). You may not copy or use this file, in either # source code or executable form, except in compliance with the License. You # may obtain a copy of the License at http://www.bittorrent.com/license/. # # Software distributed under the License is distributed on an AS IS basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # Written by Uoti Urpala and Matt Chisholm ########### # Needs redesign. Adding an app requires modifying a lot of if's. Blech. # --Dave ############ import os import sys import traceback from BitTorrent.translation import _ from ConfigParser import RawConfigParser from ConfigParser import MissingSectionHeaderError, ParsingError from BitTorrent import parseargs, version, BTFailure from BTL.platform import app_name from BTL.platform import encode_for_filesystem, decode_from_filesystem from BitTorrent.platform import get_save_dir, locale_root, is_frozen_exe from BitTorrent.platform import get_dot_dir, get_incomplete_data_dir from BitTorrent.platform import enforce_shortcut, enforce_association from BitTorrent.platform import smart_gettext_and_install from BitTorrent.platform import get_old_incomplete_data_dir from BitTorrent.platform import get_temp_subdir from BitTorrent.platform import old_broken_config_subencoding from BitTorrent.zurllib import bind_tracker_connection from BTL.exceptions import str_exc from BitTorrent.shortargs import convert_from_shortforms downloader_save_options = [ # General 'confirm_quit' , # Appearance 'progressbar_style' , 'toolbar_text' , 'toolbar_size' , # Bandwidth 'max_upload_rate' , 'max_download_rate' , # Saving 'save_in' , 'save_incomplete_in' , 'ask_for_save' , # Network 'minport' , 'maxport' , 'upnp' , 'ip' , 'resolve_hostnames' , # Misc 'open_from' , 'geometry' , 'start_maximized' , 'column_order' , 'enabled_columns' , 'column_widths' , 'sort_column' , 'sort_ascending' , 'show_details' , 'settings_tab' , 'details_tab' , 'splitter_height' , 'theme' , 'donated' , 'notified' , ] if os.name == 'nt': downloader_save_options.extend([ # General 'enforce_association' , 'launch_on_startup' , 'minimize_to_tray' , 'start_minimized' , 'close_to_tray' , # Bandwidth 'bandwidth_management', 'show_variance_line' , ]) MAIN_CONFIG_FILE = 'ui_config' TORRENT_CONFIG_FILE = 'torrent_config' alt_uiname = {'bittorrent':'btdownloadgui', 'maketorrent':'btmaketorrentgui',} def _read_config(filename): """Returns a RawConfigParser that has parsed the config file specified by the passed filename.""" # check for bad config files p = RawConfigParser() fp = None try: fp = open(filename) except IOError: pass if fp is not None: try: p.readfp(fp, filename=filename) except MissingSectionHeaderError: fp.close() del fp bad_config(filename) except ParsingError: fp.close() del fp bad_config(filename) else: fp.close() return p def _write_config(error_callback, filename, p): if not p.has_section('format'): p.add_section('format') p.set('format', 'encoding', 'utf-8') try: f = file(filename, 'wb') p.write(f) f.close() except Exception, e: try: f.close() except: pass error_callback(_("Could not permanently save options: ")+str_exc(e)) def bad_config(filename): base_bad_filename = filename + '.broken' bad_filename = base_bad_filename i = 0 while os.access(bad_filename, os.F_OK): bad_filename = base_bad_filename + str(i) i+=1 os.rename(filename, bad_filename) sys.stderr.write(_("Error reading config file. " "Old config file stored in \"%s\"") % bad_filename) def get_config(defaults, section): """This reads the key-value pairs from the specified section in the config file and from the common section. It then places those appearing in the defaults into a dict, which is then returned. @type defaults: dict @param defaults: dict of name-value pairs derived from the defaults list for this application (see defaultargs.py). Only the names in the name-value pairs are used. get_config only reads variables from the config file with matching names. @type section: str @param section: in the configuration from which to read options. So far, the sections have been named after applications, e.g., bittorrent, bittorrent-console, etc. @return: a dict containing option-value pairs. """ assert type(defaults)==dict assert type(section)==str configdir = get_dot_dir() if configdir is None: return {} if not os.path.isdir(configdir): try: os.mkdir(configdir, 0700) except: pass p = _read_config(os.path.join(configdir, 'config')) # returns parser. if p.has_section('format'): encoding = p.get('format', 'encoding') else: encoding = old_broken_config_subencoding values = {} if p.has_section(section): for name, value in p.items(section): if name in defaults: values[name] = value if p.has_section('common'): for name, value in p.items('common'): if name in defaults and name not in values: values[name] = value if defaults.get('data_dir') == '' and \ 'data_dir' not in values and os.path.isdir(configdir): datadir = os.path.join(configdir, 'data') values['data_dir'] = decode_from_filesystem(datadir) parseargs.parse_options(defaults, values, encoding) return values def save_global_config(defaults, section, error_callback, save_options=downloader_save_options): filename = os.path.join(defaults['data_dir'], MAIN_CONFIG_FILE) p = _read_config(filename) p.remove_section(section) if p.has_section(alt_uiname[section]): p.remove_section(alt_uiname[section]) p.add_section(section) for name in save_options: name.decode('ascii').encode('utf-8') # just to make sure we can if defaults.has_key(name): value = defaults[name] if isinstance(value, str): value = value.decode('ascii').encode('utf-8') elif isinstance(value, unicode): value = value.encode('utf-8') p.set(section, name, value) else: err_str = _("Configuration option mismatch: '%s'") % name if is_frozen_exe: err_str = _("You must quit %s and reinstall it. (%s)") % (app_name, err_str) error_callback(err_str) _write_config(error_callback, filename, p) def save_torrent_config(path, infohash, config, error_callback): section = infohash.encode('hex') filename = os.path.join(path, TORRENT_CONFIG_FILE) p = _read_config(filename) p.remove_section(section) p.add_section(section) for key, value in config.items(): p.set(section, key, value) _write_config(error_callback, filename, p) def read_torrent_config(global_config, path, infohash, error_callback): section = infohash.encode('hex') filename = os.path.join(path, TORRENT_CONFIG_FILE) p = _read_config(filename) if not p.has_section(section): return {} else: c = {} for name, value in p.items(section): if global_config.has_key(name): t = type(global_config[name]) if t == bool: c[name] = value in ('1', 'True', True) else: try: c[name] = type(global_config[name])(value) except ValueError, e: error_callback('%s (name:%s value:%s type:%s global:%s)' % (str_exc(e), name, repr(value), type(global_config[name]), global_config[name])) # is this reasonable? c[name] = global_config[name] elif name == 'save_as': # Backwards compatibility for BitTorrent 4.4 torrent_config file c[name] = value try: c[name] = c[name].decode('utf-8') except: pass return c def remove_torrent_config(path, infohash, error_callback): section = infohash.encode('hex') filename = os.path.join(path, TORRENT_CONFIG_FILE) p = _read_config(filename) if p.has_section(section): p.remove_section(section) _write_config(error_callback, filename, p) def parse_configuration_and_args(defaults, uiname, arglist=[], minargs=None, maxargs=None): """Given the default option settings and overrides these defaults from values read from the config file, and again overrides the config file with the arguments that appear in the arglist. 'defaults' is a list of tuples of the form (optname, value, desc) where 'optname' is a string containing the option's name, value is the option's default value, and desc is the option's description. 'uiname' is a string specifying the user interface that has been created by the caller. Ex: bittorrent, maketorrent. arglist is usually argv[1:], i.e., excluding the name used to execute the program. minargs specifies the minimum number of arguments that must appear in arglist. If the number of arguments is less than the minimum then a BTFailure exception is raised. maxargs specifies the maximum number of arguments that can appear in arglist. If the number of arguments exceeds the maximum then a BTFailure exception is raised. This returns the tuple (config,args) where config is a dictionary of (option, value) pairs, and args is the list of arguments in arglist after the command-line arguments have been removed. For example: bittorrent-curses.py --save_as lx-2.6.rpm lx-2.6.rpm.torrent --max_upload_rate 0 returns a (config,args) pair where the config dictionary contains many defaults plus the mappings 'save_as': 'linux-2.6.15.tar.gz' and 'max_upload_rate': 0 The args in the returned pair is args= ['linux-2.6.15.tar.gz.torrent'] """ assert type(defaults)==list assert type(uiname)==str assert type(arglist)==list assert minargs is None or type(minargs) in (int,long) and minargs>=0 assert maxargs is None or type(maxargs) in (int,long) and maxargs>=minargs # remap shortform arguments to their long-forms. arglist = convert_from_shortforms(arglist) defconfig = dict([(name, value) for (name, value, doc) in defaults]) if arglist[0:] == ['--version']: print version sys.exit(0) if arglist[0:] == '--help': parseargs.printHelp(uiname, defaults) sys.exit(0) if "--use_factory_defaults" not in arglist: presets = get_config(defconfig, uiname) # read from .bittorrent dir. # run as if fresh install using temporary directories. else: presets = {} temp_dir = get_temp_subdir() #set_config_dir(temp_dir) # is already set in platform.py. save_in = encode_for_filesystem( u"save_in" )[0] presets["save_in"] = \ decode_from_filesystem(os.path.join(temp_dir,save_in)) data = encode_for_filesystem( u"data" )[0] presets["data_dir"] = \ decode_from_filesystem(os.path.join(temp_dir,data)) incomplete = encode_for_filesystem( u"incomplete" )[0] presets["save_incomplete_in"] = \ decode_from_filesystem(os.path.join(temp_dir,incomplete)) presets["one_connection_per_ip"] = False config = args = None try: config, args = parseargs.parseargs(arglist, defaults, minargs, maxargs, presets) except parseargs.UsageException, e: print e parseargs.printHelp(uiname, defaults) sys.exit(0) datadir = config.get('data_dir') found_4x_config = False if datadir: datadir,bad = encode_for_filesystem(datadir) if bad: raise BTFailure(_("Invalid path encoding.")) if not os.path.exists(datadir): os.mkdir(datadir) if uiname in ('bittorrent', 'maketorrent'): values = {} p = _read_config(os.path.join(datadir, MAIN_CONFIG_FILE)) if p.has_section('format'): encoding = p.get('format', 'encoding') else: encoding = old_broken_config_subencoding if not p.has_section(uiname) and p.has_section(alt_uiname[uiname]): uiname = alt_uiname[uiname] if p.has_section(uiname): for name, value in p.items(uiname): if name in defconfig: values[name] = value elif not found_4x_config: # identify 4.x version config file if name in ('start_torrent_behavior', 'seed_forever', 'progressbar_hack', 'seed_last_forever', 'next_torrent_ratio', 'next_torrent_time', 'last_torrent_ratio', ): found_4x_config = True parseargs.parse_options(defconfig, values, encoding) presets.update(values) config, args = parseargs.parseargs(arglist, defaults, minargs, maxargs, presets) for d in ('', 'resume', 'metainfo', 'torrents'): ddir = os.path.join(datadir, d) if not os.path.exists(ddir): os.mkdir(ddir, 0700) else: assert(os.path.isdir(ddir)) if found_4x_config: # version 4.x stored KB/s, < version 4.x stores B/s config['max_upload_rate'] *= 1024 if config.get('language'): # this is non-blocking if the language does not exist smart_gettext_and_install('bittorrent', locale_root, languages=[config['language']]) if config.has_key('bind') and config['bind'] != '': bind_tracker_connection(config['bind']) if config.has_key('launch_on_startup'): enforce_shortcut(config, log_func=sys.stderr.write) if os.name == 'nt' and config.has_key('enforce_association'): enforce_association() if config.has_key('save_in') and config['save_in'] == '' and \ (not config.has_key("save_as") or config['save_as'] == '' ) \ and uiname != 'bittorrent': config['save_in'] = decode_from_filesystem(get_save_dir()) incomplete = decode_from_filesystem(get_incomplete_data_dir()) if config.get('save_incomplete_in') == '': config['save_incomplete_in'] = incomplete if config.get('save_incomplete_in') == get_old_incomplete_data_dir(): config['save_incomplete_in'] = incomplete if uiname == "test-client" or (uiname.startswith("bittorrent") and uiname != 'bittorrent-tracker'): if not config.get('ask_for_save'): # we check for existance, so things like "D:\" don't trip us up. if (config['save_in'] and not os.path.exists(config['save_in'])): try: os.makedirs(config['save_in']) except OSError, e: if (e.errno == 2 or # no such file or directory e.errno == 13): # permission denied traceback.print_exc() print >> sys.stderr, "save_in could not be created. Falling back to prompting." config['ask_for_save'] = True elif e.errno != 17: # path already exists raise if (config['save_incomplete_in'] and not os.path.exists(config['save_incomplete_in'])): try: os.makedirs(config['save_incomplete_in']) except OSError, e: if e.errno != 17: # path already exists traceback.print_exc() print >> sys.stderr, "save_incomplete_in could not be created. Falling back to default incomplete path." config['save_incomplete_in'] = incomplete return config, args
gpl-2.0
[ 3, 710, 4072, 402, 642, 570, 787, 5420, 370, 314, 10199, 32004, 3232, 5800, 844, 199, 3, 3394, 413, 14, 17, 334, 1589, 844, 680, 221, 2047, 1443, 440, 1331, 503, 675, 642, 570, 12, 315, 1902, 199, 3, 1350, 1233, 503, 7286, 1824, 12, 871, 315, 4151, 543, 314, 844, 14, 221, 2047, 199, 3, 1443, 3332, 282, 1331, 402, 314, 844, 737, 1455, 921, 1544, 14, 2075, 14101, 14, 957, 15, 1682, 8083, 199, 3, 199, 3, 2290, 1854, 1334, 314, 844, 365, 1854, 641, 376, 4319, 2281, 5597, 12, 199, 3, 2428, 3408, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 199, 3, 367, 314, 2488, 2637, 4210, 4481, 436, 4204, 1334, 314, 199, 3, 844, 14, 199, 199, 3, 27694, 701, 738, 79, 280, 738, 4599, 14774, 436, 31653, 445, 866, 24588, 77, 199, 199, 516, 5680, 199, 3, 29613, 295, 14748, 14, 221, 12934, 376, 1145, 5074, 24662, 282, 13918, 402, 340, 1159, 14, 699, 274, 335, 14, 199, 3, 258, 1553, 36, 811, 199, 516, 381, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 10199, 32004, 14, 6893, 492, 485, 199, 199, 504, 14196, 492, 13480, 15218, 199, 504, 14196, 492, 15626, 8660, 26599, 12, 28747, 547, 199, 504, 10199, 32004, 492, 2198, 589, 12, 1015, 12, 699, 52, 6782, 199, 504, 699, 7308, 14, 3246, 492, 1145, 63, 354, 199, 504, 699, 7308, 14, 3246, 492, 3752, 63, 509, 63, 11381, 12, 4849, 63, 504, 63, 11381, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 2117, 63, 694, 12, 5867, 63, 1231, 12, 365, 63, 11202, 63, 5803, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 3287, 63, 694, 12, 664, 63, 24575, 63, 576, 63, 694, 199, 504, 10199, 32004, 14, 3246, 492, 15814, 63, 24231, 12, 15814, 63, 20252, 199, 504, 10199, 32004, 14, 3246, 492, 11179, 63, 5152, 63, 460, 63, 3174, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 1753, 63, 24575, 63, 576, 63, 694, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 808, 63, 10622, 199, 504, 10199, 32004, 14, 3246, 492, 2269, 63, 15697, 63, 888, 63, 954, 2991, 199, 504, 10199, 32004, 14, 90, 4078, 492, 5398, 63, 8877, 63, 2105, 199, 504, 699, 7308, 14, 3924, 492, 620, 63, 2804, 199, 504, 10199, 32004, 14, 3612, 589, 492, 3957, 63, 504, 63, 3612, 3351, 199, 199, 22846, 63, 2117, 63, 1419, 275, 359, 272, 327, 1696, 272, 283, 9548, 63, 10589, 7, 3515, 2360, 339, 327, 13450, 16343, 554, 272, 283, 5734, 1700, 63, 2487, 7, 258, 2360, 272, 283, 13951, 63, 505, 7, 3515, 2360, 272, 283, 13951, 63, 890, 7, 3515, 2360, 339, 327, 27709, 2063, 272, 283, 988, 63, 5064, 63, 1866, 7, 755, 2360, 272, 283, 988, 63, 4249, 63, 1866, 7, 258, 2360, 339, 327, 428, 5519, 272, 283, 2117, 63, 262, 7, 5185, 2360, 272, 283, 2117, 63, 24575, 63, 262, 7, 259, 2360, 272, 283, 813, 63, 509, 63, 2117, 7, 3515, 2360, 339, 327, 7220, 272, 283, 827, 719, 7, 5185, 2360, 272, 283, 988, 719, 7, 5185, 2360, 272, 283, 384, 1590, 7, 8295, 2360, 272, 283, 711, 7, 8540, 2360, 272, 283, 6983, 63, 1102, 1247, 7, 258, 2360, 339, 327, 603, 10840, 272, 283, 1490, 63, 504, 7, 3777, 2360, 272, 283, 7660, 7, 4519, 2360, 272, 283, 928, 63, 988, 1017, 1759, 7, 755, 2360, 272, 283, 2301, 63, 1648, 7, 3515, 2360, 272, 283, 3827, 63, 3406, 7, 755, 2360, 272, 283, 2301, 63, 22209, 7, 260, 2360, 272, 283, 3191, 63, 2301, 7, 3698, 2360, 272, 283, 3191, 63, 10125, 3219, 7, 263, 2360, 272, 283, 2384, 63, 5087, 7, 3515, 2360, 272, 283, 1751, 63, 2902, 7, 3515, 2360, 272, 283, 5087, 63, 2902, 7, 3698, 2360, 272, 283, 25234, 63, 3333, 7, 755, 2360, 272, 283, 7915, 7, 463, 2360, 339, 283, 13196, 972, 7, 5185, 2360, 272, 283, 889, 8981, 7, 4519, 2360, 272, 1622, 199, 199, 692, 747, 14, 354, 508, 283, 343, 356, 272, 3224, 3422, 63, 2117, 63, 1419, 14, 2880, 779, 267, 327, 1696, 267, 283, 19817, 63, 20252, 7, 2360, 267, 283, 9850, 63, 265, 63, 16480, 7, 257, 2360, 267, 283, 19333, 63, 475, 63, 84, 803, 7, 259, 2360, 267, 283, 928, 63, 827, 1017, 1759, 7, 258, 2360, 267, 283, 1600, 63, 475, 63, 84, 803, 7, 755, 2360, 398, 327, 27709, 2063, 267, 283, 18358, 63, 8110, 297, 267, 283, 2384, 63, 6221, 63, 604, 7, 221, 2360, 267, 4794, 199, 199, 5848, 63, 5569, 63, 3817, 275, 283, 1907, 63, 888, 7, 199, 52, 726, 11574, 63, 5569, 63, 3817, 275, 283, 14101, 63, 888, 7, 199, 199, 4478, 63, 85, 32228, 275, 791, 2075, 14101, 5242, 66, 2076, 944, 912, 5885, 297, 1598, 283, 22191, 386, 269, 640, 5242, 13061, 22191, 386, 269, 640, 5885, 297, 93, 421, 199, 318, 485, 739, 63, 888, 8, 1501, 304, 272, 408, 3407, 282, 13480, 15218, 626, 965, 4565, 314, 1101, 570, 2013, 701, 2126, 314, 3032, 1788, 1041, 339, 327, 1104, 367, 4875, 1101, 1584, 272, 299, 275, 13480, 15218, 342, 272, 4090, 275, 488, 272, 862, 26, 267, 4090, 275, 1551, 8, 1501, 9, 272, 871, 5925, 26, 267, 986, 339, 340, 4090, 365, 440, 488, 26, 267, 862, 26, 288, 299, 14, 739, 3997, 8, 3997, 12, 1788, 29, 1501, 9, 267, 871, 15626, 8660, 26599, 26, 288, 4090, 14, 1600, 342, 288, 2150, 4090, 288, 4875, 63, 888, 8, 1501, 9, 267, 871, 28747, 547, 26, 288, 4090, 14, 1600, 342, 288, 2150, 4090, 288, 4875, 63, 888, 8, 1501, 9, 267, 587, 26, 288, 4090, 14, 1600, 342, 339, 372, 299, 421, 199, 318, 485, 952, 63, 888, 8, 705, 63, 3058, 12, 1788, 12, 299, 304, 272, 340, 440, 299, 14, 1989, 63, 2792, 360, 908, 735, 267, 299, 14, 525, 63, 2792, 360, 908, 358, 272, 299, 14, 409, 360, 908, 297, 283, 2991, 297, 283, 1624, 13, 24, 358, 272, 862, 26, 267, 289, 275, 570, 8, 1501, 12, 283, 6603 ]
[ 710, 4072, 402, 642, 570, 787, 5420, 370, 314, 10199, 32004, 3232, 5800, 844, 199, 3, 3394, 413, 14, 17, 334, 1589, 844, 680, 221, 2047, 1443, 440, 1331, 503, 675, 642, 570, 12, 315, 1902, 199, 3, 1350, 1233, 503, 7286, 1824, 12, 871, 315, 4151, 543, 314, 844, 14, 221, 2047, 199, 3, 1443, 3332, 282, 1331, 402, 314, 844, 737, 1455, 921, 1544, 14, 2075, 14101, 14, 957, 15, 1682, 8083, 199, 3, 199, 3, 2290, 1854, 1334, 314, 844, 365, 1854, 641, 376, 4319, 2281, 5597, 12, 199, 3, 2428, 3408, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 199, 3, 367, 314, 2488, 2637, 4210, 4481, 436, 4204, 1334, 314, 199, 3, 844, 14, 199, 199, 3, 27694, 701, 738, 79, 280, 738, 4599, 14774, 436, 31653, 445, 866, 24588, 77, 199, 199, 516, 5680, 199, 3, 29613, 295, 14748, 14, 221, 12934, 376, 1145, 5074, 24662, 282, 13918, 402, 340, 1159, 14, 699, 274, 335, 14, 199, 3, 258, 1553, 36, 811, 199, 516, 381, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 10199, 32004, 14, 6893, 492, 485, 199, 199, 504, 14196, 492, 13480, 15218, 199, 504, 14196, 492, 15626, 8660, 26599, 12, 28747, 547, 199, 504, 10199, 32004, 492, 2198, 589, 12, 1015, 12, 699, 52, 6782, 199, 504, 699, 7308, 14, 3246, 492, 1145, 63, 354, 199, 504, 699, 7308, 14, 3246, 492, 3752, 63, 509, 63, 11381, 12, 4849, 63, 504, 63, 11381, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 2117, 63, 694, 12, 5867, 63, 1231, 12, 365, 63, 11202, 63, 5803, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 3287, 63, 694, 12, 664, 63, 24575, 63, 576, 63, 694, 199, 504, 10199, 32004, 14, 3246, 492, 15814, 63, 24231, 12, 15814, 63, 20252, 199, 504, 10199, 32004, 14, 3246, 492, 11179, 63, 5152, 63, 460, 63, 3174, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 1753, 63, 24575, 63, 576, 63, 694, 199, 504, 10199, 32004, 14, 3246, 492, 664, 63, 808, 63, 10622, 199, 504, 10199, 32004, 14, 3246, 492, 2269, 63, 15697, 63, 888, 63, 954, 2991, 199, 504, 10199, 32004, 14, 90, 4078, 492, 5398, 63, 8877, 63, 2105, 199, 504, 699, 7308, 14, 3924, 492, 620, 63, 2804, 199, 504, 10199, 32004, 14, 3612, 589, 492, 3957, 63, 504, 63, 3612, 3351, 199, 199, 22846, 63, 2117, 63, 1419, 275, 359, 272, 327, 1696, 272, 283, 9548, 63, 10589, 7, 3515, 2360, 339, 327, 13450, 16343, 554, 272, 283, 5734, 1700, 63, 2487, 7, 258, 2360, 272, 283, 13951, 63, 505, 7, 3515, 2360, 272, 283, 13951, 63, 890, 7, 3515, 2360, 339, 327, 27709, 2063, 272, 283, 988, 63, 5064, 63, 1866, 7, 755, 2360, 272, 283, 988, 63, 4249, 63, 1866, 7, 258, 2360, 339, 327, 428, 5519, 272, 283, 2117, 63, 262, 7, 5185, 2360, 272, 283, 2117, 63, 24575, 63, 262, 7, 259, 2360, 272, 283, 813, 63, 509, 63, 2117, 7, 3515, 2360, 339, 327, 7220, 272, 283, 827, 719, 7, 5185, 2360, 272, 283, 988, 719, 7, 5185, 2360, 272, 283, 384, 1590, 7, 8295, 2360, 272, 283, 711, 7, 8540, 2360, 272, 283, 6983, 63, 1102, 1247, 7, 258, 2360, 339, 327, 603, 10840, 272, 283, 1490, 63, 504, 7, 3777, 2360, 272, 283, 7660, 7, 4519, 2360, 272, 283, 928, 63, 988, 1017, 1759, 7, 755, 2360, 272, 283, 2301, 63, 1648, 7, 3515, 2360, 272, 283, 3827, 63, 3406, 7, 755, 2360, 272, 283, 2301, 63, 22209, 7, 260, 2360, 272, 283, 3191, 63, 2301, 7, 3698, 2360, 272, 283, 3191, 63, 10125, 3219, 7, 263, 2360, 272, 283, 2384, 63, 5087, 7, 3515, 2360, 272, 283, 1751, 63, 2902, 7, 3515, 2360, 272, 283, 5087, 63, 2902, 7, 3698, 2360, 272, 283, 25234, 63, 3333, 7, 755, 2360, 272, 283, 7915, 7, 463, 2360, 339, 283, 13196, 972, 7, 5185, 2360, 272, 283, 889, 8981, 7, 4519, 2360, 272, 1622, 199, 199, 692, 747, 14, 354, 508, 283, 343, 356, 272, 3224, 3422, 63, 2117, 63, 1419, 14, 2880, 779, 267, 327, 1696, 267, 283, 19817, 63, 20252, 7, 2360, 267, 283, 9850, 63, 265, 63, 16480, 7, 257, 2360, 267, 283, 19333, 63, 475, 63, 84, 803, 7, 259, 2360, 267, 283, 928, 63, 827, 1017, 1759, 7, 258, 2360, 267, 283, 1600, 63, 475, 63, 84, 803, 7, 755, 2360, 398, 327, 27709, 2063, 267, 283, 18358, 63, 8110, 297, 267, 283, 2384, 63, 6221, 63, 604, 7, 221, 2360, 267, 4794, 199, 199, 5848, 63, 5569, 63, 3817, 275, 283, 1907, 63, 888, 7, 199, 52, 726, 11574, 63, 5569, 63, 3817, 275, 283, 14101, 63, 888, 7, 199, 199, 4478, 63, 85, 32228, 275, 791, 2075, 14101, 5242, 66, 2076, 944, 912, 5885, 297, 1598, 283, 22191, 386, 269, 640, 5242, 13061, 22191, 386, 269, 640, 5885, 297, 93, 421, 199, 318, 485, 739, 63, 888, 8, 1501, 304, 272, 408, 3407, 282, 13480, 15218, 626, 965, 4565, 314, 1101, 570, 2013, 701, 2126, 314, 3032, 1788, 1041, 339, 327, 1104, 367, 4875, 1101, 1584, 272, 299, 275, 13480, 15218, 342, 272, 4090, 275, 488, 272, 862, 26, 267, 4090, 275, 1551, 8, 1501, 9, 272, 871, 5925, 26, 267, 986, 339, 340, 4090, 365, 440, 488, 26, 267, 862, 26, 288, 299, 14, 739, 3997, 8, 3997, 12, 1788, 29, 1501, 9, 267, 871, 15626, 8660, 26599, 26, 288, 4090, 14, 1600, 342, 288, 2150, 4090, 288, 4875, 63, 888, 8, 1501, 9, 267, 871, 28747, 547, 26, 288, 4090, 14, 1600, 342, 288, 2150, 4090, 288, 4875, 63, 888, 8, 1501, 9, 267, 587, 26, 288, 4090, 14, 1600, 342, 339, 372, 299, 421, 199, 318, 485, 952, 63, 888, 8, 705, 63, 3058, 12, 1788, 12, 299, 304, 272, 340, 440, 299, 14, 1989, 63, 2792, 360, 908, 735, 267, 299, 14, 525, 63, 2792, 360, 908, 358, 272, 299, 14, 409, 360, 908, 297, 283, 2991, 297, 283, 1624, 13, 24,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ClimbsRocks/scikit-learn
examples/linear_model/plot_sgd_comparison.py
112
1819
""" ================================== Comparing various online solvers ================================== An example showing how different online solvers perform on the hand-written digits dataset. """ # Author: Rob Zinkov <rob at zinkov dot com> # License: BSD 3 clause import numpy as np import matplotlib.pyplot as plt from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.linear_model import SGDClassifier, Perceptron from sklearn.linear_model import PassiveAggressiveClassifier from sklearn.linear_model import LogisticRegression heldout = [0.95, 0.90, 0.75, 0.50, 0.01] rounds = 20 digits = datasets.load_digits() X, y = digits.data, digits.target classifiers = [ ("SGD", SGDClassifier()), ("ASGD", SGDClassifier(average=True)), ("Perceptron", Perceptron()), ("Passive-Aggressive I", PassiveAggressiveClassifier(loss='hinge', C=1.0)), ("Passive-Aggressive II", PassiveAggressiveClassifier(loss='squared_hinge', C=1.0)), ("SAG", LogisticRegression(solver='sag', tol=1e-1, C=1.e4 / X.shape[0])) ] xx = 1. - np.array(heldout) for name, clf in classifiers: print("training %s" % name) rng = np.random.RandomState(42) yy = [] for i in heldout: yy_ = [] for r in range(rounds): X_train, X_test, y_train, y_test = \ train_test_split(X, y, test_size=i, random_state=rng) clf.fit(X_train, y_train) y_pred = clf.predict(X_test) yy_.append(1 - np.mean(y_pred == y_test)) yy.append(np.mean(yy_)) plt.plot(xx, yy, label=name) plt.legend(loc="upper right") plt.xlabel("Proportion train") plt.ylabel("Test Error Rate") plt.show()
bsd-3-clause
[ 624, 199, 2486, 389, 199, 2404, 9332, 7750, 18470, 10196, 83, 199, 2486, 389, 199, 199, 2493, 2893, 21207, 4212, 3365, 18470, 10196, 83, 5147, 199, 265, 314, 4926, 13, 8938, 7576, 4789, 14, 199, 199, 624, 199, 3, 6529, 26, 820, 2873, 3107, 2292, 8822, 665, 29891, 737, 1315, 2292, 8822, 6308, 2414, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 6357, 492, 13148, 199, 199, 504, 6357, 14, 1238, 63, 5592, 492, 3560, 63, 396, 63, 1294, 199, 504, 6357, 14, 6676, 63, 1238, 492, 18868, 36, 8508, 12, 3492, 301, 4695, 265, 199, 504, 6357, 14, 6676, 63, 1238, 492, 510, 13202, 7248, 470, 3398, 8508, 199, 504, 6357, 14, 6676, 63, 1238, 492, 27903, 199, 199, 31415, 548, 275, 359, 16, 14, 2720, 12, 378, 14, 2710, 12, 378, 14, 2194, 12, 378, 14, 1400, 12, 378, 14, 614, 61, 199, 23171, 275, 3388, 199, 7022, 275, 13148, 14, 912, 63, 7022, 342, 199, 56, 12, 612, 275, 7576, 14, 576, 12, 7576, 14, 1375, 199, 199, 27628, 275, 359, 272, 1689, 4254, 36, 401, 18868, 36, 8508, 4000, 272, 1689, 1179, 27046, 401, 18868, 36, 8508, 8, 8536, 29, 549, 1826, 272, 1689, 2623, 301, 4695, 265, 401, 3492, 301, 4695, 265, 4000, 272, 1689, 48, 13202, 13, 7248, 470, 3398, 473, 401, 510, 13202, 7248, 470, 3398, 8508, 8, 4358, 534, 27809, 297, 12740, 445, 29, 17, 14, 16, 1826, 272, 1689, 48, 13202, 13, 7248, 470, 3398, 473, 41, 401, 510, 13202, 7248, 470, 3398, 8508, 8, 4358, 534, 12973, 63, 27809, 297, 12933, 445, 29, 17, 14, 16, 1826, 272, 1689, 51, 1254, 401, 27903, 8, 11263, 534, 83, 643, 297, 9561, 29, 17, 69, 13, 17, 12, 445, 29, 17, 14, 69, 20, 1182, 1323, 14, 1392, 59, 16, 2459, 199, 61, 199, 199, 2154, 275, 413, 14, 446, 980, 14, 1144, 8, 31415, 548, 9, 199, 199, 509, 536, 12, 6975, 315, 19137, 26, 272, 870, 480, 7588, 450, 83, 2, 450, 536, 9, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 2260, 9, 272, 20435, 275, 942, 272, 367, 284, 315, 23608, 548, 26, 267, 20435, 63, 275, 942, 267, 367, 519, 315, 1425, 8, 23171, 304, 288, 1323, 63, 2834, 12, 1323, 63, 396, 12, 612, 63, 2834, 12, 612, 63, 396, 275, 971, 355, 3560, 63, 396, 63, 1294, 8, 56, 12, 612, 12, 511, 63, 890, 29, 73, 12, 2196, 63, 929, 29, 12686, 9, 288, 6975, 14, 3269, 8, 56, 63, 2834, 12, 612, 63, 2834, 9, 288, 612, 63, 5991, 275, 6975, 14, 6892, 8, 56, 63, 396, 9, 288, 20435, 3754, 740, 8, 17, 446, 980, 14, 3670, 8, 89, 63, 5991, 508, 612, 63, 396, 430, 267, 20435, 14, 740, 8, 1590, 14, 3670, 8, 7566, 13309, 272, 4488, 14, 2798, 8, 2154, 12, 20435, 12, 1768, 29, 354, 9, 199, 199, 6003, 14, 10231, 8, 2102, 628, 4142, 2451, 531, 199, 6003, 14, 14168, 480, 919, 7314, 296, 3560, 531, 199, 6003, 14, 13849, 480, 774, 4520, 26311, 531, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2486, 389, 199, 2404, 9332, 7750, 18470, 10196, 83, 199, 2486, 389, 199, 199, 2493, 2893, 21207, 4212, 3365, 18470, 10196, 83, 5147, 199, 265, 314, 4926, 13, 8938, 7576, 4789, 14, 199, 199, 624, 199, 3, 6529, 26, 820, 2873, 3107, 2292, 8822, 665, 29891, 737, 1315, 2292, 8822, 6308, 2414, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 6357, 492, 13148, 199, 199, 504, 6357, 14, 1238, 63, 5592, 492, 3560, 63, 396, 63, 1294, 199, 504, 6357, 14, 6676, 63, 1238, 492, 18868, 36, 8508, 12, 3492, 301, 4695, 265, 199, 504, 6357, 14, 6676, 63, 1238, 492, 510, 13202, 7248, 470, 3398, 8508, 199, 504, 6357, 14, 6676, 63, 1238, 492, 27903, 199, 199, 31415, 548, 275, 359, 16, 14, 2720, 12, 378, 14, 2710, 12, 378, 14, 2194, 12, 378, 14, 1400, 12, 378, 14, 614, 61, 199, 23171, 275, 3388, 199, 7022, 275, 13148, 14, 912, 63, 7022, 342, 199, 56, 12, 612, 275, 7576, 14, 576, 12, 7576, 14, 1375, 199, 199, 27628, 275, 359, 272, 1689, 4254, 36, 401, 18868, 36, 8508, 4000, 272, 1689, 1179, 27046, 401, 18868, 36, 8508, 8, 8536, 29, 549, 1826, 272, 1689, 2623, 301, 4695, 265, 401, 3492, 301, 4695, 265, 4000, 272, 1689, 48, 13202, 13, 7248, 470, 3398, 473, 401, 510, 13202, 7248, 470, 3398, 8508, 8, 4358, 534, 27809, 297, 12740, 445, 29, 17, 14, 16, 1826, 272, 1689, 48, 13202, 13, 7248, 470, 3398, 473, 41, 401, 510, 13202, 7248, 470, 3398, 8508, 8, 4358, 534, 12973, 63, 27809, 297, 12933, 445, 29, 17, 14, 16, 1826, 272, 1689, 51, 1254, 401, 27903, 8, 11263, 534, 83, 643, 297, 9561, 29, 17, 69, 13, 17, 12, 445, 29, 17, 14, 69, 20, 1182, 1323, 14, 1392, 59, 16, 2459, 199, 61, 199, 199, 2154, 275, 413, 14, 446, 980, 14, 1144, 8, 31415, 548, 9, 199, 199, 509, 536, 12, 6975, 315, 19137, 26, 272, 870, 480, 7588, 450, 83, 2, 450, 536, 9, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 2260, 9, 272, 20435, 275, 942, 272, 367, 284, 315, 23608, 548, 26, 267, 20435, 63, 275, 942, 267, 367, 519, 315, 1425, 8, 23171, 304, 288, 1323, 63, 2834, 12, 1323, 63, 396, 12, 612, 63, 2834, 12, 612, 63, 396, 275, 971, 355, 3560, 63, 396, 63, 1294, 8, 56, 12, 612, 12, 511, 63, 890, 29, 73, 12, 2196, 63, 929, 29, 12686, 9, 288, 6975, 14, 3269, 8, 56, 63, 2834, 12, 612, 63, 2834, 9, 288, 612, 63, 5991, 275, 6975, 14, 6892, 8, 56, 63, 396, 9, 288, 20435, 3754, 740, 8, 17, 446, 980, 14, 3670, 8, 89, 63, 5991, 508, 612, 63, 396, 430, 267, 20435, 14, 740, 8, 1590, 14, 3670, 8, 7566, 13309, 272, 4488, 14, 2798, 8, 2154, 12, 20435, 12, 1768, 29, 354, 9, 199, 199, 6003, 14, 10231, 8, 2102, 628, 4142, 2451, 531, 199, 6003, 14, 14168, 480, 919, 7314, 296, 3560, 531, 199, 6003, 14, 13849, 480, 774, 4520, 26311, 531, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
larsks/cloud-init-patches
cloudinit/sources/DataSourceDigitalOcean.py
2
4286
# vi: ts=4 expandtab # # Author: Neal Shrader <neal@digitalocean.com> # Author: Ben Howard <bh@digitalocean.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # DigitalOcean Droplet API: # https://developers.digitalocean.com/documentation/metadata/ from cloudinit import log as logging from cloudinit import sources from cloudinit import util import cloudinit.sources.helpers.digitalocean as do_helper LOG = logging.getLogger(__name__) BUILTIN_DS_CONFIG = { 'metadata_url': 'http://169.254.169.254/metadata/v1.json', } # Wait for a up to a minute, retrying the meta-data server # every 2 seconds. MD_RETRIES = 30 MD_TIMEOUT = 2 MD_WAIT_RETRY = 2 MD_USE_IPV4LL = True class DataSourceDigitalOcean(sources.DataSource): def __init__(self, sys_cfg, distro, paths): sources.DataSource.__init__(self, sys_cfg, distro, paths) self.distro = distro self.metadata = dict() self.ds_cfg = util.mergemanydict([ util.get_cfg_by_path(sys_cfg, ["datasource", "DigitalOcean"], {}), BUILTIN_DS_CONFIG]) self.metadata_address = self.ds_cfg['metadata_url'] self.retries = self.ds_cfg.get('retries', MD_RETRIES) self.timeout = self.ds_cfg.get('timeout', MD_TIMEOUT) self.use_ip4LL = self.ds_cfg.get('use_ip4LL', MD_USE_IPV4LL) self.wait_retry = self.ds_cfg.get('wait_retry', MD_WAIT_RETRY) self._network_config = None def _get_sysinfo(self): return do_helper.read_sysinfo() def get_data(self): (is_do, droplet_id) = self._get_sysinfo() # only proceed if we know we are on DigitalOcean if not is_do: return False LOG.info("Running on digital ocean. droplet_id=%s" % droplet_id) ipv4LL_nic = None if self.use_ip4LL: ipv4LL_nic = do_helper.assign_ipv4_link_local() md = do_helper.read_metadata( self.metadata_address, timeout=self.timeout, sec_between=self.wait_retry, retries=self.retries) self.metadata_full = md self.metadata['instance-id'] = md.get('droplet_id', droplet_id) self.metadata['local-hostname'] = md.get('hostname', droplet_id) self.metadata['interfaces'] = md.get('interfaces') self.metadata['public-keys'] = md.get('public_keys') self.metadata['availability_zone'] = md.get('region', 'default') self.vendordata_raw = md.get("vendor_data", None) self.userdata_raw = md.get("user_data", None) if ipv4LL_nic: do_helper.del_ipv4_link_local(ipv4LL_nic) return True def check_instance_id(self, sys_cfg): return sources.instance_id_matches_system_uuid( self.get_instance_id(), 'system-serial-number') @property def network_config(self): """Configure the networking. This needs to be done each boot, since the IP information may have changed due to snapshot and/or migration. """ if self._network_config: return self._network_config interfaces = self.metadata.get('interfaces') LOG.debug(interfaces) if not interfaces: raise Exception("Unable to get meta-data from server....") nameservers = self.metadata_full['dns']['nameservers'] self._network_config = do_helper.convert_network_configuration( interfaces, nameservers) return self._network_config # Used to match classes to dependencies datasources = [ (DataSourceDigitalOcean, (sources.DEP_FILESYSTEM, )), ] # Return a list of data sources that match this set of dependencies def get_datasource_list(depends): return sources.list_from_depends(depends, datasources)
gpl-3.0
[ 3, 1321, 26, 6714, 29, 20, 26414, 199, 3, 199, 3, 259, 6529, 26, 5612, 279, 5244, 345, 424, 665, 685, 279, 32, 8573, 12201, 20867, 14, 957, 30, 199, 3, 259, 6529, 26, 26844, 7494, 1005, 221, 665, 26397, 32, 8573, 12201, 20867, 14, 957, 30, 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, 1015, 650, 12, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 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, 4743, 199, 199, 3, 29979, 47, 20867, 18110, 2723, 3261, 26, 199, 3, 4178, 921, 23826, 14, 8573, 12201, 20867, 14, 957, 15, 9970, 15, 2343, 15, 199, 199, 504, 8002, 826, 492, 943, 465, 2050, 199, 504, 8002, 826, 492, 5274, 199, 504, 8002, 826, 492, 4884, 199, 199, 646, 8002, 826, 14, 4553, 14, 7546, 14, 8573, 12201, 20867, 465, 886, 63, 3676, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 18637, 20012, 63, 3177, 63, 5569, 275, 469, 272, 283, 2343, 63, 633, 356, 283, 1014, 921, 10143, 14, 8306, 14, 10143, 14, 8306, 15, 2343, 15, 86, 17, 14, 1001, 297, 199, 93, 199, 199, 3, 13144, 367, 282, 1536, 370, 282, 12709, 12, 7269, 316, 314, 3404, 13, 576, 1654, 199, 3, 4036, 499, 4696, 14, 199, 5127, 63, 32528, 275, 4233, 199, 5127, 63, 8899, 275, 499, 199, 5127, 63, 12458, 63, 27778, 275, 499, 199, 5127, 63, 4701, 63, 11253, 20, 4464, 275, 715, 421, 199, 533, 24300, 32660, 47, 20867, 8, 4553, 14, 16693, 304, 272, 347, 636, 826, 721, 277, 12, 984, 63, 4128, 12, 20499, 12, 3792, 304, 267, 5274, 14, 16693, 855, 826, 721, 277, 12, 984, 63, 4128, 12, 20499, 12, 3792, 9, 267, 291, 14, 18371, 275, 20499, 267, 291, 14, 2343, 275, 1211, 342, 267, 291, 14, 795, 63, 4128, 275, 4884, 14, 5628, 3479, 807, 779, 288, 4884, 14, 362, 63, 4128, 63, 991, 63, 515, 8, 1274, 63, 4128, 12, 2097, 21208, 401, 298, 32660, 47, 20867, 2255, 8613, 288, 16331, 1193, 20012, 63, 3177, 63, 5569, 566, 267, 291, 14, 2343, 63, 1562, 275, 291, 14, 795, 63, 4128, 459, 2343, 63, 633, 418, 267, 291, 14, 10937, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 10937, 297, 15830, 63, 32528, 9, 267, 291, 14, 2593, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 2593, 297, 15830, 63, 8899, 9, 267, 291, 14, 1180, 63, 711, 20, 4464, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 1180, 63, 711, 20, 4464, 297, 15830, 63, 4701, 63, 11253, 20, 4464, 9, 267, 291, 14, 2573, 63, 7154, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 2573, 63, 7154, 297, 15830, 63, 12458, 63, 27778, 9, 267, 291, 423, 1200, 63, 888, 275, 488, 339, 347, 485, 362, 63, 1274, 815, 8, 277, 304, 267, 372, 886, 63, 3676, 14, 739, 63, 1274, 815, 342, 339, 347, 664, 63, 576, 8, 277, 304, 267, 334, 374, 63, 1117, 12, 5978, 2723, 63, 344, 9, 275, 291, 423, 362, 63, 1274, 815, 342, 398, 327, 1454, 20320, 340, 781, 5715, 781, 787, 641, 29979, 47, 20867, 267, 340, 440, 365, 63, 1117, 26, 288, 372, 756, 398, 5051, 14, 815, 480, 9602, 641, 20545, 312, 20867, 14, 5978, 2723, 63, 344, 2458, 83, 2, 450, 5978, 2723, 63, 344, 9, 398, 3278, 20, 4464, 63, 12165, 275, 488, 267, 340, 291, 14, 1180, 63, 711, 20, 4464, 26, 288, 3278, 20, 4464, 63, 12165, 275, 886, 63, 3676, 14, 5038, 63, 4774, 20, 63, 1073, 63, 1832, 342, 398, 6128, 275, 886, 63, 3676, 14, 739, 63, 2343, 8, 288, 291, 14, 2343, 63, 1562, 12, 2653, 29, 277, 14, 2593, 12, 288, 6513, 63, 13007, 29, 277, 14, 2573, 63, 7154, 12, 10086, 29, 277, 14, 10937, 9, 398, 291, 14, 2343, 63, 2861, 275, 6128, 267, 291, 14, 2343, 459, 842, 13, 344, 418, 275, 6128, 14, 362, 360, 4824, 2723, 63, 344, 297, 5978, 2723, 63, 344, 9, 267, 291, 14, 2343, 459, 1832, 13, 4269, 418, 275, 6128, 14, 362, 360, 4269, 297, 5978, 2723, 63, 344, 9, 267, 291, 14, 2343, 459, 7436, 418, 275, 6128, 14, 362, 360, 7436, 358, 267, 291, 14, 2343, 459, 3455, 13, 1612, 418, 275, 6128, 14, 362, 360, 3455, 63, 1612, 358, 267, 291, 14, 2343, 459, 11856, 63, 2619, 418, 275, 6128, 14, 362, 360, 4551, 297, 283, 885, 358, 267, 291, 14, 9884, 576, 63, 1773, 275, 6128, 14, 362, 480, 9884, 63, 576, 401, 488, 9, 267, 291, 14, 751, 576, 63, 1773, 275, 6128, 14, 362, 480, 751, 63, 576, 401, 488, 9, 398, 340, 3278, 20, 4464, 63, 12165, 26, 288, 886, 63, 3676, 14, 2264, 63, 4774, 20, 63, 1073, 63, 1832, 8, 4774, 20, 4464, 63, 12165, 9, 398, 372, 715, 339, 347, 1104, 63, 842, 63, 344, 8, 277, 12, 984, 63, 4128, 304, 267, 372, 5274, 14, 842, 63, 344, 63, 6742, 63, 2253, 63, 2580, 8, 288, 291, 14, 362, 63, 842, 63, 344, 1062, 283, 2253, 13, 2171, 13, 1955, 358, 339, 768, 1829, 272, 347, 2784, 63, 888, 8, 277, 304, 267, 408, 17324, 314, 2784, 316, 14, 961, 4839, 370, 506, 4224, 1924, 8498, 12, 3967, 1779, 314, 3531, 2556, 1443, 1172, 2896, 7037, 370, 5740, 436, 15, 269, 1779, 8367, 14, 267, 408, 398, 340, 291, 423, 1200, 63, 888, 26, 288, 372, 291, 423, 1200 ]
[ 1321, 26, 6714, 29, 20, 26414, 199, 3, 199, 3, 259, 6529, 26, 5612, 279, 5244, 345, 424, 665, 685, 279, 32, 8573, 12201, 20867, 14, 957, 30, 199, 3, 259, 6529, 26, 26844, 7494, 1005, 221, 665, 26397, 32, 8573, 12201, 20867, 14, 957, 30, 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, 1015, 650, 12, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 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, 4743, 199, 199, 3, 29979, 47, 20867, 18110, 2723, 3261, 26, 199, 3, 4178, 921, 23826, 14, 8573, 12201, 20867, 14, 957, 15, 9970, 15, 2343, 15, 199, 199, 504, 8002, 826, 492, 943, 465, 2050, 199, 504, 8002, 826, 492, 5274, 199, 504, 8002, 826, 492, 4884, 199, 199, 646, 8002, 826, 14, 4553, 14, 7546, 14, 8573, 12201, 20867, 465, 886, 63, 3676, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 18637, 20012, 63, 3177, 63, 5569, 275, 469, 272, 283, 2343, 63, 633, 356, 283, 1014, 921, 10143, 14, 8306, 14, 10143, 14, 8306, 15, 2343, 15, 86, 17, 14, 1001, 297, 199, 93, 199, 199, 3, 13144, 367, 282, 1536, 370, 282, 12709, 12, 7269, 316, 314, 3404, 13, 576, 1654, 199, 3, 4036, 499, 4696, 14, 199, 5127, 63, 32528, 275, 4233, 199, 5127, 63, 8899, 275, 499, 199, 5127, 63, 12458, 63, 27778, 275, 499, 199, 5127, 63, 4701, 63, 11253, 20, 4464, 275, 715, 421, 199, 533, 24300, 32660, 47, 20867, 8, 4553, 14, 16693, 304, 272, 347, 636, 826, 721, 277, 12, 984, 63, 4128, 12, 20499, 12, 3792, 304, 267, 5274, 14, 16693, 855, 826, 721, 277, 12, 984, 63, 4128, 12, 20499, 12, 3792, 9, 267, 291, 14, 18371, 275, 20499, 267, 291, 14, 2343, 275, 1211, 342, 267, 291, 14, 795, 63, 4128, 275, 4884, 14, 5628, 3479, 807, 779, 288, 4884, 14, 362, 63, 4128, 63, 991, 63, 515, 8, 1274, 63, 4128, 12, 2097, 21208, 401, 298, 32660, 47, 20867, 2255, 8613, 288, 16331, 1193, 20012, 63, 3177, 63, 5569, 566, 267, 291, 14, 2343, 63, 1562, 275, 291, 14, 795, 63, 4128, 459, 2343, 63, 633, 418, 267, 291, 14, 10937, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 10937, 297, 15830, 63, 32528, 9, 267, 291, 14, 2593, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 2593, 297, 15830, 63, 8899, 9, 267, 291, 14, 1180, 63, 711, 20, 4464, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 1180, 63, 711, 20, 4464, 297, 15830, 63, 4701, 63, 11253, 20, 4464, 9, 267, 291, 14, 2573, 63, 7154, 275, 291, 14, 795, 63, 4128, 14, 362, 360, 2573, 63, 7154, 297, 15830, 63, 12458, 63, 27778, 9, 267, 291, 423, 1200, 63, 888, 275, 488, 339, 347, 485, 362, 63, 1274, 815, 8, 277, 304, 267, 372, 886, 63, 3676, 14, 739, 63, 1274, 815, 342, 339, 347, 664, 63, 576, 8, 277, 304, 267, 334, 374, 63, 1117, 12, 5978, 2723, 63, 344, 9, 275, 291, 423, 362, 63, 1274, 815, 342, 398, 327, 1454, 20320, 340, 781, 5715, 781, 787, 641, 29979, 47, 20867, 267, 340, 440, 365, 63, 1117, 26, 288, 372, 756, 398, 5051, 14, 815, 480, 9602, 641, 20545, 312, 20867, 14, 5978, 2723, 63, 344, 2458, 83, 2, 450, 5978, 2723, 63, 344, 9, 398, 3278, 20, 4464, 63, 12165, 275, 488, 267, 340, 291, 14, 1180, 63, 711, 20, 4464, 26, 288, 3278, 20, 4464, 63, 12165, 275, 886, 63, 3676, 14, 5038, 63, 4774, 20, 63, 1073, 63, 1832, 342, 398, 6128, 275, 886, 63, 3676, 14, 739, 63, 2343, 8, 288, 291, 14, 2343, 63, 1562, 12, 2653, 29, 277, 14, 2593, 12, 288, 6513, 63, 13007, 29, 277, 14, 2573, 63, 7154, 12, 10086, 29, 277, 14, 10937, 9, 398, 291, 14, 2343, 63, 2861, 275, 6128, 267, 291, 14, 2343, 459, 842, 13, 344, 418, 275, 6128, 14, 362, 360, 4824, 2723, 63, 344, 297, 5978, 2723, 63, 344, 9, 267, 291, 14, 2343, 459, 1832, 13, 4269, 418, 275, 6128, 14, 362, 360, 4269, 297, 5978, 2723, 63, 344, 9, 267, 291, 14, 2343, 459, 7436, 418, 275, 6128, 14, 362, 360, 7436, 358, 267, 291, 14, 2343, 459, 3455, 13, 1612, 418, 275, 6128, 14, 362, 360, 3455, 63, 1612, 358, 267, 291, 14, 2343, 459, 11856, 63, 2619, 418, 275, 6128, 14, 362, 360, 4551, 297, 283, 885, 358, 267, 291, 14, 9884, 576, 63, 1773, 275, 6128, 14, 362, 480, 9884, 63, 576, 401, 488, 9, 267, 291, 14, 751, 576, 63, 1773, 275, 6128, 14, 362, 480, 751, 63, 576, 401, 488, 9, 398, 340, 3278, 20, 4464, 63, 12165, 26, 288, 886, 63, 3676, 14, 2264, 63, 4774, 20, 63, 1073, 63, 1832, 8, 4774, 20, 4464, 63, 12165, 9, 398, 372, 715, 339, 347, 1104, 63, 842, 63, 344, 8, 277, 12, 984, 63, 4128, 304, 267, 372, 5274, 14, 842, 63, 344, 63, 6742, 63, 2253, 63, 2580, 8, 288, 291, 14, 362, 63, 842, 63, 344, 1062, 283, 2253, 13, 2171, 13, 1955, 358, 339, 768, 1829, 272, 347, 2784, 63, 888, 8, 277, 304, 267, 408, 17324, 314, 2784, 316, 14, 961, 4839, 370, 506, 4224, 1924, 8498, 12, 3967, 1779, 314, 3531, 2556, 1443, 1172, 2896, 7037, 370, 5740, 436, 15, 269, 1779, 8367, 14, 267, 408, 398, 340, 291, 423, 1200, 63, 888, 26, 288, 372, 291, 423, 1200, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jewettaij/moltemplate
moltemplate/pdbsort.py
2
5841
#!/usr/bin/env python # Author: Andrew Jewett (jewett.aij at g mail) # License: MIT License (See LICENSE.md) # Copyright (c) 2013 """ Unfortunately, the lines in a PDB files are not always listed in the correct order. Software that reads PDB files is expected to re-sort this data before interpreting it. (One reason I don't like them.) This script reads a PDB file from the standard input, sorts the lines according to ChainID, SeqNum (residue-number), Icode (insert-code), and AtomID (in that order) and prints the result to the standard-out. Only the ATOM and HETATM records are effected. All other lines in the PDB file are printed back to the user verbatim. Note: the "altLoc" column (character #17 on each line) is ignored and is not used for sorting purposes. """ import sys from operator import attrgetter from collections import defaultdict g_program_name = __file__.split('/')[-1] g_version_str = '0.12.0' g_date_str = '2016-12-21' # In order to specify any amino acid in a PDB file, you must provide 3 # identifiers: # the ChainID a single letter specifying # the SeqNum an integer indicating the location within that chain # the ICode ("insert code" usually 0. I don't know why this number is # necessary. ..For the record, I never loved the PDB file format.) class AtomDescr: def __init__(self, setChainID, setSeqNum, setICode, setAtomID): self.chainID = setChainID self.seqNum = setSeqNum self.iCode = setICode self.atomID = setAtomID # I plan to store this information in a python dictionary. # Unfortunately, in order to use such classes as keys in python dictionaries # I must define comparison operators, and a hash function. # In retrospect I figured out it would have been easier just to use tuples # as dictionary keys. I suppose it was a good excercise to try to do it # using python classes instead. I'm sorry it made the code so long. def __le__(self, other): # return ((self.chainID < other.chainID) or ((self.chainID == other.cha # instead I'll exploit python's ability to compare tuples return (self.chainID, self.seqNum, self.iCode, self.atomID) <= (other.chainID, other.seqNum, other.iCode, other.atomID) def __lt__(self, other): return (self.chainID, self.seqNum, self.iCode, self.atomID) < (other.chainID, other.seqNum, other.iCode, other.atomID) def __eq__(self, other): # return ((self.chainID == x.chainID) and (self.seqNum == x.seqNum) and # (self.iCode == x.iCode)) return (self.chainID, self.seqNum, self.iCode, self.atomID) == (other.chainID, other.seqNum, other.iCode, other.atomID) def __ne__(self, other): return not __eq__(self, other) def __gt__(self, other): return not __le__(self, other) def __ge__(self, other): return not __lt__(self, other) def __cmp__(self, other): if __lt__(self, other): return -1 elif __gt__(self, other): return 1 else: return 0 def __hash__(self): numChainIDs = 128 numICodes = 128 i = self.seqNum i *= numChainIDs i += ord(self.chainID) i *= numICodes i += ord(self.iCode) i *= 10 i += self.atomID return i def main(): if len(sys.argv) == 1: use_all_residues = True elif len(sys.argv) == 7: use_all_residues = False first = AtomDescr(sys.argv[1], int(sys.argv[2]), sys.argv[3], 0) last = AtomDescr(sys.argv[4], int(sys.argv[5]), sys.argv[6], 2147483647) else: sys.stderr.write("Error(" + g_program_name + "): This program requires either 0 or 6 arguments.\n" " By default, the the sequence is extracted from the entire PDB file.\n" " In that case, no arguments are required.\n" " Alternately, you can limit the selection to a single interval of\n" " residues from one of the chains in the PDB file.\n" " To specify an interval, you must passing 6 arguments to this program.\n" " This program requires a pair of residues to designate the first and\n" " last members of the interval. Each residue requires 3 identifiers.\n" " Consequently the six arguments needed are:\n" "ChainID_first SeqNum_first ICode_first ChainID_last SeqNum_last ICode_last\n") exit(-1) atoms2lines = defaultdict(list) for line in sys.stdin: if (line[0:6] == "ATOM ") or (line[0:6] == "HETATM"): atomID = int(line[6:11]) #atomType = line[12:16] #altLoc = line[16:17] iCode = line[26:27] #resType = line[17:20] chainID = line[21:22] seqNumStr = line[22:26] seqNum = int(seqNumStr) atomdescr = AtomDescr(chainID, int(seqNumStr), iCode, int(atomID)) atoms2lines[atomdescr].append(line.rstrip('\n')) else: sys.stdout.write(line) # Extract an (unordered) list of the atomdescrs of the atoms in the sequence atomdescrs = [atomdescr for atomdescr in atoms2lines] # Residues in PDB files are often not listed in order. # Consequently, we must sort the list by chainID, seqNum, and finnaly iCode: sequence_of_atomdescrs = sorted(atomdescrs, key=attrgetter( 'chainID', 'seqNum', 'iCode', 'atomID')) for atomdescr in sequence_of_atomdescrs: for line in atoms2lines[atomdescr]: sys.stdout.write(line + '\n') return if __name__ == '__main__': main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 6529, 26, 6061, 5257, 1603, 546, 386, 84, 334, 74, 546, 386, 84, 14, 5789, 74, 737, 486, 6016, 9, 199, 3, 844, 26, 10697, 844, 221, 334, 9295, 5113, 14, 1064, 9, 199, 3, 1898, 334, 67, 9, 6171, 199, 199, 624, 2043, 31076, 12, 314, 2385, 315, 282, 30280, 1584, 787, 440, 3544, 10532, 315, 314, 2043, 3211, 1865, 14, 221, 2290, 626, 11597, 30280, 1584, 365, 1420, 370, 295, 13, 3191, 642, 2043, 666, 2544, 6421, 1337, 652, 14, 221, 334, 4395, 4499, 473, 2793, 1133, 2839, 3062, 4959, 2043, 961, 2884, 11597, 282, 30280, 570, 687, 314, 4465, 1324, 12, 30313, 314, 2385, 2043, 7182, 370, 25384, 998, 12, 28534, 5667, 334, 19581, 310, 13, 1955, 395, 473, 600, 334, 3176, 13, 600, 395, 2043, 436, 18840, 998, 334, 262, 626, 1865, 9, 436, 14767, 314, 754, 370, 314, 4465, 13, 548, 14, 2043, 5972, 314, 437, 19731, 436, 869, 775, 619, 45, 5767, 787, 10783, 6201, 14, 2043, 2900, 1163, 2385, 315, 314, 30280, 570, 787, 12487, 1771, 370, 314, 922, 16041, 24218, 14, 2043, 3390, 26, 314, 298, 4478, 3040, 2, 2763, 334, 10856, 327, 1196, 641, 1924, 1004, 9, 365, 5525, 268, 436, 365, 440, 1202, 367, 13351, 12901, 14, 199, 199, 624, 199, 199, 646, 984, 199, 504, 4182, 492, 21829, 199, 504, 5055, 492, 10018, 199, 199, 71, 63, 6815, 63, 354, 275, 636, 493, 4343, 1294, 25804, 17, 61, 199, 71, 63, 1023, 63, 495, 275, 283, 16, 14, 713, 14, 16, 7, 199, 71, 63, 602, 63, 495, 275, 283, 9261, 13, 713, 13, 2025, 7, 199, 199, 3, 1010, 1865, 370, 4165, 1263, 282, 827, 79, 1066, 344, 315, 282, 30280, 570, 12, 1265, 1471, 5647, 650, 199, 3, 14154, 26, 199, 3, 257, 314, 25384, 998, 282, 2849, 8082, 9176, 199, 3, 257, 314, 28534, 5667, 376, 3000, 9297, 314, 2909, 4453, 626, 6036, 199, 3, 257, 314, 473, 3034, 1689, 3176, 1233, 2, 9987, 378, 14, 221, 473, 2793, 1133, 5715, 10842, 642, 1329, 365, 199, 3, 4519, 5784, 14, 2508, 1858, 314, 2777, 12, 473, 7078, 560, 1354, 314, 30280, 570, 1475, 4959, 421, 199, 533, 18840, 28782, 26, 339, 347, 636, 826, 721, 277, 12, 663, 10720, 998, 12, 663, 11205, 5667, 12, 663, 948, 380, 12, 663, 12097, 998, 304, 267, 291, 14, 4429, 998, 275, 663, 10720, 998, 267, 291, 14, 3610, 5667, 275, 663, 11205, 5667, 267, 291, 14, 73, 3034, 275, 663, 948, 380, 267, 291, 14, 4188, 998, 275, 663, 12097, 998, 339, 327, 473, 8683, 370, 3877, 642, 2556, 315, 282, 2366, 2600, 14, 272, 327, 31076, 12, 315, 1865, 370, 675, 4066, 3992, 465, 2883, 315, 2366, 11196, 272, 327, 473, 1471, 5627, 9132, 10211, 12, 436, 282, 2631, 805, 14, 272, 327, 1010, 295, 1374, 20865, 473, 6085, 3297, 734, 652, 3955, 1172, 2757, 14905, 2951, 370, 675, 6346, 272, 327, 465, 2600, 2883, 14, 221, 473, 1029, 4070, 652, 1990, 282, 6954, 444, 2247, 11900, 370, 862, 370, 886, 652, 272, 327, 1808, 2366, 3992, 3140, 14, 221, 473, 6704, 308, 21342, 652, 6326, 314, 1233, 880, 1846, 14, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 327, 372, 3666, 277, 14, 4429, 998, 665, 1163, 14, 4429, 998, 9, 503, 3666, 277, 14, 4429, 998, 508, 1163, 14, 9518, 267, 327, 3140, 473, 7171, 15868, 390, 2366, 1159, 21255, 370, 6540, 6346, 267, 372, 334, 277, 14, 4429, 998, 12, 291, 14, 3610, 5667, 12, 291, 14, 73, 3034, 12, 291, 14, 4188, 998, 9, 2695, 334, 1848, 14, 4429, 998, 12, 1163, 14, 3610, 5667, 12, 1163, 14, 73, 3034, 12, 1163, 14, 4188, 998, 9, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 334, 277, 14, 4429, 998, 12, 291, 14, 3610, 5667, 12, 291, 14, 73, 3034, 12, 291, 14, 4188, 998, 9, 665, 334, 1848, 14, 4429, 998, 12, 1163, 14, 3610, 5667, 12, 1163, 14, 73, 3034, 12, 1163, 14, 4188, 998, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 327, 372, 3666, 277, 14, 4429, 998, 508, 671, 14, 4429, 998, 9, 436, 334, 277, 14, 3610, 5667, 508, 671, 14, 3610, 5667, 9, 436, 267, 327, 334, 277, 14, 73, 3034, 508, 671, 14, 73, 3034, 430, 267, 372, 334, 277, 14, 4429, 998, 12, 291, 14, 3610, 5667, 12, 291, 14, 73, 3034, 12, 291, 14, 4188, 998, 9, 508, 334, 1848, 14, 4429, 998, 12, 1163, 14, 3610, 5667, 12, 1163, 14, 73, 3034, 12, 1163, 14, 4188, 998, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 636, 4077, 721, 277, 12, 1163, 9, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 440, 636, 274, 721, 277, 12, 1163, 9, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 440, 636, 4116, 721, 277, 12, 1163, 9, 339, 347, 636, 5730, 721, 277, 12, 1163, 304, 267, 340, 636, 4116, 721, 277, 12, 1163, 304, 288, 372, 446, 17, 267, 916, 636, 3308, 721, 277, 12, 1163, 304, 288, 372, 413, 267, 587, 26, 288, 372, 378, 339, 347, 636, 2227, 721, 277, 304, 267, 1967, 10720, 12818, 275, 7960, 267, 1967, 948, 380, 83, 275, 7960, 267, 284, 275, 291, 14, 3610, 5667, 267, 284, 9000, 1967, 10720, 12818, 267, 284, 847, 6206, 8, 277, 14, 4429, 998, 9, 267, 284, 9000, 1967, 948, 380, 83, 267, 284, 847, 6206, 8, 277, 14, 73, 3034, 9, 267, 284, 9000, 1616, 267, 284, 847, 291, 14, 4188, 998, 267, 372, 284, 421, 199, 318, 2446, 837, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 26, 267, 675, 63, 452, 63, 19581, 10138, 275, 715, 272, 916, 822, 8, 1274, 14, 3020, 9, 508, 1520, 26, 267, 675, 63, 452, 63, 19581, 10138, 275, 756, 267, 1642, 275, 18840, 28782, 8, 1274, 14, 3020, 59, 17, 467, 1109, 8, 1274, 14, 3020, 59, 18, 2522, 984, 14, 3020, 59, 19, 467, 378, 9, 267, 2061, 275, 18840, 28782, 8, 1274 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 6529, 26, 6061, 5257, 1603, 546, 386, 84, 334, 74, 546, 386, 84, 14, 5789, 74, 737, 486, 6016, 9, 199, 3, 844, 26, 10697, 844, 221, 334, 9295, 5113, 14, 1064, 9, 199, 3, 1898, 334, 67, 9, 6171, 199, 199, 624, 2043, 31076, 12, 314, 2385, 315, 282, 30280, 1584, 787, 440, 3544, 10532, 315, 314, 2043, 3211, 1865, 14, 221, 2290, 626, 11597, 30280, 1584, 365, 1420, 370, 295, 13, 3191, 642, 2043, 666, 2544, 6421, 1337, 652, 14, 221, 334, 4395, 4499, 473, 2793, 1133, 2839, 3062, 4959, 2043, 961, 2884, 11597, 282, 30280, 570, 687, 314, 4465, 1324, 12, 30313, 314, 2385, 2043, 7182, 370, 25384, 998, 12, 28534, 5667, 334, 19581, 310, 13, 1955, 395, 473, 600, 334, 3176, 13, 600, 395, 2043, 436, 18840, 998, 334, 262, 626, 1865, 9, 436, 14767, 314, 754, 370, 314, 4465, 13, 548, 14, 2043, 5972, 314, 437, 19731, 436, 869, 775, 619, 45, 5767, 787, 10783, 6201, 14, 2043, 2900, 1163, 2385, 315, 314, 30280, 570, 787, 12487, 1771, 370, 314, 922, 16041, 24218, 14, 2043, 3390, 26, 314, 298, 4478, 3040, 2, 2763, 334, 10856, 327, 1196, 641, 1924, 1004, 9, 365, 5525, 268, 436, 365, 440, 1202, 367, 13351, 12901, 14, 199, 199, 624, 199, 199, 646, 984, 199, 504, 4182, 492, 21829, 199, 504, 5055, 492, 10018, 199, 199, 71, 63, 6815, 63, 354, 275, 636, 493, 4343, 1294, 25804, 17, 61, 199, 71, 63, 1023, 63, 495, 275, 283, 16, 14, 713, 14, 16, 7, 199, 71, 63, 602, 63, 495, 275, 283, 9261, 13, 713, 13, 2025, 7, 199, 199, 3, 1010, 1865, 370, 4165, 1263, 282, 827, 79, 1066, 344, 315, 282, 30280, 570, 12, 1265, 1471, 5647, 650, 199, 3, 14154, 26, 199, 3, 257, 314, 25384, 998, 282, 2849, 8082, 9176, 199, 3, 257, 314, 28534, 5667, 376, 3000, 9297, 314, 2909, 4453, 626, 6036, 199, 3, 257, 314, 473, 3034, 1689, 3176, 1233, 2, 9987, 378, 14, 221, 473, 2793, 1133, 5715, 10842, 642, 1329, 365, 199, 3, 4519, 5784, 14, 2508, 1858, 314, 2777, 12, 473, 7078, 560, 1354, 314, 30280, 570, 1475, 4959, 421, 199, 533, 18840, 28782, 26, 339, 347, 636, 826, 721, 277, 12, 663, 10720, 998, 12, 663, 11205, 5667, 12, 663, 948, 380, 12, 663, 12097, 998, 304, 267, 291, 14, 4429, 998, 275, 663, 10720, 998, 267, 291, 14, 3610, 5667, 275, 663, 11205, 5667, 267, 291, 14, 73, 3034, 275, 663, 948, 380, 267, 291, 14, 4188, 998, 275, 663, 12097, 998, 339, 327, 473, 8683, 370, 3877, 642, 2556, 315, 282, 2366, 2600, 14, 272, 327, 31076, 12, 315, 1865, 370, 675, 4066, 3992, 465, 2883, 315, 2366, 11196, 272, 327, 473, 1471, 5627, 9132, 10211, 12, 436, 282, 2631, 805, 14, 272, 327, 1010, 295, 1374, 20865, 473, 6085, 3297, 734, 652, 3955, 1172, 2757, 14905, 2951, 370, 675, 6346, 272, 327, 465, 2600, 2883, 14, 221, 473, 1029, 4070, 652, 1990, 282, 6954, 444, 2247, 11900, 370, 862, 370, 886, 652, 272, 327, 1808, 2366, 3992, 3140, 14, 221, 473, 6704, 308, 21342, 652, 6326, 314, 1233, 880, 1846, 14, 339, 347, 636, 274, 721, 277, 12, 1163, 304, 267, 327, 372, 3666, 277, 14, 4429, 998, 665, 1163, 14, 4429, 998, 9, 503, 3666, 277, 14, 4429, 998, 508, 1163, 14, 9518, 267, 327, 3140, 473, 7171, 15868, 390, 2366, 1159, 21255, 370, 6540, 6346, 267, 372, 334, 277, 14, 4429, 998, 12, 291, 14, 3610, 5667, 12, 291, 14, 73, 3034, 12, 291, 14, 4188, 998, 9, 2695, 334, 1848, 14, 4429, 998, 12, 1163, 14, 3610, 5667, 12, 1163, 14, 73, 3034, 12, 1163, 14, 4188, 998, 9, 339, 347, 636, 4116, 721, 277, 12, 1163, 304, 267, 372, 334, 277, 14, 4429, 998, 12, 291, 14, 3610, 5667, 12, 291, 14, 73, 3034, 12, 291, 14, 4188, 998, 9, 665, 334, 1848, 14, 4429, 998, 12, 1163, 14, 3610, 5667, 12, 1163, 14, 73, 3034, 12, 1163, 14, 4188, 998, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 327, 372, 3666, 277, 14, 4429, 998, 508, 671, 14, 4429, 998, 9, 436, 334, 277, 14, 3610, 5667, 508, 671, 14, 3610, 5667, 9, 436, 267, 327, 334, 277, 14, 73, 3034, 508, 671, 14, 73, 3034, 430, 267, 372, 334, 277, 14, 4429, 998, 12, 291, 14, 3610, 5667, 12, 291, 14, 73, 3034, 12, 291, 14, 4188, 998, 9, 508, 334, 1848, 14, 4429, 998, 12, 1163, 14, 3610, 5667, 12, 1163, 14, 73, 3034, 12, 1163, 14, 4188, 998, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 636, 4077, 721, 277, 12, 1163, 9, 339, 347, 636, 3308, 721, 277, 12, 1163, 304, 267, 372, 440, 636, 274, 721, 277, 12, 1163, 9, 339, 347, 636, 303, 721, 277, 12, 1163, 304, 267, 372, 440, 636, 4116, 721, 277, 12, 1163, 9, 339, 347, 636, 5730, 721, 277, 12, 1163, 304, 267, 340, 636, 4116, 721, 277, 12, 1163, 304, 288, 372, 446, 17, 267, 916, 636, 3308, 721, 277, 12, 1163, 304, 288, 372, 413, 267, 587, 26, 288, 372, 378, 339, 347, 636, 2227, 721, 277, 304, 267, 1967, 10720, 12818, 275, 7960, 267, 1967, 948, 380, 83, 275, 7960, 267, 284, 275, 291, 14, 3610, 5667, 267, 284, 9000, 1967, 10720, 12818, 267, 284, 847, 6206, 8, 277, 14, 4429, 998, 9, 267, 284, 9000, 1967, 948, 380, 83, 267, 284, 847, 6206, 8, 277, 14, 73, 3034, 9, 267, 284, 9000, 1616, 267, 284, 847, 291, 14, 4188, 998, 267, 372, 284, 421, 199, 318, 2446, 837, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 26, 267, 675, 63, 452, 63, 19581, 10138, 275, 715, 272, 916, 822, 8, 1274, 14, 3020, 9, 508, 1520, 26, 267, 675, 63, 452, 63, 19581, 10138, 275, 756, 267, 1642, 275, 18840, 28782, 8, 1274, 14, 3020, 59, 17, 467, 1109, 8, 1274, 14, 3020, 59, 18, 2522, 984, 14, 3020, 59, 19, 467, 378, 9, 267, 2061, 275, 18840, 28782, 8, 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1, 1, 1, 1 ]
lshain-android-source/external-chromium_org-tools-gyp
test/mac/gyptest-app.py
13
1477
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Verifies that app bundles are built correctly. """ import TestGyp import sys if sys.platform == 'darwin': test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) test.run_gyp('test.gyp', chdir='app-bundle') test.build('test.gyp', test.ALL, chdir='app-bundle') # Binary test.built_file_must_exist('Test App Gyp.app/Contents/MacOS/Test App Gyp', chdir='app-bundle') # Info.plist info_plist = test.built_file_path('Test App Gyp.app/Contents/Info.plist', chdir='app-bundle') test.must_exist(info_plist) test.must_contain(info_plist, 'com.google.Test App Gyp') # Variable expansion test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); # Resources test.built_file_must_exist( 'Test App Gyp.app/Contents/Resources/English.lproj/InfoPlist.strings', chdir='app-bundle') test.built_file_must_exist( 'Test App Gyp.app/Contents/Resources/English.lproj/MainMenu.nib', chdir='app-bundle') # Packaging test.built_file_must_exist('Test App Gyp.app/Contents/PkgInfo', chdir='app-bundle') test.built_file_must_match('Test App Gyp.app/Contents/PkgInfo', 'APPLause', chdir='app-bundle') test.pass_test()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 21168, 626, 1145, 27206, 787, 6137, 6657, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 646, 984, 199, 199, 692, 984, 14, 3246, 508, 283, 13245, 356, 523, 511, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8675, 297, 283, 1875, 297, 283, 8701, 1105, 819, 511, 14, 1065, 63, 6179, 360, 396, 14, 6179, 297, 13097, 534, 571, 13, 6469, 358, 819, 511, 14, 1506, 360, 396, 14, 6179, 297, 511, 14, 1761, 12, 13097, 534, 571, 13, 6469, 358, 819, 327, 14161, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 3399, 3100, 15, 774, 4693, 14133, 297, 2490, 13097, 534, 571, 13, 6469, 358, 819, 327, 10332, 14, 10265, 523, 2256, 63, 10265, 275, 511, 14, 11730, 63, 493, 63, 515, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 2354, 14, 10265, 297, 2511, 13097, 534, 571, 13, 6469, 358, 523, 511, 14, 7790, 63, 4494, 8, 815, 63, 10265, 9, 523, 511, 14, 7790, 63, 7747, 8, 815, 63, 10265, 12, 283, 957, 14, 3098, 14, 774, 4693, 14133, 358, 221, 327, 4905, 14819, 523, 511, 14, 7790, 63, 1397, 63, 7747, 8, 815, 63, 10265, 12, 20044, 9410, 25160, 63, 32304, 63, 9268, 93, 11339, 819, 327, 26250, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 489, 283, 774, 4693, 14133, 14, 571, 15, 11383, 15, 13745, 15, 19410, 14, 76, 5468, 15, 2354, 21073, 14, 5465, 297, 489, 13097, 534, 571, 13, 6469, 358, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 489, 283, 774, 4693, 14133, 14, 571, 15, 11383, 15, 13745, 15, 19410, 14, 76, 5468, 15, 6756, 5977, 14, 78, 1892, 297, 489, 13097, 534, 571, 13, 6469, 358, 819, 327, 9954, 7407, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 26878, 2354, 297, 2490, 13097, 534, 571, 13, 6469, 358, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 1431, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 26878, 2354, 297, 283, 1282, 2749, 65, 1180, 297, 2490, 13097, 534, 571, 13, 6469, 358, 8330, 511, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 21168, 626, 1145, 27206, 787, 6137, 6657, 14, 199, 624, 199, 199, 646, 25688, 199, 199, 646, 984, 199, 199, 692, 984, 14, 3246, 508, 283, 13245, 356, 523, 511, 275, 25688, 14, 774, 13899, 8, 6321, 2968, 8675, 297, 283, 1875, 297, 283, 8701, 1105, 819, 511, 14, 1065, 63, 6179, 360, 396, 14, 6179, 297, 13097, 534, 571, 13, 6469, 358, 819, 511, 14, 1506, 360, 396, 14, 6179, 297, 511, 14, 1761, 12, 13097, 534, 571, 13, 6469, 358, 819, 327, 14161, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 3399, 3100, 15, 774, 4693, 14133, 297, 2490, 13097, 534, 571, 13, 6469, 358, 819, 327, 10332, 14, 10265, 523, 2256, 63, 10265, 275, 511, 14, 11730, 63, 493, 63, 515, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 2354, 14, 10265, 297, 2511, 13097, 534, 571, 13, 6469, 358, 523, 511, 14, 7790, 63, 4494, 8, 815, 63, 10265, 9, 523, 511, 14, 7790, 63, 7747, 8, 815, 63, 10265, 12, 283, 957, 14, 3098, 14, 774, 4693, 14133, 358, 221, 327, 4905, 14819, 523, 511, 14, 7790, 63, 1397, 63, 7747, 8, 815, 63, 10265, 12, 20044, 9410, 25160, 63, 32304, 63, 9268, 93, 11339, 819, 327, 26250, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 489, 283, 774, 4693, 14133, 14, 571, 15, 11383, 15, 13745, 15, 19410, 14, 76, 5468, 15, 2354, 21073, 14, 5465, 297, 489, 13097, 534, 571, 13, 6469, 358, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 8, 489, 283, 774, 4693, 14133, 14, 571, 15, 11383, 15, 13745, 15, 19410, 14, 76, 5468, 15, 6756, 5977, 14, 78, 1892, 297, 489, 13097, 534, 571, 13, 6469, 358, 819, 327, 9954, 7407, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 4494, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 26878, 2354, 297, 2490, 13097, 534, 571, 13, 6469, 358, 523, 511, 14, 11730, 63, 493, 63, 7790, 63, 1431, 360, 774, 4693, 14133, 14, 571, 15, 11383, 15, 26878, 2354, 297, 283, 1282, 2749, 65, 1180, 297, 2490, 13097, 534, 571, 13, 6469, 358, 8330, 511, 14, 1529, 63, 396, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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 ]
xgt001/uav_msr_ip14
opencv_rnd/test_shape_detect.py
1
1569
__author__ = 'ganesh' __author__ = 'ganesh' import cv2 import numpy as np # TODO: loop through folder files filename = "alpha_N.JPG" image = cv2.imread(filename) newx,newy = image.shape[1]/6,image.shape[0]/6 #new size (w,h) img = cv2.resize(image,(newx,newy)) img_sav = img # CODE: Resize Image Toggle # cv2.imshow("resize image",img) # cv2.waitKey(0) circle = cv2.imread("circle.jpg") img = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY) image_circle = cv2.cvtColor(circle,cv2.COLOR_RGB2GRAY) retval, threshold = cv2.threshold(img,170,200,cv2.THRESH_BINARY_INV) # ret1, thresh_circ = cv2.threshold(image_circle,cv2.THRESH_BINARY) # # cv2.imshow("threshold",threshold) # cv2.waitKey(0) # contours,hierarchy = cv2.findContours(threshold,1,2) contours, hierarchy = cv2.findContours(threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) shape_circle, hier2 = cv2.findContours(image_circle,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) contours.sort(key=cv2.contourArea, reverse=True) #DOCUMENTATION # for i in range(0,100,1): ret = cv2.matchShapes(contours[i],shape_circle,1,0.0) if cv2.contourArea(contours[i]) < 300 and cv2.contourArea(contours[i]) > 50 and ret < 5 and ret > 0 : print "match:"; print ret print "Area:"; print cv2.contourArea(contours[i]) cv2.drawContours(img_sav,contours,i,(0,255,0),1) x,y,w,h = cv2.boundingRect(contours[i]) cv2.rectangle(img_sav,(x,y),(x+w,y+h),(0,255,0),2) cv2.imshow("test",img_sav) cv2.imwrite("blob"+str(i)+'.png', img_sav[y:y+h,x:x+w]) cv2.waitKey(0)
mit
[ 363, 2502, 363, 275, 283, 24975, 10613, 7, 4388, 199, 363, 2502, 363, 275, 283, 24975, 10613, 7, 421, 199, 646, 6277, 18, 199, 646, 2680, 465, 980, 199, 199, 3, 3254, 26, 4438, 4012, 4922, 1584, 421, 199, 1501, 275, 298, 4468, 63, 46, 14, 42, 11115, 2, 199, 1569, 275, 6277, 18, 14, 1017, 739, 8, 1501, 9, 199, 1222, 88, 12, 1222, 89, 275, 1834, 14, 1392, 59, 17, 12978, 22, 12, 1569, 14, 1392, 59, 16, 12978, 22, 327, 1222, 1568, 334, 87, 12, 72, 9, 199, 4060, 275, 6277, 18, 14, 8709, 8, 1569, 12803, 1222, 88, 12, 1222, 89, 430, 199, 199, 4060, 63, 23374, 275, 6050, 199, 3, 22547, 26, 799, 890, 6047, 377, 19403, 199, 3, 6277, 18, 14, 20413, 480, 8709, 1834, 401, 4060, 9, 199, 3, 6277, 18, 14, 2573, 1197, 8, 16, 9, 199, 199, 11001, 275, 6277, 18, 14, 1017, 739, 480, 11001, 14, 8476, 531, 421, 199, 4060, 275, 6277, 18, 14, 5107, 84, 4117, 8, 4060, 12, 5107, 18, 14, 7134, 63, 12067, 18, 18583, 57, 9, 199, 199, 1569, 63, 11001, 275, 6277, 18, 14, 5107, 84, 4117, 8, 11001, 12, 5107, 18, 14, 7134, 63, 12067, 18, 18583, 57, 9, 199, 199, 18476, 12, 8765, 275, 6277, 18, 14, 7227, 8, 4060, 12, 11010, 12, 1840, 12, 5107, 18, 14, 18109, 63, 13246, 63, 568, 54, 9, 199, 199, 3, 2203, 17, 12, 16126, 63, 6092, 275, 6277, 18, 14, 7227, 8, 1569, 63, 11001, 12, 5107, 18, 14, 18109, 63, 13246, 9, 199, 3, 199, 3, 6277, 18, 14, 20413, 480, 7227, 401, 7227, 9, 199, 3, 6277, 18, 14, 2573, 1197, 8, 16, 9, 199, 199, 3, 23176, 83, 12, 14861, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 7227, 12, 17, 12, 18, 9, 199, 199, 17798, 83, 12, 14446, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 7227, 12, 6277, 18, 14, 7341, 50, 63, 22841, 12, 6277, 18, 14, 25256, 63, 1282, 2514, 56, 63, 27548, 9, 199, 199, 1392, 63, 11001, 12, 394, 4446, 18, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 1569, 63, 11001, 12, 5107, 18, 14, 7341, 50, 63, 22841, 12, 5107, 18, 14, 25256, 63, 1282, 2514, 56, 63, 27548, 9, 199, 199, 17798, 83, 14, 3191, 8, 498, 29, 5107, 18, 14, 17798, 11043, 12, 3837, 29, 549, 9, 199, 199, 3, 8948, 199, 3, 421, 199, 509, 284, 315, 1425, 8, 16, 12, 1960, 12, 17, 304, 339, 2203, 275, 6277, 18, 14, 1431, 7238, 83, 8, 17798, 83, 59, 73, 467, 1392, 63, 11001, 12, 17, 12, 16, 14, 16, 9, 272, 340, 6277, 18, 14, 17798, 11043, 8, 17798, 83, 59, 73, 566, 665, 9601, 436, 6277, 18, 14, 17798, 11043, 8, 17798, 83, 59, 73, 566, 690, 5238, 436, 2203, 665, 959, 436, 2203, 690, 378, 520, 398, 870, 298, 1431, 5424, 27, 870, 2203, 267, 870, 298, 11043, 5424, 27, 870, 6277, 18, 14, 17798, 11043, 8, 17798, 83, 59, 73, 566, 267, 6277, 18, 14, 5485, 714, 10808, 83, 8, 4060, 63, 23374, 12, 17798, 83, 12, 73, 12803, 16, 12, 2299, 12, 16, 395, 17, 9, 267, 671, 12, 89, 12, 87, 12, 72, 275, 6277, 18, 14, 24511, 8252, 8, 17798, 83, 59, 73, 566, 267, 6277, 18, 14, 19954, 8, 4060, 63, 23374, 12803, 88, 12, 89, 11865, 88, 11, 87, 12, 89, 11, 72, 11865, 16, 12, 2299, 12, 16, 395, 18, 9, 267, 6277, 18, 14, 20413, 480, 396, 401, 4060, 63, 23374, 9, 267, 6277, 18, 14, 1017, 952, 480, 6582, 7709, 495, 8, 73, 6393, 1370, 4524, 297, 6050, 63, 23374, 59, 89, 26, 89, 11, 72, 12, 88, 26, 88, 11, 87, 566, 267, 6277, 18, 14, 2573, 1197, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2502, 363, 275, 283, 24975, 10613, 7, 4388, 199, 363, 2502, 363, 275, 283, 24975, 10613, 7, 421, 199, 646, 6277, 18, 199, 646, 2680, 465, 980, 199, 199, 3, 3254, 26, 4438, 4012, 4922, 1584, 421, 199, 1501, 275, 298, 4468, 63, 46, 14, 42, 11115, 2, 199, 1569, 275, 6277, 18, 14, 1017, 739, 8, 1501, 9, 199, 1222, 88, 12, 1222, 89, 275, 1834, 14, 1392, 59, 17, 12978, 22, 12, 1569, 14, 1392, 59, 16, 12978, 22, 327, 1222, 1568, 334, 87, 12, 72, 9, 199, 4060, 275, 6277, 18, 14, 8709, 8, 1569, 12803, 1222, 88, 12, 1222, 89, 430, 199, 199, 4060, 63, 23374, 275, 6050, 199, 3, 22547, 26, 799, 890, 6047, 377, 19403, 199, 3, 6277, 18, 14, 20413, 480, 8709, 1834, 401, 4060, 9, 199, 3, 6277, 18, 14, 2573, 1197, 8, 16, 9, 199, 199, 11001, 275, 6277, 18, 14, 1017, 739, 480, 11001, 14, 8476, 531, 421, 199, 4060, 275, 6277, 18, 14, 5107, 84, 4117, 8, 4060, 12, 5107, 18, 14, 7134, 63, 12067, 18, 18583, 57, 9, 199, 199, 1569, 63, 11001, 275, 6277, 18, 14, 5107, 84, 4117, 8, 11001, 12, 5107, 18, 14, 7134, 63, 12067, 18, 18583, 57, 9, 199, 199, 18476, 12, 8765, 275, 6277, 18, 14, 7227, 8, 4060, 12, 11010, 12, 1840, 12, 5107, 18, 14, 18109, 63, 13246, 63, 568, 54, 9, 199, 199, 3, 2203, 17, 12, 16126, 63, 6092, 275, 6277, 18, 14, 7227, 8, 1569, 63, 11001, 12, 5107, 18, 14, 18109, 63, 13246, 9, 199, 3, 199, 3, 6277, 18, 14, 20413, 480, 7227, 401, 7227, 9, 199, 3, 6277, 18, 14, 2573, 1197, 8, 16, 9, 199, 199, 3, 23176, 83, 12, 14861, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 7227, 12, 17, 12, 18, 9, 199, 199, 17798, 83, 12, 14446, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 7227, 12, 6277, 18, 14, 7341, 50, 63, 22841, 12, 6277, 18, 14, 25256, 63, 1282, 2514, 56, 63, 27548, 9, 199, 199, 1392, 63, 11001, 12, 394, 4446, 18, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 1569, 63, 11001, 12, 5107, 18, 14, 7341, 50, 63, 22841, 12, 5107, 18, 14, 25256, 63, 1282, 2514, 56, 63, 27548, 9, 199, 199, 17798, 83, 14, 3191, 8, 498, 29, 5107, 18, 14, 17798, 11043, 12, 3837, 29, 549, 9, 199, 199, 3, 8948, 199, 3, 421, 199, 509, 284, 315, 1425, 8, 16, 12, 1960, 12, 17, 304, 339, 2203, 275, 6277, 18, 14, 1431, 7238, 83, 8, 17798, 83, 59, 73, 467, 1392, 63, 11001, 12, 17, 12, 16, 14, 16, 9, 272, 340, 6277, 18, 14, 17798, 11043, 8, 17798, 83, 59, 73, 566, 665, 9601, 436, 6277, 18, 14, 17798, 11043, 8, 17798, 83, 59, 73, 566, 690, 5238, 436, 2203, 665, 959, 436, 2203, 690, 378, 520, 398, 870, 298, 1431, 5424, 27, 870, 2203, 267, 870, 298, 11043, 5424, 27, 870, 6277, 18, 14, 17798, 11043, 8, 17798, 83, 59, 73, 566, 267, 6277, 18, 14, 5485, 714, 10808, 83, 8, 4060, 63, 23374, 12, 17798, 83, 12, 73, 12803, 16, 12, 2299, 12, 16, 395, 17, 9, 267, 671, 12, 89, 12, 87, 12, 72, 275, 6277, 18, 14, 24511, 8252, 8, 17798, 83, 59, 73, 566, 267, 6277, 18, 14, 19954, 8, 4060, 63, 23374, 12803, 88, 12, 89, 11865, 88, 11, 87, 12, 89, 11, 72, 11865, 16, 12, 2299, 12, 16, 395, 18, 9, 267, 6277, 18, 14, 20413, 480, 396, 401, 4060, 63, 23374, 9, 267, 6277, 18, 14, 1017, 952, 480, 6582, 7709, 495, 8, 73, 6393, 1370, 4524, 297, 6050, 63, 23374, 59, 89, 26, 89, 11, 72, 12, 88, 26, 88, 11, 87, 566, 267, 6277, 18, 14, 2573, 1197, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
imtapps/django-imt-fork
django/contrib/auth/tests/views.py
22
24717
import os import re from django.conf import global_settings, settings from django.contrib.sites.models import Site, RequestSite from django.contrib.auth.models import User from django.core import mail from django.core.exceptions import SuspiciousOperation from django.core.urlresolvers import reverse, NoReverseMatch from django.http import QueryDict, HttpRequest from django.utils.encoding import force_text from django.utils.html import escape from django.utils.http import urlquote from django.utils._os import upath from django.test import TestCase from django.test.utils import override_settings from django.middleware.csrf import CsrfViewMiddleware from django.contrib.sessions.middleware import SessionMiddleware from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, SetPasswordForm, PasswordResetForm) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.auth.views import login as login_view @override_settings( LANGUAGES=( ('en', 'English'), ), LANGUAGE_CODE='en', TEMPLATE_LOADERS=global_settings.TEMPLATE_LOADERS, TEMPLATE_DIRS=( os.path.join(os.path.dirname(upath(__file__)), 'templates'), ), USE_TZ=False, PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), ) class AuthViewsTestCase(TestCase): """ Helper base class for all the follow test cases. """ fixtures = ['authtestdata.json'] urls = 'django.contrib.auth.tests.urls' def login(self, password='password'): response = self.client.post('/login/', { 'username': 'testclient', 'password': password, }) self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith(settings.LOGIN_REDIRECT_URL)) self.assertTrue(SESSION_KEY in self.client.session) def assertContainsEscaped(self, response, text, **kwargs): return self.assertContains(response, escape(force_text(text)), **kwargs) @skipIfCustomUser class AuthViewNamedURLTests(AuthViewsTestCase): urls = 'django.contrib.auth.urls' def test_named_urls(self): "Named URLs should be reversible" expected_named_urls = [ ('login', [], {}), ('logout', [], {}), ('password_change', [], {}), ('password_change_done', [], {}), ('password_reset', [], {}), ('password_reset_done', [], {}), ('password_reset_confirm', [], { 'uidb36': 'aaaaaaa', 'token': '1111-aaaaa', }), ('password_reset_complete', [], {}), ] for name, args, kwargs in expected_named_urls: try: reverse(name, args=args, kwargs=kwargs) except NoReverseMatch: self.fail("Reversal of url named '%s' failed with NoReverseMatch" % name) @skipIfCustomUser class PasswordResetTest(AuthViewsTestCase): def test_email_not_found(self): "Error is raised if the provided email address isn't currently registered" response = self.client.get('/password_reset/') self.assertEqual(response.status_code, 200) response = self.client.post('/password_reset/', {'email': 'not_a_real_email@email.com'}) self.assertContainsEscaped(response, PasswordResetForm.error_messages['unknown']) self.assertEqual(len(mail.outbox), 0) def test_email_found(self): "Email is sent if a valid email address is provided for password reset" response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertTrue("http://" in mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) def test_email_found_custom_from(self): "Email is sent if a valid email address is provided for password reset when a custom from_email is provided." response = self.client.post('/password_reset_from_email/', {'email': 'staffmember@example.com'}) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertEqual("staffmember@example.com", mail.outbox[0].from_email) @override_settings(ALLOWED_HOSTS=['adminsite.com']) def test_admin_reset(self): "If the reset view is marked as being for admin, the HTTP_HOST header is used for a domain override." response = self.client.post('/admin_password_reset/', {'email': 'staffmember@example.com'}, HTTP_HOST='adminsite.com' ) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) self.assertTrue("http://adminsite.com" in mail.outbox[0].body) self.assertEqual(settings.DEFAULT_FROM_EMAIL, mail.outbox[0].from_email) # Skip any 500 handler action (like sending more mail...) @override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True) def test_poisoned_http_host(self): "Poisoned HTTP_HOST headers can't be used for reset emails" # This attack is based on the way browsers handle URLs. The colon # should be used to separate the port, but if the URL contains an @, # the colon is interpreted as part of a username for login purposes, # making 'evil.com' the request domain. Since HTTP_HOST is used to # produce a meaningful reset URL, we need to be certain that the # HTTP_HOST header isn't poisoned. This is done as a check when get_host() # is invoked, but we check here as a practical consequence. with self.assertRaises(SuspiciousOperation): self.client.post('/password_reset/', {'email': 'staffmember@example.com'}, HTTP_HOST='www.example:dr.frankenstein@evil.tld' ) self.assertEqual(len(mail.outbox), 0) # Skip any 500 handler action (like sending more mail...) @override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True) def test_poisoned_http_host_admin_site(self): "Poisoned HTTP_HOST headers can't be used for reset emails on admin views" with self.assertRaises(SuspiciousOperation): self.client.post('/admin_password_reset/', {'email': 'staffmember@example.com'}, HTTP_HOST='www.example:dr.frankenstein@evil.tld' ) self.assertEqual(len(mail.outbox), 0) def _test_confirm_start(self): # Start by creating the email response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) return self._read_signup_email(mail.outbox[0]) def _read_signup_email(self, email): urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) self.assertTrue(urlmatch is not None, "No URL found in sent email") return urlmatch.group(), urlmatch.groups()[0] def test_confirm_valid(self): url, path = self._test_confirm_start() response = self.client.get(path) # redirect to a 'complete' page: self.assertContains(response, "Please enter your new password") def test_confirm_invalid(self): url, path = self._test_confirm_start() # Let's munge the token in the path, but keep the same length, # in case the URLconf will reject a different length. path = path[:-5] + ("0" * 4) + path[-1] response = self.client.get(path) self.assertContains(response, "The password reset link was invalid") def test_confirm_invalid_user(self): # Ensure that we get a 200 response for a non-existant user, not a 404 response = self.client.get('/reset/123456-1-1/') self.assertContains(response, "The password reset link was invalid") def test_confirm_overflow_user(self): # Ensure that we get a 200 response for a base36 user id that overflows int response = self.client.get('/reset/zzzzzzzzzzzzz-1-1/') self.assertContains(response, "The password reset link was invalid") def test_confirm_invalid_post(self): # Same as test_confirm_invalid, but trying # to do a POST instead. url, path = self._test_confirm_start() path = path[:-5] + ("0" * 4) + path[-1] self.client.post(path, { 'new_password1': 'anewpassword', 'new_password2': ' anewpassword', }) # Check the password has not been changed u = User.objects.get(email='staffmember@example.com') self.assertTrue(not u.check_password("anewpassword")) def test_confirm_complete(self): url, path = self._test_confirm_start() response = self.client.post(path, {'new_password1': 'anewpassword', 'new_password2': 'anewpassword'}) # It redirects us to a 'complete' page: self.assertEqual(response.status_code, 302) # Check the password has been changed u = User.objects.get(email='staffmember@example.com') self.assertTrue(u.check_password("anewpassword")) # Check we can't use the link again response = self.client.get(path) self.assertContains(response, "The password reset link was invalid") def test_confirm_different_passwords(self): url, path = self._test_confirm_start() response = self.client.post(path, {'new_password1': 'anewpassword', 'new_password2': 'x'}) self.assertContainsEscaped(response, SetPasswordForm.error_messages['password_mismatch']) @override_settings(AUTH_USER_MODEL='auth.CustomUser') class CustomUserPasswordResetTest(AuthViewsTestCase): fixtures = ['custom_user.json'] def _test_confirm_start(self): # Start by creating the email response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'}) self.assertEqual(response.status_code, 302) self.assertEqual(len(mail.outbox), 1) return self._read_signup_email(mail.outbox[0]) def _read_signup_email(self, email): urlmatch = re.search(r"https?://[^/]*(/.*reset/\S*)", email.body) self.assertTrue(urlmatch is not None, "No URL found in sent email") return urlmatch.group(), urlmatch.groups()[0] def test_confirm_valid_custom_user(self): url, path = self._test_confirm_start() response = self.client.get(path) # redirect to a 'complete' page: self.assertContains(response, "Please enter your new password") @skipIfCustomUser class ChangePasswordTest(AuthViewsTestCase): def fail_login(self, password='password'): response = self.client.post('/login/', { 'username': 'testclient', 'password': password, }) self.assertContainsEscaped(response, AuthenticationForm.error_messages['invalid_login'] % { 'username': User._meta.get_field('username').verbose_name }) def logout(self): response = self.client.get('/logout/') def test_password_change_fails_with_invalid_old_password(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'donuts', 'new_password1': 'password1', 'new_password2': 'password1', }) self.assertContainsEscaped(response, PasswordChangeForm.error_messages['password_incorrect']) def test_password_change_fails_with_mismatched_passwords(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'donuts', }) self.assertContainsEscaped(response, SetPasswordForm.error_messages['password_mismatch']) def test_password_change_succeeds(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'password1', }) self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/password_change/done/')) self.fail_login() self.login(password='password1') def test_password_change_done_succeeds(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'password1', }) self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/password_change/done/')) def test_password_change_done_fails(self): with self.settings(LOGIN_URL='/login/'): response = self.client.get('/password_change/done/') self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/login/?next=/password_change/done/')) @skipIfCustomUser class LoginTest(AuthViewsTestCase): def test_current_site_in_context_after_login(self): response = self.client.get(reverse('django.contrib.auth.views.login')) self.assertEqual(response.status_code, 200) if Site._meta.installed: site = Site.objects.get_current() self.assertEqual(response.context['site'], site) self.assertEqual(response.context['site_name'], site.name) else: self.assertIsInstance(response.context['site'], RequestSite) self.assertTrue(isinstance(response.context['form'], AuthenticationForm), 'Login form is not an AuthenticationForm') def test_security_check(self, password='password'): login_url = reverse('django.contrib.auth.views.login') # Those URLs should not pass the security check for bad_url in ('http://example.com', 'https://example.com', 'ftp://exampel.com', '//example.com', 'javascript:alert("XSS")'): nasty_url = '%(url)s?%(next)s=%(bad_url)s' % { 'url': login_url, 'next': REDIRECT_FIELD_NAME, 'bad_url': urlquote(bad_url), } response = self.client.post(nasty_url, { 'username': 'testclient', 'password': password, }) self.assertEqual(response.status_code, 302) self.assertFalse(bad_url in response['Location'], "%s should be blocked" % bad_url) # These URLs *should* still pass the security check for good_url in ('/view/?param=http://example.com', '/view/?param=https://example.com', '/view?param=ftp://exampel.com', 'view/?param=//example.com', 'https:///', 'HTTPS:///', '//testserver/', '/url%20with%20spaces/'): # see ticket #12534 safe_url = '%(url)s?%(next)s=%(good_url)s' % { 'url': login_url, 'next': REDIRECT_FIELD_NAME, 'good_url': urlquote(good_url), } response = self.client.post(safe_url, { 'username': 'testclient', 'password': password, }) self.assertEqual(response.status_code, 302) self.assertTrue(good_url in response['Location'], "%s should be allowed" % good_url) def test_login_csrf_rotate(self, password='password'): """ Makes sure that a login rotates the currently-used CSRF token. """ # Do a GET to establish a CSRF token # TestClient isn't used here as we're testing middleware, essentially. req = HttpRequest() CsrfViewMiddleware().process_view(req, login_view, (), {}) req.META["CSRF_COOKIE_USED"] = True resp = login_view(req) resp2 = CsrfViewMiddleware().process_response(req, resp) csrf_cookie = resp2.cookies.get(settings.CSRF_COOKIE_NAME, None) token1 = csrf_cookie.coded_value # Prepare the POST request req = HttpRequest() req.COOKIES[settings.CSRF_COOKIE_NAME] = token1 req.method = "POST" req.POST = {'username': 'testclient', 'password': password, 'csrfmiddlewaretoken': token1} req.REQUEST = req.POST # Use POST request to log in SessionMiddleware().process_request(req) CsrfViewMiddleware().process_view(req, login_view, (), {}) req.META["SERVER_NAME"] = "testserver" # Required to have redirect work in login view req.META["SERVER_PORT"] = 80 req.META["CSRF_COOKIE_USED"] = True resp = login_view(req) resp2 = CsrfViewMiddleware().process_response(req, resp) csrf_cookie = resp2.cookies.get(settings.CSRF_COOKIE_NAME, None) token2 = csrf_cookie.coded_value # Check the CSRF token switched self.assertNotEqual(token1, token2) @skipIfCustomUser class LoginURLSettings(AuthViewsTestCase): def setUp(self): super(LoginURLSettings, self).setUp() self.old_LOGIN_URL = settings.LOGIN_URL def tearDown(self): super(LoginURLSettings, self).tearDown() settings.LOGIN_URL = self.old_LOGIN_URL def get_login_required_url(self, login_url): settings.LOGIN_URL = login_url response = self.client.get('/login_required/') self.assertEqual(response.status_code, 302) return response['Location'] def test_standard_login_url(self): login_url = '/login/' login_required_url = self.get_login_required_url(login_url) querystring = QueryDict('', mutable=True) querystring['next'] = '/login_required/' self.assertEqual(login_required_url, 'http://testserver%s?%s' % (login_url, querystring.urlencode('/'))) def test_remote_login_url(self): login_url = 'http://remote.example.com/login' login_required_url = self.get_login_required_url(login_url) querystring = QueryDict('', mutable=True) querystring['next'] = 'http://testserver/login_required/' self.assertEqual(login_required_url, '%s?%s' % (login_url, querystring.urlencode('/'))) def test_https_login_url(self): login_url = 'https:///login/' login_required_url = self.get_login_required_url(login_url) querystring = QueryDict('', mutable=True) querystring['next'] = 'http://testserver/login_required/' self.assertEqual(login_required_url, '%s?%s' % (login_url, querystring.urlencode('/'))) def test_login_url_with_querystring(self): login_url = '/login/?pretty=1' login_required_url = self.get_login_required_url(login_url) querystring = QueryDict('pretty=1', mutable=True) querystring['next'] = '/login_required/' self.assertEqual(login_required_url, 'http://testserver/login/?%s' % querystring.urlencode('/')) def test_remote_login_url_with_next_querystring(self): login_url = 'http://remote.example.com/login/' login_required_url = self.get_login_required_url('%s?next=/default/' % login_url) querystring = QueryDict('', mutable=True) querystring['next'] = 'http://testserver/login_required/' self.assertEqual(login_required_url, '%s?%s' % (login_url, querystring.urlencode('/'))) @skipIfCustomUser class LogoutTest(AuthViewsTestCase): def confirm_logged_out(self): self.assertTrue(SESSION_KEY not in self.client.session) def test_logout_default(self): "Logout without next_page option renders the default template" self.login() response = self.client.get('/logout/') self.assertContains(response, 'Logged out') self.confirm_logged_out() def test_14377(self): # Bug 14377 self.login() response = self.client.get('/logout/') self.assertTrue('site' in response.context) def test_logout_with_overridden_redirect_url(self): # Bug 11223 self.login() response = self.client.get('/logout/next_page/') self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/somewhere/')) response = self.client.get('/logout/next_page/?next=/login/') self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/login/')) self.confirm_logged_out() def test_logout_with_next_page_specified(self): "Logout with next_page option given redirects to specified resource" self.login() response = self.client.get('/logout/next_page/') self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/somewhere/')) self.confirm_logged_out() def test_logout_with_redirect_argument(self): "Logout with query string redirects to specified resource" self.login() response = self.client.get('/logout/?next=/login/') self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/login/')) self.confirm_logged_out() def test_logout_with_custom_redirect_argument(self): "Logout with custom query string redirects to specified resource" self.login() response = self.client.get('/logout/custom_query/?follow=/somewhere/') self.assertEqual(response.status_code, 302) self.assertTrue(response['Location'].endswith('/somewhere/')) self.confirm_logged_out() def test_security_check(self, password='password'): logout_url = reverse('django.contrib.auth.views.logout') # Those URLs should not pass the security check for bad_url in ('http://example.com', 'https://example.com', 'ftp://exampel.com', '//example.com', 'javascript:alert("XSS")'): nasty_url = '%(url)s?%(next)s=%(bad_url)s' % { 'url': logout_url, 'next': REDIRECT_FIELD_NAME, 'bad_url': urlquote(bad_url), } self.login() response = self.client.get(nasty_url) self.assertEqual(response.status_code, 302) self.assertFalse(bad_url in response['Location'], "%s should be blocked" % bad_url) self.confirm_logged_out() # These URLs *should* still pass the security check for good_url in ('/view/?param=http://example.com', '/view/?param=https://example.com', '/view?param=ftp://exampel.com', 'view/?param=//example.com', 'https:///', 'HTTPS:///', '//testserver/', '/url%20with%20spaces/'): # see ticket #12534 safe_url = '%(url)s?%(next)s=%(good_url)s' % { 'url': logout_url, 'next': REDIRECT_FIELD_NAME, 'good_url': urlquote(good_url), } self.login() response = self.client.get(safe_url) self.assertEqual(response.status_code, 302) self.assertTrue(good_url in response['Location'], "%s should be allowed" % good_url) self.confirm_logged_out() @skipIfCustomUser class ChangelistTests(AuthViewsTestCase): urls = 'django.contrib.auth.tests.urls_admin' # #20078 - users shouldn't be allowed to guess password hashes via # repeated password__startswith queries. def test_changelist_disallows_password_lookups(self): # Make me a superuser before loging in. User.objects.filter(username='testclient').update(is_staff=True, is_superuser=True) self.login() # A lookup that tries to filter on password isn't OK with self.assertRaises(SuspiciousOperation): response = self.client.get('/admin/auth/user/?password__startswith=sha1$')
bsd-3-clause
[ 646, 747, 199, 646, 295, 199, 199, 504, 1639, 14, 2190, 492, 2288, 63, 1751, 12, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 12, 4784, 8972, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 1018, 14, 3924, 492, 428, 28651, 6044, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 12, 32036, 199, 504, 1639, 14, 1014, 492, 8133, 2141, 12, 20730, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 1360, 492, 4772, 199, 504, 1639, 14, 1208, 14, 1014, 492, 1166, 3513, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 5754, 14, 10088, 492, 22145, 25322, 199, 504, 1639, 14, 2828, 14, 11676, 14, 5754, 492, 8596, 6608, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 428, 9577, 63, 3078, 12, 820, 7458, 4168, 63, 8609, 63, 2339, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 334, 10348, 2821, 12, 13635, 32523, 12, 355, 2494, 6139, 2821, 12, 13635, 9637, 2821, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4196, 492, 4676, 465, 4676, 63, 1345, 421, 199, 32, 4415, 63, 1751, 8, 272, 30508, 5383, 2687, 267, 661, 287, 297, 283, 19410, 659, 272, 2318, 272, 30508, 2962, 63, 6012, 534, 287, 297, 272, 24877, 63, 7405, 3960, 29, 2966, 63, 1751, 14, 7433, 63, 7405, 3960, 12, 272, 24877, 63, 14455, 2687, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5876, 659, 272, 2318, 272, 4815, 63, 14226, 29, 797, 12, 272, 21705, 5172, 63, 13533, 31700, 7782, 1176, 14, 2828, 14, 1178, 14, 31342, 14, 8461, 17, 27596, 5529, 199, 9, 199, 533, 3590, 21180, 1746, 8, 1746, 304, 272, 408, 272, 11642, 1300, 1021, 367, 1006, 314, 2035, 511, 5560, 14, 272, 408, 272, 15188, 275, 788, 1178, 18481, 14, 1001, 418, 272, 8187, 275, 283, 1176, 14, 2828, 14, 1178, 14, 2219, 14, 3603, 7, 339, 347, 4676, 8, 277, 12, 2505, 534, 2060, 735, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2886, 3678, 469, 288, 283, 2473, 356, 283, 396, 1258, 297, 288, 283, 2060, 356, 2505, 12, 288, 3828, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 291, 14, 1815, 8, 1310, 459, 6592, 2278, 4130, 8, 1751, 14, 17208, 63, 19747, 63, 2632, 430, 267, 291, 14, 1815, 8, 12763, 63, 3078, 315, 291, 14, 1258, 14, 1730, 9, 339, 347, 702, 6906, 23953, 8, 277, 12, 1177, 12, 1318, 12, 1011, 958, 304, 267, 372, 291, 14, 9535, 8, 1310, 12, 4772, 8, 3990, 63, 505, 8, 505, 1826, 1011, 958, 9, 421, 199, 32, 15118, 31482, 199, 533, 3590, 2768, 7989, 2632, 2925, 8, 2817, 21180, 1746, 304, 272, 8187, 275, 283, 1176, 14, 2828, 14, 1178, 14, 3603, 7, 339, 347, 511, 63, 4579, 63, 3603, 8, 277, 304, 267, 298, 7989, 10867, 1077, 506, 29465, 1164, 2, 267, 1420, 63, 4579, 63, 3603, 275, 359, 288, 661, 2886, 297, 990, 8613, 288, 661, 11646, 297, 990, 8613, 288, 661, 2060, 63, 1461, 297, 990, 8613, 288, 661, 2060, 63, 1461, 63, 4456, 297, 990, 8613, 288, 661, 2060, 63, 3958, 297, 990, 8613, 288, 661, 2060, 63, 3958, 63, 4456, 297, 990, 8613, 288, 661, 2060, 63, 3958, 63, 9548, 297, 990, 469, 355, 283, 1535, 66, 1344, 356, 283, 6000, 11629, 297, 355, 283, 1418, 356, 283, 6984, 13, 6000, 65, 297, 288, 9998, 288, 661, 2060, 63, 3958, 63, 4883, 297, 990, 8613, 267, 1622, 267, 367, 536, 12, 1249, 12, 2074, 315, 1420, 63, 4579, 63, 3603, 26, 288, 862, 26, 355, 3837, 8, 354, 12, 1249, 29, 589, 12, 2074, 29, 958, 9, 288, 871, 32036, 26, 355, 291, 14, 1633, 480, 497, 16222, 402, 1166, 4310, 1543, 83, 7, 3405, 543, 32036, 2, 450, 536, 9, 421, 199, 32, 15118, 31482, 199, 533, 13635, 9637, 774, 8, 2817, 21180, 1746, 304, 339, 347, 511, 63, 2123, 63, 1397, 63, 4214, 8, 277, 304, 267, 298, 547, 365, 4915, 340, 314, 2741, 3031, 2287, 5712, 1133, 5544, 7264, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2060, 63, 3958, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2060, 63, 3958, 3678, 791, 2123, 356, 283, 1397, 63, 65, 63, 3093, 63, 2123, 32, 2123, 14, 957, 3071, 267, 291, 14, 9535, 23953, 8, 1310, 12, 13635, 9637, 2821, 14, 705, 63, 3431, 459, 5187, 1105, 267, 291, 14, 629, 8, 552, 8, 1198, 14, 17244, 395, 378, 9, 339, 347, 511, 63, 2123, 63, 4214, 8, 277, 304, 267, 298, 7035, 365, 4847, 340, 282, 1686, 3031, 2287, 365, 2741, 367, 2505, 5305, 2, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2060, 63, 3958, 3678, 791, 2123, 356, 283, 7018, 1114, 32, 2694, 14, 957, 3071, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 291, 14, 629, 8, 552, 8, 1198, 14, 17244, 395, 413, 9, 267, 291, 14, 1815, 480, 1014, 30443, 315, 6016, 14, 17244, 59, 16, 1055, 2030, 9, 267, 291, 14, 629, 8, 1751, 14, 3472, 63, 12491, 63, 10089, 12, 6016, 14, 17244, 59, 16, 1055, 504, 63, 2123, 9, 339, 347, 511, 63, 2123, 63, 4214, 63, 4229, 63, 504, 8, 277, 304, 267, 298, 7035, 365, 4847, 340, 282, 1686, 3031, 2287, 365, 2741, 367, 2505, 5305, 1380, 282, 3537, 687, 63, 2123, 365, 2741, 2122, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2060, 63, 3958, 63, 504, 63, 2123, 3678, 791, 2123, 356, 283, 7018, 1114, 32, 2694, 14, 957, 3071, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12 ]
[ 747, 199, 646, 295, 199, 199, 504, 1639, 14, 2190, 492, 2288, 63, 1751, 12, 2202, 199, 504, 1639, 14, 2828, 14, 8619, 14, 992, 492, 11666, 12, 4784, 8972, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 1018, 14, 3924, 492, 428, 28651, 6044, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 12, 32036, 199, 504, 1639, 14, 1014, 492, 8133, 2141, 12, 20730, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 1360, 492, 4772, 199, 504, 1639, 14, 1208, 14, 1014, 492, 1166, 3513, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1751, 199, 504, 1639, 14, 5754, 14, 10088, 492, 22145, 25322, 199, 504, 1639, 14, 2828, 14, 11676, 14, 5754, 492, 8596, 6608, 199, 199, 504, 1639, 14, 2828, 14, 1178, 492, 428, 9577, 63, 3078, 12, 820, 7458, 4168, 63, 8609, 63, 2339, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 334, 10348, 2821, 12, 13635, 32523, 12, 355, 2494, 6139, 2821, 12, 13635, 9637, 2821, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 2219, 14, 1208, 492, 3372, 3917, 31482, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4196, 492, 4676, 465, 4676, 63, 1345, 421, 199, 32, 4415, 63, 1751, 8, 272, 30508, 5383, 2687, 267, 661, 287, 297, 283, 19410, 659, 272, 2318, 272, 30508, 2962, 63, 6012, 534, 287, 297, 272, 24877, 63, 7405, 3960, 29, 2966, 63, 1751, 14, 7433, 63, 7405, 3960, 12, 272, 24877, 63, 14455, 2687, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5876, 659, 272, 2318, 272, 4815, 63, 14226, 29, 797, 12, 272, 21705, 5172, 63, 13533, 31700, 7782, 1176, 14, 2828, 14, 1178, 14, 31342, 14, 8461, 17, 27596, 5529, 199, 9, 199, 533, 3590, 21180, 1746, 8, 1746, 304, 272, 408, 272, 11642, 1300, 1021, 367, 1006, 314, 2035, 511, 5560, 14, 272, 408, 272, 15188, 275, 788, 1178, 18481, 14, 1001, 418, 272, 8187, 275, 283, 1176, 14, 2828, 14, 1178, 14, 2219, 14, 3603, 7, 339, 347, 4676, 8, 277, 12, 2505, 534, 2060, 735, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2886, 3678, 469, 288, 283, 2473, 356, 283, 396, 1258, 297, 288, 283, 2060, 356, 2505, 12, 288, 3828, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 291, 14, 1815, 8, 1310, 459, 6592, 2278, 4130, 8, 1751, 14, 17208, 63, 19747, 63, 2632, 430, 267, 291, 14, 1815, 8, 12763, 63, 3078, 315, 291, 14, 1258, 14, 1730, 9, 339, 347, 702, 6906, 23953, 8, 277, 12, 1177, 12, 1318, 12, 1011, 958, 304, 267, 372, 291, 14, 9535, 8, 1310, 12, 4772, 8, 3990, 63, 505, 8, 505, 1826, 1011, 958, 9, 421, 199, 32, 15118, 31482, 199, 533, 3590, 2768, 7989, 2632, 2925, 8, 2817, 21180, 1746, 304, 272, 8187, 275, 283, 1176, 14, 2828, 14, 1178, 14, 3603, 7, 339, 347, 511, 63, 4579, 63, 3603, 8, 277, 304, 267, 298, 7989, 10867, 1077, 506, 29465, 1164, 2, 267, 1420, 63, 4579, 63, 3603, 275, 359, 288, 661, 2886, 297, 990, 8613, 288, 661, 11646, 297, 990, 8613, 288, 661, 2060, 63, 1461, 297, 990, 8613, 288, 661, 2060, 63, 1461, 63, 4456, 297, 990, 8613, 288, 661, 2060, 63, 3958, 297, 990, 8613, 288, 661, 2060, 63, 3958, 63, 4456, 297, 990, 8613, 288, 661, 2060, 63, 3958, 63, 9548, 297, 990, 469, 355, 283, 1535, 66, 1344, 356, 283, 6000, 11629, 297, 355, 283, 1418, 356, 283, 6984, 13, 6000, 65, 297, 288, 9998, 288, 661, 2060, 63, 3958, 63, 4883, 297, 990, 8613, 267, 1622, 267, 367, 536, 12, 1249, 12, 2074, 315, 1420, 63, 4579, 63, 3603, 26, 288, 862, 26, 355, 3837, 8, 354, 12, 1249, 29, 589, 12, 2074, 29, 958, 9, 288, 871, 32036, 26, 355, 291, 14, 1633, 480, 497, 16222, 402, 1166, 4310, 1543, 83, 7, 3405, 543, 32036, 2, 450, 536, 9, 421, 199, 32, 15118, 31482, 199, 533, 13635, 9637, 774, 8, 2817, 21180, 1746, 304, 339, 347, 511, 63, 2123, 63, 1397, 63, 4214, 8, 277, 304, 267, 298, 547, 365, 4915, 340, 314, 2741, 3031, 2287, 5712, 1133, 5544, 7264, 2, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 2060, 63, 3958, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2060, 63, 3958, 3678, 791, 2123, 356, 283, 1397, 63, 65, 63, 3093, 63, 2123, 32, 2123, 14, 957, 3071, 267, 291, 14, 9535, 23953, 8, 1310, 12, 13635, 9637, 2821, 14, 705, 63, 3431, 459, 5187, 1105, 267, 291, 14, 629, 8, 552, 8, 1198, 14, 17244, 395, 378, 9, 339, 347, 511, 63, 2123, 63, 4214, 8, 277, 304, 267, 298, 7035, 365, 4847, 340, 282, 1686, 3031, 2287, 365, 2741, 367, 2505, 5305, 2, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2060, 63, 3958, 3678, 791, 2123, 356, 283, 7018, 1114, 32, 2694, 14, 957, 3071, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 291, 14, 629, 8, 552, 8, 1198, 14, 17244, 395, 413, 9, 267, 291, 14, 1815, 480, 1014, 30443, 315, 6016, 14, 17244, 59, 16, 1055, 2030, 9, 267, 291, 14, 629, 8, 1751, 14, 3472, 63, 12491, 63, 10089, 12, 6016, 14, 17244, 59, 16, 1055, 504, 63, 2123, 9, 339, 347, 511, 63, 2123, 63, 4214, 63, 4229, 63, 504, 8, 277, 304, 267, 298, 7035, 365, 4847, 340, 282, 1686, 3031, 2287, 365, 2741, 367, 2505, 5305, 1380, 282, 3537, 687, 63, 2123, 365, 2741, 2122, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 2060, 63, 3958, 63, 504, 63, 2123, 3678, 791, 2123, 356, 283, 7018, 1114, 32, 2694, 14, 957, 3071, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 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,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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 ]
ccastell/Transfer-System
Website/env/lib/python3.5/site-packages/pip/_vendor/progress/__init__.py
916
3023
# Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from __future__ import division from collections import deque from datetime import timedelta from math import ceil from sys import stderr from time import time __version__ = '1.2' class Infinite(object): file = stderr sma_window = 10 def __init__(self, *args, **kwargs): self.index = 0 self.start_ts = time() self._ts = self.start_ts self._dt = deque(maxlen=self.sma_window) for key, val in kwargs.items(): setattr(self, key, val) def __getitem__(self, key): if key.startswith('_'): return None return getattr(self, key, None) @property def avg(self): return sum(self._dt) / len(self._dt) if self._dt else 0 @property def elapsed(self): return int(time() - self.start_ts) @property def elapsed_td(self): return timedelta(seconds=self.elapsed) def update(self): pass def start(self): pass def finish(self): pass def next(self, n=1): if n > 0: now = time() dt = (now - self._ts) / n self._dt.append(dt) self._ts = now self.index = self.index + n self.update() def iter(self, it): for x in it: yield x self.next() self.finish() class Progress(Infinite): def __init__(self, *args, **kwargs): super(Progress, self).__init__(*args, **kwargs) self.max = kwargs.get('max', 100) @property def eta(self): return int(ceil(self.avg * self.remaining)) @property def eta_td(self): return timedelta(seconds=self.eta) @property def percent(self): return self.progress * 100 @property def progress(self): return min(1, self.index / self.max) @property def remaining(self): return max(self.max - self.index, 0) def start(self): self.update() def goto(self, index): incr = index - self.index self.next(incr) def iter(self, it): try: self.max = len(it) except TypeError: pass for x in it: yield x self.next() self.finish()
apache-2.0
[ 3, 1898, 334, 67, 9, 6029, 598, 73, 1308, 736, 5444, 528, 1151, 374, 665, 422, 528, 1151, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 367, 1263, 199, 3, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 2741, 626, 314, 3432, 199, 3, 4248, 4245, 436, 642, 4983, 4245, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 2334, 17632, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 199, 3, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 5055, 492, 15782, 199, 504, 2197, 492, 6871, 199, 504, 3473, 492, 30449, 199, 504, 984, 492, 4635, 199, 504, 900, 492, 900, 421, 199, 363, 1023, 363, 275, 283, 17, 14, 18, 7, 421, 199, 533, 1010, 8005, 8, 785, 304, 272, 570, 275, 4635, 272, 308, 391, 63, 3806, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1080, 275, 378, 267, 291, 14, 928, 63, 1086, 275, 900, 342, 267, 291, 423, 1086, 275, 291, 14, 928, 63, 1086, 267, 291, 423, 3583, 275, 15782, 8, 29078, 29, 277, 14, 83, 391, 63, 3806, 9, 267, 367, 790, 12, 1139, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 790, 12, 1139, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 14, 2460, 30018, 288, 372, 488, 267, 372, 2519, 8, 277, 12, 790, 12, 488, 9, 339, 768, 1829, 272, 347, 12402, 8, 277, 304, 267, 372, 3089, 8, 277, 423, 3583, 9, 1182, 822, 8, 277, 423, 3583, 9, 340, 291, 423, 3583, 587, 378, 339, 768, 1829, 272, 347, 14439, 8, 277, 304, 267, 372, 1109, 8, 521, 342, 446, 291, 14, 928, 63, 1086, 9, 339, 768, 1829, 272, 347, 14439, 63, 2076, 8, 277, 304, 267, 372, 6871, 8, 4515, 29, 277, 14, 16691, 9, 339, 347, 1678, 8, 277, 304, 267, 986, 339, 347, 1343, 8, 277, 304, 267, 986, 339, 347, 9578, 8, 277, 304, 267, 986, 339, 347, 2163, 8, 277, 12, 302, 29, 17, 304, 267, 340, 302, 690, 378, 26, 288, 3063, 275, 900, 342, 288, 4487, 275, 334, 2131, 446, 291, 423, 1086, 9, 1182, 302, 288, 291, 423, 3583, 14, 740, 8, 3583, 9, 288, 291, 423, 1086, 275, 3063, 398, 291, 14, 1080, 275, 291, 14, 1080, 435, 302, 267, 291, 14, 873, 342, 339, 347, 2740, 8, 277, 12, 652, 304, 267, 367, 671, 315, 652, 26, 288, 1995, 671, 288, 291, 14, 2184, 342, 267, 291, 14, 8192, 342, 421, 199, 533, 21211, 8, 607, 8005, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 11504, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 988, 275, 2074, 14, 362, 360, 988, 297, 2948, 9, 339, 768, 1829, 272, 347, 20356, 8, 277, 304, 267, 372, 1109, 8, 14085, 8, 277, 14, 8595, 627, 291, 14, 11266, 430, 339, 768, 1829, 272, 347, 20356, 63, 2076, 8, 277, 304, 267, 372, 6871, 8, 4515, 29, 277, 14, 1841, 9, 339, 768, 1829, 272, 347, 8878, 8, 277, 304, 267, 372, 291, 14, 5734, 627, 2948, 339, 768, 1829, 272, 347, 6696, 8, 277, 304, 267, 372, 1748, 8, 17, 12, 291, 14, 1080, 1182, 291, 14, 988, 9, 339, 768, 1829, 272, 347, 7971, 8, 277, 304, 267, 372, 1390, 8, 277, 14, 988, 446, 291, 14, 1080, 12, 378, 9, 339, 347, 1343, 8, 277, 304, 267, 291, 14, 873, 342, 339, 347, 18878, 8, 277, 12, 1478, 304, 267, 315, 1556, 275, 1478, 446, 291, 14, 1080, 267, 291, 14, 2184, 8, 19362, 9, 339, 347, 2740, 8, 277, 12, 652, 304, 267, 862, 26, 288, 291, 14, 988, 275, 822, 8, 390, 9, 267, 871, 3146, 26, 288, 986, 398, 367, 671, 315, 652, 26, 288, 1995, 671, 288, 291, 14, 2184, 342, 267, 291, 14, 8192, 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 ]
[ 1898, 334, 67, 9, 6029, 598, 73, 1308, 736, 5444, 528, 1151, 374, 665, 422, 528, 1151, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 367, 1263, 199, 3, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 2741, 626, 314, 3432, 199, 3, 4248, 4245, 436, 642, 4983, 4245, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 2334, 17632, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 199, 3, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 5055, 492, 15782, 199, 504, 2197, 492, 6871, 199, 504, 3473, 492, 30449, 199, 504, 984, 492, 4635, 199, 504, 900, 492, 900, 421, 199, 363, 1023, 363, 275, 283, 17, 14, 18, 7, 421, 199, 533, 1010, 8005, 8, 785, 304, 272, 570, 275, 4635, 272, 308, 391, 63, 3806, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1080, 275, 378, 267, 291, 14, 928, 63, 1086, 275, 900, 342, 267, 291, 423, 1086, 275, 291, 14, 928, 63, 1086, 267, 291, 423, 3583, 275, 15782, 8, 29078, 29, 277, 14, 83, 391, 63, 3806, 9, 267, 367, 790, 12, 1139, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 790, 12, 1139, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 14, 2460, 30018, 288, 372, 488, 267, 372, 2519, 8, 277, 12, 790, 12, 488, 9, 339, 768, 1829, 272, 347, 12402, 8, 277, 304, 267, 372, 3089, 8, 277, 423, 3583, 9, 1182, 822, 8, 277, 423, 3583, 9, 340, 291, 423, 3583, 587, 378, 339, 768, 1829, 272, 347, 14439, 8, 277, 304, 267, 372, 1109, 8, 521, 342, 446, 291, 14, 928, 63, 1086, 9, 339, 768, 1829, 272, 347, 14439, 63, 2076, 8, 277, 304, 267, 372, 6871, 8, 4515, 29, 277, 14, 16691, 9, 339, 347, 1678, 8, 277, 304, 267, 986, 339, 347, 1343, 8, 277, 304, 267, 986, 339, 347, 9578, 8, 277, 304, 267, 986, 339, 347, 2163, 8, 277, 12, 302, 29, 17, 304, 267, 340, 302, 690, 378, 26, 288, 3063, 275, 900, 342, 288, 4487, 275, 334, 2131, 446, 291, 423, 1086, 9, 1182, 302, 288, 291, 423, 3583, 14, 740, 8, 3583, 9, 288, 291, 423, 1086, 275, 3063, 398, 291, 14, 1080, 275, 291, 14, 1080, 435, 302, 267, 291, 14, 873, 342, 339, 347, 2740, 8, 277, 12, 652, 304, 267, 367, 671, 315, 652, 26, 288, 1995, 671, 288, 291, 14, 2184, 342, 267, 291, 14, 8192, 342, 421, 199, 533, 21211, 8, 607, 8005, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 11504, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 988, 275, 2074, 14, 362, 360, 988, 297, 2948, 9, 339, 768, 1829, 272, 347, 20356, 8, 277, 304, 267, 372, 1109, 8, 14085, 8, 277, 14, 8595, 627, 291, 14, 11266, 430, 339, 768, 1829, 272, 347, 20356, 63, 2076, 8, 277, 304, 267, 372, 6871, 8, 4515, 29, 277, 14, 1841, 9, 339, 768, 1829, 272, 347, 8878, 8, 277, 304, 267, 372, 291, 14, 5734, 627, 2948, 339, 768, 1829, 272, 347, 6696, 8, 277, 304, 267, 372, 1748, 8, 17, 12, 291, 14, 1080, 1182, 291, 14, 988, 9, 339, 768, 1829, 272, 347, 7971, 8, 277, 304, 267, 372, 1390, 8, 277, 14, 988, 446, 291, 14, 1080, 12, 378, 9, 339, 347, 1343, 8, 277, 304, 267, 291, 14, 873, 342, 339, 347, 18878, 8, 277, 12, 1478, 304, 267, 315, 1556, 275, 1478, 446, 291, 14, 1080, 267, 291, 14, 2184, 8, 19362, 9, 339, 347, 2740, 8, 277, 12, 652, 304, 267, 862, 26, 288, 291, 14, 988, 275, 822, 8, 390, 9, 267, 871, 3146, 26, 288, 986, 398, 367, 671, 315, 652, 26, 288, 1995, 671, 288, 291, 14, 2184, 342, 267, 291, 14, 8192, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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c. 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. """This example retrieves the report download stream. To get report fields, run get_report_fields.py. The LoadFromStorage method is pulling credentials and properties from a "googleads.yaml" file. By default, it looks for this file in your home directory. For more information, see the "Caching authentication information" section of our README. Tags: ReportDefinitionService.mutate Api: AdWordsOnly """ __author__ = 'Mark Saniscalchi' import logging import StringIO import sys from googleads import adwords logging.basicConfig(level=logging.INFO) logging.getLogger('suds.transport').setLevel(logging.DEBUG) # The chunk size used for the report download. CHUNK_SIZE = 16 * 1024 def main(client): report_downloader = client.GetReportDownloader(version='v201506') # Create report definition. report = { 'reportName': 'Last 7 days CRITERIA_PERFORMANCE_REPORT', 'dateRangeType': 'LAST_7_DAYS', 'reportType': 'CRITERIA_PERFORMANCE_REPORT', 'downloadFormat': 'CSV', 'selector': { 'fields': ['CampaignId', 'AdGroupId', 'Id', 'CriteriaType', 'Criteria', 'FinalUrls', 'Impressions', 'Clicks', 'Cost'] } } # Retrieve the report stream and print it out report_data = StringIO.StringIO() stream_data = report_downloader.DownloadReportAsStream( report, skip_report_header=False, skip_column_header=False, skip_report_summary=False, include_zero_impressions=False) try: while True: chunk = stream_data.read(CHUNK_SIZE) if not chunk: break report_data.write(chunk.decode() if sys.version_info[0] == 3 and getattr(report_data, 'mode', 'w') == 'w' else chunk) print report_data.getvalue() finally: report_data.close() stream_data.close() if __name__ == '__main__': adwords_client = adwords.AdWordsClient.LoadFromStorage() main(adwords_client)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2765, 2893, 9619, 2310, 314, 3622, 5235, 2547, 14, 199, 199, 1378, 664, 3622, 1504, 12, 1255, 664, 63, 3070, 63, 955, 14, 647, 14, 199, 199, 1918, 7190, 2532, 6408, 1083, 365, 10299, 316, 6235, 436, 4382, 687, 282, 199, 2, 29882, 14, 5963, 2, 570, 14, 4885, 849, 12, 652, 10734, 367, 642, 570, 315, 2195, 5629, 199, 3619, 14, 2104, 1655, 2556, 12, 1937, 314, 298, 35, 23302, 6299, 2556, 2, 199, 2792, 402, 4154, 27781, 14, 199, 199, 9440, 26, 11774, 10701, 3167, 14, 6552, 323, 199, 7394, 26, 4431, 23759, 5903, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 6470, 428, 7199, 915, 13175, 7, 199, 199, 646, 2050, 199, 646, 5228, 199, 646, 984, 199, 199, 504, 6233, 9402, 492, 1503, 3148, 421, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 4531, 9, 199, 4806, 14, 5572, 360, 9648, 795, 14, 5545, 1959, 13548, 8, 4806, 14, 5287, 9, 199, 199, 3, 710, 3728, 1568, 1202, 367, 314, 3622, 5235, 14, 199, 20512, 63, 4305, 275, 3193, 627, 6619, 421, 199, 318, 2446, 8, 1258, 304, 523, 3622, 63, 22846, 275, 1890, 14, 1002, 7457, 3514, 3422, 8, 1023, 534, 86, 1797, 13725, 358, 819, 327, 2790, 3622, 5492, 14, 523, 3622, 275, 469, 489, 283, 3070, 985, 356, 283, 6090, 1520, 7609, 17101, 11084, 13033, 63, 4227, 30340, 63, 17356, 297, 489, 283, 602, 4709, 804, 356, 283, 16901, 63, 23, 63, 25683, 297, 489, 283, 3070, 804, 356, 283, 2944, 11084, 13033, 63, 4227, 30340, 63, 17356, 297, 489, 283, 4249, 3484, 356, 283, 19018, 297, 489, 283, 6662, 356, 469, 881, 283, 955, 356, 788, 3630, 11721, 1304, 297, 283, 2767, 2448, 1304, 297, 283, 1304, 297, 283, 35, 7527, 65, 804, 297, 2151, 283, 35, 7527, 65, 297, 283, 12776, 21867, 478, 297, 283, 8499, 6274, 297, 283, 20653, 5618, 297, 283, 15568, 418, 489, 789, 523, 789, 819, 327, 13939, 314, 3622, 2547, 436, 870, 652, 734, 523, 3622, 63, 576, 275, 5228, 14, 6424, 342, 523, 2547, 63, 576, 275, 3622, 63, 22846, 14, 11950, 7457, 2822, 3296, 8, 489, 3622, 12, 3372, 63, 3070, 63, 1291, 29, 797, 12, 3372, 63, 2301, 63, 1291, 29, 797, 12, 489, 3372, 63, 3070, 63, 4705, 29, 797, 12, 2387, 63, 4262, 63, 3236, 6274, 29, 797, 9, 819, 862, 26, 272, 1830, 715, 26, 489, 3728, 275, 2547, 63, 576, 14, 739, 8, 20512, 63, 4305, 9, 489, 340, 440, 3728, 26, 2059, 489, 3622, 63, 576, 14, 952, 8, 4604, 14, 2708, 342, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 717, 436, 2519, 8, 3070, 63, 576, 12, 283, 632, 297, 283, 87, 358, 508, 283, 87, 7, 587, 3728, 9, 272, 870, 3622, 63, 576, 14, 7150, 342, 523, 3753, 26, 272, 3622, 63, 576, 14, 1600, 342, 272, 2547, 63, 576, 14, 1600, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 1503, 3148, 63, 1258, 275, 1503, 3148, 14, 2767, 23759, 3041, 14, 6200, 2532, 6408, 342, 523, 2446, 8, 350, 3148, 63, 1258, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 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, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 2765, 2893, 9619, 2310, 314, 3622, 5235, 2547, 14, 199, 199, 1378, 664, 3622, 1504, 12, 1255, 664, 63, 3070, 63, 955, 14, 647, 14, 199, 199, 1918, 7190, 2532, 6408, 1083, 365, 10299, 316, 6235, 436, 4382, 687, 282, 199, 2, 29882, 14, 5963, 2, 570, 14, 4885, 849, 12, 652, 10734, 367, 642, 570, 315, 2195, 5629, 199, 3619, 14, 2104, 1655, 2556, 12, 1937, 314, 298, 35, 23302, 6299, 2556, 2, 199, 2792, 402, 4154, 27781, 14, 199, 199, 9440, 26, 11774, 10701, 3167, 14, 6552, 323, 199, 7394, 26, 4431, 23759, 5903, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 6470, 428, 7199, 915, 13175, 7, 199, 199, 646, 2050, 199, 646, 5228, 199, 646, 984, 199, 199, 504, 6233, 9402, 492, 1503, 3148, 421, 199, 4806, 14, 19602, 8, 1896, 29, 4806, 14, 4531, 9, 199, 4806, 14, 5572, 360, 9648, 795, 14, 5545, 1959, 13548, 8, 4806, 14, 5287, 9, 199, 199, 3, 710, 3728, 1568, 1202, 367, 314, 3622, 5235, 14, 199, 20512, 63, 4305, 275, 3193, 627, 6619, 421, 199, 318, 2446, 8, 1258, 304, 523, 3622, 63, 22846, 275, 1890, 14, 1002, 7457, 3514, 3422, 8, 1023, 534, 86, 1797, 13725, 358, 819, 327, 2790, 3622, 5492, 14, 523, 3622, 275, 469, 489, 283, 3070, 985, 356, 283, 6090, 1520, 7609, 17101, 11084, 13033, 63, 4227, 30340, 63, 17356, 297, 489, 283, 602, 4709, 804, 356, 283, 16901, 63, 23, 63, 25683, 297, 489, 283, 3070, 804, 356, 283, 2944, 11084, 13033, 63, 4227, 30340, 63, 17356, 297, 489, 283, 4249, 3484, 356, 283, 19018, 297, 489, 283, 6662, 356, 469, 881, 283, 955, 356, 788, 3630, 11721, 1304, 297, 283, 2767, 2448, 1304, 297, 283, 1304, 297, 283, 35, 7527, 65, 804, 297, 2151, 283, 35, 7527, 65, 297, 283, 12776, 21867, 478, 297, 283, 8499, 6274, 297, 283, 20653, 5618, 297, 283, 15568, 418, 489, 789, 523, 789, 819, 327, 13939, 314, 3622, 2547, 436, 870, 652, 734, 523, 3622, 63, 576, 275, 5228, 14, 6424, 342, 523, 2547, 63, 576, 275, 3622, 63, 22846, 14, 11950, 7457, 2822, 3296, 8, 489, 3622, 12, 3372, 63, 3070, 63, 1291, 29, 797, 12, 3372, 63, 2301, 63, 1291, 29, 797, 12, 489, 3372, 63, 3070, 63, 4705, 29, 797, 12, 2387, 63, 4262, 63, 3236, 6274, 29, 797, 9, 819, 862, 26, 272, 1830, 715, 26, 489, 3728, 275, 2547, 63, 576, 14, 739, 8, 20512, 63, 4305, 9, 489, 340, 440, 3728, 26, 2059, 489, 3622, 63, 576, 14, 952, 8, 4604, 14, 2708, 342, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 717, 436, 2519, 8, 3070, 63, 576, 12, 283, 632, 297, 283, 87, 358, 508, 283, 87, 7, 587, 3728, 9, 272, 870, 3622, 63, 576, 14, 7150, 342, 523, 3753, 26, 272, 3622, 63, 576, 14, 1600, 342, 272, 2547, 63, 576, 14, 1600, 342, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 1503, 3148, 63, 1258, 275, 1503, 3148, 14, 2767, 23759, 3041, 14, 6200, 2532, 6408, 342, 523, 2446, 8, 350, 3148, 63, 1258, 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, 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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 ]
rmehta/erpnext
erpnext/setup/doctype/authorization_rule/authorization_rule.py
121
2292
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe from frappe.utils import cstr, flt from frappe import _, msgprint from frappe.model.document import Document class AuthorizationRule(Document): def check_duplicate_entry(self): exists = frappe.db.sql("""select name, docstatus from `tabAuthorization Rule` where transaction = %s and based_on = %s and system_user = %s and system_role = %s and approving_user = %s and approving_role = %s and to_emp =%s and to_designation=%s and name != %s""", (self.transaction, self.based_on, cstr(self.system_user), cstr(self.system_role), cstr(self.approving_user), cstr(self.approving_role), cstr(self.to_emp), cstr(self.to_designation), self.name)) auth_exists = exists and exists[0][0] or '' if auth_exists: frappe.throw(_("Duplicate Entry. Please check Authorization Rule {0}").format(auth_exists)) def validate_rule(self): if self.transaction != 'Appraisal': if not self.approving_role and not self.approving_user: frappe.throw(_("Please enter Approving Role or Approving User")) elif self.system_user and self.system_user == self.approving_user: frappe.throw(_("Approving User cannot be same as user the rule is Applicable To")) elif self.system_role and self.system_role == self.approving_role: frappe.throw(_("Approving Role cannot be same as role the rule is Applicable To")) elif self.transaction in ['Purchase Order', 'Purchase Receipt', \ 'Purchase Invoice', 'Stock Entry'] and self.based_on \ in ['Average Discount', 'Customerwise Discount', 'Itemwise Discount']: frappe.throw(_("Cannot set authorization on basis of Discount for {0}").format(self.transaction)) elif self.based_on == 'Average Discount' and flt(self.value) > 100.00: frappe.throw(_("Discount must be less than 100")) elif self.based_on == 'Customerwise Discount' and not self.master_name: frappe.throw(_("Customer required for 'Customerwise Discount'")) else: if self.transaction == 'Appraisal': self.based_on = "Not Applicable" def validate(self): self.check_duplicate_entry() self.validate_rule() if not self.value: self.value = 0.0
gpl-3.0
[ 3, 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 199, 504, 6950, 14, 1208, 492, 286, 495, 12, 17166, 199, 504, 6950, 492, 5501, 1499, 1361, 199, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 199, 533, 21527, 5065, 8, 5564, 304, 199, 198, 318, 1104, 63, 11081, 63, 2373, 8, 277, 304, 507, 198, 2444, 275, 6950, 14, 697, 14, 3009, 4852, 2416, 536, 12, 1382, 1205, 687, 658, 2902, 11626, 11949, 64, 686, 198, 4509, 6008, 275, 450, 83, 436, 4079, 63, 265, 275, 450, 83, 436, 2656, 63, 751, 275, 450, 83, 686, 198, 460, 2656, 63, 3756, 275, 450, 83, 436, 4286, 4007, 63, 751, 275, 450, 83, 436, 4286, 4007, 63, 3756, 275, 450, 83, 686, 198, 460, 370, 63, 2109, 275, 5, 83, 436, 370, 63, 14748, 425, 2458, 83, 436, 536, 1137, 450, 83, 7208, 686, 198, 8, 277, 14, 5945, 12, 291, 14, 6788, 63, 265, 12, 286, 495, 8, 277, 14, 2253, 63, 751, 395, 1585, 198, 67, 495, 8, 277, 14, 2253, 63, 3756, 395, 286, 495, 8, 277, 14, 11227, 4007, 63, 751, 395, 1585, 198, 67, 495, 8, 277, 14, 11227, 4007, 63, 3756, 395, 286, 495, 8, 277, 14, 475, 63, 2109, 395, 1585, 198, 67, 495, 8, 277, 14, 475, 63, 14748, 425, 395, 291, 14, 354, 430, 507, 198, 1178, 63, 2444, 275, 3495, 436, 3495, 59, 16, 1527, 16, 61, 503, 2125, 507, 198, 692, 1790, 63, 2444, 26, 686, 198, 9098, 14, 11964, 6115, 14773, 11855, 14, 7754, 1104, 21527, 11949, 469, 16, 30273, 908, 8, 1178, 63, 2444, 430, 4388, 198, 318, 4107, 63, 2200, 8, 277, 304, 507, 198, 692, 291, 14, 5945, 1137, 283, 2640, 345, 28235, 356, 686, 198, 692, 440, 291, 14, 11227, 4007, 63, 3756, 436, 440, 291, 14, 11227, 4007, 63, 751, 26, 1585, 198, 9098, 14, 11964, 6115, 8254, 9509, 19615, 4007, 18033, 503, 19615, 4007, 2876, 2237, 686, 198, 4164, 291, 14, 2253, 63, 751, 436, 291, 14, 2253, 63, 751, 508, 291, 14, 11227, 4007, 63, 751, 26, 1585, 198, 9098, 14, 11964, 6115, 25923, 4007, 2876, 3913, 506, 2011, 465, 922, 314, 2332, 365, 4693, 606, 461, 4005, 2237, 686, 198, 4164, 291, 14, 2253, 63, 3756, 436, 291, 14, 2253, 63, 3756, 508, 291, 14, 11227, 4007, 63, 3756, 26, 1585, 198, 9098, 14, 11964, 6115, 25923, 4007, 18033, 3913, 506, 2011, 465, 4719, 314, 2332, 365, 4693, 606, 461, 4005, 2237, 686, 198, 4164, 291, 14, 5945, 315, 788, 20486, 9240, 297, 283, 20486, 799, 13866, 297, 971, 1871, 198, 7, 20486, 19868, 297, 283, 17103, 11855, 418, 436, 291, 14, 6788, 63, 265, 971, 1871, 198, 262, 788, 17400, 5289, 835, 297, 283, 17025, 2605, 5289, 835, 297, 283, 2081, 2605, 5289, 835, 2565, 1585, 198, 9098, 14, 11964, 6115, 6612, 663, 13448, 641, 5597, 402, 5289, 835, 367, 469, 16, 30273, 908, 8, 277, 14, 5945, 430, 686, 198, 4164, 291, 14, 6788, 63, 265, 508, 283, 17400, 5289, 835, 7, 436, 17166, 8, 277, 14, 585, 9, 690, 2948, 14, 383, 26, 1585, 198, 9098, 14, 11964, 6115, 2825, 835, 1471, 506, 6656, 2419, 2948, 2237, 686, 198, 4164, 291, 14, 6788, 63, 265, 508, 283, 17025, 2605, 5289, 835, 7, 436, 440, 291, 14, 4133, 63, 354, 26, 1585, 198, 9098, 14, 11964, 6115, 17025, 1415, 367, 283, 17025, 2605, 5289, 835, 7, 2237, 507, 198, 2836, 26, 686, 198, 692, 291, 14, 5945, 508, 283, 2640, 345, 28235, 356, 1585, 198, 277, 14, 6788, 63, 265, 275, 298, 1763, 4693, 606, 461, 2, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 1074, 63, 11081, 63, 2373, 342, 507, 198, 277, 14, 3502, 63, 2200, 342, 507, 198, 692, 440, 291, 14, 585, 26, 291, 14, 585, 275, 378, 14, 16, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 199, 504, 6950, 14, 1208, 492, 286, 495, 12, 17166, 199, 504, 6950, 492, 5501, 1499, 1361, 199, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 199, 533, 21527, 5065, 8, 5564, 304, 199, 198, 318, 1104, 63, 11081, 63, 2373, 8, 277, 304, 507, 198, 2444, 275, 6950, 14, 697, 14, 3009, 4852, 2416, 536, 12, 1382, 1205, 687, 658, 2902, 11626, 11949, 64, 686, 198, 4509, 6008, 275, 450, 83, 436, 4079, 63, 265, 275, 450, 83, 436, 2656, 63, 751, 275, 450, 83, 686, 198, 460, 2656, 63, 3756, 275, 450, 83, 436, 4286, 4007, 63, 751, 275, 450, 83, 436, 4286, 4007, 63, 3756, 275, 450, 83, 686, 198, 460, 370, 63, 2109, 275, 5, 83, 436, 370, 63, 14748, 425, 2458, 83, 436, 536, 1137, 450, 83, 7208, 686, 198, 8, 277, 14, 5945, 12, 291, 14, 6788, 63, 265, 12, 286, 495, 8, 277, 14, 2253, 63, 751, 395, 1585, 198, 67, 495, 8, 277, 14, 2253, 63, 3756, 395, 286, 495, 8, 277, 14, 11227, 4007, 63, 751, 395, 1585, 198, 67, 495, 8, 277, 14, 11227, 4007, 63, 3756, 395, 286, 495, 8, 277, 14, 475, 63, 2109, 395, 1585, 198, 67, 495, 8, 277, 14, 475, 63, 14748, 425, 395, 291, 14, 354, 430, 507, 198, 1178, 63, 2444, 275, 3495, 436, 3495, 59, 16, 1527, 16, 61, 503, 2125, 507, 198, 692, 1790, 63, 2444, 26, 686, 198, 9098, 14, 11964, 6115, 14773, 11855, 14, 7754, 1104, 21527, 11949, 469, 16, 30273, 908, 8, 1178, 63, 2444, 430, 4388, 198, 318, 4107, 63, 2200, 8, 277, 304, 507, 198, 692, 291, 14, 5945, 1137, 283, 2640, 345, 28235, 356, 686, 198, 692, 440, 291, 14, 11227, 4007, 63, 3756, 436, 440, 291, 14, 11227, 4007, 63, 751, 26, 1585, 198, 9098, 14, 11964, 6115, 8254, 9509, 19615, 4007, 18033, 503, 19615, 4007, 2876, 2237, 686, 198, 4164, 291, 14, 2253, 63, 751, 436, 291, 14, 2253, 63, 751, 508, 291, 14, 11227, 4007, 63, 751, 26, 1585, 198, 9098, 14, 11964, 6115, 25923, 4007, 2876, 3913, 506, 2011, 465, 922, 314, 2332, 365, 4693, 606, 461, 4005, 2237, 686, 198, 4164, 291, 14, 2253, 63, 3756, 436, 291, 14, 2253, 63, 3756, 508, 291, 14, 11227, 4007, 63, 3756, 26, 1585, 198, 9098, 14, 11964, 6115, 25923, 4007, 18033, 3913, 506, 2011, 465, 4719, 314, 2332, 365, 4693, 606, 461, 4005, 2237, 686, 198, 4164, 291, 14, 5945, 315, 788, 20486, 9240, 297, 283, 20486, 799, 13866, 297, 971, 1871, 198, 7, 20486, 19868, 297, 283, 17103, 11855, 418, 436, 291, 14, 6788, 63, 265, 971, 1871, 198, 262, 788, 17400, 5289, 835, 297, 283, 17025, 2605, 5289, 835, 297, 283, 2081, 2605, 5289, 835, 2565, 1585, 198, 9098, 14, 11964, 6115, 6612, 663, 13448, 641, 5597, 402, 5289, 835, 367, 469, 16, 30273, 908, 8, 277, 14, 5945, 430, 686, 198, 4164, 291, 14, 6788, 63, 265, 508, 283, 17400, 5289, 835, 7, 436, 17166, 8, 277, 14, 585, 9, 690, 2948, 14, 383, 26, 1585, 198, 9098, 14, 11964, 6115, 2825, 835, 1471, 506, 6656, 2419, 2948, 2237, 686, 198, 4164, 291, 14, 6788, 63, 265, 508, 283, 17025, 2605, 5289, 835, 7, 436, 440, 291, 14, 4133, 63, 354, 26, 1585, 198, 9098, 14, 11964, 6115, 17025, 1415, 367, 283, 17025, 2605, 5289, 835, 7, 2237, 507, 198, 2836, 26, 686, 198, 692, 291, 14, 5945, 508, 283, 2640, 345, 28235, 356, 1585, 198, 277, 14, 6788, 63, 265, 275, 298, 1763, 4693, 606, 461, 2, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 1074, 63, 11081, 63, 2373, 342, 507, 198, 277, 14, 3502, 63, 2200, 342, 507, 198, 692, 440, 291, 14, 585, 26, 291, 14, 585, 275, 378, 14, 16, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vmx/spring
spring/docgen.py
1
6786
import math import time from hashlib import md5 from itertools import cycle import random import numpy as np from spring.states import STATES, NUM_STATES from fastdocgen import build_achievements class Iterator(object): def __init__(self): self.prefix = None def __iter__(self): return self def add_prefix(self, key): if self.prefix: return '%s-%s' % (self.prefix, key) else: return key class ExistingKey(Iterator): def __init__(self, working_set, working_set_access, prefix): self.working_set = working_set self.working_set_access = working_set_access self.prefix = prefix def next(self, curr_items, curr_deletes): num_existing_items = curr_items - curr_deletes num_hot_items = int(num_existing_items * self.working_set / 100.0) num_cold_items = num_existing_items - num_hot_items left_limit = 1 + curr_deletes if self.working_set_access == 100 or \ random.randint(0, 100) <= self.working_set_access: left_limit += num_cold_items right_limit = curr_items else: right_limit = left_limit + num_cold_items key = np.random.random_integers(left_limit, right_limit) key = '%012d' % key return self.add_prefix(key) class SequentialHotKey(Iterator): def __init__(self, sid, ws, prefix): self.sid = sid self.ws = ws self.prefix = prefix def __iter__(self): num_hot_keys = int(self.ws.items * self.ws.working_set / 100.0) num_cold_items = self.ws.items - num_hot_keys for seq_id in xrange(1 + num_cold_items + self.sid, 1 + self.ws.items, self.ws.workers): key = '%012d' % seq_id key = self.add_prefix(key) yield key class NewKey(Iterator): def __init__(self, prefix, expiration): self.prefix = prefix self.expiration = expiration self.ttls = cycle(range(150, 450, 30)) def next(self, curr_items): key = '%012d' % curr_items key = self.add_prefix(key) ttl = None if self.expiration and random.randint(1, 100) <= self.expiration: ttl = self.ttls.next() return key, ttl class KeyForRemoval(Iterator): def __init__(self, prefix): self.prefix = prefix def next(self, curr_deletes): key = '%012d' % curr_deletes return self.add_prefix(key) class NewDocument(Iterator): SIZE_VARIATION = 0.25 # 25% KEY_LENGTH = 10 def __init__(self, avg_size): self.avg_size = avg_size @classmethod def _get_variation_coeff(cls): return np.random.uniform(1 - cls.SIZE_VARIATION, 1 + cls.SIZE_VARIATION) @staticmethod def _build_alphabet(key): return md5(key).hexdigest() + md5(key[::-1]).hexdigest() @staticmethod def _build_name(alphabet): return '%s %s' % (alphabet[:6], alphabet[6:12]) @staticmethod def _build_email(alphabet): return '%s@%s.com' % (alphabet[12:18], alphabet[18:24]) @staticmethod def _build_city(alphabet): return alphabet[24:30] @staticmethod def _build_realm(alphabet): return alphabet[30:36] @staticmethod def _build_country(alphabet): return alphabet[42:48] @staticmethod def _build_county(alphabet): return alphabet[48:54] @staticmethod def _build_street(alphabet): return alphabet[54:62] @staticmethod def _build_coins(alphabet): return max(0.1, int(alphabet[36:40], 16) / 100.0) @staticmethod def _build_gmtime(alphabet): seconds = 396 * 24 * 3600 * (int(alphabet[63], 16) % 12) return tuple(time.gmtime(seconds)) @staticmethod def _build_year(alphabet): return 1985 + int(alphabet[62], 16) @staticmethod def _build_state(alphabet): idx = alphabet.find('7') % NUM_STATES return STATES[idx][0] @staticmethod def _build_full_state(alphabet): idx = alphabet.find('8') % NUM_STATES return STATES[idx][1] @staticmethod def _build_category(alphabet): return int(alphabet[41], 16) % 3 @staticmethod def _build_achievements(alphabet): return build_achievements(alphabet) or [0] @staticmethod def _build_body(alphabet, length): length_int = int(length) num_slices = int(math.ceil(length / 64)) # 64 == len(alphabet) body = num_slices * alphabet return body[:length_int] def next(self, key): next_length = self._get_variation_coeff() * self.avg_size alphabet = self._build_alphabet(key) return { 'name': self._build_name(alphabet), 'email': self._build_email(alphabet), 'city': self._build_city(alphabet), 'realm': self._build_realm(alphabet), 'coins': self._build_coins(alphabet), 'category': self._build_category(alphabet), 'achievements': self._build_achievements(alphabet), 'body': self._build_body(alphabet, next_length) } class NewNestedDocument(NewDocument): OVERHEAD = 450 # Minimum size due to fixed fields, body size is variable def _size(self): if self.avg_size <= self.OVERHEAD: return 0 if random.random() < 0.975: # Normal distribution with mean=self.avg_size normal = np.random.normal(loc=1.0, scale=0.17) return (self.avg_size - self.OVERHEAD) * normal else: # Beta distribution, 2KB-2MB range return 2048 / np.random.beta(a=2.2, b=1.0) def next(self, key): alphabet = self._build_alphabet(key) size = self._size() return { 'name': {'f': {'f': {'f': self._build_name(alphabet)}}}, 'email': {'f': {'f': self._build_email(alphabet)}}, 'street': {'f': {'f': self._build_street(alphabet)}}, 'city': {'f': {'f': self._build_city(alphabet)}}, 'county': {'f': {'f': self._build_county(alphabet)}}, 'state': {'f': self._build_state(alphabet)}, 'full_state': {'f': self._build_full_state(alphabet)}, 'country': {'f': self._build_country(alphabet)}, 'realm': {'f': self._build_realm(alphabet)}, 'coins': {'f': self._build_coins(alphabet)}, 'category': self._build_category(alphabet), 'achievements': self._build_achievements(alphabet), 'gmtime': self._build_gmtime(alphabet), 'year': self._build_year(alphabet), 'body': self._build_body(alphabet, size), }
apache-2.0
[ 646, 3473, 199, 646, 900, 199, 504, 8337, 492, 6128, 21, 199, 504, 7975, 492, 8643, 199, 199, 646, 2196, 199, 646, 2680, 465, 980, 199, 199, 504, 2249, 5985, 14, 4981, 492, 13146, 654, 12, 11576, 63, 23162, 199, 199, 504, 7377, 1301, 2268, 492, 1900, 63, 1225, 1873, 432, 1470, 421, 199, 533, 25769, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1861, 275, 488, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 339, 347, 1050, 63, 1861, 8, 277, 12, 790, 304, 267, 340, 291, 14, 1861, 26, 288, 372, 1543, 83, 3295, 83, 7, 450, 334, 277, 14, 1861, 12, 790, 9, 267, 587, 26, 288, 372, 790, 421, 199, 533, 1316, 26958, 1197, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 6449, 63, 409, 12, 6449, 63, 409, 63, 2732, 12, 2403, 304, 267, 291, 14, 9818, 63, 409, 275, 6449, 63, 409, 267, 291, 14, 9818, 63, 409, 63, 2732, 275, 6449, 63, 409, 63, 2732, 267, 291, 14, 1861, 275, 2403, 339, 347, 2163, 8, 277, 12, 8230, 63, 1744, 12, 8230, 63, 26289, 304, 267, 1967, 63, 5952, 63, 1744, 275, 8230, 63, 1744, 446, 8230, 63, 26289, 267, 1967, 63, 8885, 63, 1744, 275, 1109, 8, 1507, 63, 5952, 63, 1744, 627, 291, 14, 9818, 63, 409, 1182, 2948, 14, 16, 9, 267, 1967, 63, 761, 68, 63, 1744, 275, 1967, 63, 5952, 63, 1744, 446, 1967, 63, 8885, 63, 1744, 398, 3602, 63, 3097, 275, 413, 435, 8230, 63, 26289, 267, 340, 291, 14, 9818, 63, 409, 63, 2732, 508, 2948, 503, 971, 355, 2196, 14, 8393, 8, 16, 12, 2948, 9, 2695, 291, 14, 9818, 63, 409, 63, 2732, 26, 288, 3602, 63, 3097, 847, 1967, 63, 761, 68, 63, 1744, 288, 2451, 63, 3097, 275, 8230, 63, 1744, 267, 587, 26, 288, 2451, 63, 3097, 275, 3602, 63, 3097, 435, 1967, 63, 761, 68, 63, 1744, 267, 790, 275, 980, 14, 2355, 14, 2355, 63, 23931, 8, 3039, 63, 3097, 12, 2451, 63, 3097, 9, 267, 790, 275, 1543, 11533, 68, 7, 450, 790, 267, 372, 291, 14, 525, 63, 1861, 8, 498, 9, 421, 199, 533, 3240, 9092, 19942, 1197, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 15764, 12, 10900, 12, 2403, 304, 267, 291, 14, 4148, 275, 15764, 267, 291, 14, 3569, 275, 10900, 267, 291, 14, 1861, 275, 2403, 339, 347, 636, 1661, 721, 277, 304, 267, 1967, 63, 8885, 63, 1612, 275, 1109, 8, 277, 14, 3569, 14, 1744, 627, 291, 14, 3569, 14, 9818, 63, 409, 1182, 2948, 14, 16, 9, 267, 1967, 63, 761, 68, 63, 1744, 275, 291, 14, 3569, 14, 1744, 446, 1967, 63, 8885, 63, 1612, 398, 367, 5412, 63, 344, 315, 4945, 8, 17, 435, 1967, 63, 761, 68, 63, 1744, 435, 291, 14, 4148, 12, 2490, 413, 435, 291, 14, 3569, 14, 1744, 12, 2490, 291, 14, 3569, 14, 11009, 304, 288, 790, 275, 1543, 11533, 68, 7, 450, 5412, 63, 344, 288, 790, 275, 291, 14, 525, 63, 1861, 8, 498, 9, 288, 1995, 790, 421, 199, 533, 7053, 1197, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 2403, 12, 15399, 304, 267, 291, 14, 1861, 275, 2403, 267, 291, 14, 15469, 275, 15399, 267, 291, 14, 6215, 478, 275, 8643, 8, 1842, 8, 8251, 12, 841, 1400, 12, 4233, 430, 339, 347, 2163, 8, 277, 12, 8230, 63, 1744, 304, 267, 790, 275, 1543, 11533, 68, 7, 450, 8230, 63, 1744, 267, 790, 275, 291, 14, 525, 63, 1861, 8, 498, 9, 267, 14856, 275, 488, 267, 340, 291, 14, 15469, 436, 2196, 14, 8393, 8, 17, 12, 2948, 9, 2695, 291, 14, 15469, 26, 288, 14856, 275, 291, 14, 6215, 478, 14, 2184, 342, 267, 372, 790, 12, 14856, 421, 199, 533, 2606, 1858, 497, 14128, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 2403, 304, 267, 291, 14, 1861, 275, 2403, 339, 347, 2163, 8, 277, 12, 8230, 63, 26289, 304, 267, 790, 275, 1543, 11533, 68, 7, 450, 8230, 63, 26289, 267, 372, 291, 14, 525, 63, 1861, 8, 498, 9, 421, 199, 533, 7053, 5564, 8, 3585, 304, 339, 32289, 63, 12349, 2594, 275, 378, 14, 821, 221, 327, 5661, 5, 272, 9301, 63, 9127, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 12402, 63, 890, 304, 267, 291, 14, 8595, 63, 890, 275, 12402, 63, 890, 339, 768, 3744, 272, 347, 485, 362, 63, 3808, 425, 63, 8903, 8, 1886, 304, 267, 372, 980, 14, 2355, 14, 8830, 8, 17, 446, 843, 14, 4305, 63, 12349, 2594, 12, 413, 435, 843, 14, 4305, 63, 12349, 2594, 9, 339, 768, 4639, 272, 347, 485, 1506, 63, 31884, 8, 498, 304, 267, 372, 6128, 21, 8, 498, 680, 11453, 342, 435, 6128, 21, 8, 498, 14172, 17, 6575, 11453, 342, 339, 768, 4639, 272, 347, 485, 1506, 63, 354, 8, 31884, 304, 267, 372, 1543, 83, 450, 83, 7, 450, 334, 31884, 1491, 22, 467, 27230, 59, 22, 26, 713, 566, 339, 768, 4639, 272, 347, 485, 1506, 63, 2123, 8, 31884, 304, 267, 372, 1543, 83, 19437, 83, 14, 957, 7, 450, 334, 31884, 59, 713, 26, 1085, 467, 27230, 59, 1085, 26, 1194, 566, 339, 768, 4639, 272, 347, 485, 1506, 63, 3690, 8, 31884, 304, 267, 372, 27230, 59, 1194, 26, 1216, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 7728, 8, 31884, 304, 267, 372, 27230, 59, 1216, 26, 1344, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 6063, 8, 31884, 304, 267, 372, 27230, 59, 2260, 26, 2006, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 3094, 369, 8, 31884, 304, 267, 372, 27230, 59, 2006, 26, 1477, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 20451, 8, 31884, 304, 267, 372, 27230, 59, 1477, 26, 2789, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 331, 3617, 8, 31884, 304, 267, 372, 1390, 8, 16, 14, 17, 12, 1109, 8, 31884, 59, 1344, 26, 2167, 467, 3193, 9, 1182, 2948, 14, 16, 9, 339, 768, 4639, 272, 347, 485 ]
[ 3473, 199, 646, 900, 199, 504, 8337, 492, 6128, 21, 199, 504, 7975, 492, 8643, 199, 199, 646, 2196, 199, 646, 2680, 465, 980, 199, 199, 504, 2249, 5985, 14, 4981, 492, 13146, 654, 12, 11576, 63, 23162, 199, 199, 504, 7377, 1301, 2268, 492, 1900, 63, 1225, 1873, 432, 1470, 421, 199, 533, 25769, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1861, 275, 488, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 291, 339, 347, 1050, 63, 1861, 8, 277, 12, 790, 304, 267, 340, 291, 14, 1861, 26, 288, 372, 1543, 83, 3295, 83, 7, 450, 334, 277, 14, 1861, 12, 790, 9, 267, 587, 26, 288, 372, 790, 421, 199, 533, 1316, 26958, 1197, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 6449, 63, 409, 12, 6449, 63, 409, 63, 2732, 12, 2403, 304, 267, 291, 14, 9818, 63, 409, 275, 6449, 63, 409, 267, 291, 14, 9818, 63, 409, 63, 2732, 275, 6449, 63, 409, 63, 2732, 267, 291, 14, 1861, 275, 2403, 339, 347, 2163, 8, 277, 12, 8230, 63, 1744, 12, 8230, 63, 26289, 304, 267, 1967, 63, 5952, 63, 1744, 275, 8230, 63, 1744, 446, 8230, 63, 26289, 267, 1967, 63, 8885, 63, 1744, 275, 1109, 8, 1507, 63, 5952, 63, 1744, 627, 291, 14, 9818, 63, 409, 1182, 2948, 14, 16, 9, 267, 1967, 63, 761, 68, 63, 1744, 275, 1967, 63, 5952, 63, 1744, 446, 1967, 63, 8885, 63, 1744, 398, 3602, 63, 3097, 275, 413, 435, 8230, 63, 26289, 267, 340, 291, 14, 9818, 63, 409, 63, 2732, 508, 2948, 503, 971, 355, 2196, 14, 8393, 8, 16, 12, 2948, 9, 2695, 291, 14, 9818, 63, 409, 63, 2732, 26, 288, 3602, 63, 3097, 847, 1967, 63, 761, 68, 63, 1744, 288, 2451, 63, 3097, 275, 8230, 63, 1744, 267, 587, 26, 288, 2451, 63, 3097, 275, 3602, 63, 3097, 435, 1967, 63, 761, 68, 63, 1744, 267, 790, 275, 980, 14, 2355, 14, 2355, 63, 23931, 8, 3039, 63, 3097, 12, 2451, 63, 3097, 9, 267, 790, 275, 1543, 11533, 68, 7, 450, 790, 267, 372, 291, 14, 525, 63, 1861, 8, 498, 9, 421, 199, 533, 3240, 9092, 19942, 1197, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 15764, 12, 10900, 12, 2403, 304, 267, 291, 14, 4148, 275, 15764, 267, 291, 14, 3569, 275, 10900, 267, 291, 14, 1861, 275, 2403, 339, 347, 636, 1661, 721, 277, 304, 267, 1967, 63, 8885, 63, 1612, 275, 1109, 8, 277, 14, 3569, 14, 1744, 627, 291, 14, 3569, 14, 9818, 63, 409, 1182, 2948, 14, 16, 9, 267, 1967, 63, 761, 68, 63, 1744, 275, 291, 14, 3569, 14, 1744, 446, 1967, 63, 8885, 63, 1612, 398, 367, 5412, 63, 344, 315, 4945, 8, 17, 435, 1967, 63, 761, 68, 63, 1744, 435, 291, 14, 4148, 12, 2490, 413, 435, 291, 14, 3569, 14, 1744, 12, 2490, 291, 14, 3569, 14, 11009, 304, 288, 790, 275, 1543, 11533, 68, 7, 450, 5412, 63, 344, 288, 790, 275, 291, 14, 525, 63, 1861, 8, 498, 9, 288, 1995, 790, 421, 199, 533, 7053, 1197, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 2403, 12, 15399, 304, 267, 291, 14, 1861, 275, 2403, 267, 291, 14, 15469, 275, 15399, 267, 291, 14, 6215, 478, 275, 8643, 8, 1842, 8, 8251, 12, 841, 1400, 12, 4233, 430, 339, 347, 2163, 8, 277, 12, 8230, 63, 1744, 304, 267, 790, 275, 1543, 11533, 68, 7, 450, 8230, 63, 1744, 267, 790, 275, 291, 14, 525, 63, 1861, 8, 498, 9, 267, 14856, 275, 488, 267, 340, 291, 14, 15469, 436, 2196, 14, 8393, 8, 17, 12, 2948, 9, 2695, 291, 14, 15469, 26, 288, 14856, 275, 291, 14, 6215, 478, 14, 2184, 342, 267, 372, 790, 12, 14856, 421, 199, 533, 2606, 1858, 497, 14128, 8, 3585, 304, 339, 347, 636, 826, 721, 277, 12, 2403, 304, 267, 291, 14, 1861, 275, 2403, 339, 347, 2163, 8, 277, 12, 8230, 63, 26289, 304, 267, 790, 275, 1543, 11533, 68, 7, 450, 8230, 63, 26289, 267, 372, 291, 14, 525, 63, 1861, 8, 498, 9, 421, 199, 533, 7053, 5564, 8, 3585, 304, 339, 32289, 63, 12349, 2594, 275, 378, 14, 821, 221, 327, 5661, 5, 272, 9301, 63, 9127, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 12402, 63, 890, 304, 267, 291, 14, 8595, 63, 890, 275, 12402, 63, 890, 339, 768, 3744, 272, 347, 485, 362, 63, 3808, 425, 63, 8903, 8, 1886, 304, 267, 372, 980, 14, 2355, 14, 8830, 8, 17, 446, 843, 14, 4305, 63, 12349, 2594, 12, 413, 435, 843, 14, 4305, 63, 12349, 2594, 9, 339, 768, 4639, 272, 347, 485, 1506, 63, 31884, 8, 498, 304, 267, 372, 6128, 21, 8, 498, 680, 11453, 342, 435, 6128, 21, 8, 498, 14172, 17, 6575, 11453, 342, 339, 768, 4639, 272, 347, 485, 1506, 63, 354, 8, 31884, 304, 267, 372, 1543, 83, 450, 83, 7, 450, 334, 31884, 1491, 22, 467, 27230, 59, 22, 26, 713, 566, 339, 768, 4639, 272, 347, 485, 1506, 63, 2123, 8, 31884, 304, 267, 372, 1543, 83, 19437, 83, 14, 957, 7, 450, 334, 31884, 59, 713, 26, 1085, 467, 27230, 59, 1085, 26, 1194, 566, 339, 768, 4639, 272, 347, 485, 1506, 63, 3690, 8, 31884, 304, 267, 372, 27230, 59, 1194, 26, 1216, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 7728, 8, 31884, 304, 267, 372, 27230, 59, 1216, 26, 1344, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 6063, 8, 31884, 304, 267, 372, 27230, 59, 2260, 26, 2006, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 3094, 369, 8, 31884, 304, 267, 372, 27230, 59, 2006, 26, 1477, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 20451, 8, 31884, 304, 267, 372, 27230, 59, 1477, 26, 2789, 61, 339, 768, 4639, 272, 347, 485, 1506, 63, 331, 3617, 8, 31884, 304, 267, 372, 1390, 8, 16, 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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 ]
angelapper/edx-platform
common/lib/xmodule/xmodule/mongo_utils.py
6
2979
""" Common MongoDB connection functions. """ import logging import pymongo from mongodb_proxy import MongoProxy logger = logging.getLogger(__name__) # pylint: disable=invalid-name # pylint: disable=bad-continuation def connect_to_mongodb( db, host, port=27017, tz_aware=True, user=None, password=None, retry_wait_time=0.1, proxy=True, **kwargs ): """ Returns a MongoDB Database connection, optionally wrapped in a proxy. The proxy handles AutoReconnect errors by retrying read operations, since these exceptions typically indicate a temporary step-down condition for MongoDB. """ # The MongoReplicaSetClient class is deprecated in Mongo 3.x, in favor of using # the MongoClient class for all connections. Update/simplify this code when using # PyMongo 3.x. if kwargs.get('replicaSet'): # Enable reading from secondary nodes in the MongoDB replicaset by using the # MongoReplicaSetClient class. # The 'replicaSet' parameter in kwargs is required for secondary reads. # The read_preference should be set to a proper value, like SECONDARY_PREFERRED. mongo_client_class = pymongo.MongoReplicaSetClient else: # No 'replicaSet' in kwargs - so no secondary reads. mongo_client_class = pymongo.MongoClient mongo_conn = pymongo.database.Database( mongo_client_class( host=host, port=port, tz_aware=tz_aware, document_class=dict, **kwargs ), db ) if proxy: mongo_conn = MongoProxy( mongo_conn, wait_time=retry_wait_time ) # If credentials were provided, authenticate the user. if user is not None and password is not None: mongo_conn.authenticate(user, password) return mongo_conn def create_collection_index( collection, keys, ignore_created=True, ignore_created_opts=True, **kwargs ): """ Create a MongoDB index in a collection. Optionally, ignore errors related to the index already existing. """ # For an explanation of the error codes: # https://github.com/mongodb/mongo/blob/v3.0/src/mongo/db/catalog/index_catalog.cpp#L542-L583 # https://github.com/mongodb/mongo/blob/v3.0/src/mongo/base/error_codes.err#L70-L87 # pylint: disable=invalid-name INDEX_ALREADY_EXISTS = 68 INDEX_OPTIONS_CONFLICT = 85 try: collection.create_index(keys, **kwargs) except pymongo.errors.OperationFailure as exc: errors_to_ignore = [] if ignore_created: errors_to_ignore.append(INDEX_ALREADY_EXISTS) if ignore_created_opts: errors_to_ignore.append(INDEX_OPTIONS_CONFLICT) if exc.code in errors_to_ignore: logger.warning("Existing index in collection '{}' remained unchanged!: {}".format( collection.full_name, exc.details['errmsg']) ) else: raise exc
agpl-3.0
[ 624, 199, 7844, 28458, 1950, 3423, 14, 199, 624, 199, 646, 2050, 199, 199, 646, 21878, 199, 504, 32315, 13152, 63, 3280, 492, 13503, 4936, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 421, 199, 3, 4287, 26, 3507, 29, 4087, 13, 20305, 199, 318, 4907, 63, 475, 63, 22130, 13152, 8, 272, 1592, 12, 1591, 12, 272, 1844, 29, 1465, 9570, 12, 5823, 63, 14600, 29, 549, 12, 922, 29, 403, 12, 2505, 29, 403, 12, 272, 7269, 63, 2573, 63, 521, 29, 16, 14, 17, 12, 4566, 29, 549, 12, 1011, 958, 199, 304, 272, 408, 272, 1803, 282, 28458, 8692, 1950, 12, 14190, 8072, 315, 282, 4566, 14, 710, 4566, 272, 10022, 9195, 497, 2242, 2552, 701, 7269, 316, 1586, 5331, 12, 3967, 3520, 4967, 272, 13609, 6623, 282, 7937, 3650, 13, 2110, 5558, 367, 28458, 14, 272, 408, 272, 327, 710, 13503, 29581, 1084, 3041, 1021, 365, 5906, 315, 13503, 650, 14, 88, 12, 315, 17914, 402, 1808, 272, 327, 314, 13503, 3041, 1021, 367, 1006, 6947, 14, 6162, 15, 19084, 642, 1233, 1380, 1808, 272, 327, 1611, 20393, 650, 14, 88, 14, 272, 340, 2074, 14, 362, 360, 12317, 1084, 735, 267, 327, 12030, 7664, 687, 13851, 3380, 315, 314, 28458, 16234, 409, 701, 1808, 314, 267, 327, 13503, 29581, 1084, 3041, 1021, 14, 267, 327, 710, 283, 12317, 1084, 7, 2725, 315, 2074, 365, 1415, 367, 13851, 11597, 14, 267, 327, 710, 1586, 63, 14994, 1077, 506, 663, 370, 282, 5576, 574, 12, 2839, 5795, 1864, 36, 4392, 63, 4225, 15849, 7387, 14, 267, 18006, 63, 1258, 63, 533, 275, 21878, 14, 20393, 29581, 1084, 3041, 272, 587, 26, 267, 327, 3091, 283, 12317, 1084, 7, 315, 2074, 446, 880, 949, 13851, 11597, 14, 267, 18006, 63, 1258, 63, 533, 275, 21878, 14, 20393, 3041, 339, 18006, 63, 1631, 275, 21878, 14, 4659, 14, 7243, 8, 267, 18006, 63, 1258, 63, 533, 8, 288, 1591, 29, 1102, 12, 288, 1844, 29, 719, 12, 288, 5823, 63, 14600, 29, 3903, 63, 14600, 12, 288, 2213, 63, 533, 29, 807, 12, 288, 1011, 958, 267, 2318, 267, 1592, 272, 776, 339, 340, 4566, 26, 267, 18006, 63, 1631, 275, 13503, 4936, 8, 288, 18006, 63, 1631, 12, 288, 3618, 63, 521, 29, 7154, 63, 2573, 63, 521, 267, 776, 339, 327, 982, 6235, 4898, 2741, 12, 12895, 314, 922, 14, 272, 340, 922, 365, 440, 488, 436, 2505, 365, 440, 488, 26, 267, 18006, 63, 1631, 14, 13975, 8, 751, 12, 2505, 9, 339, 372, 18006, 63, 1631, 421, 199, 318, 1218, 63, 3627, 63, 1080, 8, 272, 3245, 12, 2883, 12, 272, 3686, 63, 3966, 29, 549, 12, 3686, 63, 3966, 63, 3291, 29, 549, 12, 1011, 958, 199, 304, 272, 408, 272, 2790, 282, 28458, 1478, 315, 282, 3245, 14, 22383, 12, 272, 3686, 2552, 4048, 370, 314, 1478, 2575, 3411, 14, 272, 408, 272, 327, 2104, 376, 17531, 402, 314, 1125, 9479, 26, 272, 327, 4178, 921, 5031, 14, 957, 15, 22130, 13152, 15, 9217, 15, 6582, 15, 86, 19, 14, 16, 15, 2164, 15, 9217, 15, 697, 15, 7959, 15, 1080, 63, 7959, 14, 5910, 3, 44, 19861, 13, 44, 16793, 272, 327, 4178, 921, 5031, 14, 957, 15, 22130, 13152, 15, 9217, 15, 6582, 15, 86, 19, 14, 16, 15, 2164, 15, 9217, 15, 1095, 15, 705, 63, 6021, 14, 1508, 3, 44, 2760, 13, 44, 1555, 272, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 17055, 63, 32687, 63, 23558, 275, 10851, 272, 17055, 63, 8808, 63, 3103, 2507, 52, 275, 16412, 272, 862, 26, 267, 3245, 14, 981, 63, 1080, 8, 1612, 12, 1011, 958, 9, 272, 871, 21878, 14, 2550, 14, 6044, 6782, 465, 3178, 26, 267, 2552, 63, 475, 63, 4247, 275, 942, 267, 340, 3686, 63, 3966, 26, 288, 2552, 63, 475, 63, 4247, 14, 740, 8, 10215, 63, 32687, 63, 23558, 9, 267, 340, 3686, 63, 3966, 63, 3291, 26, 288, 2552, 63, 475, 63, 4247, 14, 740, 8, 10215, 63, 8808, 63, 3103, 2507, 52, 9, 267, 340, 3178, 14, 600, 315, 2552, 63, 475, 63, 4247, 26, 288, 2512, 14, 3764, 480, 23490, 1478, 315, 3245, 19574, 5706, 379, 14874, 1, 26, 8352, 908, 8, 355, 3245, 14, 2861, 63, 354, 12, 3178, 14, 5087, 459, 16024, 1105, 288, 776, 267, 587, 26, 288, 746, 3178, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7844, 28458, 1950, 3423, 14, 199, 624, 199, 646, 2050, 199, 199, 646, 21878, 199, 504, 32315, 13152, 63, 3280, 492, 13503, 4936, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 421, 199, 3, 4287, 26, 3507, 29, 4087, 13, 20305, 199, 318, 4907, 63, 475, 63, 22130, 13152, 8, 272, 1592, 12, 1591, 12, 272, 1844, 29, 1465, 9570, 12, 5823, 63, 14600, 29, 549, 12, 922, 29, 403, 12, 2505, 29, 403, 12, 272, 7269, 63, 2573, 63, 521, 29, 16, 14, 17, 12, 4566, 29, 549, 12, 1011, 958, 199, 304, 272, 408, 272, 1803, 282, 28458, 8692, 1950, 12, 14190, 8072, 315, 282, 4566, 14, 710, 4566, 272, 10022, 9195, 497, 2242, 2552, 701, 7269, 316, 1586, 5331, 12, 3967, 3520, 4967, 272, 13609, 6623, 282, 7937, 3650, 13, 2110, 5558, 367, 28458, 14, 272, 408, 272, 327, 710, 13503, 29581, 1084, 3041, 1021, 365, 5906, 315, 13503, 650, 14, 88, 12, 315, 17914, 402, 1808, 272, 327, 314, 13503, 3041, 1021, 367, 1006, 6947, 14, 6162, 15, 19084, 642, 1233, 1380, 1808, 272, 327, 1611, 20393, 650, 14, 88, 14, 272, 340, 2074, 14, 362, 360, 12317, 1084, 735, 267, 327, 12030, 7664, 687, 13851, 3380, 315, 314, 28458, 16234, 409, 701, 1808, 314, 267, 327, 13503, 29581, 1084, 3041, 1021, 14, 267, 327, 710, 283, 12317, 1084, 7, 2725, 315, 2074, 365, 1415, 367, 13851, 11597, 14, 267, 327, 710, 1586, 63, 14994, 1077, 506, 663, 370, 282, 5576, 574, 12, 2839, 5795, 1864, 36, 4392, 63, 4225, 15849, 7387, 14, 267, 18006, 63, 1258, 63, 533, 275, 21878, 14, 20393, 29581, 1084, 3041, 272, 587, 26, 267, 327, 3091, 283, 12317, 1084, 7, 315, 2074, 446, 880, 949, 13851, 11597, 14, 267, 18006, 63, 1258, 63, 533, 275, 21878, 14, 20393, 3041, 339, 18006, 63, 1631, 275, 21878, 14, 4659, 14, 7243, 8, 267, 18006, 63, 1258, 63, 533, 8, 288, 1591, 29, 1102, 12, 288, 1844, 29, 719, 12, 288, 5823, 63, 14600, 29, 3903, 63, 14600, 12, 288, 2213, 63, 533, 29, 807, 12, 288, 1011, 958, 267, 2318, 267, 1592, 272, 776, 339, 340, 4566, 26, 267, 18006, 63, 1631, 275, 13503, 4936, 8, 288, 18006, 63, 1631, 12, 288, 3618, 63, 521, 29, 7154, 63, 2573, 63, 521, 267, 776, 339, 327, 982, 6235, 4898, 2741, 12, 12895, 314, 922, 14, 272, 340, 922, 365, 440, 488, 436, 2505, 365, 440, 488, 26, 267, 18006, 63, 1631, 14, 13975, 8, 751, 12, 2505, 9, 339, 372, 18006, 63, 1631, 421, 199, 318, 1218, 63, 3627, 63, 1080, 8, 272, 3245, 12, 2883, 12, 272, 3686, 63, 3966, 29, 549, 12, 3686, 63, 3966, 63, 3291, 29, 549, 12, 1011, 958, 199, 304, 272, 408, 272, 2790, 282, 28458, 1478, 315, 282, 3245, 14, 22383, 12, 272, 3686, 2552, 4048, 370, 314, 1478, 2575, 3411, 14, 272, 408, 272, 327, 2104, 376, 17531, 402, 314, 1125, 9479, 26, 272, 327, 4178, 921, 5031, 14, 957, 15, 22130, 13152, 15, 9217, 15, 6582, 15, 86, 19, 14, 16, 15, 2164, 15, 9217, 15, 697, 15, 7959, 15, 1080, 63, 7959, 14, 5910, 3, 44, 19861, 13, 44, 16793, 272, 327, 4178, 921, 5031, 14, 957, 15, 22130, 13152, 15, 9217, 15, 6582, 15, 86, 19, 14, 16, 15, 2164, 15, 9217, 15, 1095, 15, 705, 63, 6021, 14, 1508, 3, 44, 2760, 13, 44, 1555, 272, 327, 4287, 26, 3507, 29, 3197, 13, 354, 272, 17055, 63, 32687, 63, 23558, 275, 10851, 272, 17055, 63, 8808, 63, 3103, 2507, 52, 275, 16412, 272, 862, 26, 267, 3245, 14, 981, 63, 1080, 8, 1612, 12, 1011, 958, 9, 272, 871, 21878, 14, 2550, 14, 6044, 6782, 465, 3178, 26, 267, 2552, 63, 475, 63, 4247, 275, 942, 267, 340, 3686, 63, 3966, 26, 288, 2552, 63, 475, 63, 4247, 14, 740, 8, 10215, 63, 32687, 63, 23558, 9, 267, 340, 3686, 63, 3966, 63, 3291, 26, 288, 2552, 63, 475, 63, 4247, 14, 740, 8, 10215, 63, 8808, 63, 3103, 2507, 52, 9, 267, 340, 3178, 14, 600, 315, 2552, 63, 475, 63, 4247, 26, 288, 2512, 14, 3764, 480, 23490, 1478, 315, 3245, 19574, 5706, 379, 14874, 1, 26, 8352, 908, 8, 355, 3245, 14, 2861, 63, 354, 12, 3178, 14, 5087, 459, 16024, 1105, 288, 776, 267, 587, 26, 288, 746, 3178, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
brennentsmith/teletraan
deploy-board/deploy_board/webapp/helpers/builds_helper.py
6
2445
# Copyright 2016 Pinterest, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -*- coding: utf-8 -*- """Collection of build related calls """ from deploy_board.webapp.helpers.deployclient import DeployClient deploy_client = DeployClient() def get_build(request, id): return deploy_client.get("/builds/%s" % id, request.teletraan_user_id.token) def get_branches(request, name): return deploy_client.get("/builds/names/%s/branches" % name, request.teletraan_user_id.token) def get_builds(request, **kwargs): params = deploy_client.gen_params(kwargs) return deploy_client.get("/builds/", request.teletraan_user_id.token, params=params) def publish_build(request, build): return deploy_client.post("/builds/", request.teletraan_user_id.token, data=build) def get_build_names(request, **kwargs): params = deploy_client.gen_params(kwargs) return deploy_client.get("/builds/names/", request.teletraan_user_id.token, params=params) def delete_build(request, id): return deploy_client.delete("/builds/%s" % id, request.teletraan_user_id.token) def get_commits(request, **kwargs): params = deploy_client.gen_params(kwargs) return deploy_client.get("/commits/", request.teletraan_user_id.token, params=params) def get_commit(request, repo, sha): return deploy_client.get("/commits/%s/%s" % (repo, sha), request.teletraan_user_id.token) def get_builds_and_tags(request, **kwargs): params = deploy_client.gen_params(kwargs); return deploy_client.get("/builds/tags",request.teletraan_user_id.token, params=params) def get_build_and_tag(request, id): return deploy_client.get("/builds/{0}/tags".format(id), request.teletraan_user_id.token) def set_build_tag(request, tag): return deploy_client.post("/tags/", request.teletraan_user_id.token, data=tag) def del_build_tag(request, id): return deploy_client.delete("/tags/{0}/".format(id), request.teletraan_user_id.token)
apache-2.0
[ 3, 1898, 7800, 510, 18700, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 7768, 402, 1900, 4048, 4882, 199, 624, 199, 504, 12287, 63, 3576, 14, 22632, 14, 7546, 14, 11060, 1258, 492, 21588, 3374, 3041, 199, 199, 11060, 63, 1258, 275, 21588, 3374, 3041, 342, 421, 199, 318, 664, 63, 1506, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 3149, 83, 2, 450, 1305, 12, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 664, 63, 16896, 8, 1069, 12, 536, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 15, 1247, 3149, 83, 15, 16896, 2, 450, 536, 12, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 664, 63, 10838, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 9, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 421, 199, 318, 2780, 63, 1506, 8, 1069, 12, 1900, 304, 272, 372, 12287, 63, 1258, 14, 1932, 4769, 10838, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 666, 29, 1506, 9, 421, 199, 318, 664, 63, 1506, 63, 1247, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 9, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 15, 1247, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 421, 199, 318, 3145, 63, 1506, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 1807, 4769, 10838, 3149, 83, 2, 450, 1305, 12, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 664, 63, 18679, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 9, 272, 372, 12287, 63, 1258, 14, 362, 4769, 18679, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 421, 199, 318, 664, 63, 3543, 8, 1069, 12, 3831, 12, 7793, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 18679, 3149, 83, 3149, 83, 2, 450, 334, 3417, 12, 7793, 395, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 199, 199, 318, 664, 63, 10838, 63, 460, 63, 2969, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 2736, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 15, 2969, 401, 1069, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 199, 199, 318, 664, 63, 1506, 63, 460, 63, 1450, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 5321, 16, 5995, 2969, 1674, 908, 8, 344, 395, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 663, 63, 1506, 63, 1450, 8, 1069, 12, 1947, 304, 272, 372, 12287, 63, 1258, 14, 1932, 4769, 2969, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 666, 29, 1450, 9, 421, 199, 318, 2150, 63, 1506, 63, 1450, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 1807, 4769, 2969, 5321, 16, 5995, 1674, 908, 8, 344, 395, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 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 ]
[ 1898, 7800, 510, 18700, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 7768, 402, 1900, 4048, 4882, 199, 624, 199, 504, 12287, 63, 3576, 14, 22632, 14, 7546, 14, 11060, 1258, 492, 21588, 3374, 3041, 199, 199, 11060, 63, 1258, 275, 21588, 3374, 3041, 342, 421, 199, 318, 664, 63, 1506, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 3149, 83, 2, 450, 1305, 12, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 664, 63, 16896, 8, 1069, 12, 536, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 15, 1247, 3149, 83, 15, 16896, 2, 450, 536, 12, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 664, 63, 10838, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 9, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 421, 199, 318, 2780, 63, 1506, 8, 1069, 12, 1900, 304, 272, 372, 12287, 63, 1258, 14, 1932, 4769, 10838, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 666, 29, 1506, 9, 421, 199, 318, 664, 63, 1506, 63, 1247, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 9, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 15, 1247, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 421, 199, 318, 3145, 63, 1506, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 1807, 4769, 10838, 3149, 83, 2, 450, 1305, 12, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 664, 63, 18679, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 9, 272, 372, 12287, 63, 1258, 14, 362, 4769, 18679, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 421, 199, 318, 664, 63, 3543, 8, 1069, 12, 3831, 12, 7793, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 18679, 3149, 83, 3149, 83, 2, 450, 334, 3417, 12, 7793, 395, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 199, 199, 318, 664, 63, 10838, 63, 460, 63, 2969, 8, 1069, 12, 1011, 958, 304, 272, 1862, 275, 12287, 63, 1258, 14, 2268, 63, 1162, 8, 958, 2736, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 15, 2969, 401, 1069, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 1862, 29, 1162, 9, 199, 199, 318, 664, 63, 1506, 63, 460, 63, 1450, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 362, 4769, 10838, 5321, 16, 5995, 2969, 1674, 908, 8, 344, 395, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 9, 421, 199, 318, 663, 63, 1506, 63, 1450, 8, 1069, 12, 1947, 304, 272, 372, 12287, 63, 1258, 14, 1932, 4769, 2969, 10665, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 12, 666, 29, 1450, 9, 421, 199, 318, 2150, 63, 1506, 63, 1450, 8, 1069, 12, 1305, 304, 272, 372, 12287, 63, 1258, 14, 1807, 4769, 2969, 5321, 16, 5995, 1674, 908, 8, 344, 395, 1056, 14, 15253, 1239, 290, 63, 751, 63, 344, 14, 1418, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hainm/statsmodels
examples/python/robust_models_1.py
25
8588
## M-Estimators for Robust Linear Modeling from __future__ import print_function import numpy as np from scipy import stats import matplotlib.pyplot as plt import statsmodels.api as sm # * An M-estimator minimizes the function # # $$Q(e_i, \rho) = \sum_i~\rho \left (\frac{e_i}{s}\right )$$ # # where $\rho$ is a symmetric function of the residuals # # * The effect of $\rho$ is to reduce the influence of outliers # * $s$ is an estimate of scale. # * The robust estimates $\hat{\beta}$ are computed by the iteratively re-weighted least squares algorithm # * We have several choices available for the weighting functions to be used norms = sm.robust.norms def plot_weights(support, weights_func, xlabels, xticks): fig = plt.figure(figsize=(12,8)) ax = fig.add_subplot(111) ax.plot(support, weights_func(support)) ax.set_xticks(xticks) ax.set_xticklabels(xlabels, fontsize=16) ax.set_ylim(-.1, 1.1) return ax #### Andrew's Wave help(norms.AndrewWave.weights) a = 1.339 support = np.linspace(-np.pi*a, np.pi*a, 100) andrew = norms.AndrewWave(a=a) plot_weights(support, andrew.weights, ['$-\pi*a$', '0', '$\pi*a$'], [-np.pi*a, 0, np.pi*a]); #### Hampel's 17A help(norms.Hampel.weights) c = 8 support = np.linspace(-3*c, 3*c, 1000) hampel = norms.Hampel(a=2., b=4., c=c) plot_weights(support, hampel.weights, ['3*c', '0', '3*c'], [-3*c, 0, 3*c]); #### Huber's t help(norms.HuberT.weights) t = 1.345 support = np.linspace(-3*t, 3*t, 1000) huber = norms.HuberT(t=t) plot_weights(support, huber.weights, ['-3*t', '0', '3*t'], [-3*t, 0, 3*t]); #### Least Squares help(norms.LeastSquares.weights) support = np.linspace(-3, 3, 1000) lst_sq = norms.LeastSquares() plot_weights(support, lst_sq.weights, ['-3', '0', '3'], [-3, 0, 3]); #### Ramsay's Ea help(norms.RamsayE.weights) a = .3 support = np.linspace(-3*a, 3*a, 1000) ramsay = norms.RamsayE(a=a) plot_weights(support, ramsay.weights, ['-3*a', '0', '3*a'], [-3*a, 0, 3*a]); #### Trimmed Mean help(norms.TrimmedMean.weights) c = 2 support = np.linspace(-3*c, 3*c, 1000) trimmed = norms.TrimmedMean(c=c) plot_weights(support, trimmed.weights, ['-3*c', '0', '3*c'], [-3*c, 0, 3*c]); #### Tukey's Biweight help(norms.TukeyBiweight.weights) c = 4.685 support = np.linspace(-3*c, 3*c, 1000) tukey = norms.TukeyBiweight(c=c) plot_weights(support, tukey.weights, ['-3*c', '0', '3*c'], [-3*c, 0, 3*c]); #### Scale Estimators # * Robust estimates of the location x = np.array([1, 2, 3, 4, 500]) # * The mean is not a robust estimator of location x.mean() # * The median, on the other hand, is a robust estimator with a breakdown point of 50% np.median(x) # * Analagously for the scale # * The standard deviation is not robust x.std() # Median Absolute Deviation # # $$ median_i |X_i - median_j(X_j)|) $$ # Standardized Median Absolute Deviation is a consistent estimator for $\hat{\sigma}$ # # $$\hat{\sigma}=K \cdot MAD$$ # # where $K$ depends on the distribution. For the normal distribution for example, # # $$K = \Phi^{-1}(.75)$$ stats.norm.ppf(.75) print(x) sm.robust.scale.stand_mad(x) np.array([1,2,3,4,5.]).std() # * The default for Robust Linear Models is MAD # * another popular choice is Huber's proposal 2 np.random.seed(12345) fat_tails = stats.t(6).rvs(40) kde = sm.nonparametric.KDE(fat_tails) kde.fit() fig = plt.figure(figsize=(12,8)) ax = fig.add_subplot(111) ax.plot(kde.support, kde.density); print(fat_tails.mean(), fat_tails.std()) print(stats.norm.fit(fat_tails)) print(stats.t.fit(fat_tails, f0=6)) huber = sm.robust.scale.Huber() loc, scale = huber(fat_tails) print(loc, scale) sm.robust.stand_mad(fat_tails) sm.robust.stand_mad(fat_tails, c=stats.t(6).ppf(.75)) sm.robust.scale.mad(fat_tails) #### Duncan's Occupational Prestige data - M-estimation for outliers from statsmodels.graphics.api import abline_plot from statsmodels.formula.api import ols, rlm prestige = sm.datasets.get_rdataset("Duncan", "car", cache=True).data print(prestige.head(10)) fig = plt.figure(figsize=(12,12)) ax1 = fig.add_subplot(211, xlabel='Income', ylabel='Prestige') ax1.scatter(prestige.income, prestige.prestige) xy_outlier = prestige.ix['minister'][['income','prestige']] ax1.annotate('Minister', xy_outlier, xy_outlier+1, fontsize=16) ax2 = fig.add_subplot(212, xlabel='Education', ylabel='Prestige') ax2.scatter(prestige.education, prestige.prestige); ols_model = ols('prestige ~ income + education', prestige).fit() print(ols_model.summary()) infl = ols_model.get_influence() student = infl.summary_frame()['student_resid'] print(student) print(student.ix[np.abs(student) > 2]) print(infl.summary_frame().ix['minister']) sidak = ols_model.outlier_test('sidak') sidak.sort('unadj_p', inplace=True) print(sidak) fdr = ols_model.outlier_test('fdr_bh') fdr.sort('unadj_p', inplace=True) print(fdr) rlm_model = rlm('prestige ~ income + education', prestige).fit() print(rlm_model.summary()) print(rlm_model.weights) #### Hertzprung Russell data for Star Cluster CYG 0B1 - Leverage Points # * Data is on the luminosity and temperature of 47 stars in the direction of Cygnus. dta = sm.datasets.get_rdataset("starsCYG", "robustbase", cache=True).data from matplotlib.patches import Ellipse fig = plt.figure(figsize=(12,8)) ax = fig.add_subplot(111, xlabel='log(Temp)', ylabel='log(Light)', title='Hertzsprung-Russell Diagram of Star Cluster CYG OB1') ax.scatter(*dta.values.T) # highlight outliers e = Ellipse((3.5, 6), .2, 1, alpha=.25, color='r') ax.add_patch(e); ax.annotate('Red giants', xy=(3.6, 6), xytext=(3.8, 6), arrowprops=dict(facecolor='black', shrink=0.05, width=2), horizontalalignment='left', verticalalignment='bottom', clip_on=True, # clip to the axes bounding box fontsize=16, ) # annotate these with their index for i,row in dta.ix[dta['log.Te'] < 3.8].iterrows(): ax.annotate(i, row, row + .01, fontsize=14) xlim, ylim = ax.get_xlim(), ax.get_ylim() from IPython.display import Image Image(filename='star_diagram.png') y = dta['log.light'] X = sm.add_constant(dta['log.Te'], prepend=True) ols_model = sm.OLS(y, X).fit() abline_plot(model_results=ols_model, ax=ax) rlm_mod = sm.RLM(y, X, sm.robust.norms.TrimmedMean(.5)).fit() abline_plot(model_results=rlm_mod, ax=ax, color='red') # * Why? Because M-estimators are not robust to leverage points. infl = ols_model.get_influence() h_bar = 2*(ols_model.df_model + 1 )/ols_model.nobs hat_diag = infl.summary_frame()['hat_diag'] hat_diag.ix[hat_diag > h_bar] sidak2 = ols_model.outlier_test('sidak') sidak2.sort('unadj_p', inplace=True) print(sidak2) fdr2 = ols_model.outlier_test('fdr_bh') fdr2.sort('unadj_p', inplace=True) print(fdr2) # * Let's delete that line del ax.lines[-1] weights = np.ones(len(X)) weights[X[X['log.Te'] < 3.8].index.values - 1] = 0 wls_model = sm.WLS(y, X, weights=weights).fit() abline_plot(model_results=wls_model, ax=ax, color='green') # * MM estimators are good for this type of problem, unfortunately, we don't yet have these yet. # * It's being worked on, but it gives a good excuse to look at the R cell magics in the notebook. yy = y.values[:,None] xx = X['log.Te'].values[:,None] get_ipython().magic(u'load_ext rmagic') get_ipython().magic(u'R library(robustbase)') get_ipython().magic(u'Rpush yy xx') get_ipython().magic(u'R mod <- lmrob(yy ~ xx);') get_ipython().magic(u'R params <- mod$coefficients;') get_ipython().magic(u'Rpull params') get_ipython().magic(u'R print(mod)') print(params) abline_plot(intercept=params[0], slope=params[1], ax=ax, color='green') #### Exercise: Breakdown points of M-estimator np.random.seed(12345) nobs = 200 beta_true = np.array([3, 1, 2.5, 3, -4]) X = np.random.uniform(-20,20, size=(nobs, len(beta_true)-1)) # stack a constant in front X = sm.add_constant(X, prepend=True) # np.c_[np.ones(nobs), X] mc_iter = 500 contaminate = .25 # percentage of response variables to contaminate all_betas = [] for i in range(mc_iter): y = np.dot(X, beta_true) + np.random.normal(size=200) random_idx = np.random.randint(0, nobs, size=int(contaminate * nobs)) y[random_idx] = np.random.uniform(-750, 750) beta_hat = sm.RLM(y, X).fit().params all_betas.append(beta_hat) all_betas = np.asarray(all_betas) se_loss = lambda x : np.linalg.norm(x, ord=2)**2 se_beta = map(se_loss, all_betas - beta_true) ##### Squared error loss np.array(se_beta).mean() all_betas.mean(0) beta_true se_loss(all_betas.mean(0) - beta_true)
bsd-3-clause
[ 199, 309, 603, 13, 9169, 9095, 367, 6848, 15549, 12489, 4900, 2983, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 646, 5020, 992, 14, 1246, 465, 4383, 421, 199, 3, 627, 1626, 603, 13, 8627, 18790, 6491, 314, 805, 221, 199, 3, 221, 199, 3, 2672, 4, 49, 8, 69, 63, 73, 12, 971, 10412, 9, 275, 971, 1838, 63, 73, 94, 60, 10412, 971, 3039, 14749, 10865, 91, 69, 63, 73, 8847, 83, 4988, 1019, 776, 23174, 199, 3, 221, 199, 3, 2382, 2672, 60, 10412, 4, 365, 282, 16371, 805, 402, 314, 16731, 83, 221, 199, 3, 221, 199, 3, 627, 710, 7763, 402, 2672, 60, 10412, 4, 365, 370, 7114, 314, 315, 24585, 402, 734, 14035, 199, 3, 627, 2672, 83, 4, 365, 376, 14497, 402, 4666, 14, 221, 199, 3, 627, 710, 23399, 23505, 2672, 60, 8554, 12911, 5683, 93, 4, 787, 9235, 701, 314, 4826, 9462, 295, 13, 13522, 5210, 26170, 5563, 199, 199, 3, 627, 2136, 1172, 9978, 3415, 2808, 367, 314, 5401, 316, 3423, 370, 506, 1202, 199, 199, 26413, 275, 4383, 14, 293, 15549, 14, 26413, 421, 199, 318, 5137, 63, 4916, 8, 4058, 12, 4931, 63, 1532, 12, 671, 3512, 12, 671, 10406, 304, 272, 6085, 275, 4488, 14, 8941, 8, 23899, 2687, 713, 12, 24, 430, 272, 2185, 275, 6085, 14, 525, 63, 13334, 8, 6673, 9, 272, 2185, 14, 2798, 8, 4058, 12, 4931, 63, 1532, 8, 4058, 430, 272, 2185, 14, 409, 63, 26217, 8, 26217, 9, 272, 2185, 14, 409, 63, 88, 27435, 8, 88, 3512, 12, 19740, 29, 975, 9, 272, 2185, 14, 409, 63, 18123, 2801, 14, 17, 12, 413, 14, 17, 9, 272, 372, 2185, 421, 199, 381, 6061, 5257, 1159, 644, 811, 199, 199, 3437, 8, 26413, 14, 3325, 5257, 21393, 14, 4916, 9, 421, 199, 65, 275, 413, 14, 11870, 199, 4058, 275, 980, 14, 11649, 2801, 1590, 14, 1038, 10, 65, 12, 980, 14, 1038, 10, 65, 12, 2948, 9, 199, 460, 5257, 275, 6590, 706, 14, 3325, 5257, 21393, 8, 65, 29, 65, 9, 199, 2798, 63, 4916, 8, 4058, 12, 436, 5257, 14, 4916, 12, 788, 4, 2696, 1038, 10, 65, 4268, 283, 16, 297, 4505, 60, 1038, 10, 65, 4, 995, 5243, 1590, 14, 1038, 10, 65, 12, 378, 12, 980, 14, 1038, 10, 65, 21153, 421, 199, 381, 869, 5282, 352, 1159, 5557, 33, 199, 199, 3437, 8, 26413, 14, 40, 5282, 352, 14, 4916, 9, 421, 199, 67, 275, 1695, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 67, 12, 650, 10, 67, 12, 5198, 9, 199, 2411, 311, 352, 275, 6590, 706, 14, 40, 5282, 352, 8, 65, 29, 18, 2020, 330, 29, 20, 2020, 286, 29, 67, 9, 199, 2798, 63, 4916, 8, 4058, 12, 394, 5282, 352, 14, 4916, 12, 788, 19, 10, 67, 297, 283, 16, 297, 283, 19, 10, 67, 995, 5243, 19, 10, 67, 12, 378, 12, 650, 10, 67, 21153, 421, 199, 381, 869, 10400, 1159, 307, 199, 199, 3437, 8, 26413, 14, 40, 10400, 52, 14, 4916, 9, 421, 199, 84, 275, 413, 14, 9908, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 84, 12, 650, 10, 84, 12, 5198, 9, 199, 72, 10400, 275, 6590, 706, 14, 40, 10400, 52, 8, 84, 29, 84, 9, 199, 2798, 63, 4916, 8, 4058, 12, 394, 10400, 14, 4916, 12, 11573, 19, 10, 84, 297, 283, 16, 297, 283, 19, 10, 84, 995, 5243, 19, 10, 84, 12, 378, 12, 650, 10, 84, 21153, 421, 199, 381, 7005, 1810, 428, 392, 11044, 199, 199, 3437, 8, 26413, 14, 2553, 1810, 51, 392, 11044, 14, 4916, 9, 421, 199, 4058, 275, 980, 14, 11649, 2801, 19, 12, 650, 12, 5198, 9, 199, 6916, 63, 3526, 275, 6590, 706, 14, 2553, 1810, 51, 392, 11044, 342, 199, 2798, 63, 4916, 8, 4058, 12, 9877, 63, 3526, 14, 4916, 12, 11573, 19, 297, 283, 16, 297, 283, 19, 995, 5243, 19, 12, 378, 12, 650, 21153, 421, 199, 381, 820, 19470, 1187, 1159, 662, 65, 199, 199, 3437, 8, 26413, 14, 50, 19470, 1187, 37, 14, 4916, 9, 421, 199, 65, 275, 1275, 19, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 65, 12, 650, 10, 65, 12, 5198, 9, 199, 345, 706, 1187, 275, 6590, 706, 14, 50, 19470, 1187, 37, 8, 65, 29, 65, 9, 199, 2798, 63, 4916, 8, 4058, 12, 660, 706, 1187, 14, 4916, 12, 11573, 19, 10, 65, 297, 283, 16, 297, 283, 19, 10, 65, 995, 5243, 19, 10, 65, 12, 378, 12, 650, 10, 65, 21153, 421, 199, 381, 12480, 77, 3594, 25136, 199, 199, 3437, 8, 26413, 14, 31081, 3594, 14825, 14, 4916, 9, 421, 199, 67, 275, 499, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 67, 12, 650, 10, 67, 12, 5198, 9, 199, 12263, 3594, 275, 6590, 706, 14, 31081, 3594, 14825, 8, 67, 29, 67, 9, 199, 2798, 63, 4916, 8, 4058, 12, 24196, 14, 4916, 12, 11573, 19, 10, 67, 297, 283, 16, 297, 283, 19, 10, 67, 995, 5243, 19, 10, 67, 12, 378, 12, 650, 10, 67, 21153, 421, 199, 381, 377, 85, 498, 1159, 31012, 3463, 199, 199, 3437, 8, 26413, 14, 30669, 498, 17975, 3463, 14, 4916, 9, 421, 199, 67, 275, 841, 14, 19836, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 67, 12, 650, 10, 67, 12, 5198, 9, 199, 10963, 498, 275, 6590, 706, 14, 30669, 498, 17975, 3463, 8, 67, 29, 67, 9, 199, 2798, 63, 4916, 8, 4058, 12, 30799, 498, 14, 4916, 12, 11573, 19, 10, 67, 297, 283, 16, 297, 283, 19, 10, 67, 995, 5243, 19, 10, 67, 12, 378, 12, 650, 10, 67, 21153, 421, 199, 381, 22869, 15896, 9095, 199, 199, 3, 627, 6848, 15549, 23505, 402, 314, 2909, 199, 199, 88, 275, 980, 14, 1144, 779, 17, 12, 499, 12, 650, 12, 841, 12, 6891, 566, 421, 199, 3, 627, 710, 4615, 365, 440, 282, 23399, 8943, 402, 2909, 199, 199, 88 ]
[ 309, 603, 13, 9169, 9095, 367, 6848, 15549, 12489, 4900, 2983, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5020, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 646, 5020, 992, 14, 1246, 465, 4383, 421, 199, 3, 627, 1626, 603, 13, 8627, 18790, 6491, 314, 805, 221, 199, 3, 221, 199, 3, 2672, 4, 49, 8, 69, 63, 73, 12, 971, 10412, 9, 275, 971, 1838, 63, 73, 94, 60, 10412, 971, 3039, 14749, 10865, 91, 69, 63, 73, 8847, 83, 4988, 1019, 776, 23174, 199, 3, 221, 199, 3, 2382, 2672, 60, 10412, 4, 365, 282, 16371, 805, 402, 314, 16731, 83, 221, 199, 3, 221, 199, 3, 627, 710, 7763, 402, 2672, 60, 10412, 4, 365, 370, 7114, 314, 315, 24585, 402, 734, 14035, 199, 3, 627, 2672, 83, 4, 365, 376, 14497, 402, 4666, 14, 221, 199, 3, 627, 710, 23399, 23505, 2672, 60, 8554, 12911, 5683, 93, 4, 787, 9235, 701, 314, 4826, 9462, 295, 13, 13522, 5210, 26170, 5563, 199, 199, 3, 627, 2136, 1172, 9978, 3415, 2808, 367, 314, 5401, 316, 3423, 370, 506, 1202, 199, 199, 26413, 275, 4383, 14, 293, 15549, 14, 26413, 421, 199, 318, 5137, 63, 4916, 8, 4058, 12, 4931, 63, 1532, 12, 671, 3512, 12, 671, 10406, 304, 272, 6085, 275, 4488, 14, 8941, 8, 23899, 2687, 713, 12, 24, 430, 272, 2185, 275, 6085, 14, 525, 63, 13334, 8, 6673, 9, 272, 2185, 14, 2798, 8, 4058, 12, 4931, 63, 1532, 8, 4058, 430, 272, 2185, 14, 409, 63, 26217, 8, 26217, 9, 272, 2185, 14, 409, 63, 88, 27435, 8, 88, 3512, 12, 19740, 29, 975, 9, 272, 2185, 14, 409, 63, 18123, 2801, 14, 17, 12, 413, 14, 17, 9, 272, 372, 2185, 421, 199, 381, 6061, 5257, 1159, 644, 811, 199, 199, 3437, 8, 26413, 14, 3325, 5257, 21393, 14, 4916, 9, 421, 199, 65, 275, 413, 14, 11870, 199, 4058, 275, 980, 14, 11649, 2801, 1590, 14, 1038, 10, 65, 12, 980, 14, 1038, 10, 65, 12, 2948, 9, 199, 460, 5257, 275, 6590, 706, 14, 3325, 5257, 21393, 8, 65, 29, 65, 9, 199, 2798, 63, 4916, 8, 4058, 12, 436, 5257, 14, 4916, 12, 788, 4, 2696, 1038, 10, 65, 4268, 283, 16, 297, 4505, 60, 1038, 10, 65, 4, 995, 5243, 1590, 14, 1038, 10, 65, 12, 378, 12, 980, 14, 1038, 10, 65, 21153, 421, 199, 381, 869, 5282, 352, 1159, 5557, 33, 199, 199, 3437, 8, 26413, 14, 40, 5282, 352, 14, 4916, 9, 421, 199, 67, 275, 1695, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 67, 12, 650, 10, 67, 12, 5198, 9, 199, 2411, 311, 352, 275, 6590, 706, 14, 40, 5282, 352, 8, 65, 29, 18, 2020, 330, 29, 20, 2020, 286, 29, 67, 9, 199, 2798, 63, 4916, 8, 4058, 12, 394, 5282, 352, 14, 4916, 12, 788, 19, 10, 67, 297, 283, 16, 297, 283, 19, 10, 67, 995, 5243, 19, 10, 67, 12, 378, 12, 650, 10, 67, 21153, 421, 199, 381, 869, 10400, 1159, 307, 199, 199, 3437, 8, 26413, 14, 40, 10400, 52, 14, 4916, 9, 421, 199, 84, 275, 413, 14, 9908, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 84, 12, 650, 10, 84, 12, 5198, 9, 199, 72, 10400, 275, 6590, 706, 14, 40, 10400, 52, 8, 84, 29, 84, 9, 199, 2798, 63, 4916, 8, 4058, 12, 394, 10400, 14, 4916, 12, 11573, 19, 10, 84, 297, 283, 16, 297, 283, 19, 10, 84, 995, 5243, 19, 10, 84, 12, 378, 12, 650, 10, 84, 21153, 421, 199, 381, 7005, 1810, 428, 392, 11044, 199, 199, 3437, 8, 26413, 14, 2553, 1810, 51, 392, 11044, 14, 4916, 9, 421, 199, 4058, 275, 980, 14, 11649, 2801, 19, 12, 650, 12, 5198, 9, 199, 6916, 63, 3526, 275, 6590, 706, 14, 2553, 1810, 51, 392, 11044, 342, 199, 2798, 63, 4916, 8, 4058, 12, 9877, 63, 3526, 14, 4916, 12, 11573, 19, 297, 283, 16, 297, 283, 19, 995, 5243, 19, 12, 378, 12, 650, 21153, 421, 199, 381, 820, 19470, 1187, 1159, 662, 65, 199, 199, 3437, 8, 26413, 14, 50, 19470, 1187, 37, 14, 4916, 9, 421, 199, 65, 275, 1275, 19, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 65, 12, 650, 10, 65, 12, 5198, 9, 199, 345, 706, 1187, 275, 6590, 706, 14, 50, 19470, 1187, 37, 8, 65, 29, 65, 9, 199, 2798, 63, 4916, 8, 4058, 12, 660, 706, 1187, 14, 4916, 12, 11573, 19, 10, 65, 297, 283, 16, 297, 283, 19, 10, 65, 995, 5243, 19, 10, 65, 12, 378, 12, 650, 10, 65, 21153, 421, 199, 381, 12480, 77, 3594, 25136, 199, 199, 3437, 8, 26413, 14, 31081, 3594, 14825, 14, 4916, 9, 421, 199, 67, 275, 499, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 67, 12, 650, 10, 67, 12, 5198, 9, 199, 12263, 3594, 275, 6590, 706, 14, 31081, 3594, 14825, 8, 67, 29, 67, 9, 199, 2798, 63, 4916, 8, 4058, 12, 24196, 14, 4916, 12, 11573, 19, 10, 67, 297, 283, 16, 297, 283, 19, 10, 67, 995, 5243, 19, 10, 67, 12, 378, 12, 650, 10, 67, 21153, 421, 199, 381, 377, 85, 498, 1159, 31012, 3463, 199, 199, 3437, 8, 26413, 14, 30669, 498, 17975, 3463, 14, 4916, 9, 421, 199, 67, 275, 841, 14, 19836, 199, 4058, 275, 980, 14, 11649, 2801, 19, 10, 67, 12, 650, 10, 67, 12, 5198, 9, 199, 10963, 498, 275, 6590, 706, 14, 30669, 498, 17975, 3463, 8, 67, 29, 67, 9, 199, 2798, 63, 4916, 8, 4058, 12, 30799, 498, 14, 4916, 12, 11573, 19, 10, 67, 297, 283, 16, 297, 283, 19, 10, 67, 995, 5243, 19, 10, 67, 12, 378, 12, 650, 10, 67, 21153, 421, 199, 381, 22869, 15896, 9095, 199, 199, 3, 627, 6848, 15549, 23505, 402, 314, 2909, 199, 199, 88, 275, 980, 14, 1144, 779, 17, 12, 499, 12, 650, 12, 841, 12, 6891, 566, 421, 199, 3, 627, 710, 4615, 365, 440, 282, 23399, 8943, 402, 2909, 199, 199, 88, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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icode_literals import string import warnings from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.db.models.signals import pre_delete, pre_save from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from .requests import RequestSite as RealRequestSite from .shortcuts import get_current_site as real_get_current_site 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() if host not in SITE_CACHE: site = self.get(domain__iexact=host) SITE_CACHE[host] = site return SITE_CACHE[host] 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]) 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 class RequestSite(RealRequestSite): def __init__(self, *args, **kwargs): warnings.warn( "Please import RequestSite from django.contrib.sites.requests.", RemovedInDjango19Warning, stacklevel=2) super(RequestSite, self).__init__(*args, **kwargs) def get_current_site(request): warnings.warn( "Please import get_current_site from django.contrib.sites.shortcuts.", RemovedInDjango19Warning, stacklevel=2) return real_get_current_site(request) 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, 646, 3598, 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, 1208, 14, 15383, 492, 23687, 1167, 3849, 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, 504, 1275, 6615, 492, 4784, 8972, 465, 14849, 2017, 8972, 199, 504, 1275, 17469, 492, 664, 63, 1818, 63, 2124, 465, 3363, 63, 362, 63, 1818, 63, 2124, 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, 340, 1591, 440, 315, 428, 4427, 63, 8677, 26, 288, 4770, 275, 291, 14, 362, 8, 2261, 363, 32344, 29, 1102, 9, 288, 428, 4427, 63, 8677, 59, 1102, 61, 275, 4770, 267, 372, 428, 4427, 63, 8677, 59, 1102, 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, 566, 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, 533, 4784, 8972, 8, 10099, 2017, 8972, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 3598, 14, 4050, 8, 288, 298, 8254, 492, 4784, 8972, 687, 1639, 14, 2828, 14, 8619, 14, 6615, 4765, 288, 23687, 1167, 3849, 12, 13232, 29, 18, 9, 267, 1613, 8, 2017, 8972, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 421, 199, 318, 664, 63, 1818, 63, 2124, 8, 1069, 304, 272, 3598, 14, 4050, 8, 267, 298, 8254, 492, 664, 63, 1818, 63, 2124, 687, 1639, 14, 2828, 14, 8619, 14, 17469, 4765, 267, 23687, 1167, 3849, 12, 13232, 29, 18, 9, 272, 372, 3363, 63, 362, 63, 1818, 63, 2124, 8, 1069, 9, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 1059, 199, 646, 3598, 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, 1208, 14, 15383, 492, 23687, 1167, 3849, 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, 504, 1275, 6615, 492, 4784, 8972, 465, 14849, 2017, 8972, 199, 504, 1275, 17469, 492, 664, 63, 1818, 63, 2124, 465, 3363, 63, 362, 63, 1818, 63, 2124, 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, 340, 1591, 440, 315, 428, 4427, 63, 8677, 26, 288, 4770, 275, 291, 14, 362, 8, 2261, 363, 32344, 29, 1102, 9, 288, 428, 4427, 63, 8677, 59, 1102, 61, 275, 4770, 267, 372, 428, 4427, 63, 8677, 59, 1102, 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, 566, 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, 533, 4784, 8972, 8, 10099, 2017, 8972, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 3598, 14, 4050, 8, 288, 298, 8254, 492, 4784, 8972, 687, 1639, 14, 2828, 14, 8619, 14, 6615, 4765, 288, 23687, 1167, 3849, 12, 13232, 29, 18, 9, 267, 1613, 8, 2017, 8972, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 421, 199, 318, 664, 63, 1818, 63, 2124, 8, 1069, 304, 272, 3598, 14, 4050, 8, 267, 298, 8254, 492, 664, 63, 1818, 63, 2124, 687, 1639, 14, 2828, 14, 8619, 14, 17469, 4765, 267, 23687, 1167, 3849, 12, 13232, 29, 18, 9, 272, 372, 3363, 63, 362, 63, 1818, 63, 2124, 8, 1069, 9, 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,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0, 0, 0, 0, 0, 0, 0 ]
thomaslima/PySpice
ngspice-shared/test-module.py
1
2074
#################################################################################################### import PySpice.Logging.Logging as Logging logger = Logging.setup_logging() #################################################################################################### from PySpice.Spice.NgSpice.Shared import NgSpiceShared #################################################################################################### class MyNgSpiceShared(NgSpiceShared): ############################################## def get_vsrc_data(self, voltage, time, node, ngspice_id): self._logger.debug('ngspice_id-{} get_vsrc_data @{} node {}'.format(ngspice_id, time, node)) voltage[0] = 1. return 0 ############################################## def get_isrc_data(self, current, time, node, ngspice_id): self._logger.debug('ngspice_id-{} get_isrc_data @{} node {}'.format(ngspice_id, time, node)) current[0] = 1. return 0 #################################################################################################### time_step = '1m' # circuit = """ .title rc circuit # * V1 1 0 1 # V1 1 0 dc 0 external # R1 1 2 1 # C1 2 0 1 ic=0 # .tran {} 3 uic # .end # """.format(time_step) circuit = """ .title Low-Pass RC Filter Vinput in 0 DC 0V AC SIN(0V 1V 50Hz 0s 0) Rf in out 1k Cf out 0 1u .options TNOM = 25 .options TEMP = 25 .ic .ac dec 10 1 1Meg .end """ ngspice_shared = MyNgSpiceShared(send_data=False) ngspice_shared.load_circuit(circuit) ngspice_shared.run() print(ngspice_shared.plot_names) # vectors = ngspice_shared.vectors('tran1') # print(vectors) # vectors = ngspice_shared.vectors('ac1') # print(vectors) # print(vectors['frequency']) # print(ngspice_shared.plot('ac1')) analysis = ngspice_shared.plot('ac1').to_analysis() print(analysis.nodes) print(analysis.branches) #################################################################################################### # # End # ####################################################################################################
gpl-3.0
[ 3060, 1371, 381, 199, 199, 646, 1611, 51, 1038, 301, 14, 14054, 14, 14054, 465, 19928, 199, 2921, 275, 19928, 14, 2758, 63, 4806, 342, 199, 199, 3060, 1371, 381, 199, 199, 504, 1611, 51, 1038, 301, 14, 51, 1038, 301, 14, 46, 71, 51, 1038, 301, 14, 12197, 492, 653, 71, 51, 1038, 301, 12197, 199, 199, 3060, 1371, 381, 199, 199, 533, 4932, 46, 71, 51, 1038, 301, 12197, 8, 46, 71, 51, 1038, 301, 12197, 304, 339, 26316, 3726, 339, 347, 664, 63, 86, 2164, 63, 576, 8, 277, 12, 29943, 12, 900, 12, 1031, 12, 302, 458, 1038, 301, 63, 344, 304, 267, 291, 423, 2921, 14, 1757, 360, 78, 458, 1038, 301, 63, 344, 13, 2440, 664, 63, 86, 2164, 63, 576, 768, 2440, 1031, 9499, 908, 8, 78, 458, 1038, 301, 63, 344, 12, 900, 12, 1031, 430, 267, 29943, 59, 16, 61, 275, 413, 14, 267, 372, 378, 339, 26316, 3726, 339, 347, 664, 63, 374, 1195, 63, 576, 8, 277, 12, 1453, 12, 900, 12, 1031, 12, 302, 458, 1038, 301, 63, 344, 304, 267, 291, 423, 2921, 14, 1757, 360, 78, 458, 1038, 301, 63, 344, 13, 2440, 664, 63, 374, 1195, 63, 576, 768, 2440, 1031, 9499, 908, 8, 78, 458, 1038, 301, 63, 344, 12, 900, 12, 1031, 430, 267, 1453, 59, 16, 61, 275, 413, 14, 267, 372, 378, 199, 199, 3060, 1371, 381, 199, 199, 521, 63, 2926, 275, 283, 17, 77, 7, 199, 199, 3, 20304, 275, 408, 1275, 1213, 4819, 20304, 199, 3, 627, 812, 17, 413, 378, 413, 199, 3, 812, 17, 413, 378, 12326, 378, 5957, 199, 3, 820, 17, 413, 499, 413, 199, 3, 445, 17, 499, 378, 413, 284, 67, 29, 16, 199, 3, 1275, 3936, 1052, 650, 399, 530, 199, 3, 1275, 500, 199, 3, 30512, 908, 8, 521, 63, 2926, 9, 199, 199, 18516, 275, 408, 199, 14, 1213, 21766, 13, 4986, 29256, 9388, 199, 54, 1210, 315, 378, 30592, 378, 54, 6570, 428, 568, 8, 16, 54, 413, 54, 5238, 13026, 378, 83, 378, 9, 199, 28115, 315, 734, 413, 75, 199, 24304, 734, 378, 413, 85, 199, 14, 1419, 377, 2826, 45, 275, 5661, 199, 14, 1419, 24314, 275, 5661, 199, 14, 530, 199, 14, 645, 9700, 1616, 413, 413, 1352, 71, 199, 14, 500, 199, 624, 199, 199, 78, 458, 1038, 301, 63, 5555, 275, 4932, 46, 71, 51, 1038, 301, 12197, 8, 2254, 63, 576, 29, 797, 9, 199, 78, 458, 1038, 301, 63, 5555, 14, 912, 63, 18516, 8, 18516, 9, 199, 78, 458, 1038, 301, 63, 5555, 14, 1065, 342, 199, 1361, 8, 78, 458, 1038, 301, 63, 5555, 14, 2798, 63, 1247, 9, 199, 3, 11102, 275, 302, 458, 1038, 301, 63, 5555, 14, 12280, 360, 3936, 17, 358, 199, 3, 870, 8, 12280, 9, 199, 3, 11102, 275, 302, 458, 1038, 301, 63, 5555, 14, 12280, 360, 645, 17, 358, 199, 3, 870, 8, 12280, 9, 199, 3, 870, 8, 12280, 459, 11132, 1105, 199, 3, 870, 8, 78, 458, 1038, 301, 63, 5555, 14, 2798, 360, 645, 17, 1333, 199, 10466, 275, 302, 458, 1038, 301, 63, 5555, 14, 2798, 360, 645, 17, 1959, 475, 63, 10466, 342, 199, 199, 1361, 8, 10466, 14, 2415, 9, 199, 1361, 8, 10466, 14, 16896, 9, 199, 199, 3060, 1371, 381, 199, 3, 199, 3, 9599, 199, 3, 199, 3060, 1371, 381, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1371, 381, 199, 199, 646, 1611, 51, 1038, 301, 14, 14054, 14, 14054, 465, 19928, 199, 2921, 275, 19928, 14, 2758, 63, 4806, 342, 199, 199, 3060, 1371, 381, 199, 199, 504, 1611, 51, 1038, 301, 14, 51, 1038, 301, 14, 46, 71, 51, 1038, 301, 14, 12197, 492, 653, 71, 51, 1038, 301, 12197, 199, 199, 3060, 1371, 381, 199, 199, 533, 4932, 46, 71, 51, 1038, 301, 12197, 8, 46, 71, 51, 1038, 301, 12197, 304, 339, 26316, 3726, 339, 347, 664, 63, 86, 2164, 63, 576, 8, 277, 12, 29943, 12, 900, 12, 1031, 12, 302, 458, 1038, 301, 63, 344, 304, 267, 291, 423, 2921, 14, 1757, 360, 78, 458, 1038, 301, 63, 344, 13, 2440, 664, 63, 86, 2164, 63, 576, 768, 2440, 1031, 9499, 908, 8, 78, 458, 1038, 301, 63, 344, 12, 900, 12, 1031, 430, 267, 29943, 59, 16, 61, 275, 413, 14, 267, 372, 378, 339, 26316, 3726, 339, 347, 664, 63, 374, 1195, 63, 576, 8, 277, 12, 1453, 12, 900, 12, 1031, 12, 302, 458, 1038, 301, 63, 344, 304, 267, 291, 423, 2921, 14, 1757, 360, 78, 458, 1038, 301, 63, 344, 13, 2440, 664, 63, 374, 1195, 63, 576, 768, 2440, 1031, 9499, 908, 8, 78, 458, 1038, 301, 63, 344, 12, 900, 12, 1031, 430, 267, 1453, 59, 16, 61, 275, 413, 14, 267, 372, 378, 199, 199, 3060, 1371, 381, 199, 199, 521, 63, 2926, 275, 283, 17, 77, 7, 199, 199, 3, 20304, 275, 408, 1275, 1213, 4819, 20304, 199, 3, 627, 812, 17, 413, 378, 413, 199, 3, 812, 17, 413, 378, 12326, 378, 5957, 199, 3, 820, 17, 413, 499, 413, 199, 3, 445, 17, 499, 378, 413, 284, 67, 29, 16, 199, 3, 1275, 3936, 1052, 650, 399, 530, 199, 3, 1275, 500, 199, 3, 30512, 908, 8, 521, 63, 2926, 9, 199, 199, 18516, 275, 408, 199, 14, 1213, 21766, 13, 4986, 29256, 9388, 199, 54, 1210, 315, 378, 30592, 378, 54, 6570, 428, 568, 8, 16, 54, 413, 54, 5238, 13026, 378, 83, 378, 9, 199, 28115, 315, 734, 413, 75, 199, 24304, 734, 378, 413, 85, 199, 14, 1419, 377, 2826, 45, 275, 5661, 199, 14, 1419, 24314, 275, 5661, 199, 14, 530, 199, 14, 645, 9700, 1616, 413, 413, 1352, 71, 199, 14, 500, 199, 624, 199, 199, 78, 458, 1038, 301, 63, 5555, 275, 4932, 46, 71, 51, 1038, 301, 12197, 8, 2254, 63, 576, 29, 797, 9, 199, 78, 458, 1038, 301, 63, 5555, 14, 912, 63, 18516, 8, 18516, 9, 199, 78, 458, 1038, 301, 63, 5555, 14, 1065, 342, 199, 1361, 8, 78, 458, 1038, 301, 63, 5555, 14, 2798, 63, 1247, 9, 199, 3, 11102, 275, 302, 458, 1038, 301, 63, 5555, 14, 12280, 360, 3936, 17, 358, 199, 3, 870, 8, 12280, 9, 199, 3, 11102, 275, 302, 458, 1038, 301, 63, 5555, 14, 12280, 360, 645, 17, 358, 199, 3, 870, 8, 12280, 9, 199, 3, 870, 8, 12280, 459, 11132, 1105, 199, 3, 870, 8, 78, 458, 1038, 301, 63, 5555, 14, 2798, 360, 645, 17, 1333, 199, 10466, 275, 302, 458, 1038, 301, 63, 5555, 14, 2798, 360, 645, 17, 1959, 475, 63, 10466, 342, 199, 199, 1361, 8, 10466, 14, 2415, 9, 199, 1361, 8, 10466, 14, 16896, 9, 199, 199, 3060, 1371, 381, 199, 3, 199, 3, 9599, 199, 3, 199, 3060, 1371, 381, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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ools.py
295
2449
# -*- coding: utf-8 -*- """ werkzeug.contrib.testtools ~~~~~~~~~~~~~~~~~~~~~~~~~~ This module implements extended wrappers for simplified testing. `TestResponse` A response wrapper which adds various cached attributes for simplified assertions on various content types. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from werkzeug.utils import cached_property, import_string from werkzeug.wrappers import Response from warnings import warn warn(DeprecationWarning('werkzeug.contrib.testtools is deprecated and ' 'will be removed with Werkzeug 1.0')) class ContentAccessors(object): """ A mixin class for response objects that provides a couple of useful accessors for unittesting. """ def xml(self): """Get an etree if possible.""" if 'xml' not in self.mimetype: raise AttributeError( 'Not a XML response (Content-Type: %s)' % self.mimetype) for module in ['xml.etree.ElementTree', 'ElementTree', 'elementtree.ElementTree']: etree = import_string(module, silent=True) if etree is not None: return etree.XML(self.body) raise RuntimeError('You must have ElementTree installed ' 'to use TestResponse.xml') xml = cached_property(xml) def lxml(self): """Get an lxml etree if possible.""" if ('html' not in self.mimetype and 'xml' not in self.mimetype): raise AttributeError('Not an HTML/XML response') from lxml import etree try: from lxml.html import fromstring except ImportError: fromstring = etree.HTML if self.mimetype=='text/html': return fromstring(self.data) return etree.XML(self.data) lxml = cached_property(lxml) def json(self): """Get the result of simplejson.loads if possible.""" if 'json' not in self.mimetype: raise AttributeError('Not a JSON response') try: from simplejson import loads except ImportError: from json import loads return loads(self.data) json = cached_property(json) class TestResponse(Response, ContentAccessors): """Pass this to `werkzeug.test.Client` for easier unittesting."""
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 2828, 14, 396, 2537, 272, 18294, 4919, 1714, 339, 961, 859, 9031, 9243, 17995, 367, 26867, 5343, 14, 339, 658, 774, 2364, 64, 267, 437, 1177, 4975, 1314, 9584, 7750, 6328, 3004, 367, 267, 26867, 22835, 641, 7750, 1564, 2943, 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, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 10380, 14, 1208, 492, 6328, 63, 1829, 12, 492, 63, 875, 199, 504, 10380, 14, 21148, 492, 7232, 199, 199, 504, 3598, 492, 7987, 199, 4050, 8, 15561, 360, 17719, 14, 2828, 14, 396, 2537, 365, 5906, 436, 283, 717, 283, 14117, 506, 4829, 543, 22798, 413, 14, 16, 1333, 421, 199, 533, 6646, 3946, 1384, 8, 785, 304, 272, 408, 272, 437, 20048, 1021, 367, 1177, 2251, 626, 6571, 282, 17535, 402, 2997, 272, 31908, 367, 2882, 316, 14, 272, 408, 339, 347, 2748, 8, 277, 304, 267, 408, 1002, 376, 7559, 340, 3962, 1041, 267, 340, 283, 1652, 7, 440, 315, 291, 14, 17450, 26, 288, 746, 4281, 8, 355, 283, 1763, 282, 4692, 1177, 334, 2714, 13, 804, 26, 450, 83, 3171, 355, 450, 291, 14, 17450, 9, 267, 367, 859, 315, 788, 1652, 14, 9464, 14, 15325, 297, 283, 15325, 297, 2432, 283, 2108, 2350, 14, 15325, 2565, 288, 7559, 275, 492, 63, 875, 8, 578, 12, 10866, 29, 549, 9, 288, 340, 7559, 365, 440, 488, 26, 355, 372, 7559, 14, 4317, 8, 277, 14, 2030, 9, 267, 746, 6064, 360, 5556, 1471, 1172, 13139, 4903, 283, 2574, 283, 475, 675, 1379, 2364, 14, 1652, 358, 272, 2748, 275, 6328, 63, 1829, 8, 1652, 9, 339, 347, 14490, 8, 277, 304, 267, 408, 1002, 376, 14490, 7559, 340, 3962, 1041, 267, 340, 661, 1360, 7, 440, 315, 291, 14, 17450, 436, 283, 1652, 7, 440, 315, 291, 14, 17450, 304, 288, 746, 4281, 360, 1763, 376, 4163, 15, 4317, 1177, 358, 267, 687, 14490, 492, 7559, 267, 862, 26, 288, 687, 14490, 14, 1360, 492, 687, 875, 267, 871, 3545, 26, 288, 687, 875, 275, 7559, 14, 4943, 267, 340, 291, 14, 17450, 6803, 505, 15, 1360, 356, 288, 372, 687, 875, 8, 277, 14, 576, 9, 267, 372, 7559, 14, 4317, 8, 277, 14, 576, 9, 272, 14490, 275, 6328, 63, 1829, 8, 22899, 9, 339, 347, 2022, 8, 277, 304, 267, 408, 1002, 314, 754, 402, 13804, 14, 3640, 340, 3962, 1041, 267, 340, 283, 1001, 7, 440, 315, 291, 14, 17450, 26, 288, 746, 4281, 360, 1763, 282, 4840, 1177, 358, 267, 862, 26, 288, 687, 13804, 492, 14404, 267, 871, 3545, 26, 288, 687, 2022, 492, 14404, 267, 372, 14404, 8, 277, 14, 576, 9, 272, 2022, 275, 6328, 63, 1829, 8, 1001, 9, 421, 199, 533, 1379, 2364, 8, 2364, 12, 6646, 3946, 1384, 304, 272, 408, 4986, 642, 370, 658, 17719, 14, 396, 14, 3041, 64, 367, 14905, 2882, 316, 1041, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10380, 14, 2828, 14, 396, 2537, 272, 18294, 4919, 1714, 339, 961, 859, 9031, 9243, 17995, 367, 26867, 5343, 14, 339, 658, 774, 2364, 64, 267, 437, 1177, 4975, 1314, 9584, 7750, 6328, 3004, 367, 267, 26867, 22835, 641, 7750, 1564, 2943, 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, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 504, 10380, 14, 1208, 492, 6328, 63, 1829, 12, 492, 63, 875, 199, 504, 10380, 14, 21148, 492, 7232, 199, 199, 504, 3598, 492, 7987, 199, 4050, 8, 15561, 360, 17719, 14, 2828, 14, 396, 2537, 365, 5906, 436, 283, 717, 283, 14117, 506, 4829, 543, 22798, 413, 14, 16, 1333, 421, 199, 533, 6646, 3946, 1384, 8, 785, 304, 272, 408, 272, 437, 20048, 1021, 367, 1177, 2251, 626, 6571, 282, 17535, 402, 2997, 272, 31908, 367, 2882, 316, 14, 272, 408, 339, 347, 2748, 8, 277, 304, 267, 408, 1002, 376, 7559, 340, 3962, 1041, 267, 340, 283, 1652, 7, 440, 315, 291, 14, 17450, 26, 288, 746, 4281, 8, 355, 283, 1763, 282, 4692, 1177, 334, 2714, 13, 804, 26, 450, 83, 3171, 355, 450, 291, 14, 17450, 9, 267, 367, 859, 315, 788, 1652, 14, 9464, 14, 15325, 297, 283, 15325, 297, 2432, 283, 2108, 2350, 14, 15325, 2565, 288, 7559, 275, 492, 63, 875, 8, 578, 12, 10866, 29, 549, 9, 288, 340, 7559, 365, 440, 488, 26, 355, 372, 7559, 14, 4317, 8, 277, 14, 2030, 9, 267, 746, 6064, 360, 5556, 1471, 1172, 13139, 4903, 283, 2574, 283, 475, 675, 1379, 2364, 14, 1652, 358, 272, 2748, 275, 6328, 63, 1829, 8, 1652, 9, 339, 347, 14490, 8, 277, 304, 267, 408, 1002, 376, 14490, 7559, 340, 3962, 1041, 267, 340, 661, 1360, 7, 440, 315, 291, 14, 17450, 436, 283, 1652, 7, 440, 315, 291, 14, 17450, 304, 288, 746, 4281, 360, 1763, 376, 4163, 15, 4317, 1177, 358, 267, 687, 14490, 492, 7559, 267, 862, 26, 288, 687, 14490, 14, 1360, 492, 687, 875, 267, 871, 3545, 26, 288, 687, 875, 275, 7559, 14, 4943, 267, 340, 291, 14, 17450, 6803, 505, 15, 1360, 356, 288, 372, 687, 875, 8, 277, 14, 576, 9, 267, 372, 7559, 14, 4317, 8, 277, 14, 576, 9, 272, 14490, 275, 6328, 63, 1829, 8, 22899, 9, 339, 347, 2022, 8, 277, 304, 267, 408, 1002, 314, 754, 402, 13804, 14, 3640, 340, 3962, 1041, 267, 340, 283, 1001, 7, 440, 315, 291, 14, 17450, 26, 288, 746, 4281, 360, 1763, 282, 4840, 1177, 358, 267, 862, 26, 288, 687, 13804, 492, 14404, 267, 871, 3545, 26, 288, 687, 2022, 492, 14404, 267, 372, 14404, 8, 277, 14, 576, 9, 272, 2022, 275, 6328, 63, 1829, 8, 1001, 9, 421, 199, 533, 1379, 2364, 8, 2364, 12, 6646, 3946, 1384, 304, 272, 408, 4986, 642, 370, 658, 17719, 14, 396, 14, 3041, 64, 367, 14905, 2882, 316, 1041, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
gram526/VTK
Common/Core/Testing/Python/TestSwigPointer.py
21
1362
"""Test swig-style wrapped pointers Created on Oct 2, 2014 by David Gobbi """ import sys import vtk from vtk.test import Testing class TestSwigPointer(Testing.vtkTest): def testVoidPointer(self): a = vtk.vtkIntArray() a.SetNumberOfTuples(1) a.SetValue(0, 1) b = vtk.vtkIntArray() b.SetNumberOfTuples(1) b.SetValue(0, 2) ptr = a.GetVoidPointer(0) # check the format _0123456789abcdef_p_void self.assertEqual(ptr[0:1], "_") self.assertEqual(ptr[-7:], "_p_void") address = int(ptr[1:-7], 16) # check that we can use the pointer b.SetVoidArray(ptr, 1, 1) self.assertEqual(b.GetValue(0), 1) a.SetValue(0, 10) self.assertEqual(b.GetValue(0), 10) def testObjectPointer(self): a = vtk.vtkInformation() ptr = a.__this__ # check the format _0123456789abcdef_p_vtkInformation self.assertEqual(ptr[0:1], "_") self.assertEqual(ptr[-17:], "_p_vtkInformation") address = int(ptr[1:-17], 16) # create a VTK object from the swig pointer b = vtk.vtkObject(ptr) self.assertEqual(b.GetClassName(), a.GetClassName()) self.assertEqual(a.__this__, b.__this__) self.assertEqual(a, b) if __name__ == "__main__": Testing.main([(TestSwigPointer, 'test')])
bsd-3-clause
[ 624, 774, 30057, 13, 2487, 8072, 21116, 199, 199, 10502, 641, 18365, 499, 12, 6927, 701, 20232, 3971, 2501, 73, 199, 624, 199, 199, 646, 984, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 199, 533, 1379, 10941, 528, 12190, 8, 9029, 14, 11919, 774, 304, 272, 347, 511, 29545, 12190, 8, 277, 304, 267, 282, 275, 11144, 14, 11919, 3241, 3836, 342, 267, 282, 14, 1084, 16030, 7075, 83, 8, 17, 9, 267, 282, 14, 21322, 8, 16, 12, 413, 9, 267, 330, 275, 11144, 14, 11919, 3241, 3836, 342, 267, 330, 14, 1084, 16030, 7075, 83, 8, 17, 9, 267, 330, 14, 21322, 8, 16, 12, 499, 9, 267, 12448, 275, 282, 14, 1002, 29545, 12190, 8, 16, 9, 267, 327, 1104, 314, 1475, 485, 11371, 10678, 63, 80, 63, 1647, 267, 291, 14, 629, 8, 4695, 59, 16, 26, 17, 467, 2668, 531, 267, 291, 14, 629, 8, 4695, 1988, 23, 8429, 2668, 80, 63, 1647, 531, 267, 2287, 275, 1109, 8, 4695, 59, 17, 6809, 23, 467, 3193, 9, 267, 327, 1104, 626, 781, 883, 675, 314, 7849, 267, 330, 14, 1084, 29545, 3836, 8, 4695, 12, 413, 12, 413, 9, 267, 291, 14, 629, 8, 66, 14, 9334, 8, 16, 395, 413, 9, 267, 282, 14, 21322, 8, 16, 12, 1616, 9, 267, 291, 14, 629, 8, 66, 14, 9334, 8, 16, 395, 1616, 9, 339, 347, 511, 1692, 12190, 8, 277, 304, 267, 282, 275, 11144, 14, 11919, 4935, 342, 267, 12448, 275, 282, 855, 3749, 363, 267, 327, 1104, 314, 1475, 485, 11371, 10678, 63, 80, 63, 11919, 4935, 267, 291, 14, 629, 8, 4695, 59, 16, 26, 17, 467, 2668, 531, 267, 291, 14, 629, 8, 4695, 1988, 1196, 8429, 2668, 80, 63, 11919, 4935, 531, 267, 2287, 275, 1109, 8, 4695, 59, 17, 6809, 1196, 467, 3193, 9, 267, 327, 1218, 282, 812, 15263, 909, 687, 314, 30057, 7849, 267, 330, 275, 11144, 14, 11919, 1692, 8, 4695, 9, 267, 291, 14, 629, 8, 66, 14, 1002, 23200, 1062, 282, 14, 1002, 23200, 1012, 267, 291, 14, 629, 8, 65, 855, 3749, 3108, 330, 855, 3749, 3368, 267, 291, 14, 629, 8, 65, 12, 330, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 11940, 14, 973, 7694, 774, 10941, 528, 12190, 12, 283, 396, 2023, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 774, 30057, 13, 2487, 8072, 21116, 199, 199, 10502, 641, 18365, 499, 12, 6927, 701, 20232, 3971, 2501, 73, 199, 624, 199, 199, 646, 984, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 199, 533, 1379, 10941, 528, 12190, 8, 9029, 14, 11919, 774, 304, 272, 347, 511, 29545, 12190, 8, 277, 304, 267, 282, 275, 11144, 14, 11919, 3241, 3836, 342, 267, 282, 14, 1084, 16030, 7075, 83, 8, 17, 9, 267, 282, 14, 21322, 8, 16, 12, 413, 9, 267, 330, 275, 11144, 14, 11919, 3241, 3836, 342, 267, 330, 14, 1084, 16030, 7075, 83, 8, 17, 9, 267, 330, 14, 21322, 8, 16, 12, 499, 9, 267, 12448, 275, 282, 14, 1002, 29545, 12190, 8, 16, 9, 267, 327, 1104, 314, 1475, 485, 11371, 10678, 63, 80, 63, 1647, 267, 291, 14, 629, 8, 4695, 59, 16, 26, 17, 467, 2668, 531, 267, 291, 14, 629, 8, 4695, 1988, 23, 8429, 2668, 80, 63, 1647, 531, 267, 2287, 275, 1109, 8, 4695, 59, 17, 6809, 23, 467, 3193, 9, 267, 327, 1104, 626, 781, 883, 675, 314, 7849, 267, 330, 14, 1084, 29545, 3836, 8, 4695, 12, 413, 12, 413, 9, 267, 291, 14, 629, 8, 66, 14, 9334, 8, 16, 395, 413, 9, 267, 282, 14, 21322, 8, 16, 12, 1616, 9, 267, 291, 14, 629, 8, 66, 14, 9334, 8, 16, 395, 1616, 9, 339, 347, 511, 1692, 12190, 8, 277, 304, 267, 282, 275, 11144, 14, 11919, 4935, 342, 267, 12448, 275, 282, 855, 3749, 363, 267, 327, 1104, 314, 1475, 485, 11371, 10678, 63, 80, 63, 11919, 4935, 267, 291, 14, 629, 8, 4695, 59, 16, 26, 17, 467, 2668, 531, 267, 291, 14, 629, 8, 4695, 1988, 1196, 8429, 2668, 80, 63, 11919, 4935, 531, 267, 2287, 275, 1109, 8, 4695, 59, 17, 6809, 1196, 467, 3193, 9, 267, 327, 1218, 282, 812, 15263, 909, 687, 314, 30057, 7849, 267, 330, 275, 11144, 14, 11919, 1692, 8, 4695, 9, 267, 291, 14, 629, 8, 66, 14, 1002, 23200, 1062, 282, 14, 1002, 23200, 1012, 267, 291, 14, 629, 8, 65, 855, 3749, 3108, 330, 855, 3749, 3368, 267, 291, 14, 629, 8, 65, 12, 330, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 11940, 14, 973, 7694, 774, 10941, 528, 12190, 12, 283, 396, 2023, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
drnextgis/mapproxy
mapproxy/service/base.py
13
1692
# This file is part of the MapProxy project. # Copyright (C) 2010 Omniscale <http://omniscale.de> # # 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. """ Service handler (WMS, TMS, etc.). """ from mapproxy.exception import RequestError class Server(object): names = tuple() request_parser = lambda x: None request_methods = () def handle(self, req): try: parsed_req = self.parse_request(req) handler = getattr(self, parsed_req.request_handler_name) return handler(parsed_req) except RequestError as e: return e.render() def parse_request(self, req): return self.request_parser(req) def decorate_img(self, image, service, layers, environ, query_extent): """ Callback that allows the ImageSource associated with a response to be modified before it is returned. The callback is passed the ImageSource instance and must return a valid ImageSource """ if 'mapproxy.decorate_img' in environ: image = environ['mapproxy.decorate_img']( image, service, layers, environ=environ, query_extent=query_extent) return image
apache-2.0
[ 3, 961, 570, 365, 1777, 402, 314, 9672, 4936, 2199, 14, 199, 3, 1898, 334, 35, 9, 7129, 593, 10344, 374, 2357, 665, 1014, 921, 676, 26294, 2357, 14, 271, 30, 199, 3, 221, 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, 221, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 3167, 3016, 334, 55, 3053, 12, 377, 3053, 12, 5423, 25860, 199, 624, 199, 504, 2341, 3280, 14, 1971, 492, 4784, 547, 199, 199, 533, 7146, 8, 785, 304, 272, 1561, 275, 2008, 342, 272, 1056, 63, 2087, 275, 2400, 671, 26, 488, 272, 1056, 63, 2474, 275, 6248, 2286, 347, 2429, 8, 277, 12, 2648, 304, 267, 862, 26, 288, 4565, 63, 2103, 275, 291, 14, 1122, 63, 1069, 8, 2103, 9, 288, 3016, 275, 2519, 8, 277, 12, 4565, 63, 2103, 14, 1069, 63, 2232, 63, 354, 9, 288, 372, 3016, 8, 6751, 63, 2103, 9, 267, 871, 4784, 547, 465, 325, 26, 288, 372, 325, 14, 3352, 342, 2286, 347, 2198, 63, 1069, 8, 277, 12, 2648, 304, 267, 372, 291, 14, 1069, 63, 2087, 8, 2103, 9, 339, 347, 24774, 63, 4060, 8, 277, 12, 1834, 12, 2435, 12, 9393, 12, 6160, 12, 1827, 63, 11599, 304, 267, 408, 17555, 626, 6127, 314, 6047, 2980, 4568, 543, 282, 1177, 370, 288, 506, 6042, 2544, 652, 365, 2138, 14, 710, 3233, 365, 3032, 314, 288, 6047, 2980, 1256, 436, 1471, 372, 282, 1686, 6047, 2980, 408, 267, 340, 283, 1130, 3280, 14, 6518, 323, 63, 4060, 7, 315, 6160, 26, 288, 1834, 275, 6160, 459, 1130, 3280, 14, 6518, 323, 63, 4060, 21407, 355, 1834, 12, 2435, 12, 9393, 12, 6160, 29, 2314, 12, 1827, 63, 11599, 29, 1131, 63, 11599, 9, 267, 372, 1834, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1777, 402, 314, 9672, 4936, 2199, 14, 199, 3, 1898, 334, 35, 9, 7129, 593, 10344, 374, 2357, 665, 1014, 921, 676, 26294, 2357, 14, 271, 30, 199, 3, 221, 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, 221, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 3167, 3016, 334, 55, 3053, 12, 377, 3053, 12, 5423, 25860, 199, 624, 199, 504, 2341, 3280, 14, 1971, 492, 4784, 547, 199, 199, 533, 7146, 8, 785, 304, 272, 1561, 275, 2008, 342, 272, 1056, 63, 2087, 275, 2400, 671, 26, 488, 272, 1056, 63, 2474, 275, 6248, 2286, 347, 2429, 8, 277, 12, 2648, 304, 267, 862, 26, 288, 4565, 63, 2103, 275, 291, 14, 1122, 63, 1069, 8, 2103, 9, 288, 3016, 275, 2519, 8, 277, 12, 4565, 63, 2103, 14, 1069, 63, 2232, 63, 354, 9, 288, 372, 3016, 8, 6751, 63, 2103, 9, 267, 871, 4784, 547, 465, 325, 26, 288, 372, 325, 14, 3352, 342, 2286, 347, 2198, 63, 1069, 8, 277, 12, 2648, 304, 267, 372, 291, 14, 1069, 63, 2087, 8, 2103, 9, 339, 347, 24774, 63, 4060, 8, 277, 12, 1834, 12, 2435, 12, 9393, 12, 6160, 12, 1827, 63, 11599, 304, 267, 408, 17555, 626, 6127, 314, 6047, 2980, 4568, 543, 282, 1177, 370, 288, 506, 6042, 2544, 652, 365, 2138, 14, 710, 3233, 365, 3032, 314, 288, 6047, 2980, 1256, 436, 1471, 372, 282, 1686, 6047, 2980, 408, 267, 340, 283, 1130, 3280, 14, 6518, 323, 63, 4060, 7, 315, 6160, 26, 288, 1834, 275, 6160, 459, 1130, 3280, 14, 6518, 323, 63, 4060, 21407, 355, 1834, 12, 2435, 12, 9393, 12, 6160, 29, 2314, 12, 1827, 63, 11599, 29, 1131, 63, 11599, 9, 267, 372, 1834, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
MickSandoz/compassion-switzerland
sponsorship_switzerland/models/child.py
1
2660
# -*- encoding: utf-8 -*- ############################################################################## # # Copyright (C) 2016 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name # @author: Emanuel Cino <ecino@compassion.ch> # # The licence is in the file __openerp__.py # ############################################################################## from openerp import models, fields def major_revision(child, revised_values): """ Finds the correct communication to send. """ if len(revised_values) == 1: communication_type = child.env['partner.communication.config'].search([ ('name', 'ilike', revised_values.name), ('name', 'like', 'Major Revision'), ]) else: communication_type = child.env.ref( 'sponsorship_switzerland.major_revision_multiple') if communication_type: child.env['partner.communication.job'].create({ 'config_id': communication_type.id, 'partner_id': child.sponsor_id.id, 'object_id': child.id, }) class CompassionChild(models.Model): """ Add fields for retrieving values for communications. Send a communication when a major revision is received. """ _inherit = 'compassion.child' old_values = fields.Char(compute='_compute_revised_values') old_firstname = fields.Char(compute='_compute_revised_values') current_values = fields.Char(compute='_compute_revised_values') def _compute_revised_values(self): for child in self: child.old_values = ', '.join(child.revised_value_ids.translate( 'old_value')) child.current_values = child.revised_value_ids.get_field_value() child.old_firstname = child.revised_value_ids.filtered( lambda c: c.name == 'First Name').old_value or child.firstname def _major_revision(self, vals): """ Private method when a major revision is received for a child. Send a communication to the sponsor. """ super(CompassionChild, self)._major_revision(vals) if self.revised_value_ids and self.sponsor_id: major_revision(self, self.revised_value_ids) class Household(models.Model): """ Send Communication when Household Major Revision is received. """ _inherit = 'compassion.household' def _major_revision(self, vals): super(Household, self)._major_revision(vals) if self.revised_value_ids: for child in self.child_ids: if child.sponsor_id: major_revision(child, self.revised_value_ids)
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 7800, 3599, 305, 438, 6624, 334, 1014, 921, 1544, 14, 863, 305, 438, 14, 335, 9, 199, 3, 259, 799, 274, 11571, 4978, 687, 1115, 422, 369, 315, 1603, 397, 527, 7, 536, 199, 3, 259, 768, 2502, 26, 662, 1237, 13086, 445, 10175, 665, 825, 10175, 32, 863, 305, 438, 14, 335, 30, 199, 3, 199, 3, 259, 710, 23854, 4894, 365, 315, 314, 570, 636, 11267, 4343, 647, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 1709, 12, 1504, 421, 199, 318, 12160, 63, 5792, 8, 1739, 12, 295, 17311, 63, 1459, 304, 272, 408, 31434, 314, 3211, 23506, 370, 3222, 14, 408, 272, 340, 822, 8, 264, 17311, 63, 1459, 9, 508, 413, 26, 267, 23506, 63, 466, 275, 1982, 14, 1813, 459, 3899, 14, 29351, 14, 888, 2278, 1733, 779, 288, 661, 354, 297, 283, 27774, 297, 295, 17311, 63, 1459, 14, 354, 395, 288, 661, 354, 297, 283, 2930, 297, 283, 21657, 27095, 659, 267, 4794, 272, 587, 26, 267, 23506, 63, 466, 275, 1982, 14, 1813, 14, 1121, 8, 288, 283, 83, 29733, 3319, 63, 83, 2503, 2282, 9688, 14, 8452, 63, 5792, 63, 6048, 358, 272, 340, 23506, 63, 466, 26, 267, 1982, 14, 1813, 459, 3899, 14, 29351, 14, 2423, 2278, 981, 2561, 288, 283, 888, 63, 344, 356, 23506, 63, 466, 14, 344, 12, 288, 283, 3899, 63, 344, 356, 1982, 14, 83, 29733, 63, 344, 14, 344, 12, 288, 283, 785, 63, 344, 356, 1982, 14, 344, 12, 267, 3828, 421, 199, 533, 3599, 305, 438, 3493, 8, 992, 14, 1685, 304, 272, 408, 2654, 1504, 367, 23812, 1338, 367, 13882, 1298, 14, 272, 10217, 282, 23506, 1380, 282, 12160, 6974, 365, 3086, 14, 272, 408, 272, 485, 6486, 275, 283, 863, 305, 438, 14, 1739, 7, 339, 2269, 63, 1459, 275, 1504, 14, 1610, 8, 3357, 17574, 3357, 63, 264, 17311, 63, 1459, 358, 272, 2269, 63, 25603, 275, 1504, 14, 1610, 8, 3357, 17574, 3357, 63, 264, 17311, 63, 1459, 358, 272, 1453, 63, 1459, 275, 1504, 14, 1610, 8, 3357, 17574, 3357, 63, 264, 17311, 63, 1459, 358, 339, 347, 485, 3357, 63, 264, 17311, 63, 1459, 8, 277, 304, 267, 367, 1982, 315, 291, 26, 288, 1982, 14, 1753, 63, 1459, 275, 1656, 1987, 904, 8, 1739, 14, 264, 17311, 63, 585, 63, 1580, 14, 5275, 8, 355, 283, 1753, 63, 585, 1333, 288, 1982, 14, 1818, 63, 1459, 275, 1982, 14, 264, 17311, 63, 585, 63, 1580, 14, 362, 63, 698, 63, 585, 342, 288, 1982, 14, 1753, 63, 25603, 275, 1982, 14, 264, 17311, 63, 585, 63, 1580, 14, 11142, 8, 355, 2400, 286, 26, 286, 14, 354, 508, 283, 7147, 2812, 1959, 1753, 63, 585, 503, 1982, 14, 25603, 339, 347, 485, 8452, 63, 5792, 8, 277, 12, 5322, 304, 267, 408, 18551, 1083, 1380, 282, 12160, 6974, 365, 3086, 367, 282, 1982, 14, 288, 10217, 282, 23506, 370, 314, 308, 29733, 14, 267, 408, 267, 1613, 8, 2404, 305, 438, 3493, 12, 291, 10445, 8452, 63, 5792, 8, 3643, 9, 267, 340, 291, 14, 264, 17311, 63, 585, 63, 1580, 436, 291, 14, 83, 29733, 63, 344, 26, 288, 12160, 63, 5792, 8, 277, 12, 291, 14, 264, 17311, 63, 585, 63, 1580, 9, 421, 199, 533, 869, 7130, 12239, 8, 992, 14, 1685, 304, 272, 408, 10217, 29585, 1380, 869, 7130, 12239, 16593, 5857, 27095, 365, 3086, 14, 408, 272, 485, 6486, 275, 283, 863, 305, 438, 14, 6740, 12239, 7, 339, 347, 485, 8452, 63, 5792, 8, 277, 12, 5322, 304, 267, 1613, 8, 40, 7130, 12239, 12, 291, 10445, 8452, 63, 5792, 8, 3643, 9, 267, 340, 291, 14, 264, 17311, 63, 585, 63, 1580, 26, 288, 367, 1982, 315, 291, 14, 1739, 63, 1580, 26, 355, 340, 1982, 14, 83, 29733, 63, 344, 26, 490, 12160, 63, 5792, 8, 1739, 12, 291, 14, 264, 17311, 63, 585, 63, 1580, 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 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 1898, 334, 35, 9, 7800, 3599, 305, 438, 6624, 334, 1014, 921, 1544, 14, 863, 305, 438, 14, 335, 9, 199, 3, 259, 799, 274, 11571, 4978, 687, 1115, 422, 369, 315, 1603, 397, 527, 7, 536, 199, 3, 259, 768, 2502, 26, 662, 1237, 13086, 445, 10175, 665, 825, 10175, 32, 863, 305, 438, 14, 335, 30, 199, 3, 199, 3, 259, 710, 23854, 4894, 365, 315, 314, 570, 636, 11267, 4343, 647, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 1709, 12, 1504, 421, 199, 318, 12160, 63, 5792, 8, 1739, 12, 295, 17311, 63, 1459, 304, 272, 408, 31434, 314, 3211, 23506, 370, 3222, 14, 408, 272, 340, 822, 8, 264, 17311, 63, 1459, 9, 508, 413, 26, 267, 23506, 63, 466, 275, 1982, 14, 1813, 459, 3899, 14, 29351, 14, 888, 2278, 1733, 779, 288, 661, 354, 297, 283, 27774, 297, 295, 17311, 63, 1459, 14, 354, 395, 288, 661, 354, 297, 283, 2930, 297, 283, 21657, 27095, 659, 267, 4794, 272, 587, 26, 267, 23506, 63, 466, 275, 1982, 14, 1813, 14, 1121, 8, 288, 283, 83, 29733, 3319, 63, 83, 2503, 2282, 9688, 14, 8452, 63, 5792, 63, 6048, 358, 272, 340, 23506, 63, 466, 26, 267, 1982, 14, 1813, 459, 3899, 14, 29351, 14, 2423, 2278, 981, 2561, 288, 283, 888, 63, 344, 356, 23506, 63, 466, 14, 344, 12, 288, 283, 3899, 63, 344, 356, 1982, 14, 83, 29733, 63, 344, 14, 344, 12, 288, 283, 785, 63, 344, 356, 1982, 14, 344, 12, 267, 3828, 421, 199, 533, 3599, 305, 438, 3493, 8, 992, 14, 1685, 304, 272, 408, 2654, 1504, 367, 23812, 1338, 367, 13882, 1298, 14, 272, 10217, 282, 23506, 1380, 282, 12160, 6974, 365, 3086, 14, 272, 408, 272, 485, 6486, 275, 283, 863, 305, 438, 14, 1739, 7, 339, 2269, 63, 1459, 275, 1504, 14, 1610, 8, 3357, 17574, 3357, 63, 264, 17311, 63, 1459, 358, 272, 2269, 63, 25603, 275, 1504, 14, 1610, 8, 3357, 17574, 3357, 63, 264, 17311, 63, 1459, 358, 272, 1453, 63, 1459, 275, 1504, 14, 1610, 8, 3357, 17574, 3357, 63, 264, 17311, 63, 1459, 358, 339, 347, 485, 3357, 63, 264, 17311, 63, 1459, 8, 277, 304, 267, 367, 1982, 315, 291, 26, 288, 1982, 14, 1753, 63, 1459, 275, 1656, 1987, 904, 8, 1739, 14, 264, 17311, 63, 585, 63, 1580, 14, 5275, 8, 355, 283, 1753, 63, 585, 1333, 288, 1982, 14, 1818, 63, 1459, 275, 1982, 14, 264, 17311, 63, 585, 63, 1580, 14, 362, 63, 698, 63, 585, 342, 288, 1982, 14, 1753, 63, 25603, 275, 1982, 14, 264, 17311, 63, 585, 63, 1580, 14, 11142, 8, 355, 2400, 286, 26, 286, 14, 354, 508, 283, 7147, 2812, 1959, 1753, 63, 585, 503, 1982, 14, 25603, 339, 347, 485, 8452, 63, 5792, 8, 277, 12, 5322, 304, 267, 408, 18551, 1083, 1380, 282, 12160, 6974, 365, 3086, 367, 282, 1982, 14, 288, 10217, 282, 23506, 370, 314, 308, 29733, 14, 267, 408, 267, 1613, 8, 2404, 305, 438, 3493, 12, 291, 10445, 8452, 63, 5792, 8, 3643, 9, 267, 340, 291, 14, 264, 17311, 63, 585, 63, 1580, 436, 291, 14, 83, 29733, 63, 344, 26, 288, 12160, 63, 5792, 8, 277, 12, 291, 14, 264, 17311, 63, 585, 63, 1580, 9, 421, 199, 533, 869, 7130, 12239, 8, 992, 14, 1685, 304, 272, 408, 10217, 29585, 1380, 869, 7130, 12239, 16593, 5857, 27095, 365, 3086, 14, 408, 272, 485, 6486, 275, 283, 863, 305, 438, 14, 6740, 12239, 7, 339, 347, 485, 8452, 63, 5792, 8, 277, 12, 5322, 304, 267, 1613, 8, 40, 7130, 12239, 12, 291, 10445, 8452, 63, 5792, 8, 3643, 9, 267, 340, 291, 14, 264, 17311, 63, 585, 63, 1580, 26, 288, 367, 1982, 315, 291, 14, 1739, 63, 1580, 26, 355, 340, 1982, 14, 83, 29733, 63, 344, 26, 490, 12160, 63, 5792, 8, 1739, 12, 291, 14, 264, 17311, 63, 585, 63, 1580, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
birdsarah/bokeh
examples/embed/slideshow/app_reveal.py
42
7875
# -*- coding: utf-8 -*- """ In this example, we want to show you how you can take isolated blocks of code (featuring different kinds of Bokeh visualizations) and rearrange them in a bigger (encompassing) flask-based application without losing the independence of each example. This is the reason of some weirdness through the code. We are using this "building blocks" approach here because we believe it has some conceptual advantages for people trying to quickly understand, and more importantly, use the embed API, in a more complex way than just a simple script. """ import time from threading import Thread import numpy as np import scipy.special from bokeh.embed import autoload_server from bokeh.models import GlyphRenderer from bokeh.plotting import cursession, figure, output_server, push from flask import Flask, render_template app = Flask(__name__) @app.route('/') def render_plot(): """ Get the script tags from each plot object and "insert" them into the template. This also starts different threads for each update function, so you can have a non-blocking update. """ dist_plot, dist_session = distribution() dist_tag = autoload_server(dist_plot, dist_session) anim_plot, anim_session = animated() anim_tag = autoload_server(anim_plot, anim_session) # for update_animation as target we need to pass the anim_plot and anim_session as args thread = Thread(target=update_animation, args=(anim_plot, anim_session)) thread.start() pop = Population() pop_tag = autoload_server(pop.layout, pop.session) # for update_population as target we need to pass the pop instance as args thread = Thread(target=update_population, args=(pop,)) thread.start() return render_template('app_plot.html', tag1=dist_tag, tag2=anim_tag, tag3=pop_tag) def distribution(): mu, sigma = 0, 0.5 measured = np.random.normal(mu, sigma, 1000) hist, edges = np.histogram(measured, density=True, bins=20) x = np.linspace(-2, 2, 1000) pdf = 1 / (sigma * np.sqrt(2 * np.pi)) * np.exp(-(x - mu) ** 2 / (2 * sigma ** 2)) cdf = (1 + scipy.special.erf((x - mu) / np.sqrt(2 * sigma ** 2))) / 2 output_server("distribution_reveal") p = figure(title="Interactive plots", background_fill="#E5E5E5") p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], fill_color="#333333", line_color="#E5E5E5", line_width=3) # Use `line` renderers to display the PDF and CDF p.line(x, pdf, line_color="#348abd", line_width=8, alpha=0.7, legend="PDF") p.line(x, cdf, line_color="#7a68a6", line_width=8, alpha=0.7, legend="CDF") p.legend.orientation = "top_left" p.xaxis.axis_label = 'x' p.xgrid[0].grid_line_color = "white" p.xgrid[0].grid_line_width = 3 p.yaxis.axis_label = 'Pr(x)' p.ygrid[0].grid_line_color = "white" p.ygrid[0].grid_line_width = 3 push() return p, cursession() def animated(): from numpy import pi, cos, sin, linspace N = 50 + 1 r_base = 8 theta = linspace(0, 2 * pi, N) r_x = linspace(0, 6 * pi, N - 1) rmin = r_base - cos(r_x) - 1 rmax = r_base + sin(r_x) + 1 colors = ["FFFFCC", "#C7E9B4", "#7FCDBB", "#41B6C4", "#2C7FB8", "#253494", "#2C7FB8", "#41B6C4", "#7FCDBB", "#C7E9B4"] * 5 output_server("animated_reveal") p = figure(title="Animations", x_range=[-11, 11], y_range=[-11, 11]) p.annular_wedge( 0, 0, rmin, rmax, theta[:-1], theta[1:], inner_radius_units="data", outer_radius_units="data", fill_color=colors, line_color="black", ) push() return p, cursession() def update_animation(plot, session): from numpy import roll renderer = plot.select(dict(type=GlyphRenderer)) ds = renderer[0].data_source while True: rmin = ds.data["inner_radius"] rmin = roll(rmin, 1) ds.data["inner_radius"] = rmin rmax = ds.data["outer_radius"] rmax = roll(rmax, -1) ds.data["outer_radius"] = rmax cursession().store_objects(ds) time.sleep(0.1) class Population(object): year = 2010 location = "World" def __init__(self): from bokeh.models import ColumnDataSource from bokeh.document import Document from bokeh.session import Session from bokeh.sampledata.population import load_population self.document = Document() self.session = Session() self.session.use_doc('population_reveal') self.session.load_document(self.document) self.df = load_population() self.source_pyramid = ColumnDataSource(data=dict()) # just render at the initialization self._render() def _render(self): self.pyramid_plot() self.create_layout() self.document.add(self.layout) self.update_pyramid() def pyramid_plot(self): from bokeh.models import (Plot, DataRange1d, LinearAxis, Grid, Legend, SingleIntervalTicker) from bokeh.models.glyphs import Quad xdr = DataRange1d() ydr = DataRange1d() self.plot = Plot(title="Widgets", x_range=xdr, y_range=ydr, plot_width=600, plot_height=600) xaxis = LinearAxis() self.plot.add_layout(xaxis, 'below') yaxis = LinearAxis(ticker=SingleIntervalTicker(interval=5)) self.plot.add_layout(yaxis, 'left') self.plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker)) self.plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) male_quad = Quad(left="male", right=0, bottom="groups", top="shifted", fill_color="#3B8686") male_quad_glyph = self.plot.add_glyph(self.source_pyramid, male_quad) female_quad = Quad(left=0, right="female", bottom="groups", top="shifted", fill_color="#CFF09E") female_quad_glyph = self.plot.add_glyph(self.source_pyramid, female_quad) self.plot.add_layout(Legend(legends=dict(Male=[male_quad_glyph], Female=[female_quad_glyph]))) def on_year_change(self, obj, attr, old, new): self.year = int(new) self.update_pyramid() def on_location_change(self, obj, attr, old, new): self.location = new self.update_pyramid() def create_layout(self): from bokeh.models.widgets import Select, HBox, VBox years = list(map(str, sorted(self.df.Year.unique()))) locations = sorted(self.df.Location.unique()) year_select = Select(title="Year:", value="2010", options=years) location_select = Select(title="Location:", value="World", options=locations) year_select.on_change('value', self.on_year_change) location_select.on_change('value', self.on_location_change) controls = HBox(year_select, location_select) self.layout = VBox(controls, self.plot) def update_pyramid(self): pyramid = self.df[(self.df.Location == self.location) & (self.df.Year == self.year)] male = pyramid[pyramid.Sex == "Male"] female = pyramid[pyramid.Sex == "Female"] total = male.Value.sum() + female.Value.sum() male_percent = -male.Value / total female_percent = female.Value / total groups = male.AgeGrpStart.tolist() shifted = groups[1:] + [groups[-1] + 5] self.source_pyramid.data = dict( groups=groups, shifted=shifted, male=male_percent, female=female_percent, ) self.session.store_document(self.document) def update_population(plot): while True: plot.session.load_document(plot.document) time.sleep(0.1) if __name__ == '__main__': app.run(debug=True)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 607, 642, 2893, 12, 781, 2934, 370, 2498, 1265, 4212, 1265, 883, 5452, 23348, 5664, 402, 1233, 199, 8, 11873, 4039, 3365, 24241, 402, 5088, 16610, 13104, 12270, 9, 436, 295, 285, 1842, 3062, 315, 282, 199, 5076, 836, 334, 287, 863, 405, 316, 9, 7209, 13, 6788, 4223, 1928, 560, 1044, 314, 31043, 29578, 199, 1618, 1924, 2893, 14, 961, 365, 314, 4499, 402, 2005, 22965, 4171, 4012, 314, 1233, 14, 199, 6004, 787, 1808, 642, 298, 17952, 5664, 2, 18140, 2348, 2952, 781, 506, 317, 4754, 652, 965, 2005, 199, 21318, 1061, 19396, 867, 7441, 367, 13135, 9936, 370, 23661, 20647, 12, 436, 1655, 199, 19559, 590, 12, 675, 314, 6441, 3261, 12, 315, 282, 1655, 6114, 4340, 2419, 2951, 282, 3486, 2884, 14, 199, 624, 199, 646, 900, 199, 504, 5796, 492, 11086, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 6664, 199, 199, 504, 25214, 14, 6427, 492, 2599, 912, 63, 1000, 199, 504, 25214, 14, 992, 492, 598, 7234, 11355, 199, 504, 25214, 14, 2798, 1337, 492, 1094, 1730, 12, 9658, 12, 1072, 63, 1000, 12, 6675, 199, 199, 504, 7209, 492, 16704, 12, 3795, 63, 1160, 199, 571, 275, 16704, 3460, 354, 3368, 199, 199, 32, 571, 14, 4449, 7825, 199, 318, 3795, 63, 2798, 837, 272, 408, 272, 2372, 314, 2884, 3762, 687, 1924, 5137, 909, 436, 298, 3176, 2, 3062, 1901, 314, 1978, 14, 339, 961, 2597, 9174, 3365, 7183, 367, 1924, 1678, 805, 12, 880, 1265, 883, 1172, 272, 282, 2222, 13, 13091, 1678, 14, 272, 408, 272, 2917, 63, 2798, 12, 2917, 63, 1730, 275, 4084, 342, 272, 2917, 63, 1450, 275, 2599, 912, 63, 1000, 8, 2686, 63, 2798, 12, 2917, 63, 1730, 9, 339, 27183, 63, 2798, 12, 27183, 63, 1730, 275, 376, 12754, 342, 272, 27183, 63, 1450, 275, 2599, 912, 63, 1000, 8, 22019, 63, 2798, 12, 27183, 63, 1730, 9, 272, 327, 367, 1678, 63, 22228, 465, 1347, 781, 1929, 370, 986, 314, 27183, 63, 2798, 436, 27183, 63, 1730, 465, 1249, 272, 2462, 275, 11086, 8, 1375, 29, 873, 63, 22228, 12, 1249, 2687, 22019, 63, 2798, 12, 27183, 63, 1730, 430, 272, 2462, 14, 928, 342, 339, 4560, 275, 13244, 5332, 342, 272, 4560, 63, 1450, 275, 2599, 912, 63, 1000, 8, 1935, 14, 4209, 12, 4560, 14, 1730, 9, 272, 327, 367, 1678, 63, 16003, 465, 1347, 781, 1929, 370, 986, 314, 4560, 1256, 465, 1249, 272, 2462, 275, 11086, 8, 1375, 29, 873, 63, 16003, 12, 1249, 2687, 1935, 4641, 272, 2462, 14, 928, 342, 339, 372, 3795, 63, 1160, 360, 571, 63, 2798, 14, 1360, 297, 1947, 17, 29, 2686, 63, 1450, 12, 1947, 18, 29, 22019, 63, 1450, 12, 1947, 19, 29, 1935, 63, 1450, 9, 421, 199, 318, 4084, 837, 339, 8504, 12, 10819, 275, 378, 12, 378, 14, 21, 339, 27396, 275, 980, 14, 2355, 14, 3302, 8, 6553, 12, 10819, 12, 5198, 9, 272, 13612, 12, 8207, 275, 980, 14, 14805, 8, 19116, 3297, 12, 13650, 29, 549, 12, 13341, 29, 1165, 9, 339, 671, 275, 980, 14, 11649, 2801, 18, 12, 499, 12, 5198, 9, 272, 11249, 275, 413, 1182, 334, 9412, 627, 980, 14, 5079, 8, 18, 627, 980, 14, 1038, 430, 627, 980, 14, 1474, 2801, 8, 88, 446, 8504, 9, 1011, 499, 1182, 334, 18, 627, 10819, 1011, 499, 430, 272, 26037, 275, 334, 17, 435, 7026, 14, 6664, 14, 31740, 1332, 88, 446, 8504, 9, 1182, 980, 14, 5079, 8, 18, 627, 10819, 1011, 499, 1724, 1182, 499, 339, 1072, 63, 1000, 480, 4972, 63, 30496, 279, 531, 339, 299, 275, 9658, 8, 1213, 628, 23879, 19695, 401, 2049, 8020, 63, 4498, 13476, 37, 21, 37, 21, 37, 21, 531, 272, 299, 14, 14567, 8, 2119, 29, 11141, 12, 9048, 29, 16, 12, 3602, 29, 6929, 4439, 17, 467, 2451, 29, 6929, 59, 17, 8429, 1779, 5554, 63, 2326, 13476, 28380, 401, 1004, 63, 2326, 13476, 37, 21, 37, 21, 37, 21, 401, 1004, 63, 2063, 29, 19, 9, 339, 327, 3645, 658, 604, 64, 2903, 26529, 370, 2929, 314, 15537, 436, 445, 3888, 272, 299, 14, 604, 8, 88, 12, 11249, 12, 1004, 63, 2326, 13476, 13442, 25492, 401, 1004, 63, 2063, 29, 24, 12, 5131, 29, 16, 14, 23, 12, 15906, 628, 7638, 531, 272, 299, 14, 604, 8, 88, 12, 26037, 12, 1004, 63, 2326, 13476, 23, 65, 2333, 65, 22, 401, 1004, 63, 2063, 29, 24, 12, 5131, 29, 16, 14, 23, 12, 15906, 628, 18967, 531, 339, 299, 14, 10231, 14, 17001, 275, 298, 2119, 63, 3039, 2, 339, 299, 14, 21854, 14, 3127, 63, 1302, 275, 283, 88, 7, 272, 299, 14, 88, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2326, 275, 298, 7510, 2, 272, 299, 14, 88, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2063, 275, 650, 339, 299, 14, 23876, 14, 3127, 63, 1302, 275, 283, 9779, 8, 88, 3171, 272, 299, 14, 89, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2326, 275, 298, 7510, 2, 272, 299, 14, 89, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2063, 275, 650, 339, 6675, 342, 339, 372, 299, 12, 1094, 1730, 342, 421, 199, 318, 376, 12754, 837, 339, 687, 2680, 492, 6682, 12, 9794, 12, 9829, 12, 7403, 2638, 339, 653, 275, 5238, 435, 413, 272, 519, 63, 1095, 275, 1695, 272, 12724, 275, 7403, 2638, 8, 16, 12, 499, 627, 6682, 12, 653, 9, 272, 519, 63, 88, 275, 7403, 2638, 8, 16, 12, 1227, 627, 6682, 12, 653, 446, 413, 9, 272, 519, 827, 275, 519, 63, 1095, 446, 9794, 8, 82, 63, 88, 9, 446, 413, 272, 519, 988, 275, 519, 63, 1095, 435, 9829, 8, 82, 63, 88, 9, 435, 413, 339, 9229, 275, 2097, 6968, 2571, 401, 5426, 35, 23, 37, 25, 34, 20, 401, 5426, 23, 4161, 2846, 34, 401, 5426, 2953, 34, 22, 35, 20, 401, 5426, 18, 35, 23, 8223, 24, 401, 1598, 5426, 28047, 2635, 401, 5426, 18, 35, 23, 8223, 24, 401, 5426, 2953, 34, 22, 35, 20, 401, 5426 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 607, 642, 2893, 12, 781, 2934, 370, 2498, 1265, 4212, 1265, 883, 5452, 23348, 5664, 402, 1233, 199, 8, 11873, 4039, 3365, 24241, 402, 5088, 16610, 13104, 12270, 9, 436, 295, 285, 1842, 3062, 315, 282, 199, 5076, 836, 334, 287, 863, 405, 316, 9, 7209, 13, 6788, 4223, 1928, 560, 1044, 314, 31043, 29578, 199, 1618, 1924, 2893, 14, 961, 365, 314, 4499, 402, 2005, 22965, 4171, 4012, 314, 1233, 14, 199, 6004, 787, 1808, 642, 298, 17952, 5664, 2, 18140, 2348, 2952, 781, 506, 317, 4754, 652, 965, 2005, 199, 21318, 1061, 19396, 867, 7441, 367, 13135, 9936, 370, 23661, 20647, 12, 436, 1655, 199, 19559, 590, 12, 675, 314, 6441, 3261, 12, 315, 282, 1655, 6114, 4340, 2419, 2951, 282, 3486, 2884, 14, 199, 624, 199, 646, 900, 199, 504, 5796, 492, 11086, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 6664, 199, 199, 504, 25214, 14, 6427, 492, 2599, 912, 63, 1000, 199, 504, 25214, 14, 992, 492, 598, 7234, 11355, 199, 504, 25214, 14, 2798, 1337, 492, 1094, 1730, 12, 9658, 12, 1072, 63, 1000, 12, 6675, 199, 199, 504, 7209, 492, 16704, 12, 3795, 63, 1160, 199, 571, 275, 16704, 3460, 354, 3368, 199, 199, 32, 571, 14, 4449, 7825, 199, 318, 3795, 63, 2798, 837, 272, 408, 272, 2372, 314, 2884, 3762, 687, 1924, 5137, 909, 436, 298, 3176, 2, 3062, 1901, 314, 1978, 14, 339, 961, 2597, 9174, 3365, 7183, 367, 1924, 1678, 805, 12, 880, 1265, 883, 1172, 272, 282, 2222, 13, 13091, 1678, 14, 272, 408, 272, 2917, 63, 2798, 12, 2917, 63, 1730, 275, 4084, 342, 272, 2917, 63, 1450, 275, 2599, 912, 63, 1000, 8, 2686, 63, 2798, 12, 2917, 63, 1730, 9, 339, 27183, 63, 2798, 12, 27183, 63, 1730, 275, 376, 12754, 342, 272, 27183, 63, 1450, 275, 2599, 912, 63, 1000, 8, 22019, 63, 2798, 12, 27183, 63, 1730, 9, 272, 327, 367, 1678, 63, 22228, 465, 1347, 781, 1929, 370, 986, 314, 27183, 63, 2798, 436, 27183, 63, 1730, 465, 1249, 272, 2462, 275, 11086, 8, 1375, 29, 873, 63, 22228, 12, 1249, 2687, 22019, 63, 2798, 12, 27183, 63, 1730, 430, 272, 2462, 14, 928, 342, 339, 4560, 275, 13244, 5332, 342, 272, 4560, 63, 1450, 275, 2599, 912, 63, 1000, 8, 1935, 14, 4209, 12, 4560, 14, 1730, 9, 272, 327, 367, 1678, 63, 16003, 465, 1347, 781, 1929, 370, 986, 314, 4560, 1256, 465, 1249, 272, 2462, 275, 11086, 8, 1375, 29, 873, 63, 16003, 12, 1249, 2687, 1935, 4641, 272, 2462, 14, 928, 342, 339, 372, 3795, 63, 1160, 360, 571, 63, 2798, 14, 1360, 297, 1947, 17, 29, 2686, 63, 1450, 12, 1947, 18, 29, 22019, 63, 1450, 12, 1947, 19, 29, 1935, 63, 1450, 9, 421, 199, 318, 4084, 837, 339, 8504, 12, 10819, 275, 378, 12, 378, 14, 21, 339, 27396, 275, 980, 14, 2355, 14, 3302, 8, 6553, 12, 10819, 12, 5198, 9, 272, 13612, 12, 8207, 275, 980, 14, 14805, 8, 19116, 3297, 12, 13650, 29, 549, 12, 13341, 29, 1165, 9, 339, 671, 275, 980, 14, 11649, 2801, 18, 12, 499, 12, 5198, 9, 272, 11249, 275, 413, 1182, 334, 9412, 627, 980, 14, 5079, 8, 18, 627, 980, 14, 1038, 430, 627, 980, 14, 1474, 2801, 8, 88, 446, 8504, 9, 1011, 499, 1182, 334, 18, 627, 10819, 1011, 499, 430, 272, 26037, 275, 334, 17, 435, 7026, 14, 6664, 14, 31740, 1332, 88, 446, 8504, 9, 1182, 980, 14, 5079, 8, 18, 627, 10819, 1011, 499, 1724, 1182, 499, 339, 1072, 63, 1000, 480, 4972, 63, 30496, 279, 531, 339, 299, 275, 9658, 8, 1213, 628, 23879, 19695, 401, 2049, 8020, 63, 4498, 13476, 37, 21, 37, 21, 37, 21, 531, 272, 299, 14, 14567, 8, 2119, 29, 11141, 12, 9048, 29, 16, 12, 3602, 29, 6929, 4439, 17, 467, 2451, 29, 6929, 59, 17, 8429, 1779, 5554, 63, 2326, 13476, 28380, 401, 1004, 63, 2326, 13476, 37, 21, 37, 21, 37, 21, 401, 1004, 63, 2063, 29, 19, 9, 339, 327, 3645, 658, 604, 64, 2903, 26529, 370, 2929, 314, 15537, 436, 445, 3888, 272, 299, 14, 604, 8, 88, 12, 11249, 12, 1004, 63, 2326, 13476, 13442, 25492, 401, 1004, 63, 2063, 29, 24, 12, 5131, 29, 16, 14, 23, 12, 15906, 628, 7638, 531, 272, 299, 14, 604, 8, 88, 12, 26037, 12, 1004, 63, 2326, 13476, 23, 65, 2333, 65, 22, 401, 1004, 63, 2063, 29, 24, 12, 5131, 29, 16, 14, 23, 12, 15906, 628, 18967, 531, 339, 299, 14, 10231, 14, 17001, 275, 298, 2119, 63, 3039, 2, 339, 299, 14, 21854, 14, 3127, 63, 1302, 275, 283, 88, 7, 272, 299, 14, 88, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2326, 275, 298, 7510, 2, 272, 299, 14, 88, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2063, 275, 650, 339, 299, 14, 23876, 14, 3127, 63, 1302, 275, 283, 9779, 8, 88, 3171, 272, 299, 14, 89, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2326, 275, 298, 7510, 2, 272, 299, 14, 89, 3825, 59, 16, 1055, 3825, 63, 604, 63, 2063, 275, 650, 339, 6675, 342, 339, 372, 299, 12, 1094, 1730, 342, 421, 199, 318, 376, 12754, 837, 339, 687, 2680, 492, 6682, 12, 9794, 12, 9829, 12, 7403, 2638, 339, 653, 275, 5238, 435, 413, 272, 519, 63, 1095, 275, 1695, 272, 12724, 275, 7403, 2638, 8, 16, 12, 499, 627, 6682, 12, 653, 9, 272, 519, 63, 88, 275, 7403, 2638, 8, 16, 12, 1227, 627, 6682, 12, 653, 446, 413, 9, 272, 519, 827, 275, 519, 63, 1095, 446, 9794, 8, 82, 63, 88, 9, 446, 413, 272, 519, 988, 275, 519, 63, 1095, 435, 9829, 8, 82, 63, 88, 9, 435, 413, 339, 9229, 275, 2097, 6968, 2571, 401, 5426, 35, 23, 37, 25, 34, 20, 401, 5426, 23, 4161, 2846, 34, 401, 5426, 2953, 34, 22, 35, 20, 401, 5426, 18, 35, 23, 8223, 24, 401, 1598, 5426, 28047, 2635, 401, 5426, 18, 35, 23, 8223, 24, 401, 5426, 2953, 34, 22, 35, 20, 401, 5426, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Unidata/MetPy
v0.6/_downloads/Find_Natural_Neighbors_Verification.py
3
2729
# Copyright (c) 2016 MetPy Developers. # Distributed under the terms of the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause """ Find Natural Neighbors Verification =================================== Finding natural neighbors in a triangulation A triangle is a natural neighbor of a point if that point is within a circumradius of the circumcenter of a circumscribed circle containing the triangle. """ import matplotlib.pyplot as plt import numpy as np from scipy.spatial import Delaunay from metpy.gridding.triangles import find_natural_neighbors # Create test observations, test points, and plot the triangulation and points. gx, gy = np.meshgrid(np.arange(0, 20, 4), np.arange(0, 20, 4)) pts = np.vstack([gx.ravel(), gy.ravel()]).T tri = Delaunay(pts) fig, ax = plt.subplots(figsize=(15, 10)) for i, inds in enumerate(tri.simplices): pts = tri.points[inds] x, y = np.vstack((pts, pts[0])).T ax.plot(x, y) ax.annotate(i, xy=(np.mean(x), np.mean(y))) test_points = np.array([[2, 2], [5, 10], [12, 13.4], [12, 8], [20, 20]]) for i, (x, y) in enumerate(test_points): ax.plot(x, y, 'k.', markersize=6) ax.annotate('test ' + str(i), xy=(x, y)) ########################################### # Since finding natural neighbors already calculates circumcenters and circumradii, return # that information for later use. # # The key of the neighbors dictionary refers to the test point index, and the list of integers # are the triangles that are natural neighbors of that particular test point. # # Since point 4 is far away from the triangulation, it has no natural neighbors. # Point 3 is at the confluence of several triangles so it has many natural neighbors. neighbors, tri_info = find_natural_neighbors(tri, test_points) print(neighbors) ########################################### # We can then use the information in tri_info later. # # The dictionary key is the index of a particular triangle in the Delaunay triangulation data # structure. 'cc' is that triangle's circumcenter, and 'r' is the radius of the circumcircle # containing that triangle. fig, ax = plt.subplots(figsize=(15, 10)) for i, inds in enumerate(tri.simplices): pts = tri.points[inds] x, y = np.vstack((pts, pts[0])).T ax.plot(x, y) ax.annotate(i, xy=(np.mean(x), np.mean(y))) # Using circumcenter and radius information from tri_info, plot circumcircles and # circumcenters for each triangle. for _idx, item in tri_info.items(): ax.plot(item['cc'][0], item['cc'][1], 'k.', markersize=5) circ = plt.Circle(item['cc'], item['r'], edgecolor='k', facecolor='none', transform=fig.axes[0].transData) ax.add_artist(circ) ax.set_aspect('equal', 'datalim') plt.show()
bsd-3-clause
[ 3, 1898, 334, 67, 9, 7800, 10072, 2713, 23493, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 6289, 650, 13, 16009, 844, 14, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 6289, 13, 19, 13, 16009, 199, 624, 199, 6591, 653, 292, 4889, 5612, 7398, 5444, 7313, 199, 2486, 5918, 199, 199, 6591, 316, 19981, 15845, 315, 282, 3229, 621, 5332, 199, 199, 33, 26268, 365, 282, 19981, 15503, 402, 282, 2376, 340, 626, 2376, 365, 4453, 282, 27027, 8017, 402, 314, 199, 6092, 453, 4218, 402, 282, 27027, 14922, 17990, 3035, 314, 26268, 14, 199, 624, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 11679, 492, 18464, 65, 324, 1187, 199, 199, 504, 7647, 647, 14, 7928, 617, 316, 14, 599, 13162, 492, 2342, 63, 15759, 63, 11113, 199, 199, 3, 2790, 511, 19739, 12, 511, 4501, 12, 436, 5137, 314, 3229, 621, 5332, 436, 4501, 14, 199, 20777, 12, 28089, 275, 980, 14, 6480, 3825, 8, 1590, 14, 5605, 8, 16, 12, 3388, 12, 841, 395, 980, 14, 5605, 8, 16, 12, 3388, 12, 841, 430, 199, 8382, 275, 980, 14, 20221, 779, 20777, 14, 11186, 1062, 28089, 14, 11186, 342, 6575, 52, 199, 599, 275, 18464, 65, 324, 1187, 8, 8382, 9, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 23899, 2687, 1046, 12, 1616, 430, 199, 509, 284, 12, 315, 795, 315, 3874, 8, 599, 14, 11184, 7598, 304, 272, 21286, 275, 3229, 14, 3438, 59, 18212, 61, 272, 671, 12, 612, 275, 980, 14, 20221, 1332, 8382, 12, 21286, 59, 16, 2459, 14, 52, 272, 2185, 14, 2798, 8, 88, 12, 612, 9, 272, 2185, 14, 10898, 8, 73, 12, 13222, 2687, 1590, 14, 3670, 8, 88, 395, 980, 14, 3670, 8, 89, 1724, 199, 199, 396, 63, 3438, 275, 980, 14, 1144, 4038, 18, 12, 499, 467, 359, 21, 12, 1616, 467, 359, 713, 12, 4944, 14, 20, 467, 359, 713, 12, 1695, 467, 359, 1165, 12, 3388, 3934, 199, 199, 509, 284, 12, 334, 88, 12, 612, 9, 315, 3874, 8, 396, 63, 3438, 304, 272, 2185, 14, 2798, 8, 88, 12, 612, 12, 283, 75, 3130, 3608, 890, 29, 22, 9, 272, 2185, 14, 10898, 360, 396, 283, 435, 620, 8, 73, 395, 13222, 2687, 88, 12, 612, 430, 199, 199, 26634, 5680, 199, 3, 9336, 17196, 19981, 15845, 2575, 6966, 2335, 27027, 15660, 436, 27027, 12841, 73, 12, 372, 199, 3, 626, 2556, 367, 2945, 675, 14, 199, 3, 199, 3, 710, 790, 402, 314, 15845, 2600, 15724, 370, 314, 511, 2376, 1478, 12, 436, 314, 769, 402, 9446, 199, 3, 787, 314, 3229, 13162, 626, 787, 19981, 15845, 402, 626, 6770, 511, 2376, 14, 199, 3, 199, 3, 9336, 2376, 841, 365, 12474, 13437, 687, 314, 3229, 621, 5332, 12, 652, 965, 949, 19981, 15845, 14, 199, 3, 7584, 650, 365, 737, 314, 406, 24585, 402, 9978, 3229, 13162, 880, 652, 965, 5002, 19981, 15845, 14, 199, 11113, 12, 3229, 63, 815, 275, 2342, 63, 15759, 63, 11113, 8, 599, 12, 511, 63, 3438, 9, 199, 1361, 8, 11113, 9, 199, 199, 26634, 5680, 199, 3, 2136, 883, 2066, 675, 314, 2556, 315, 3229, 63, 815, 2945, 14, 199, 3, 199, 3, 710, 2600, 790, 365, 314, 1478, 402, 282, 6770, 26268, 315, 314, 18464, 65, 324, 1187, 3229, 621, 5332, 666, 199, 3, 5523, 14, 283, 2055, 7, 365, 626, 26268, 1159, 27027, 4218, 12, 436, 283, 82, 7, 365, 314, 9362, 402, 314, 27027, 11001, 199, 3, 3035, 626, 26268, 14, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 23899, 2687, 1046, 12, 1616, 430, 199, 509, 284, 12, 315, 795, 315, 3874, 8, 599, 14, 11184, 7598, 304, 272, 21286, 275, 3229, 14, 3438, 59, 18212, 61, 272, 671, 12, 612, 275, 980, 14, 20221, 1332, 8382, 12, 21286, 59, 16, 2459, 14, 52, 272, 2185, 14, 2798, 8, 88, 12, 612, 9, 272, 2185, 14, 10898, 8, 73, 12, 13222, 2687, 1590, 14, 3670, 8, 88, 395, 980, 14, 3670, 8, 89, 1724, 199, 199, 3, 11719, 27027, 4218, 436, 9362, 2556, 687, 3229, 63, 815, 12, 5137, 27027, 6092, 2978, 436, 199, 3, 27027, 15660, 367, 1924, 26268, 14, 199, 509, 485, 2996, 12, 1242, 315, 3229, 63, 815, 14, 1744, 837, 272, 2185, 14, 2798, 8, 1053, 459, 2055, 3488, 16, 467, 1242, 459, 2055, 3488, 17, 467, 283, 75, 3130, 3608, 890, 29, 21, 9, 272, 9304, 275, 4488, 14, 24587, 8, 1053, 459, 2055, 995, 1242, 459, 82, 995, 6275, 2326, 534, 75, 297, 8870, 2326, 534, 3592, 297, 1993, 5793, 29, 592, 14, 6402, 59, 16, 1055, 1515, 1451, 9, 272, 2185, 14, 525, 63, 11215, 8, 6092, 9, 199, 199, 1219, 14, 409, 63, 18658, 360, 1452, 297, 283, 4616, 279, 1017, 358, 199, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 7800, 10072, 2713, 23493, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 6289, 650, 13, 16009, 844, 14, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 6289, 13, 19, 13, 16009, 199, 624, 199, 6591, 653, 292, 4889, 5612, 7398, 5444, 7313, 199, 2486, 5918, 199, 199, 6591, 316, 19981, 15845, 315, 282, 3229, 621, 5332, 199, 199, 33, 26268, 365, 282, 19981, 15503, 402, 282, 2376, 340, 626, 2376, 365, 4453, 282, 27027, 8017, 402, 314, 199, 6092, 453, 4218, 402, 282, 27027, 14922, 17990, 3035, 314, 26268, 14, 199, 624, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 11679, 492, 18464, 65, 324, 1187, 199, 199, 504, 7647, 647, 14, 7928, 617, 316, 14, 599, 13162, 492, 2342, 63, 15759, 63, 11113, 199, 199, 3, 2790, 511, 19739, 12, 511, 4501, 12, 436, 5137, 314, 3229, 621, 5332, 436, 4501, 14, 199, 20777, 12, 28089, 275, 980, 14, 6480, 3825, 8, 1590, 14, 5605, 8, 16, 12, 3388, 12, 841, 395, 980, 14, 5605, 8, 16, 12, 3388, 12, 841, 430, 199, 8382, 275, 980, 14, 20221, 779, 20777, 14, 11186, 1062, 28089, 14, 11186, 342, 6575, 52, 199, 599, 275, 18464, 65, 324, 1187, 8, 8382, 9, 199, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 23899, 2687, 1046, 12, 1616, 430, 199, 509, 284, 12, 315, 795, 315, 3874, 8, 599, 14, 11184, 7598, 304, 272, 21286, 275, 3229, 14, 3438, 59, 18212, 61, 272, 671, 12, 612, 275, 980, 14, 20221, 1332, 8382, 12, 21286, 59, 16, 2459, 14, 52, 272, 2185, 14, 2798, 8, 88, 12, 612, 9, 272, 2185, 14, 10898, 8, 73, 12, 13222, 2687, 1590, 14, 3670, 8, 88, 395, 980, 14, 3670, 8, 89, 1724, 199, 199, 396, 63, 3438, 275, 980, 14, 1144, 4038, 18, 12, 499, 467, 359, 21, 12, 1616, 467, 359, 713, 12, 4944, 14, 20, 467, 359, 713, 12, 1695, 467, 359, 1165, 12, 3388, 3934, 199, 199, 509, 284, 12, 334, 88, 12, 612, 9, 315, 3874, 8, 396, 63, 3438, 304, 272, 2185, 14, 2798, 8, 88, 12, 612, 12, 283, 75, 3130, 3608, 890, 29, 22, 9, 272, 2185, 14, 10898, 360, 396, 283, 435, 620, 8, 73, 395, 13222, 2687, 88, 12, 612, 430, 199, 199, 26634, 5680, 199, 3, 9336, 17196, 19981, 15845, 2575, 6966, 2335, 27027, 15660, 436, 27027, 12841, 73, 12, 372, 199, 3, 626, 2556, 367, 2945, 675, 14, 199, 3, 199, 3, 710, 790, 402, 314, 15845, 2600, 15724, 370, 314, 511, 2376, 1478, 12, 436, 314, 769, 402, 9446, 199, 3, 787, 314, 3229, 13162, 626, 787, 19981, 15845, 402, 626, 6770, 511, 2376, 14, 199, 3, 199, 3, 9336, 2376, 841, 365, 12474, 13437, 687, 314, 3229, 621, 5332, 12, 652, 965, 949, 19981, 15845, 14, 199, 3, 7584, 650, 365, 737, 314, 406, 24585, 402, 9978, 3229, 13162, 880, 652, 965, 5002, 19981, 15845, 14, 199, 11113, 12, 3229, 63, 815, 275, 2342, 63, 15759, 63, 11113, 8, 599, 12, 511, 63, 3438, 9, 199, 1361, 8, 11113, 9, 199, 199, 26634, 5680, 199, 3, 2136, 883, 2066, 675, 314, 2556, 315, 3229, 63, 815, 2945, 14, 199, 3, 199, 3, 710, 2600, 790, 365, 314, 1478, 402, 282, 6770, 26268, 315, 314, 18464, 65, 324, 1187, 3229, 621, 5332, 666, 199, 3, 5523, 14, 283, 2055, 7, 365, 626, 26268, 1159, 27027, 4218, 12, 436, 283, 82, 7, 365, 314, 9362, 402, 314, 27027, 11001, 199, 3, 3035, 626, 26268, 14, 199, 592, 12, 2185, 275, 4488, 14, 21430, 8, 23899, 2687, 1046, 12, 1616, 430, 199, 509, 284, 12, 315, 795, 315, 3874, 8, 599, 14, 11184, 7598, 304, 272, 21286, 275, 3229, 14, 3438, 59, 18212, 61, 272, 671, 12, 612, 275, 980, 14, 20221, 1332, 8382, 12, 21286, 59, 16, 2459, 14, 52, 272, 2185, 14, 2798, 8, 88, 12, 612, 9, 272, 2185, 14, 10898, 8, 73, 12, 13222, 2687, 1590, 14, 3670, 8, 88, 395, 980, 14, 3670, 8, 89, 1724, 199, 199, 3, 11719, 27027, 4218, 436, 9362, 2556, 687, 3229, 63, 815, 12, 5137, 27027, 6092, 2978, 436, 199, 3, 27027, 15660, 367, 1924, 26268, 14, 199, 509, 485, 2996, 12, 1242, 315, 3229, 63, 815, 14, 1744, 837, 272, 2185, 14, 2798, 8, 1053, 459, 2055, 3488, 16, 467, 1242, 459, 2055, 3488, 17, 467, 283, 75, 3130, 3608, 890, 29, 21, 9, 272, 9304, 275, 4488, 14, 24587, 8, 1053, 459, 2055, 995, 1242, 459, 82, 995, 6275, 2326, 534, 75, 297, 8870, 2326, 534, 3592, 297, 1993, 5793, 29, 592, 14, 6402, 59, 16, 1055, 1515, 1451, 9, 272, 2185, 14, 525, 63, 11215, 8, 6092, 9, 199, 199, 1219, 14, 409, 63, 18658, 360, 1452, 297, 283, 4616, 279, 1017, 358, 199, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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umm. # # GWSumm 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. # # GWSumm 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 GWSumm. If not, see <http://www.gnu.org/licenses/>. """Definitions for range plots """ from __future__ import division import re import hashlib from math import pi import numpy from gwpy.segments import (Segment, SegmentList) from gwpy.timeseries import TimeSeries from .. import (globalv, version) from .registry import (get_plot, register_plot) from ..data import (get_range_channel, get_range, get_timeseries) from ..segments import get_segments from ..utils import split_channels __author__ = 'Duncan Macleod <duncan.macleod@ligo.org>' __version__ = version.version class RangePlotMixin(object): data = 'spectrogram' _threadsafe = False defaults = { 'snr': 8.0, 'stride': 60., 'fftlength': 8, 'overlap': 4, 'fmin': 10, } def __init__(self, *args, **kwargs): super(RangePlotMixin, self).__init__(*args, **kwargs) self.rangeparams = {} for key in ['mass1', 'mass2', 'snr', 'energy', 'stride', 'fftlength', 'overlap', 'fmin', 'fmax']: try: value = self.pargs.pop(key) except KeyError: continue if not isinstance(value, (tuple, list)): value = [value]*len(self.channels) self.rangeparams[key] = value def process(self): """Read in all necessary data, and generate the figure. """ # generate data keys = [] for i, channel in enumerate(self.channels): kwargs = dict((key, self.rangeparams[key][i]) for key in self.rangeparams if self.rangeparams[key][i] is not None) if self.state and not self.all_data: valid = self.state.active else: valid = SegmentList([self.span]) rlist = get_range(channel, valid, query=self.read, **kwargs) try: keys.append(rlist[0].channel) except IndexError: keys.append(get_range_channel(channel, **kwargs)) # reset channel lists and generate time-series plot channels = self.channels outputfile = self.outputfile self.channels = keys out = super(RangePlotMixin, self).process(outputfile=outputfile) self.channels = channels return out class RangeDataPlot(RangePlotMixin, get_plot('timeseries')): type = 'range' defaults = get_plot('timeseries').defaults.copy() defaults.update(RangePlotMixin.defaults.copy()) defaults.update({ 'ylabel': 'Sensitive distance [Mpc]', }) register_plot(RangeDataPlot) class RangeDataHistogramPlot(RangePlotMixin, get_plot('histogram')): type = 'range-histogram' defaults = get_plot('histogram').defaults.copy() defaults.update(RangePlotMixin.defaults.copy()) defaults.update({ 'xlabel': 'Sensitive distance [Mpc]', }) register_plot(RangeDataHistogramPlot) # -- time-volume -------------------------------------------------------------- class SimpleTimeVolumeDataPlot(get_plot('segments')): """Time-series of the time-volume searched by an interferometer """ data = 'timeseries' type = 'time-volume' defaults = get_plot('timeseries').defaults.copy() def __init__(self, sources, *args, **kwargs): if isinstance(sources, str): sources = split_channels(sources) channels = sources[::2] flags = sources[1::2] get_plot('timeseries').__init__(self, channels, *args, **kwargs) self._allflags = [] self.flags = flags @classmethod def from_ini(cls, *args, **kwargs): return get_plot('timeseries').from_ini(cls, *args, **kwargs) @property def pid(self): try: return self._pid except: chans = "".join(map(str, self.channels+self.flags)) self._pid = hashlib.md5(chans).hexdigest()[:6] return self.pid @pid.setter def pid(self, id_): self._pid = str(id_) @pid.deleter def pid(self): del self._pid @staticmethod def calculate_time_volume(segments, range): ts = TimeSeries(numpy.zeros(range.size), xindex=range.times, unit='s') dx = range.dx.value # use float, not LIGOTimeGPS for speed segments = type(segments)([type(s)(float(s[0]), float(s[1])) for s in segments]) def livetime_(t): return float(abs(SegmentList([Segment(t, t+dx)]) & segments)) livetime = numpy.vectorize(livetime_, otypes=[float]) ts[:] = livetime(ts.times.value) * ts.unit return (4/3. * pi * ts * range ** 3).to('Mpc^3 year') def process(self, outputfile=None): """Generate the figure for this plot """ plot, axes = self.init_plot() ax = axes[0] # get plotting arguments cumulative = self.pargs.pop('cumulative', False) plotargs = self.parse_plot_kwargs() legendargs = self.parse_legend_kwargs() # set ylabel if cumulative: self.pargs.setdefault('ylabel', 'Cumulative time-volume [Mpc$^3$ yr]') else: self.pargs.setdefault('ylabel', 'Time-volume [Mpc$^3$ yr]') # get data for channel, flag, pargs in zip(self.channels, self.flags, plotargs): pad = 0 if self.state and not self.all_data: valid = self.state.active pad = numpy.nan elif channel.sample_rate: valid = SegmentList([self.span.protract( 1/channel.sample_rate.value)]) else: valid = SegmentList([self.span]) data = get_timeseries( channel, valid, query=False).join(gap='pad', pad=pad) if not data.unit or data.unit.name == 'undef': data.override_unit('Mpc') segments = get_segments(flag, valid, query=False) timevolume = self.calculate_time_volume(segments.active, data) if cumulative: ax.plot(timevolume.cumsum(), **pargs) else: ax.plot(timevolume, **pargs) # add horizontal lines to add for yval in self.pargs.get('hline', []): try: yval = float(yval) except ValueError: continue else: ax.plot([self.start, self.end], [yval, yval], linestyle='--', color='red') # customise plot for key, val in self.pargs.iteritems(): try: getattr(ax, 'set_%s' % key)(val) except AttributeError: setattr(ax, key, val) if (len(self.channels) > 1 or plotargs[0].get('label', None) in [re.sub(r'(_|\\_)', r'\_', str(self.channels[0])), None]): plot.add_legend(ax=ax, **legendargs) # add extra axes and finalise if not plot.colorbars: plot.add_colorbar(ax=ax, visible=False) if self.state: self.add_state_segments(ax) return self.finalize(outputfile=outputfile) register_plot(SimpleTimeVolumeDataPlot) class GWpyTimeVolumeDataPlot(RangePlotMixin, SimpleTimeVolumeDataPlot): """TimeVolumeDataPlot where the range is calculated on-the-fly """ type = 'strain-time-volume' _threadsafe = False register_plot(GWpyTimeVolumeDataPlot)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 35, 9, 577, 1097, 290, 10444, 274, 364, 334, 6965, 9, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 598, 5035, 453, 77, 14, 199, 3, 199, 3, 598, 5035, 453, 77, 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, 598, 5035, 453, 77, 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, 598, 5035, 453, 77, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 16738, 367, 1425, 19695, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 295, 199, 646, 8337, 199, 504, 3473, 492, 6682, 199, 199, 646, 2680, 199, 199, 504, 22192, 647, 14, 13879, 492, 334, 12520, 12, 29858, 1296, 9, 199, 504, 22192, 647, 14, 28551, 492, 4703, 9641, 199, 199, 504, 2508, 492, 334, 2966, 86, 12, 1015, 9, 199, 504, 1275, 5189, 492, 334, 362, 63, 2798, 12, 2274, 63, 2798, 9, 199, 504, 2508, 576, 492, 334, 362, 63, 1842, 63, 2775, 12, 664, 63, 1842, 12, 664, 63, 28551, 9, 199, 504, 2508, 13879, 492, 664, 63, 13879, 199, 504, 2508, 1208, 492, 3715, 63, 6324, 199, 199, 363, 2502, 363, 275, 283, 36, 1097, 290, 10444, 274, 364, 665, 68, 1097, 290, 14, 391, 2265, 364, 32, 317, 1939, 14, 1308, 3524, 199, 363, 1023, 363, 275, 1015, 14, 1023, 421, 199, 533, 13114, 10711, 4256, 8, 785, 304, 272, 666, 275, 283, 20865, 293, 1679, 7, 272, 485, 2671, 3489, 275, 756, 272, 4243, 275, 469, 267, 283, 5167, 82, 356, 1695, 14, 16, 12, 267, 283, 12318, 356, 5212, 2020, 267, 283, 9996, 1267, 356, 1695, 12, 267, 283, 16736, 356, 841, 12, 267, 283, 70, 827, 356, 1616, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 4709, 10711, 4256, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 1842, 1162, 275, 1052, 267, 367, 790, 315, 788, 11535, 17, 297, 283, 11535, 18, 297, 283, 5167, 82, 297, 283, 8443, 297, 283, 12318, 297, 283, 9996, 1267, 297, 490, 283, 16736, 297, 283, 70, 827, 297, 283, 70, 988, 2565, 288, 862, 26, 355, 574, 275, 291, 14, 462, 458, 14, 1935, 8, 498, 9, 288, 871, 4067, 26, 355, 1980, 288, 340, 440, 1228, 8, 585, 12, 334, 2960, 12, 769, 2298, 355, 574, 275, 359, 585, 3672, 552, 8, 277, 14, 6324, 9, 288, 291, 14, 1842, 1162, 59, 498, 61, 275, 574, 339, 347, 2112, 8, 277, 304, 267, 408, 3284, 315, 1006, 5784, 666, 12, 436, 3550, 314, 9658, 14, 267, 408, 267, 327, 3550, 666, 267, 2883, 275, 942, 267, 367, 284, 12, 3623, 315, 3874, 8, 277, 14, 6324, 304, 288, 2074, 275, 1211, 1332, 498, 12, 291, 14, 1842, 1162, 59, 498, 1527, 73, 566, 367, 2079, 790, 315, 291, 14, 1842, 1162, 340, 2079, 291, 14, 1842, 1162, 59, 498, 1527, 73, 61, 365, 440, 488, 9, 288, 340, 291, 14, 929, 436, 440, 291, 14, 452, 63, 576, 26, 355, 1686, 275, 291, 14, 929, 14, 2682, 288, 587, 26, 355, 1686, 275, 29858, 1296, 779, 277, 14, 3751, 566, 288, 519, 513, 275, 664, 63, 1842, 8, 2775, 12, 1686, 12, 1827, 29, 277, 14, 739, 12, 1011, 958, 9, 288, 862, 26, 355, 2883, 14, 740, 8, 82, 513, 59, 16, 1055, 2775, 9, 288, 871, 7888, 26, 355, 2883, 14, 740, 8, 362, 63, 1842, 63, 2775, 8, 2775, 12, 1011, 958, 430, 398, 327, 5305, 3623, 5548, 436, 3550, 900, 13, 5602, 5137, 267, 9245, 275, 291, 14, 6324, 267, 32513, 275, 291, 14, 1199, 493, 267, 291, 14, 6324, 275, 2883, 267, 734, 275, 1613, 8, 4709, 10711, 4256, 12, 291, 680, 1412, 8, 1199, 493, 29, 1199, 493, 9, 267, 291, 14, 6324, 275, 9245, 267, 372, 734, 421, 199, 533, 13114, 1451, 10711, 8, 4709, 10711, 4256, 12, 664, 63, 2798, 360, 28551, 8109, 272, 730, 275, 283, 1842, 7, 272, 4243, 275, 664, 63, 2798, 360, 28551, 1959, 4322, 14, 1574, 342, 272, 4243, 14, 873, 8, 4709, 10711, 4256, 14, 4322, 14, 1574, 1012, 272, 4243, 14, 873, 2561, 267, 283, 13849, 356, 283, 18569, 3013, 6033, 359, 45, 2352, 4300, 272, 3828, 199, 199, 2683, 63, 2798, 8, 4709, 1451, 10711, 9, 421, 199, 533, 13114, 1451, 25055, 10711, 8, 4709, 10711, 4256, 12, 664, 63, 2798, 360, 14805, 8109, 272, 730, 275, 283, 1842, 13, 14805, 7, 272, 4243, 275, 664, 63, 2798, 360, 14805, 1959, 4322, 14, 1574, 342, 272, 4243, 14, 873, 8, 4709, 10711, 4256, 14, 4322, 14, 1574, 1012, 272, 4243, 14, 873, 2561, 267, 283, 14168, 356, 283, 18569, 3013, 6033, 359, 45, 2352, 4300, 272, 3828, 199, 199, 2683, 63, 2798, 8, 4709, 1451, 25055, 10711, 9, 421, 199, 3, 1553, 900, 13, 2405, 9527, 10965, 199, 199, 533, 5870, 1366, 6464, 1451, 10711, 8, 362, 63, 2798, 360, 13879, 8109, 272, 408, 1366, 13, 5602, 402, 314, 900, 13, 2405, 17543, 701, 376, 1640, 2412, 1377, 351, 272, 408, 272, 666, 275, 283, 28551, 7, 272, 730, 275, 283, 521, 13, 2405, 7, 272, 4243, 275, 664, 63, 2798, 360, 28551, 1959, 4322, 14, 1574, 342, 339, 347, 636, 826, 721, 277, 12, 5274, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 1228, 8, 4553, 12, 620, 304, 288, 5274, 275, 3715 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 35, 9, 577, 1097, 290, 10444, 274, 364, 334, 6965, 9, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 598, 5035, 453, 77, 14, 199, 3, 199, 3, 598, 5035, 453, 77, 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, 598, 5035, 453, 77, 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, 598, 5035, 453, 77, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 16738, 367, 1425, 19695, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 295, 199, 646, 8337, 199, 504, 3473, 492, 6682, 199, 199, 646, 2680, 199, 199, 504, 22192, 647, 14, 13879, 492, 334, 12520, 12, 29858, 1296, 9, 199, 504, 22192, 647, 14, 28551, 492, 4703, 9641, 199, 199, 504, 2508, 492, 334, 2966, 86, 12, 1015, 9, 199, 504, 1275, 5189, 492, 334, 362, 63, 2798, 12, 2274, 63, 2798, 9, 199, 504, 2508, 576, 492, 334, 362, 63, 1842, 63, 2775, 12, 664, 63, 1842, 12, 664, 63, 28551, 9, 199, 504, 2508, 13879, 492, 664, 63, 13879, 199, 504, 2508, 1208, 492, 3715, 63, 6324, 199, 199, 363, 2502, 363, 275, 283, 36, 1097, 290, 10444, 274, 364, 665, 68, 1097, 290, 14, 391, 2265, 364, 32, 317, 1939, 14, 1308, 3524, 199, 363, 1023, 363, 275, 1015, 14, 1023, 421, 199, 533, 13114, 10711, 4256, 8, 785, 304, 272, 666, 275, 283, 20865, 293, 1679, 7, 272, 485, 2671, 3489, 275, 756, 272, 4243, 275, 469, 267, 283, 5167, 82, 356, 1695, 14, 16, 12, 267, 283, 12318, 356, 5212, 2020, 267, 283, 9996, 1267, 356, 1695, 12, 267, 283, 16736, 356, 841, 12, 267, 283, 70, 827, 356, 1616, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 4709, 10711, 4256, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 1842, 1162, 275, 1052, 267, 367, 790, 315, 788, 11535, 17, 297, 283, 11535, 18, 297, 283, 5167, 82, 297, 283, 8443, 297, 283, 12318, 297, 283, 9996, 1267, 297, 490, 283, 16736, 297, 283, 70, 827, 297, 283, 70, 988, 2565, 288, 862, 26, 355, 574, 275, 291, 14, 462, 458, 14, 1935, 8, 498, 9, 288, 871, 4067, 26, 355, 1980, 288, 340, 440, 1228, 8, 585, 12, 334, 2960, 12, 769, 2298, 355, 574, 275, 359, 585, 3672, 552, 8, 277, 14, 6324, 9, 288, 291, 14, 1842, 1162, 59, 498, 61, 275, 574, 339, 347, 2112, 8, 277, 304, 267, 408, 3284, 315, 1006, 5784, 666, 12, 436, 3550, 314, 9658, 14, 267, 408, 267, 327, 3550, 666, 267, 2883, 275, 942, 267, 367, 284, 12, 3623, 315, 3874, 8, 277, 14, 6324, 304, 288, 2074, 275, 1211, 1332, 498, 12, 291, 14, 1842, 1162, 59, 498, 1527, 73, 566, 367, 2079, 790, 315, 291, 14, 1842, 1162, 340, 2079, 291, 14, 1842, 1162, 59, 498, 1527, 73, 61, 365, 440, 488, 9, 288, 340, 291, 14, 929, 436, 440, 291, 14, 452, 63, 576, 26, 355, 1686, 275, 291, 14, 929, 14, 2682, 288, 587, 26, 355, 1686, 275, 29858, 1296, 779, 277, 14, 3751, 566, 288, 519, 513, 275, 664, 63, 1842, 8, 2775, 12, 1686, 12, 1827, 29, 277, 14, 739, 12, 1011, 958, 9, 288, 862, 26, 355, 2883, 14, 740, 8, 82, 513, 59, 16, 1055, 2775, 9, 288, 871, 7888, 26, 355, 2883, 14, 740, 8, 362, 63, 1842, 63, 2775, 8, 2775, 12, 1011, 958, 430, 398, 327, 5305, 3623, 5548, 436, 3550, 900, 13, 5602, 5137, 267, 9245, 275, 291, 14, 6324, 267, 32513, 275, 291, 14, 1199, 493, 267, 291, 14, 6324, 275, 2883, 267, 734, 275, 1613, 8, 4709, 10711, 4256, 12, 291, 680, 1412, 8, 1199, 493, 29, 1199, 493, 9, 267, 291, 14, 6324, 275, 9245, 267, 372, 734, 421, 199, 533, 13114, 1451, 10711, 8, 4709, 10711, 4256, 12, 664, 63, 2798, 360, 28551, 8109, 272, 730, 275, 283, 1842, 7, 272, 4243, 275, 664, 63, 2798, 360, 28551, 1959, 4322, 14, 1574, 342, 272, 4243, 14, 873, 8, 4709, 10711, 4256, 14, 4322, 14, 1574, 1012, 272, 4243, 14, 873, 2561, 267, 283, 13849, 356, 283, 18569, 3013, 6033, 359, 45, 2352, 4300, 272, 3828, 199, 199, 2683, 63, 2798, 8, 4709, 1451, 10711, 9, 421, 199, 533, 13114, 1451, 25055, 10711, 8, 4709, 10711, 4256, 12, 664, 63, 2798, 360, 14805, 8109, 272, 730, 275, 283, 1842, 13, 14805, 7, 272, 4243, 275, 664, 63, 2798, 360, 14805, 1959, 4322, 14, 1574, 342, 272, 4243, 14, 873, 8, 4709, 10711, 4256, 14, 4322, 14, 1574, 1012, 272, 4243, 14, 873, 2561, 267, 283, 14168, 356, 283, 18569, 3013, 6033, 359, 45, 2352, 4300, 272, 3828, 199, 199, 2683, 63, 2798, 8, 4709, 1451, 25055, 10711, 9, 421, 199, 3, 1553, 900, 13, 2405, 9527, 10965, 199, 199, 533, 5870, 1366, 6464, 1451, 10711, 8, 362, 63, 2798, 360, 13879, 8109, 272, 408, 1366, 13, 5602, 402, 314, 900, 13, 2405, 17543, 701, 376, 1640, 2412, 1377, 351, 272, 408, 272, 666, 275, 283, 28551, 7, 272, 730, 275, 283, 521, 13, 2405, 7, 272, 4243, 275, 664, 63, 2798, 360, 28551, 1959, 4322, 14, 1574, 342, 339, 347, 636, 826, 721, 277, 12, 5274, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 1228, 8, 4553, 12, 620, 304, 288, 5274, 275, 3715, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
johannes-gehrs/centos_packages
packages.py
1
6353
from __future__ import absolute_import, division, unicode_literals import xml.etree.ElementTree as ElT import bz2 import io import os import uuid import sqlite3 import config import re import datetime import pickle import requests REPODATA_ARC_SUFFIX = "x86_64/" METADATA_SUFFIX = "repodata/repomd.xml" PACKAGE_TIMESTAMP_FILE = config.DATA_DIR + 'packages_timestamp.pickled' YUM_REPODATA_XML_NAMESPACE = 'http://linux.duke.edu/metadata/repo' def _find_db_link_in_xml(xml_text): root = ElT.fromstring(xml_text) for data_elmnt in root.iter('{' + YUM_REPODATA_XML_NAMESPACE + '}data'): if data_elmnt.attrib['type'] == 'primary_db': return data_elmnt.find('{' + YUM_REPODATA_XML_NAMESPACE + '}location').attrib['href'] else: raise ValueError('Data not found in XML') def _download_one(version): for repo in config.active_repos(): repo_base_url = config.REPO_BASE_URL + unicode(version) + \ '/' + repo + '/' + REPODATA_ARC_SUFFIX metadata_request_ulr = repo_base_url + METADATA_SUFFIX metadata_request = requests.get(metadata_request_ulr) db_href = _find_db_link_in_xml(metadata_request.text) db_request_url = repo_base_url + db_href db_request = requests.get(db_request_url) if db_request.status_code != 200: raise IOError('Could not get file ' + db_request_url) database = bz2.decompress(db_request.content) temp_filename = config.DATA_DIR + unicode(uuid.uuid1()) final_filename = config.DATA_DIR + repo + '_' + version + '.sqlite' with io.open(temp_filename, mode='wb') as file: file.write(database) os.rename(temp_filename, final_filename) def download(): for version in config.OS_VERSIONS: _download_one(version) def _conn_factory(version, repo): conn = sqlite3.connect(config.DATA_DIR + repo + '_' + version + '.sqlite') conn.row_factory = sqlite3.Row return conn def _primary_query_execute(conn, repo): c = conn.cursor() query = ''' SELECT name, arch, version, epoch, ? AS repo, "release", summary, description, rpm_sourcerpm, url, rpm_license AS license, location_href, pkgKey FROM packages WHERE 1=1 -- AND name = 'kernel' --LIMIT 15 ''' c.execute(query, (repo,)) return c.fetchall() def _read_from_dbs(version): package_list = [] for repo in config.active_repos(): conn = _conn_factory(version, repo) package_list = package_list + _primary_query_execute(conn, repo) return package_list def _prepare(package_list): prepared = {} for row in package_list: prepared.setdefault(row[b'name'], []).append(dict(row)) for name in prepared: prepared[name].sort(cmp=compare_rpm_versions) return prepared def _not_none_epoch(epoch): if epoch is not None: return epoch return '0' def _is_int(mystring): try: int(mystring) return True except ValueError: return False # http://stackoverflow.com/questions/3206319/how-do-i-compare-rpm-versions-in-python # hold my beer while I implement this def _compare_rpm_label_fields(field1, field2): alphanumeric_matches = lambda field: list(re.finditer(r'[a-zA-Z0-9]+', field)) field1_matches, field2_matches = alphanumeric_matches(field1), alphanumeric_matches(field2) for match_pair in zip(field1_matches, field2_matches): value_pair = [match.group() for match in match_pair] numeric_vals = [_is_int(value) for value in value_pair] # Non-equal types if not all(numeric_vals) and any(numeric_vals): if numeric_vals[1]: return -1 if numeric_vals[0]: return 1 # Equal types: Alphanumeric if not any(numeric_vals): if value_pair[0] < value_pair[1]: return -1 if value_pair[0] > value_pair[1]: return 1 # Equal types: Numeric if all(numeric_vals): if int(value_pair[0]) < int(value_pair[1]): return -1 if int(value_pair[0]) > int(value_pair[1]): return 1 assert value_pair[0] == value_pair[1] # Decision by no. of fields if len(field1_matches) < len(field2_matches): return -1 if len(field1_matches) > len(field2_matches): return 1 if len(field1_matches) == len(field2_matches): return 0 raise RuntimeError('This code should not be reached, because one of the if paths ' 'should have been executed.') def compare_rpm_versions(version_one, version_two): label_components = ['epoch', 'version', 'release'] for component in label_components: result = _compare_rpm_label_fields(version_one[component], version_two[component]) if result != 0: break return result def get_version(version): return _prepare(_read_from_dbs(version)) def get_all(): packages_dict = {} for os_version in config.OS_VERSIONS: packages_dict[os_version] = get_version(os_version) return packages_dict def minor_os_release(all_packages_dict): newest_package_version = all_packages_dict['centos-release'][-1] major_release = newest_package_version['version'] minor_release_integer = re.match(r'.*?\.', newest_package_version['release']).group()[:-1] return major_release + '.' + minor_release_integer def set_timestamp_to_now(): now = datetime.datetime.now() with io.open(PACKAGE_TIMESTAMP_FILE, mode='wb') as myfile: pickle.dump(now, myfile) def get_timestamp(): with io.open(PACKAGE_TIMESTAMP_FILE, mode='rb') as myfile: timestamp = pickle.load(myfile) return timestamp def rpm_download_url(package_version, os_version): return config.REPO_BASE_URL + os_version + '/' + package_version['repo'] + \ '/' + REPODATA_ARC_SUFFIX + package_version['location_href'] def newest_versions_as_list(os_version, all_packages_dict): newest_versions_list = [] for package_name in all_packages_dict[os_version]: newest_versions_list.append(all_packages_dict[os_version][package_name][-1]) return newest_versions_list
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 646, 2748, 14, 9464, 14, 15325, 465, 13096, 52, 199, 646, 15055, 18, 199, 646, 5890, 199, 646, 747, 199, 646, 5377, 199, 646, 11723, 19, 199, 646, 1101, 199, 646, 295, 199, 646, 2197, 199, 646, 5927, 199, 646, 4145, 199, 199, 20424, 3998, 63, 24028, 63, 12273, 275, 298, 88, 1184, 63, 772, 6687, 199, 8314, 63, 12273, 275, 298, 1155, 22971, 15, 3417, 1064, 14, 1652, 2, 199, 19265, 63, 20277, 63, 3817, 275, 1101, 14, 3998, 63, 3022, 435, 283, 5154, 63, 3954, 14, 20428, 7, 199, 57, 2639, 63, 20424, 3998, 63, 4317, 63, 13001, 275, 283, 1014, 921, 5135, 14, 2033, 415, 14, 8654, 15, 2343, 15, 3417, 7, 199, 199, 318, 485, 1623, 63, 697, 63, 1073, 63, 262, 63, 1652, 8, 1652, 63, 505, 304, 272, 1738, 275, 13096, 52, 14, 13521, 8, 1652, 63, 505, 9, 339, 367, 666, 63, 352, 20481, 315, 1738, 14, 1661, 360, 1445, 435, 1488, 2639, 63, 20424, 3998, 63, 4317, 63, 13001, 435, 28544, 576, 735, 267, 340, 666, 63, 352, 20481, 14, 6640, 459, 466, 418, 508, 283, 3327, 63, 697, 356, 288, 372, 666, 63, 352, 20481, 14, 1623, 360, 1445, 435, 1488, 2639, 63, 20424, 3998, 63, 4317, 63, 13001, 435, 28544, 1985, 1959, 6640, 459, 6399, 418, 272, 587, 26, 267, 746, 1722, 360, 1451, 440, 1911, 315, 4692, 358, 421, 199, 318, 485, 4249, 63, 368, 8, 1023, 304, 272, 367, 3831, 315, 1101, 14, 2682, 63, 11857, 837, 267, 3831, 63, 1095, 63, 633, 275, 1101, 14, 20424, 63, 5825, 63, 2632, 435, 2649, 8, 1023, 9, 435, 971, 717, 7324, 435, 3831, 435, 7324, 435, 5363, 1512, 3998, 63, 24028, 63, 12273, 267, 3341, 63, 1069, 63, 348, 82, 275, 3831, 63, 1095, 63, 633, 435, 19357, 8071, 63, 12273, 267, 3341, 63, 1069, 275, 4145, 14, 362, 8, 2343, 63, 1069, 63, 348, 82, 9, 267, 1592, 63, 6399, 275, 485, 1623, 63, 697, 63, 1073, 63, 262, 63, 1652, 8, 2343, 63, 1069, 14, 505, 9, 398, 1592, 63, 1069, 63, 633, 275, 3831, 63, 1095, 63, 633, 435, 1592, 63, 6399, 267, 1592, 63, 1069, 275, 4145, 14, 362, 8, 697, 63, 1069, 63, 633, 9, 267, 340, 1592, 63, 1069, 14, 1205, 63, 600, 1137, 1926, 26, 288, 746, 5925, 360, 6531, 440, 664, 570, 283, 435, 1592, 63, 1069, 63, 633, 9, 267, 3050, 275, 15055, 18, 14, 14954, 8, 697, 63, 1069, 14, 1317, 9, 398, 2388, 63, 1501, 275, 1101, 14, 3998, 63, 3022, 435, 2649, 8, 2580, 14, 2580, 17, 1012, 267, 4242, 63, 1501, 275, 1101, 14, 3998, 63, 3022, 435, 3831, 435, 14135, 435, 1015, 435, 1987, 10659, 7, 267, 543, 5890, 14, 1490, 8, 808, 63, 1501, 12, 818, 534, 6603, 358, 465, 570, 26, 288, 570, 14, 952, 8, 4659, 9, 267, 747, 14, 8165, 8, 808, 63, 1501, 12, 4242, 63, 1501, 9, 421, 199, 318, 5235, 837, 272, 367, 1015, 315, 1101, 14, 3100, 63, 26358, 26, 267, 485, 4249, 63, 368, 8, 1023, 9, 421, 199, 318, 485, 1631, 63, 3702, 8, 1023, 12, 3831, 304, 272, 2557, 275, 11723, 19, 14, 2242, 8, 888, 14, 3998, 63, 3022, 435, 3831, 435, 14135, 435, 1015, 435, 1987, 10659, 358, 272, 2557, 14, 1143, 63, 3702, 275, 11723, 19, 14, 5810, 272, 372, 2557, 421, 199, 318, 485, 3327, 63, 1131, 63, 2526, 8, 1631, 12, 3831, 304, 272, 286, 275, 2557, 14, 3937, 342, 272, 1827, 275, 1449, 288, 10468, 536, 12, 3819, 12, 1015, 12, 9463, 12, 355, 5805, 4319, 3831, 12, 298, 3221, 401, 6212, 12, 1369, 12, 21980, 63, 83, 567, 2247, 7073, 12, 355, 1166, 12, 21980, 63, 1682, 4319, 4190, 12, 2909, 63, 6399, 12, 5496, 1197, 288, 4442, 6117, 288, 6038, 413, 29, 17, 288, 1553, 259, 2401, 536, 275, 283, 4989, 7, 288, 1553, 13387, 4114, 288, 1449, 272, 286, 14, 2526, 8, 1131, 12, 334, 3417, 4641, 272, 372, 286, 14, 10174, 342, 421, 199, 318, 485, 739, 63, 504, 63, 30764, 8, 1023, 304, 272, 2559, 63, 513, 275, 942, 272, 367, 3831, 315, 1101, 14, 2682, 63, 11857, 837, 267, 2557, 275, 485, 1631, 63, 3702, 8, 1023, 12, 3831, 9, 267, 2559, 63, 513, 275, 2559, 63, 513, 435, 485, 3327, 63, 1131, 63, 2526, 8, 1631, 12, 3831, 9, 272, 372, 2559, 63, 513, 421, 199, 318, 485, 6726, 8, 2491, 63, 513, 304, 272, 16318, 275, 1052, 272, 367, 1962, 315, 2559, 63, 513, 26, 267, 16318, 14, 5486, 8, 1143, 59, 66, 7, 354, 995, 15364, 740, 8, 807, 8, 1143, 430, 339, 367, 536, 315, 16318, 26, 267, 16318, 59, 354, 1055, 3191, 8, 5730, 29, 5785, 63, 14191, 63, 6234, 9, 339, 372, 16318, 421, 199, 318, 485, 1397, 63, 3592, 63, 7367, 8, 7367, 304, 272, 340, 9463, 365, 440, 488, 26, 267, 372, 9463, 272, 372, 283, 16, 7, 421, 199, 318, 485, 374, 63, 442, 8, 1662, 875, 304, 272, 862, 26, 267, 1109, 8, 1662, 875, 9, 267, 372, 715, 272, 871, 1722, 26, 267, 372, 756, 421, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 708, 22653, 1167, 15, 1917, 13, 1117, 13, 73, 13, 5785, 13, 14191, 13, 6234, 13, 262, 13, 1548, 199, 3, 10266, 3002, 506, 281, 1830, 473, 5669, 642, 199, 318, 485, 5785, 63, 14191, 63, 1302, 63, 955, 8, 698, 17, 12, 901, 18, 304, 272, 27964, 63, 6742, 275, 2400, 901, 26, 769, 8, 264, 14, 19373, 8, 82, 3894, 65, 13, 6353, 13, 58, 16, 13, 25, 11529, 901, 430, 272, 901, 17, 63, 6742, 12, 901, 18, 63, 6742, 275, 27964, 63, 6742, 8, 698, 17, 395, 27964, 63, 6742, 8, 698, 18, 9, 339, 367, 1336, 63, 3852, 315, 3482, 8, 698, 17, 63, 6742, 12, 901, 18, 63, 6742, 304, 267, 574, 63, 3852, 275, 359, 1431, 14, 923, 342, 367, 1336, 315, 1336, 63, 3852, 61, 267, 8950, 63, 3643, 275, 15500, 374, 63, 442, 8, 585 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 2649, 63, 5955, 199, 646, 2748, 14, 9464, 14, 15325, 465, 13096, 52, 199, 646, 15055, 18, 199, 646, 5890, 199, 646, 747, 199, 646, 5377, 199, 646, 11723, 19, 199, 646, 1101, 199, 646, 295, 199, 646, 2197, 199, 646, 5927, 199, 646, 4145, 199, 199, 20424, 3998, 63, 24028, 63, 12273, 275, 298, 88, 1184, 63, 772, 6687, 199, 8314, 63, 12273, 275, 298, 1155, 22971, 15, 3417, 1064, 14, 1652, 2, 199, 19265, 63, 20277, 63, 3817, 275, 1101, 14, 3998, 63, 3022, 435, 283, 5154, 63, 3954, 14, 20428, 7, 199, 57, 2639, 63, 20424, 3998, 63, 4317, 63, 13001, 275, 283, 1014, 921, 5135, 14, 2033, 415, 14, 8654, 15, 2343, 15, 3417, 7, 199, 199, 318, 485, 1623, 63, 697, 63, 1073, 63, 262, 63, 1652, 8, 1652, 63, 505, 304, 272, 1738, 275, 13096, 52, 14, 13521, 8, 1652, 63, 505, 9, 339, 367, 666, 63, 352, 20481, 315, 1738, 14, 1661, 360, 1445, 435, 1488, 2639, 63, 20424, 3998, 63, 4317, 63, 13001, 435, 28544, 576, 735, 267, 340, 666, 63, 352, 20481, 14, 6640, 459, 466, 418, 508, 283, 3327, 63, 697, 356, 288, 372, 666, 63, 352, 20481, 14, 1623, 360, 1445, 435, 1488, 2639, 63, 20424, 3998, 63, 4317, 63, 13001, 435, 28544, 1985, 1959, 6640, 459, 6399, 418, 272, 587, 26, 267, 746, 1722, 360, 1451, 440, 1911, 315, 4692, 358, 421, 199, 318, 485, 4249, 63, 368, 8, 1023, 304, 272, 367, 3831, 315, 1101, 14, 2682, 63, 11857, 837, 267, 3831, 63, 1095, 63, 633, 275, 1101, 14, 20424, 63, 5825, 63, 2632, 435, 2649, 8, 1023, 9, 435, 971, 717, 7324, 435, 3831, 435, 7324, 435, 5363, 1512, 3998, 63, 24028, 63, 12273, 267, 3341, 63, 1069, 63, 348, 82, 275, 3831, 63, 1095, 63, 633, 435, 19357, 8071, 63, 12273, 267, 3341, 63, 1069, 275, 4145, 14, 362, 8, 2343, 63, 1069, 63, 348, 82, 9, 267, 1592, 63, 6399, 275, 485, 1623, 63, 697, 63, 1073, 63, 262, 63, 1652, 8, 2343, 63, 1069, 14, 505, 9, 398, 1592, 63, 1069, 63, 633, 275, 3831, 63, 1095, 63, 633, 435, 1592, 63, 6399, 267, 1592, 63, 1069, 275, 4145, 14, 362, 8, 697, 63, 1069, 63, 633, 9, 267, 340, 1592, 63, 1069, 14, 1205, 63, 600, 1137, 1926, 26, 288, 746, 5925, 360, 6531, 440, 664, 570, 283, 435, 1592, 63, 1069, 63, 633, 9, 267, 3050, 275, 15055, 18, 14, 14954, 8, 697, 63, 1069, 14, 1317, 9, 398, 2388, 63, 1501, 275, 1101, 14, 3998, 63, 3022, 435, 2649, 8, 2580, 14, 2580, 17, 1012, 267, 4242, 63, 1501, 275, 1101, 14, 3998, 63, 3022, 435, 3831, 435, 14135, 435, 1015, 435, 1987, 10659, 7, 267, 543, 5890, 14, 1490, 8, 808, 63, 1501, 12, 818, 534, 6603, 358, 465, 570, 26, 288, 570, 14, 952, 8, 4659, 9, 267, 747, 14, 8165, 8, 808, 63, 1501, 12, 4242, 63, 1501, 9, 421, 199, 318, 5235, 837, 272, 367, 1015, 315, 1101, 14, 3100, 63, 26358, 26, 267, 485, 4249, 63, 368, 8, 1023, 9, 421, 199, 318, 485, 1631, 63, 3702, 8, 1023, 12, 3831, 304, 272, 2557, 275, 11723, 19, 14, 2242, 8, 888, 14, 3998, 63, 3022, 435, 3831, 435, 14135, 435, 1015, 435, 1987, 10659, 358, 272, 2557, 14, 1143, 63, 3702, 275, 11723, 19, 14, 5810, 272, 372, 2557, 421, 199, 318, 485, 3327, 63, 1131, 63, 2526, 8, 1631, 12, 3831, 304, 272, 286, 275, 2557, 14, 3937, 342, 272, 1827, 275, 1449, 288, 10468, 536, 12, 3819, 12, 1015, 12, 9463, 12, 355, 5805, 4319, 3831, 12, 298, 3221, 401, 6212, 12, 1369, 12, 21980, 63, 83, 567, 2247, 7073, 12, 355, 1166, 12, 21980, 63, 1682, 4319, 4190, 12, 2909, 63, 6399, 12, 5496, 1197, 288, 4442, 6117, 288, 6038, 413, 29, 17, 288, 1553, 259, 2401, 536, 275, 283, 4989, 7, 288, 1553, 13387, 4114, 288, 1449, 272, 286, 14, 2526, 8, 1131, 12, 334, 3417, 4641, 272, 372, 286, 14, 10174, 342, 421, 199, 318, 485, 739, 63, 504, 63, 30764, 8, 1023, 304, 272, 2559, 63, 513, 275, 942, 272, 367, 3831, 315, 1101, 14, 2682, 63, 11857, 837, 267, 2557, 275, 485, 1631, 63, 3702, 8, 1023, 12, 3831, 9, 267, 2559, 63, 513, 275, 2559, 63, 513, 435, 485, 3327, 63, 1131, 63, 2526, 8, 1631, 12, 3831, 9, 272, 372, 2559, 63, 513, 421, 199, 318, 485, 6726, 8, 2491, 63, 513, 304, 272, 16318, 275, 1052, 272, 367, 1962, 315, 2559, 63, 513, 26, 267, 16318, 14, 5486, 8, 1143, 59, 66, 7, 354, 995, 15364, 740, 8, 807, 8, 1143, 430, 339, 367, 536, 315, 16318, 26, 267, 16318, 59, 354, 1055, 3191, 8, 5730, 29, 5785, 63, 14191, 63, 6234, 9, 339, 372, 16318, 421, 199, 318, 485, 1397, 63, 3592, 63, 7367, 8, 7367, 304, 272, 340, 9463, 365, 440, 488, 26, 267, 372, 9463, 272, 372, 283, 16, 7, 421, 199, 318, 485, 374, 63, 442, 8, 1662, 875, 304, 272, 862, 26, 267, 1109, 8, 1662, 875, 9, 267, 372, 715, 272, 871, 1722, 26, 267, 372, 756, 421, 199, 3, 1455, 921, 23153, 14, 957, 15, 16069, 15, 708, 22653, 1167, 15, 1917, 13, 1117, 13, 73, 13, 5785, 13, 14191, 13, 6234, 13, 262, 13, 1548, 199, 3, 10266, 3002, 506, 281, 1830, 473, 5669, 642, 199, 318, 485, 5785, 63, 14191, 63, 1302, 63, 955, 8, 698, 17, 12, 901, 18, 304, 272, 27964, 63, 6742, 275, 2400, 901, 26, 769, 8, 264, 14, 19373, 8, 82, 3894, 65, 13, 6353, 13, 58, 16, 13, 25, 11529, 901, 430, 272, 901, 17, 63, 6742, 12, 901, 18, 63, 6742, 275, 27964, 63, 6742, 8, 698, 17, 395, 27964, 63, 6742, 8, 698, 18, 9, 339, 367, 1336, 63, 3852, 315, 3482, 8, 698, 17, 63, 6742, 12, 901, 18, 63, 6742, 304, 267, 574, 63, 3852, 275, 359, 1431, 14, 923, 342, 367, 1336, 315, 1336, 63, 3852, 61, 267, 8950, 63, 3643, 275, 15500, 374, 63, 442, 8, 585, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
florian-f/sklearn
sklearn/datasets/svmlight_format.py
1
13269
"""This module implements a loader and dumper for the svmlight format This format is a text-based format, with one sample per line. It does not store zero valued features hence is suitable for sparse dataset. The first element of each line can be used to store a target variable to predict. This format is used as the default format for both svmlight and the libsvm command line programs. """ # Authors: Mathieu Blondel <mathieu@mblondel.org> # Lars Buitinck <L.J.Buitinck@uva.nl> # Olivier Grisel <olivier.grisel@ensta.org> # License: Simple BSD. from bz2 import BZ2File from contextlib import closing import gzip import io import os.path import numpy as np import scipy.sparse as sp from ._svmlight_format import _load_svmlight_file from .. import __version__ from ..externals import six from ..utils import atleast2d_or_csr from ..externals.six import u, b def load_svmlight_file(f, n_features=None, dtype=np.float64, multilabel=False, zero_based="auto", query_id=False): """Load datasets in the svmlight / libsvm format into sparse CSR matrix This format is a text-based format, with one sample per line. It does not store zero valued features hence is suitable for sparse dataset. The first element of each line can be used to store a target variable to predict. This format is used as the default format for both svmlight and the libsvm command line programs. Parsing a text based source can be expensive. When working on repeatedly on the same dataset, it is recommended to wrap this loader with joblib.Memory.cache to store a memmapped backup of the CSR results of the first call and benefit from the near instantaneous loading of memmapped structures for the subsequent calls. In case the file contains a pairwise preference constraint (known as "qid" in the svmlight format) these are ignored unless the query_id parameter is set to True. These pairwise preference constraints can be used to contraint the combination of samples when using pairwise loss functions (as is the case in some learning to rank problems) so that only pairs with the same query_id value are considered. This implementation is written in Cython and is reasonably fast. However, a faster API-compatible loader is also available at: https://github.com/mblondel/svmlight-loader Parameters ---------- f: {str, file-like, int} (Path to) a file to load. If a path ends in ".gz" or ".bz2", it will be uncompressed on the fly. If an integer is passed, it is assumed to be a file descriptor. A file-like or file descriptor will not be closed by this function. A file-like object must be opened in binary mode. n_features: int or None The number of features to use. If None, it will be inferred. This argument is useful to load several files that are subsets of a bigger sliced dataset: each subset might not have example of every feature, hence the inferred shape might vary from one slice to another. multilabel: boolean, optional Samples may have several labels each (see http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html) zero_based: boolean or "auto", optional Whether column indices in f are zero-based (True) or one-based (False). If column indices are one-based, they are transformed to zero-based to match Python/NumPy conventions. If set to "auto", a heuristic check is applied to determine this from the file contents. Both kinds of files occur "in the wild", but they are unfortunately not self-identifying. Using "auto" or True should always be safe. query_id: boolean, defaults to False If True, will return the query_id array for each file. Returns ------- X: scipy.sparse matrix of shape (n_samples, n_features) y: ndarray of shape (n_samples,), or, in the multilabel a list of tuples of length n_samples. query_id: array of shape (n_samples,) query_id for each sample. Only returned when query_id is set to True. See also -------- load_svmlight_files: similar function for loading multiple files in this format, enforcing the same number of features/columns on all of them. """ return tuple(load_svmlight_files([f], n_features, dtype, multilabel, zero_based, query_id)) def _gen_open(f): if isinstance(f, int): # file descriptor return io.open(f, "rb", closefd=False) elif not isinstance(f, six.string_types): raise TypeError("expected {str, int, file-like}, got %s" % type(f)) _, ext = os.path.splitext(f) if ext == ".gz": return gzip.open(f, "rb") elif ext == ".bz2": return BZ2File(f, "rb") else: return open(f, "rb") def _open_and_load(f, dtype, multilabel, zero_based, query_id): if hasattr(f, "read"): return _load_svmlight_file(f, dtype, multilabel, zero_based, query_id) # XXX remove closing when Python 2.7+/3.1+ required with closing(_gen_open(f)) as f: return _load_svmlight_file(f, dtype, multilabel, zero_based, query_id) def load_svmlight_files(files, n_features=None, dtype=np.float64, multilabel=False, zero_based="auto", query_id=False): """Load dataset from multiple files in SVMlight format This function is equivalent to mapping load_svmlight_file over a list of files, except that the results are concatenated into a single, flat list and the samples vectors are constrained to all have the same number of features. In case the file contains a pairwise preference constraint (known as "qid" in the svmlight format) these are ignored unless the query_id parameter is set to True. These pairwise preference constraints can be used to constraint the combination of samples when using pairwise loss functions (as is the case in some learning to rank problems) so that only pairs with the same query_id value are considered. Parameters ---------- files : iterable over {str, file-like, int} (Paths of) files to load. If a path ends in ".gz" or ".bz2", it will be uncompressed on the fly. If an integer is passed, it is assumed to be a file descriptor. File-likes and file descriptors will not be closed by this function. File-like objects must be opened in binary mode. n_features: int or None The number of features to use. If None, it will be inferred from the maximum column index occurring in any of the files. multilabel: boolean, optional Samples may have several labels each (see http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html) zero_based: boolean or "auto", optional Whether column indices in f are zero-based (True) or one-based (False). If column indices are one-based, they are transformed to zero-based to match Python/NumPy conventions. If set to "auto", a heuristic check is applied to determine this from the file contents. Both kinds of files occur "in the wild", but they are unfortunately not self-identifying. Using "auto" or True should always be safe. query_id: boolean, defaults to False If True, will return the query_id array for each file. Returns ------- [X1, y1, ..., Xn, yn] where each (Xi, yi) pair is the result from load_svmlight_file(files[i]). If query_id is set to True, this will return instead [X1, y1, q1, ..., Xn, yn, qn] where (Xi, yi, qi) is the result from load_svmlight_file(files[i]) Rationale --------- When fitting a model to a matrix X_train and evaluating it against a matrix X_test, it is essential that X_train and X_test have the same number of features (X_train.shape[1] == X_test.shape[1]). This may not be the case if you load the files individually with load_svmlight_file. See also -------- load_svmlight_file """ r = [_open_and_load(f, dtype, multilabel, bool(zero_based), bool(query_id)) for f in files] if (zero_based is False or zero_based == "auto" and all(np.min(tmp[1]) > 0 for tmp in r)): for ind in r: indices = ind[1] indices -= 1 if n_features is None: n_features = max(ind[1].max() for ind in r) + 1 result = [] for data, indices, indptr, y, query_values in r: shape = (indptr.shape[0] - 1, n_features) X = sp.csr_matrix((data, indices, indptr), shape) X.sort_indices() result += X, y if query_id: result.append(query_values) return result def _dump_svmlight(X, y, f, one_based, comment, query_id): is_sp = int(hasattr(X, "tocsr")) if X.dtype == np.float64: value_pattern = u("%d:%0.16e") else: value_pattern = u("%d:%f") if y.dtype.kind == 'i': line_pattern = u("%d") else: line_pattern = u("%f") if query_id is not None: line_pattern += u(" qid:%d") line_pattern += u(" %s\n") if comment: f.write(b("# Generated by dump_svmlight_file from scikit-learn %s\n" % __version__)) f.write(b("# Column indices are %s-based\n" % ["zero", "one"][one_based])) f.write(b("#\n")) f.writelines(b("# %s\n" % line) for line in comment.splitlines()) for i in range(X.shape[0]): s = " ".join([value_pattern % (j + one_based, X[i, j]) for j in X[i].nonzero()[is_sp]]) if query_id is not None: feat = (y[i], query_id[i], s) else: feat = (y[i], s) f.write((line_pattern % feat).encode('ascii')) def dump_svmlight_file(X, y, f, zero_based=True, comment=None, query_id=None): """Dump the dataset in svmlight / libsvm file format. This format is a text-based format, with one sample per line. It does not store zero valued features hence is suitable for sparse dataset. The first element of each line can be used to store a target variable to predict. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] Training vectors, where n_samples is the number of samples and n_features is the number of features. y : array-like, shape = [n_samples] Target values. f : string or file-like in binary mode If string, specifies the path that will contain the data. If file-like, data will be written to f. f should be opened in binary mode. zero_based : boolean, optional Whether column indices should be written zero-based (True) or one-based (False). comment : string, optional Comment to insert at the top of the file. This should be either a Unicode string, which will be encoded as UTF-8, or an ASCII byte string. If a comment is given, then it will be preceded by one that identifies the file as having been dumped by scikit-learn. Note that not all tools grok comments in SVMlight files. query_id : array-like, shape = [n_samples] Array containing pairwise preference constraints (qid in svmlight format). """ if comment is not None: # Convert comment string to list of lines in UTF-8. # If a byte string is passed, then check whether it's ASCII; # if a user wants to get fancy, they'll have to decode themselves. # Avoid mention of str and unicode types for Python 3.x compat. if isinstance(comment, bytes): comment.decode("ascii") # just for the exception else: comment = comment.encode("utf-8") if six.b("\0") in comment: raise ValueError("comment string contains NUL byte") y = np.asarray(y) if y.ndim != 1: raise ValueError("expected y of shape (n_samples,), got %r" % (y.shape,)) Xval = atleast2d_or_csr(X) if Xval.shape[0] != y.shape[0]: raise ValueError("X.shape[0] and y.shape[0] should be the same, got" " %r and %r instead." % (Xval.shape[0], y.shape[0])) # We had some issues with CSR matrices with unsorted indices (e.g. #1501), # so sort them here, but first make sure we don't modify the user's X. # TODO We can do this cheaper; sorted_indices copies the whole matrix. if Xval is X and hasattr(Xval, "sorted_indices"): X = Xval.sorted_indices() else: X = Xval if hasattr(X, "sort_indices"): X.sort_indices() if query_id is not None: query_id = np.asarray(query_id) if query_id.shape[0] != y.shape[0]: raise ValueError("expected query_id of shape (n_samples,), got %r" % (query_id.shape,)) one_based = not zero_based if hasattr(f, "write"): _dump_svmlight(X, y, f, one_based, comment, query_id) else: with open(f, "wb") as f: _dump_svmlight(X, y, f, one_based, comment, query_id)
bsd-3-clause
[ 624, 2765, 859, 9031, 282, 5077, 436, 5461, 281, 367, 314, 23044, 4040, 1475, 199, 199, 2765, 1475, 365, 282, 1318, 13, 6788, 1475, 12, 543, 1373, 2690, 1126, 1004, 14, 2779, 1630, 199, 1397, 3877, 4697, 574, 68, 4534, 19407, 365, 11233, 367, 5178, 4789, 14, 199, 199, 1918, 1642, 1819, 402, 1924, 1004, 883, 506, 1202, 370, 3877, 282, 1347, 1750, 370, 199, 6892, 14, 199, 199, 2765, 1475, 365, 1202, 465, 314, 849, 1475, 367, 3865, 23044, 4040, 436, 314, 199, 8450, 2611, 1414, 1004, 18572, 14, 199, 624, 199, 199, 3, 6642, 26, 21066, 29364, 699, 5298, 2264, 665, 3442, 29364, 32, 887, 5298, 2264, 14, 1308, 30, 199, 3, 3515, 491, 4291, 4779, 390, 262, 346, 665, 44, 14, 42, 14, 1713, 390, 262, 346, 32, 85, 3042, 14, 7530, 30, 199, 3, 3515, 593, 317, 26645, 598, 322, 5891, 665, 23711, 26645, 14, 7928, 5891, 32, 287, 1207, 14, 1308, 30, 199, 3, 844, 26, 5870, 6289, 14, 199, 199, 504, 15055, 18, 492, 32402, 18, 1173, 199, 504, 15502, 492, 11261, 199, 646, 11756, 199, 646, 5890, 199, 646, 747, 14, 515, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 13653, 16820, 4040, 63, 908, 492, 485, 912, 63, 16820, 4040, 63, 493, 199, 504, 2508, 492, 636, 1023, 363, 199, 504, 2508, 24688, 492, 3816, 199, 504, 2508, 1208, 492, 737, 11790, 18, 68, 63, 269, 63, 10101, 199, 504, 2508, 24688, 14, 4174, 492, 399, 12, 330, 421, 199, 318, 2248, 63, 16820, 4040, 63, 493, 8, 70, 12, 302, 63, 3179, 29, 403, 12, 2152, 29, 1590, 14, 1609, 772, 12, 2432, 3510, 1302, 29, 797, 12, 4697, 63, 6788, 628, 2495, 401, 1827, 63, 344, 29, 797, 304, 272, 408, 6200, 13148, 315, 314, 23044, 4040, 1182, 1973, 16820, 1475, 1901, 5178, 16449, 3634, 339, 961, 1475, 365, 282, 1318, 13, 6788, 1475, 12, 543, 1373, 2690, 1126, 1004, 14, 2779, 1630, 272, 440, 3877, 4697, 574, 68, 4534, 19407, 365, 11233, 367, 5178, 4789, 14, 339, 710, 1642, 1819, 402, 1924, 1004, 883, 506, 1202, 370, 3877, 282, 1347, 1750, 272, 370, 12610, 14, 339, 961, 1475, 365, 1202, 465, 314, 849, 1475, 367, 3865, 23044, 4040, 436, 314, 272, 1973, 16820, 1414, 1004, 18572, 14, 339, 28747, 282, 1318, 4079, 1350, 883, 506, 23133, 14, 3979, 6449, 641, 272, 27714, 641, 314, 2011, 4789, 12, 652, 365, 14318, 370, 4816, 642, 272, 5077, 543, 3906, 773, 14, 8628, 14, 1637, 370, 3877, 282, 7573, 11663, 6902, 402, 314, 272, 16449, 2058, 402, 314, 1642, 1240, 436, 22477, 3269, 687, 314, 17429, 2727, 867, 13815, 272, 8697, 402, 7573, 11663, 13955, 367, 314, 13372, 4882, 14, 339, 1010, 1930, 314, 570, 3509, 282, 24859, 16705, 5828, 334, 3159, 272, 465, 298, 81, 344, 2, 315, 314, 23044, 4040, 1475, 9, 3520, 787, 5525, 7444, 314, 272, 1827, 63, 344, 2725, 365, 663, 370, 715, 14, 5723, 24859, 16705, 272, 9565, 883, 506, 1202, 370, 18782, 442, 314, 14665, 402, 5845, 272, 1380, 1808, 24859, 5621, 3423, 334, 305, 365, 314, 1930, 315, 2005, 272, 9328, 370, 6915, 8826, 9, 880, 626, 1454, 6342, 543, 314, 2011, 272, 1827, 63, 344, 574, 787, 8652, 14, 2286, 961, 4514, 365, 5313, 315, 26741, 436, 365, 4499, 6665, 7377, 14, 272, 9738, 12, 282, 12930, 3261, 13, 6490, 5077, 365, 2597, 2808, 737, 26, 2541, 4178, 921, 5031, 14, 957, 15, 887, 5298, 2264, 15, 16820, 4040, 13, 3422, 339, 3897, 272, 4143, 272, 289, 26, 469, 495, 12, 570, 13, 2930, 12, 1109, 93, 267, 334, 2042, 370, 9, 282, 570, 370, 2248, 14, 982, 282, 931, 11187, 315, 3680, 6838, 2, 503, 3680, 10582, 18, 401, 652, 911, 267, 506, 25904, 641, 314, 23158, 14, 982, 376, 3000, 365, 3032, 12, 652, 365, 10826, 370, 267, 506, 282, 570, 5872, 14, 437, 570, 13, 2930, 503, 570, 5872, 911, 440, 506, 6876, 267, 701, 642, 805, 14, 437, 570, 13, 2930, 909, 1471, 506, 12123, 315, 3366, 818, 14, 339, 302, 63, 3179, 26, 1109, 503, 488, 267, 710, 1329, 402, 4534, 370, 675, 14, 982, 488, 12, 652, 911, 506, 22515, 14, 961, 267, 1423, 365, 2997, 370, 2248, 9978, 1584, 626, 787, 30767, 402, 282, 267, 29416, 6014, 68, 4789, 26, 1924, 10026, 5594, 440, 1172, 2893, 402, 267, 4036, 3878, 12, 19407, 314, 22515, 2215, 5594, 17083, 687, 1373, 267, 6014, 370, 4573, 14, 339, 3510, 1302, 26, 5046, 12, 2716, 267, 428, 1889, 1443, 1172, 9978, 3628, 1924, 334, 3239, 267, 1455, 921, 1544, 14, 19551, 69, 14, 343, 85, 14, 8654, 14, 8122, 22500, 24862, 472, 15, 8450, 2611, 2537, 15, 12281, 15, 3029, 1302, 14, 1360, 9, 339, 4697, 63, 6788, 26, 5046, 503, 298, 2495, 401, 2716, 267, 7480, 2763, 4918, 315, 289, 787, 4697, 13, 6788, 334, 549, 9, 503, 1373, 13, 6788, 267, 334, 797, 680, 982, 2763, 4918, 787, 1373, 13, 6788, 12, 2985, 787, 14834, 370, 267, 4697, 13, 6788, 370, 1336, 2018, 15, 5667, 2713, 8758, 852, 14, 267, 982, 663, 370, 298, 2495, 401, 282, 25332, 1104, 365, 6781, 370, 6705, 642, 687, 267, 314, 570, 4072, 14, 17650, 24241, 402, 1584, 4781, 298, 262, 314, 336, 668, 401, 1325, 2985, 267, 787, 625, 21839, 440, 291, 13, 22232, 316, 14, 11719, 298, 2495, 2, 503, 715, 1077, 267, 3544, 506, 5048, 14, 339, 1827, 63, 344, 26, 5046, 12, 4243, 370, 756, 267, 982, 715, 12, 911, 372, 314, 1827, 63, 344, 1625, 367, 1924, 570, 14, 339, 1803, 272, 5514, 272, 1323, 26, 7026, 14, 4421, 3634, 402, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 339, 612, 26, 6800, 402, 2215, 334, 78, 63, 3356, 4706, 503, 12, 315, 314, 3510, 1302, 282, 769, 402, 267, 6346, 402, 2582, 302, 63, 3356, 14, 339, 1827, 63, 344, 26, 1625, 402, 2215, 334, 78, 63, 3356, 4258, 2126, 1827, 63, 344, 367, 1924, 2690, 14, 5972, 2138, 1380, 1827, 63, 344, 365, 663, 370, 2126, 715, 14, 339, 1666, 2597, 272, 3001, 272, 2248, 63, 16820, 4040, 63 ]
[ 2765, 859, 9031, 282, 5077, 436, 5461, 281, 367, 314, 23044, 4040, 1475, 199, 199, 2765, 1475, 365, 282, 1318, 13, 6788, 1475, 12, 543, 1373, 2690, 1126, 1004, 14, 2779, 1630, 199, 1397, 3877, 4697, 574, 68, 4534, 19407, 365, 11233, 367, 5178, 4789, 14, 199, 199, 1918, 1642, 1819, 402, 1924, 1004, 883, 506, 1202, 370, 3877, 282, 1347, 1750, 370, 199, 6892, 14, 199, 199, 2765, 1475, 365, 1202, 465, 314, 849, 1475, 367, 3865, 23044, 4040, 436, 314, 199, 8450, 2611, 1414, 1004, 18572, 14, 199, 624, 199, 199, 3, 6642, 26, 21066, 29364, 699, 5298, 2264, 665, 3442, 29364, 32, 887, 5298, 2264, 14, 1308, 30, 199, 3, 3515, 491, 4291, 4779, 390, 262, 346, 665, 44, 14, 42, 14, 1713, 390, 262, 346, 32, 85, 3042, 14, 7530, 30, 199, 3, 3515, 593, 317, 26645, 598, 322, 5891, 665, 23711, 26645, 14, 7928, 5891, 32, 287, 1207, 14, 1308, 30, 199, 3, 844, 26, 5870, 6289, 14, 199, 199, 504, 15055, 18, 492, 32402, 18, 1173, 199, 504, 15502, 492, 11261, 199, 646, 11756, 199, 646, 5890, 199, 646, 747, 14, 515, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 465, 2249, 199, 199, 504, 13653, 16820, 4040, 63, 908, 492, 485, 912, 63, 16820, 4040, 63, 493, 199, 504, 2508, 492, 636, 1023, 363, 199, 504, 2508, 24688, 492, 3816, 199, 504, 2508, 1208, 492, 737, 11790, 18, 68, 63, 269, 63, 10101, 199, 504, 2508, 24688, 14, 4174, 492, 399, 12, 330, 421, 199, 318, 2248, 63, 16820, 4040, 63, 493, 8, 70, 12, 302, 63, 3179, 29, 403, 12, 2152, 29, 1590, 14, 1609, 772, 12, 2432, 3510, 1302, 29, 797, 12, 4697, 63, 6788, 628, 2495, 401, 1827, 63, 344, 29, 797, 304, 272, 408, 6200, 13148, 315, 314, 23044, 4040, 1182, 1973, 16820, 1475, 1901, 5178, 16449, 3634, 339, 961, 1475, 365, 282, 1318, 13, 6788, 1475, 12, 543, 1373, 2690, 1126, 1004, 14, 2779, 1630, 272, 440, 3877, 4697, 574, 68, 4534, 19407, 365, 11233, 367, 5178, 4789, 14, 339, 710, 1642, 1819, 402, 1924, 1004, 883, 506, 1202, 370, 3877, 282, 1347, 1750, 272, 370, 12610, 14, 339, 961, 1475, 365, 1202, 465, 314, 849, 1475, 367, 3865, 23044, 4040, 436, 314, 272, 1973, 16820, 1414, 1004, 18572, 14, 339, 28747, 282, 1318, 4079, 1350, 883, 506, 23133, 14, 3979, 6449, 641, 272, 27714, 641, 314, 2011, 4789, 12, 652, 365, 14318, 370, 4816, 642, 272, 5077, 543, 3906, 773, 14, 8628, 14, 1637, 370, 3877, 282, 7573, 11663, 6902, 402, 314, 272, 16449, 2058, 402, 314, 1642, 1240, 436, 22477, 3269, 687, 314, 17429, 2727, 867, 13815, 272, 8697, 402, 7573, 11663, 13955, 367, 314, 13372, 4882, 14, 339, 1010, 1930, 314, 570, 3509, 282, 24859, 16705, 5828, 334, 3159, 272, 465, 298, 81, 344, 2, 315, 314, 23044, 4040, 1475, 9, 3520, 787, 5525, 7444, 314, 272, 1827, 63, 344, 2725, 365, 663, 370, 715, 14, 5723, 24859, 16705, 272, 9565, 883, 506, 1202, 370, 18782, 442, 314, 14665, 402, 5845, 272, 1380, 1808, 24859, 5621, 3423, 334, 305, 365, 314, 1930, 315, 2005, 272, 9328, 370, 6915, 8826, 9, 880, 626, 1454, 6342, 543, 314, 2011, 272, 1827, 63, 344, 574, 787, 8652, 14, 2286, 961, 4514, 365, 5313, 315, 26741, 436, 365, 4499, 6665, 7377, 14, 272, 9738, 12, 282, 12930, 3261, 13, 6490, 5077, 365, 2597, 2808, 737, 26, 2541, 4178, 921, 5031, 14, 957, 15, 887, 5298, 2264, 15, 16820, 4040, 13, 3422, 339, 3897, 272, 4143, 272, 289, 26, 469, 495, 12, 570, 13, 2930, 12, 1109, 93, 267, 334, 2042, 370, 9, 282, 570, 370, 2248, 14, 982, 282, 931, 11187, 315, 3680, 6838, 2, 503, 3680, 10582, 18, 401, 652, 911, 267, 506, 25904, 641, 314, 23158, 14, 982, 376, 3000, 365, 3032, 12, 652, 365, 10826, 370, 267, 506, 282, 570, 5872, 14, 437, 570, 13, 2930, 503, 570, 5872, 911, 440, 506, 6876, 267, 701, 642, 805, 14, 437, 570, 13, 2930, 909, 1471, 506, 12123, 315, 3366, 818, 14, 339, 302, 63, 3179, 26, 1109, 503, 488, 267, 710, 1329, 402, 4534, 370, 675, 14, 982, 488, 12, 652, 911, 506, 22515, 14, 961, 267, 1423, 365, 2997, 370, 2248, 9978, 1584, 626, 787, 30767, 402, 282, 267, 29416, 6014, 68, 4789, 26, 1924, 10026, 5594, 440, 1172, 2893, 402, 267, 4036, 3878, 12, 19407, 314, 22515, 2215, 5594, 17083, 687, 1373, 267, 6014, 370, 4573, 14, 339, 3510, 1302, 26, 5046, 12, 2716, 267, 428, 1889, 1443, 1172, 9978, 3628, 1924, 334, 3239, 267, 1455, 921, 1544, 14, 19551, 69, 14, 343, 85, 14, 8654, 14, 8122, 22500, 24862, 472, 15, 8450, 2611, 2537, 15, 12281, 15, 3029, 1302, 14, 1360, 9, 339, 4697, 63, 6788, 26, 5046, 503, 298, 2495, 401, 2716, 267, 7480, 2763, 4918, 315, 289, 787, 4697, 13, 6788, 334, 549, 9, 503, 1373, 13, 6788, 267, 334, 797, 680, 982, 2763, 4918, 787, 1373, 13, 6788, 12, 2985, 787, 14834, 370, 267, 4697, 13, 6788, 370, 1336, 2018, 15, 5667, 2713, 8758, 852, 14, 267, 982, 663, 370, 298, 2495, 401, 282, 25332, 1104, 365, 6781, 370, 6705, 642, 687, 267, 314, 570, 4072, 14, 17650, 24241, 402, 1584, 4781, 298, 262, 314, 336, 668, 401, 1325, 2985, 267, 787, 625, 21839, 440, 291, 13, 22232, 316, 14, 11719, 298, 2495, 2, 503, 715, 1077, 267, 3544, 506, 5048, 14, 339, 1827, 63, 344, 26, 5046, 12, 4243, 370, 756, 267, 982, 715, 12, 911, 372, 314, 1827, 63, 344, 1625, 367, 1924, 570, 14, 339, 1803, 272, 5514, 272, 1323, 26, 7026, 14, 4421, 3634, 402, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 339, 612, 26, 6800, 402, 2215, 334, 78, 63, 3356, 4706, 503, 12, 315, 314, 3510, 1302, 282, 769, 402, 267, 6346, 402, 2582, 302, 63, 3356, 14, 339, 1827, 63, 344, 26, 1625, 402, 2215, 334, 78, 63, 3356, 4258, 2126, 1827, 63, 344, 367, 1924, 2690, 14, 5972, 2138, 1380, 1827, 63, 344, 365, 663, 370, 2126, 715, 14, 339, 1666, 2597, 272, 3001, 272, 2248, 63, 16820, 4040, 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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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 ]
GitHublong/hue
desktop/core/ext-py/Django-1.6.10/django/contrib/sessions/backends/cache.py
122
2505
from django.conf import settings from django.contrib.sessions.backends.base import SessionBase, CreateError from django.core.cache import get_cache from django.utils.six.moves import xrange KEY_PREFIX = "django.contrib.sessions.cache" class SessionStore(SessionBase): """ A cache-based session store. """ def __init__(self, session_key=None): self._cache = get_cache(settings.SESSION_CACHE_ALIAS) super(SessionStore, self).__init__(session_key) @property def cache_key(self): return KEY_PREFIX + self._get_or_create_session_key() def load(self): try: session_data = self._cache.get(self.cache_key, None) except Exception: # Some backends (e.g. memcache) raise an exception on invalid # cache keys. If this happens, reset the session. See #17810. session_data = None if session_data is not None: return session_data self.create() return {} def create(self): # Because a cache can fail silently (e.g. memcache), we don't know if # we are failing to create a new session because of a key collision or # because the cache is missing. So we try for a (large) number of times # and then raise an exception. That's the risk you shoulder if using # cache backing. for i in xrange(10000): self._session_key = self._get_new_session_key() try: self.save(must_create=True) except CreateError: continue self.modified = True return raise RuntimeError( "Unable to create a new session key. " "It is likely that the cache is unavailable.") def save(self, must_create=False): if must_create: func = self._cache.add else: func = self._cache.set result = func(self.cache_key, self._get_session(no_load=must_create), self.get_expiry_age()) if must_create and not result: raise CreateError def exists(self, session_key): return (KEY_PREFIX + session_key) in self._cache def delete(self, session_key=None): if session_key is None: if self.session_key is None: return session_key = self.session_key self._cache.delete(KEY_PREFIX + session_key) @classmethod def clear_expired(cls): pass
apache-2.0
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 1095, 492, 8596, 1563, 12, 2790, 547, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 4945, 199, 199, 3078, 63, 6351, 275, 298, 1176, 14, 2828, 14, 11676, 14, 1637, 2, 421, 199, 533, 8596, 5502, 8, 4434, 1563, 304, 272, 408, 272, 437, 2581, 13, 6788, 2351, 3877, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2351, 63, 498, 29, 403, 304, 267, 291, 423, 1637, 275, 664, 63, 1637, 8, 1751, 14, 12763, 63, 8677, 63, 12644, 9, 267, 1613, 8, 4434, 5502, 12, 291, 2843, 826, 721, 1730, 63, 498, 9, 339, 768, 1829, 272, 347, 2581, 63, 498, 8, 277, 304, 267, 372, 9301, 63, 6351, 435, 291, 423, 362, 63, 269, 63, 981, 63, 1730, 63, 498, 342, 339, 347, 2248, 8, 277, 304, 267, 862, 26, 288, 2351, 63, 576, 275, 291, 423, 1637, 14, 362, 8, 277, 14, 1637, 63, 498, 12, 488, 9, 267, 871, 2186, 26, 288, 327, 6601, 14745, 334, 69, 14, 71, 14, 21598, 9, 746, 376, 1919, 641, 3866, 288, 327, 2581, 2883, 14, 982, 642, 10986, 12, 5305, 314, 2351, 14, 1666, 327, 11175, 709, 14, 288, 2351, 63, 576, 275, 488, 267, 340, 2351, 63, 576, 365, 440, 488, 26, 288, 372, 2351, 63, 576, 267, 291, 14, 981, 342, 267, 372, 1052, 339, 347, 1218, 8, 277, 304, 267, 327, 13821, 282, 2581, 883, 2449, 18030, 334, 69, 14, 71, 14, 21598, 395, 781, 2793, 1133, 5715, 340, 267, 327, 781, 787, 18648, 370, 1218, 282, 892, 2351, 2952, 402, 282, 790, 25061, 503, 267, 327, 2952, 314, 2581, 365, 4124, 14, 2002, 781, 862, 367, 282, 334, 9629, 9, 1329, 402, 5431, 267, 327, 436, 2066, 746, 376, 1919, 14, 10314, 1159, 314, 22633, 1265, 930, 348, 424, 340, 1808, 267, 327, 2581, 21094, 14, 267, 367, 284, 315, 4945, 8, 9943, 304, 288, 291, 423, 1730, 63, 498, 275, 291, 423, 362, 63, 1222, 63, 1730, 63, 498, 342, 288, 862, 26, 355, 291, 14, 2117, 8, 7790, 63, 981, 29, 549, 9, 288, 871, 2790, 547, 26, 355, 1980, 288, 291, 14, 5540, 275, 715, 288, 372, 267, 746, 6064, 8, 288, 298, 6005, 370, 1218, 282, 892, 2351, 790, 14, 298, 288, 298, 7940, 365, 12060, 626, 314, 2581, 365, 18735, 2685, 339, 347, 3354, 8, 277, 12, 1471, 63, 981, 29, 797, 304, 267, 340, 1471, 63, 981, 26, 288, 2562, 275, 291, 423, 1637, 14, 525, 267, 587, 26, 288, 2562, 275, 291, 423, 1637, 14, 409, 267, 754, 275, 2562, 8, 277, 14, 1637, 63, 498, 12, 1993, 291, 423, 362, 63, 1730, 8, 889, 63, 912, 29, 7790, 63, 981, 395, 1993, 291, 14, 362, 63, 16844, 63, 474, 1012, 267, 340, 1471, 63, 981, 436, 440, 754, 26, 288, 746, 2790, 547, 339, 347, 3495, 8, 277, 12, 2351, 63, 498, 304, 267, 372, 334, 3078, 63, 6351, 435, 2351, 63, 498, 9, 315, 291, 423, 1637, 339, 347, 3145, 8, 277, 12, 2351, 63, 498, 29, 403, 304, 267, 340, 2351, 63, 498, 365, 488, 26, 288, 340, 291, 14, 1730, 63, 498, 365, 488, 26, 355, 372, 288, 2351, 63, 498, 275, 291, 14, 1730, 63, 498, 267, 291, 423, 1637, 14, 1807, 8, 3078, 63, 6351, 435, 2351, 63, 498, 9, 339, 768, 3744, 272, 347, 5436, 63, 16340, 8, 1886, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 11676, 14, 7765, 14, 1095, 492, 8596, 1563, 12, 2790, 547, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 4945, 199, 199, 3078, 63, 6351, 275, 298, 1176, 14, 2828, 14, 11676, 14, 1637, 2, 421, 199, 533, 8596, 5502, 8, 4434, 1563, 304, 272, 408, 272, 437, 2581, 13, 6788, 2351, 3877, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2351, 63, 498, 29, 403, 304, 267, 291, 423, 1637, 275, 664, 63, 1637, 8, 1751, 14, 12763, 63, 8677, 63, 12644, 9, 267, 1613, 8, 4434, 5502, 12, 291, 2843, 826, 721, 1730, 63, 498, 9, 339, 768, 1829, 272, 347, 2581, 63, 498, 8, 277, 304, 267, 372, 9301, 63, 6351, 435, 291, 423, 362, 63, 269, 63, 981, 63, 1730, 63, 498, 342, 339, 347, 2248, 8, 277, 304, 267, 862, 26, 288, 2351, 63, 576, 275, 291, 423, 1637, 14, 362, 8, 277, 14, 1637, 63, 498, 12, 488, 9, 267, 871, 2186, 26, 288, 327, 6601, 14745, 334, 69, 14, 71, 14, 21598, 9, 746, 376, 1919, 641, 3866, 288, 327, 2581, 2883, 14, 982, 642, 10986, 12, 5305, 314, 2351, 14, 1666, 327, 11175, 709, 14, 288, 2351, 63, 576, 275, 488, 267, 340, 2351, 63, 576, 365, 440, 488, 26, 288, 372, 2351, 63, 576, 267, 291, 14, 981, 342, 267, 372, 1052, 339, 347, 1218, 8, 277, 304, 267, 327, 13821, 282, 2581, 883, 2449, 18030, 334, 69, 14, 71, 14, 21598, 395, 781, 2793, 1133, 5715, 340, 267, 327, 781, 787, 18648, 370, 1218, 282, 892, 2351, 2952, 402, 282, 790, 25061, 503, 267, 327, 2952, 314, 2581, 365, 4124, 14, 2002, 781, 862, 367, 282, 334, 9629, 9, 1329, 402, 5431, 267, 327, 436, 2066, 746, 376, 1919, 14, 10314, 1159, 314, 22633, 1265, 930, 348, 424, 340, 1808, 267, 327, 2581, 21094, 14, 267, 367, 284, 315, 4945, 8, 9943, 304, 288, 291, 423, 1730, 63, 498, 275, 291, 423, 362, 63, 1222, 63, 1730, 63, 498, 342, 288, 862, 26, 355, 291, 14, 2117, 8, 7790, 63, 981, 29, 549, 9, 288, 871, 2790, 547, 26, 355, 1980, 288, 291, 14, 5540, 275, 715, 288, 372, 267, 746, 6064, 8, 288, 298, 6005, 370, 1218, 282, 892, 2351, 790, 14, 298, 288, 298, 7940, 365, 12060, 626, 314, 2581, 365, 18735, 2685, 339, 347, 3354, 8, 277, 12, 1471, 63, 981, 29, 797, 304, 267, 340, 1471, 63, 981, 26, 288, 2562, 275, 291, 423, 1637, 14, 525, 267, 587, 26, 288, 2562, 275, 291, 423, 1637, 14, 409, 267, 754, 275, 2562, 8, 277, 14, 1637, 63, 498, 12, 1993, 291, 423, 362, 63, 1730, 8, 889, 63, 912, 29, 7790, 63, 981, 395, 1993, 291, 14, 362, 63, 16844, 63, 474, 1012, 267, 340, 1471, 63, 981, 436, 440, 754, 26, 288, 746, 2790, 547, 339, 347, 3495, 8, 277, 12, 2351, 63, 498, 304, 267, 372, 334, 3078, 63, 6351, 435, 2351, 63, 498, 9, 315, 291, 423, 1637, 339, 347, 3145, 8, 277, 12, 2351, 63, 498, 29, 403, 304, 267, 340, 2351, 63, 498, 365, 488, 26, 288, 340, 291, 14, 1730, 63, 498, 365, 488, 26, 355, 372, 288, 2351, 63, 498, 275, 291, 14, 1730, 63, 498, 267, 291, 423, 1637, 14, 1807, 8, 3078, 63, 6351, 435, 2351, 63, 498, 9, 339, 768, 3744, 272, 347, 5436, 63, 16340, 8, 1886, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
farazrehman/aws-resources
CloudFormation/nash/lib/python2.7/site-packages/troposphere/elasticbeanstalk.py
18
2738
# Copyright (c) 2013, Mark Peek <mark@peek.org> # All rights reserved. # # See LICENSE file for full license. from . import AWSObject, AWSProperty, Tags WebServer = "WebServer" Worker = "Worker" WebServerType = "Standard" WorkerType = "SQS/HTTP" class SourceBundle(AWSProperty): props = { 'S3Bucket': (basestring, True), 'S3Key': (basestring, True), } class SourceConfiguration(AWSProperty): props = { 'ApplicationName': (basestring, True), 'TemplateName': (basestring, True), } class OptionSettings(AWSProperty): props = { 'Namespace': (basestring, True), 'OptionName': (basestring, True), 'Value': (basestring, True), } class Application(AWSObject): resource_type = "AWS::ElasticBeanstalk::Application" props = { 'ApplicationName': (basestring, False), 'Description': (basestring, False), } class ApplicationVersion(AWSObject): resource_type = "AWS::ElasticBeanstalk::ApplicationVersion" props = { 'ApplicationName': (basestring, True), 'Description': (basestring, False), 'SourceBundle': (SourceBundle, False), } class ConfigurationTemplate(AWSObject): resource_type = "AWS::ElasticBeanstalk::ConfigurationTemplate" props = { 'ApplicationName': (basestring, True), 'Description': (basestring, False), 'EnvironmentId': (basestring, False), 'OptionSettings': ([OptionSettings], False), 'SolutionStackName': (basestring, False), 'SourceConfiguration': (SourceConfiguration, False), } def validate_tier_name(name): valid_names = [WebServer, Worker] if name not in valid_names: raise ValueError('Tier name needs to be one of %r' % valid_names) return name def validate_tier_type(tier_type): valid_types = [WebServerType, WorkerType] if tier_type not in valid_types: raise ValueError('Tier type needs to be one of %r' % valid_types) return tier_type class Tier(AWSProperty): props = { 'Name': (validate_tier_name, False), 'Type': (validate_tier_type, False), 'Version': (basestring, False), } class Environment(AWSObject): resource_type = "AWS::ElasticBeanstalk::Environment" props = { 'ApplicationName': (basestring, True), 'CNAMEPrefix': (basestring, False), 'Description': (basestring, False), 'EnvironmentName': (basestring, False), 'OptionSettings': ([OptionSettings], False), 'SolutionStackName': (basestring, False), 'Tags': (Tags, False), 'TemplateName': (basestring, False), 'Tier': (Tier, False), 'VersionLabel': (basestring, False), }
gpl-2.0
[ 3, 1898, 334, 67, 9, 6171, 12, 7173, 510, 4374, 665, 1657, 32, 13164, 14, 1308, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 5113, 570, 367, 2615, 4190, 14, 199, 199, 504, 1275, 492, 10168, 1692, 12, 10168, 3697, 12, 25204, 421, 199, 5926, 3120, 275, 298, 5926, 3120, 2, 199, 12678, 275, 298, 12678, 2, 199, 5926, 3120, 804, 275, 298, 9232, 2, 199, 12678, 804, 275, 298, 18445, 51, 15, 2856, 2, 421, 199, 533, 5800, 12320, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 51, 19, 12311, 356, 334, 17628, 12, 715, 395, 267, 283, 51, 19, 1197, 356, 334, 17628, 12, 715, 395, 272, 789, 421, 199, 533, 5800, 5688, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 4231, 985, 356, 334, 17628, 12, 715, 395, 272, 789, 421, 199, 533, 3207, 5268, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 8814, 356, 334, 17628, 12, 715, 395, 267, 283, 2602, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 1110, 356, 334, 17628, 12, 715, 395, 272, 789, 421, 199, 533, 13515, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 5039, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 272, 789, 421, 199, 533, 13515, 3353, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 5039, 3353, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 267, 283, 2980, 12320, 356, 334, 2980, 12320, 12, 756, 395, 272, 789, 421, 199, 533, 11595, 4231, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 5688, 4231, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 267, 283, 8263, 1304, 356, 334, 17628, 12, 756, 395, 267, 283, 2602, 5268, 356, 7287, 2602, 5268, 467, 756, 395, 267, 283, 24277, 4851, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 2980, 5688, 356, 334, 2980, 5688, 12, 756, 395, 272, 789, 421, 199, 318, 4107, 63, 13949, 63, 354, 8, 354, 304, 272, 1686, 63, 1247, 275, 359, 5926, 3120, 12, 23886, 61, 272, 340, 536, 440, 315, 1686, 63, 1247, 26, 267, 746, 1722, 360, 52, 4446, 536, 4839, 370, 506, 1373, 402, 450, 82, 7, 450, 1686, 63, 1247, 9, 272, 372, 536, 421, 199, 318, 4107, 63, 13949, 63, 466, 8, 13949, 63, 466, 304, 272, 1686, 63, 1313, 275, 359, 5926, 3120, 804, 12, 23886, 804, 61, 272, 340, 31800, 63, 466, 440, 315, 1686, 63, 1313, 26, 267, 746, 1722, 360, 52, 4446, 730, 4839, 370, 506, 1373, 402, 450, 82, 7, 450, 1686, 63, 1313, 9, 272, 372, 31800, 63, 466, 421, 199, 533, 377, 4446, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 985, 356, 334, 3502, 63, 13949, 63, 354, 12, 756, 395, 267, 283, 804, 356, 334, 3502, 63, 13949, 63, 466, 12, 756, 395, 267, 283, 3353, 356, 334, 17628, 12, 756, 395, 272, 789, 421, 199, 533, 9711, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 8263, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 35, 2339, 4793, 356, 334, 17628, 12, 756, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 267, 283, 8263, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 2602, 5268, 356, 7287, 2602, 5268, 467, 756, 395, 267, 283, 24277, 4851, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 9440, 356, 334, 9440, 12, 756, 395, 267, 283, 4231, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 52, 4446, 356, 334, 52, 4446, 12, 756, 395, 267, 283, 3353, 4314, 356, 334, 17628, 12, 756, 395, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6171, 12, 7173, 510, 4374, 665, 1657, 32, 13164, 14, 1308, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 5113, 570, 367, 2615, 4190, 14, 199, 199, 504, 1275, 492, 10168, 1692, 12, 10168, 3697, 12, 25204, 421, 199, 5926, 3120, 275, 298, 5926, 3120, 2, 199, 12678, 275, 298, 12678, 2, 199, 5926, 3120, 804, 275, 298, 9232, 2, 199, 12678, 804, 275, 298, 18445, 51, 15, 2856, 2, 421, 199, 533, 5800, 12320, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 51, 19, 12311, 356, 334, 17628, 12, 715, 395, 267, 283, 51, 19, 1197, 356, 334, 17628, 12, 715, 395, 272, 789, 421, 199, 533, 5800, 5688, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 4231, 985, 356, 334, 17628, 12, 715, 395, 272, 789, 421, 199, 533, 3207, 5268, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 8814, 356, 334, 17628, 12, 715, 395, 267, 283, 2602, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 1110, 356, 334, 17628, 12, 715, 395, 272, 789, 421, 199, 533, 13515, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 5039, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 272, 789, 421, 199, 533, 13515, 3353, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 5039, 3353, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 267, 283, 2980, 12320, 356, 334, 2980, 12320, 12, 756, 395, 272, 789, 421, 199, 533, 11595, 4231, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 5688, 4231, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 267, 283, 8263, 1304, 356, 334, 17628, 12, 756, 395, 267, 283, 2602, 5268, 356, 7287, 2602, 5268, 467, 756, 395, 267, 283, 24277, 4851, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 2980, 5688, 356, 334, 2980, 5688, 12, 756, 395, 272, 789, 421, 199, 318, 4107, 63, 13949, 63, 354, 8, 354, 304, 272, 1686, 63, 1247, 275, 359, 5926, 3120, 12, 23886, 61, 272, 340, 536, 440, 315, 1686, 63, 1247, 26, 267, 746, 1722, 360, 52, 4446, 536, 4839, 370, 506, 1373, 402, 450, 82, 7, 450, 1686, 63, 1247, 9, 272, 372, 536, 421, 199, 318, 4107, 63, 13949, 63, 466, 8, 13949, 63, 466, 304, 272, 1686, 63, 1313, 275, 359, 5926, 3120, 804, 12, 23886, 804, 61, 272, 340, 31800, 63, 466, 440, 315, 1686, 63, 1313, 26, 267, 746, 1722, 360, 52, 4446, 730, 4839, 370, 506, 1373, 402, 450, 82, 7, 450, 1686, 63, 1313, 9, 272, 372, 31800, 63, 466, 421, 199, 533, 377, 4446, 8, 13226, 3697, 304, 272, 10792, 275, 469, 267, 283, 985, 356, 334, 3502, 63, 13949, 63, 354, 12, 756, 395, 267, 283, 804, 356, 334, 3502, 63, 13949, 63, 466, 12, 756, 395, 267, 283, 3353, 356, 334, 17628, 12, 756, 395, 272, 789, 421, 199, 533, 9711, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 27822, 3655, 290, 270, 4878, 447, 8263, 2, 339, 10792, 275, 469, 267, 283, 5039, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 35, 2339, 4793, 356, 334, 17628, 12, 756, 395, 267, 283, 5831, 356, 334, 17628, 12, 756, 395, 267, 283, 8263, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 2602, 5268, 356, 7287, 2602, 5268, 467, 756, 395, 267, 283, 24277, 4851, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 9440, 356, 334, 9440, 12, 756, 395, 267, 283, 4231, 985, 356, 334, 17628, 12, 756, 395, 267, 283, 52, 4446, 356, 334, 52, 4446, 12, 756, 395, 267, 283, 3353, 4314, 356, 334, 17628, 12, 756, 395, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
garbled1/ansible
test/runner/injector/importer.py
163
7660
#!/usr/bin/env python """Interpreter and code coverage injector for use with ansible-test. The injector serves two main purposes: 1) Control the python interpreter used to run test tools and ansible code. 2) Provide optional code coverage analysis of ansible code. The injector is executed one of two ways: 1) On the controller via a symbolic link such as ansible or pytest. This is accomplished by prepending the injector directory to the PATH by ansible-test. 2) As the python interpreter when running ansible modules. This is only supported when connecting to the local host. Otherwise set the ANSIBLE_TEST_REMOTE_INTERPRETER environment variable. It can be empty to auto-detect the python interpreter on the remote host. If not empty it will be used to set ansible_python_interpreter. NOTE: Running ansible-test with the --tox option or inside a virtual environment may prevent the injector from working for tests which use connection types other than local, or which use become, due to lack of permissions to access the interpreter for the virtual environment. """ from __future__ import absolute_import, print_function import errno import json import os import sys import pipes import logging import getpass logger = logging.getLogger('injector') # pylint: disable=locally-disabled, invalid-name # pylint: disable=locally-disabled, invalid-name config = None # type: InjectorConfig class InjectorConfig(object): """Mandatory configuration.""" def __init__(self, config_path): """Initialize config.""" with open(config_path) as config_fd: _config = json.load(config_fd) self.python_interpreter = _config['python_interpreter'] self.coverage_file = _config['coverage_file'] # Read from the environment instead of config since it needs to be changed by integration test scripts. # It also does not need to flow from the controller to the remote. It is only used on the controller. self.remote_interpreter = os.environ.get('ANSIBLE_TEST_REMOTE_INTERPRETER', None) self.arguments = [to_text(c) for c in sys.argv] def to_text(value): """ :type value: str | None :rtype: str | None """ if value is None: return None if isinstance(value, bytes): return value.decode('utf-8') return u'%s' % value def main(): """Main entry point.""" global config # pylint: disable=locally-disabled, global-statement formatter = logging.Formatter('%(asctime)s %(process)d %(levelname)s %(message)s') log_name = 'ansible-test-coverage.%s.log' % getpass.getuser() self_dir = os.path.dirname(os.path.abspath(__file__)) handler = logging.FileHandler(os.path.join('/tmp', log_name)) handler.setFormatter(formatter) logger.addHandler(handler) handler = logging.FileHandler(os.path.abspath(os.path.join(self_dir, '..', 'logs', log_name))) handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) try: logger.debug('Self: %s', __file__) config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'injector.json') try: config = InjectorConfig(config_path) except IOError: logger.exception('Error reading config: %s', config_path) exit('No injector config found. Set ANSIBLE_TEST_REMOTE_INTERPRETER if the test is not connecting to the local host.') logger.debug('Arguments: %s', ' '.join(pipes.quote(c) for c in config.arguments)) logger.debug('Python interpreter: %s', config.python_interpreter) logger.debug('Remote interpreter: %s', config.remote_interpreter) logger.debug('Coverage file: %s', config.coverage_file) require_cwd = False if os.path.basename(__file__) == 'injector.py': if config.coverage_file: args, env, require_cwd = cover() else: args, env = runner() else: args, env = injector() logger.debug('Run command: %s', ' '.join(pipes.quote(c) for c in args)) altered_cwd = False try: cwd = os.getcwd() except OSError as ex: # some platforms, such as OS X, may not allow querying the working directory when using become to drop privileges if ex.errno != errno.EACCES: raise if require_cwd: # make sure the program we execute can determine the working directory if it's required cwd = '/' os.chdir(cwd) altered_cwd = True else: cwd = None logger.debug('Working directory: %s%s', cwd or '?', ' (altered)' if altered_cwd else '') for key in sorted(env.keys()): logger.debug('%s=%s', key, env[key]) os.execvpe(args[0], args, env) except Exception as ex: logger.fatal(ex) raise def injector(): """ :rtype: list[str], dict[str, str] """ command = os.path.basename(__file__) executable = find_executable(command) if config.coverage_file: args, env = coverage_command() else: args, env = [config.python_interpreter], os.environ.copy() args += [executable] if command in ('ansible', 'ansible-playbook', 'ansible-pull'): if config.remote_interpreter is None: interpreter = os.path.join(os.path.dirname(__file__), 'injector.py') elif config.remote_interpreter == '': interpreter = None else: interpreter = config.remote_interpreter if interpreter: args += ['--extra-vars', 'ansible_python_interpreter=' + interpreter] args += config.arguments[1:] return args, env def runner(): """ :rtype: list[str], dict[str, str] """ args, env = [config.python_interpreter], os.environ.copy() args += config.arguments[1:] return args, env def cover(): """ :rtype: list[str], dict[str, str], bool """ if len(config.arguments) > 1: executable = config.arguments[1] else: executable = '' require_cwd = False if os.path.basename(executable).startswith('ansible_module_'): args, env = coverage_command() # coverage requires knowing the working directory require_cwd = True else: args, env = [config.python_interpreter], os.environ.copy() args += config.arguments[1:] return args, env, require_cwd def coverage_command(): """ :rtype: list[str], dict[str, str] """ self_dir = os.path.dirname(os.path.abspath(__file__)) args = [ config.python_interpreter, '-m', 'coverage.__main__', 'run', '--rcfile', os.path.join(self_dir, '.coveragerc'), ] env = os.environ.copy() env['COVERAGE_FILE'] = config.coverage_file return args, env def find_executable(executable): """ :type executable: str :rtype: str """ self = os.path.abspath(__file__) path = os.environ.get('PATH', os.defpath) seen_dirs = set() for path_dir in path.split(os.pathsep): if path_dir in seen_dirs: continue seen_dirs.add(path_dir) candidate = os.path.abspath(os.path.join(path_dir, executable)) if candidate == self: continue if os.path.exists(candidate) and os.access(candidate, os.F_OK | os.X_OK): return candidate raise Exception('Executable "%s" not found in path: %s' % (executable, path)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 2620, 26499, 436, 1233, 11745, 16182, 269, 367, 675, 543, 3242, 13, 396, 14, 199, 199, 1918, 16182, 269, 23739, 2877, 2446, 12901, 26, 199, 199, 17, 9, 8612, 314, 2366, 12693, 1202, 370, 1255, 511, 7249, 436, 3242, 1233, 14, 199, 18, 9, 22896, 2716, 1233, 11745, 11284, 402, 3242, 1233, 14, 199, 199, 1918, 16182, 269, 365, 7934, 1373, 402, 2877, 15217, 26, 199, 199, 17, 9, 4068, 314, 7614, 4799, 282, 13673, 2142, 4066, 465, 3242, 503, 4613, 14, 2043, 961, 365, 1066, 863, 1891, 379, 701, 876, 6455, 314, 16182, 269, 2082, 370, 314, 15097, 701, 3242, 13, 396, 14, 199, 199, 18, 9, 3709, 314, 2366, 12693, 1380, 3879, 3242, 4621, 14, 2043, 961, 365, 1454, 3748, 1380, 18170, 370, 314, 2257, 1591, 14, 2043, 6630, 663, 314, 32271, 7187, 63, 2864, 63, 16058, 63, 3843, 3311, 775, 540, 3734, 1750, 14, 2043, 2779, 883, 506, 2701, 370, 2599, 13, 13552, 314, 2366, 12693, 641, 314, 3982, 1591, 14, 2043, 982, 440, 2701, 652, 911, 506, 1202, 370, 663, 3242, 63, 1548, 63, 20244, 14, 199, 199, 19855, 26, 26848, 3242, 13, 396, 543, 314, 1553, 475, 88, 945, 503, 6272, 282, 5791, 3734, 489, 1443, 7981, 314, 16182, 269, 687, 6449, 367, 2295, 1314, 675, 1950, 489, 2943, 1163, 2419, 2257, 12, 503, 1314, 675, 8649, 12, 7037, 370, 29098, 402, 3443, 489, 370, 2879, 314, 12693, 367, 314, 5791, 3734, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 7554, 199, 646, 2022, 199, 646, 747, 199, 646, 984, 199, 646, 20988, 199, 646, 2050, 199, 646, 18354, 199, 199, 2921, 275, 2050, 14, 5572, 360, 14815, 269, 358, 221, 327, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 3866, 13, 354, 199, 3, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 3866, 13, 354, 199, 888, 275, 488, 221, 327, 730, 26, 1010, 19625, 2028, 421, 199, 533, 1010, 19625, 2028, 8, 785, 304, 272, 408, 45, 13530, 2897, 1041, 272, 347, 636, 826, 721, 277, 12, 1101, 63, 515, 304, 267, 408, 9345, 1101, 1041, 267, 543, 1551, 8, 888, 63, 515, 9, 465, 1101, 63, 2592, 26, 288, 485, 888, 275, 2022, 14, 912, 8, 888, 63, 2592, 9, 398, 291, 14, 1548, 63, 20244, 275, 485, 888, 459, 1548, 63, 20244, 418, 267, 291, 14, 10828, 63, 493, 275, 485, 888, 459, 10828, 63, 493, 418, 398, 327, 5574, 687, 314, 3734, 3140, 402, 1101, 3967, 652, 4839, 370, 506, 2896, 701, 13150, 511, 10554, 14, 267, 327, 2779, 2597, 1630, 440, 1929, 370, 6369, 687, 314, 7614, 370, 314, 3982, 14, 2779, 365, 1454, 1202, 641, 314, 7614, 14, 267, 291, 14, 3846, 63, 20244, 275, 747, 14, 2314, 14, 362, 360, 8490, 63, 2864, 63, 16058, 63, 3843, 3311, 775, 540, 297, 488, 9, 398, 291, 14, 4958, 275, 359, 475, 63, 505, 8, 67, 9, 367, 286, 315, 984, 14, 3020, 61, 421, 199, 318, 370, 63, 505, 8, 585, 304, 272, 408, 272, 520, 466, 574, 26, 620, 1204, 488, 272, 520, 4500, 26, 620, 1204, 488, 272, 408, 272, 340, 574, 365, 488, 26, 267, 372, 488, 339, 340, 1228, 8, 585, 12, 2783, 304, 267, 372, 574, 14, 2708, 360, 1624, 13, 24, 358, 339, 372, 399, 5956, 83, 7, 450, 574, 421, 199, 318, 2446, 837, 272, 408, 6756, 2397, 2376, 1041, 272, 2288, 1101, 221, 327, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 2288, 13, 6242, 339, 9698, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 1412, 9, 68, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 358, 272, 943, 63, 354, 275, 283, 4853, 13, 396, 13, 10828, 4111, 83, 14, 793, 7, 450, 18354, 14, 362, 751, 342, 272, 291, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 339, 3016, 275, 2050, 14, 21982, 8, 736, 14, 515, 14, 904, 2336, 2791, 297, 943, 63, 354, 430, 272, 3016, 14, 26076, 8, 8911, 9, 272, 2512, 14, 18826, 8, 2232, 9, 339, 3016, 275, 2050, 14, 21982, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 277, 63, 694, 12, 19155, 283, 7270, 297, 943, 63, 354, 1724, 272, 3016, 14, 26076, 8, 8911, 9, 272, 2512, 14, 18826, 8, 2232, 9, 339, 2512, 14, 13548, 8, 4806, 14, 5287, 9, 339, 862, 26, 267, 2512, 14, 1757, 360, 12887, 26, 450, 83, 297, 636, 493, 3368, 398, 1101, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 22159, 283, 14815, 269, 14, 1001, 358, 398, 862, 26, 288, 1101, 275, 1010, 19625, 2028, 8, 888, 63, 515, 9, 267, 871, 5925, 26, 288, 2512, 14, 1971, 360, 547, 7664, 1101, 26, 450, 83, 297, 1101, 63, 515, 9, 288, 4458, 360, 1944, 16182, 269, 1101, 1911, 14, 2494, 32271, 7187, 63, 2864, 63, 16058, 63, 3843, 3311, 775, 540, 340, 314, 511, 365, 440, 18170, 370, 314, 2257, 1591, 2659, 398, 2512, 14, 1757, 360, 14517, 26, 450, 83, 297, 283, 1987, 904, 8, 29942, 14, 3513, 8, 67, 9, 367, 286, 315, 1101, 14, 4958, 430, 267, 2512, 14, 1757, 360, 4718, 12693, 26, 450, 83, 297, 1101, 14, 1548, 63, 20244, 9, 267, 2512, 14, 1757, 360, 6713, 12693, 26, 450, 83, 297, 1101, 14, 3846, 63, 20244, 9, 267, 2512, 14, 1757, 360, 27444, 570, 26, 450, 83, 297, 1101, 14, 10828, 63, 493, 9, 398, 4409, 63, 6525, 275, 756, 398, 340, 747, 14, 515, 14, 4846, 3460, 493, 3368, 508, 283, 14815, 269, 14, 647, 356, 288, 340, 1101, 14, 10828, 63, 493, 26, 355, 1249, 12, 2589, 12, 4409, 63, 6525, 275, 8486, 342, 288, 587, 26, 355, 1249, 12, 2589, 275, 7876, 342, 267, 587, 26, 288, 1249, 12, 2589, 275, 16182, 269, 342, 398, 2512, 14, 1757, 360, 2540, 1414, 26, 450, 83, 297, 283, 1987, 904, 8, 29942, 14, 3513, 8, 67, 9, 367, 286 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 2620, 26499, 436, 1233, 11745, 16182, 269, 367, 675, 543, 3242, 13, 396, 14, 199, 199, 1918, 16182, 269, 23739, 2877, 2446, 12901, 26, 199, 199, 17, 9, 8612, 314, 2366, 12693, 1202, 370, 1255, 511, 7249, 436, 3242, 1233, 14, 199, 18, 9, 22896, 2716, 1233, 11745, 11284, 402, 3242, 1233, 14, 199, 199, 1918, 16182, 269, 365, 7934, 1373, 402, 2877, 15217, 26, 199, 199, 17, 9, 4068, 314, 7614, 4799, 282, 13673, 2142, 4066, 465, 3242, 503, 4613, 14, 2043, 961, 365, 1066, 863, 1891, 379, 701, 876, 6455, 314, 16182, 269, 2082, 370, 314, 15097, 701, 3242, 13, 396, 14, 199, 199, 18, 9, 3709, 314, 2366, 12693, 1380, 3879, 3242, 4621, 14, 2043, 961, 365, 1454, 3748, 1380, 18170, 370, 314, 2257, 1591, 14, 2043, 6630, 663, 314, 32271, 7187, 63, 2864, 63, 16058, 63, 3843, 3311, 775, 540, 3734, 1750, 14, 2043, 2779, 883, 506, 2701, 370, 2599, 13, 13552, 314, 2366, 12693, 641, 314, 3982, 1591, 14, 2043, 982, 440, 2701, 652, 911, 506, 1202, 370, 663, 3242, 63, 1548, 63, 20244, 14, 199, 199, 19855, 26, 26848, 3242, 13, 396, 543, 314, 1553, 475, 88, 945, 503, 6272, 282, 5791, 3734, 489, 1443, 7981, 314, 16182, 269, 687, 6449, 367, 2295, 1314, 675, 1950, 489, 2943, 1163, 2419, 2257, 12, 503, 1314, 675, 8649, 12, 7037, 370, 29098, 402, 3443, 489, 370, 2879, 314, 12693, 367, 314, 5791, 3734, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 7554, 199, 646, 2022, 199, 646, 747, 199, 646, 984, 199, 646, 20988, 199, 646, 2050, 199, 646, 18354, 199, 199, 2921, 275, 2050, 14, 5572, 360, 14815, 269, 358, 221, 327, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 3866, 13, 354, 199, 3, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 3866, 13, 354, 199, 888, 275, 488, 221, 327, 730, 26, 1010, 19625, 2028, 421, 199, 533, 1010, 19625, 2028, 8, 785, 304, 272, 408, 45, 13530, 2897, 1041, 272, 347, 636, 826, 721, 277, 12, 1101, 63, 515, 304, 267, 408, 9345, 1101, 1041, 267, 543, 1551, 8, 888, 63, 515, 9, 465, 1101, 63, 2592, 26, 288, 485, 888, 275, 2022, 14, 912, 8, 888, 63, 2592, 9, 398, 291, 14, 1548, 63, 20244, 275, 485, 888, 459, 1548, 63, 20244, 418, 267, 291, 14, 10828, 63, 493, 275, 485, 888, 459, 10828, 63, 493, 418, 398, 327, 5574, 687, 314, 3734, 3140, 402, 1101, 3967, 652, 4839, 370, 506, 2896, 701, 13150, 511, 10554, 14, 267, 327, 2779, 2597, 1630, 440, 1929, 370, 6369, 687, 314, 7614, 370, 314, 3982, 14, 2779, 365, 1454, 1202, 641, 314, 7614, 14, 267, 291, 14, 3846, 63, 20244, 275, 747, 14, 2314, 14, 362, 360, 8490, 63, 2864, 63, 16058, 63, 3843, 3311, 775, 540, 297, 488, 9, 398, 291, 14, 4958, 275, 359, 475, 63, 505, 8, 67, 9, 367, 286, 315, 984, 14, 3020, 61, 421, 199, 318, 370, 63, 505, 8, 585, 304, 272, 408, 272, 520, 466, 574, 26, 620, 1204, 488, 272, 520, 4500, 26, 620, 1204, 488, 272, 408, 272, 340, 574, 365, 488, 26, 267, 372, 488, 339, 340, 1228, 8, 585, 12, 2783, 304, 267, 372, 574, 14, 2708, 360, 1624, 13, 24, 358, 339, 372, 399, 5956, 83, 7, 450, 574, 421, 199, 318, 2446, 837, 272, 408, 6756, 2397, 2376, 1041, 272, 2288, 1101, 221, 327, 4287, 26, 3507, 29, 31294, 13, 7011, 12, 2288, 13, 6242, 339, 9698, 275, 2050, 14, 7772, 24713, 18331, 9, 83, 2818, 1412, 9, 68, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 358, 272, 943, 63, 354, 275, 283, 4853, 13, 396, 13, 10828, 4111, 83, 14, 793, 7, 450, 18354, 14, 362, 751, 342, 272, 291, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 339, 3016, 275, 2050, 14, 21982, 8, 736, 14, 515, 14, 904, 2336, 2791, 297, 943, 63, 354, 430, 272, 3016, 14, 26076, 8, 8911, 9, 272, 2512, 14, 18826, 8, 2232, 9, 339, 3016, 275, 2050, 14, 21982, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 277, 63, 694, 12, 19155, 283, 7270, 297, 943, 63, 354, 1724, 272, 3016, 14, 26076, 8, 8911, 9, 272, 2512, 14, 18826, 8, 2232, 9, 339, 2512, 14, 13548, 8, 4806, 14, 5287, 9, 339, 862, 26, 267, 2512, 14, 1757, 360, 12887, 26, 450, 83, 297, 636, 493, 3368, 398, 1101, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 22159, 283, 14815, 269, 14, 1001, 358, 398, 862, 26, 288, 1101, 275, 1010, 19625, 2028, 8, 888, 63, 515, 9, 267, 871, 5925, 26, 288, 2512, 14, 1971, 360, 547, 7664, 1101, 26, 450, 83, 297, 1101, 63, 515, 9, 288, 4458, 360, 1944, 16182, 269, 1101, 1911, 14, 2494, 32271, 7187, 63, 2864, 63, 16058, 63, 3843, 3311, 775, 540, 340, 314, 511, 365, 440, 18170, 370, 314, 2257, 1591, 2659, 398, 2512, 14, 1757, 360, 14517, 26, 450, 83, 297, 283, 1987, 904, 8, 29942, 14, 3513, 8, 67, 9, 367, 286, 315, 1101, 14, 4958, 430, 267, 2512, 14, 1757, 360, 4718, 12693, 26, 450, 83, 297, 1101, 14, 1548, 63, 20244, 9, 267, 2512, 14, 1757, 360, 6713, 12693, 26, 450, 83, 297, 1101, 14, 3846, 63, 20244, 9, 267, 2512, 14, 1757, 360, 27444, 570, 26, 450, 83, 297, 1101, 14, 10828, 63, 493, 9, 398, 4409, 63, 6525, 275, 756, 398, 340, 747, 14, 515, 14, 4846, 3460, 493, 3368, 508, 283, 14815, 269, 14, 647, 356, 288, 340, 1101, 14, 10828, 63, 493, 26, 355, 1249, 12, 2589, 12, 4409, 63, 6525, 275, 8486, 342, 288, 587, 26, 355, 1249, 12, 2589, 275, 7876, 342, 267, 587, 26, 288, 1249, 12, 2589, 275, 16182, 269, 342, 398, 2512, 14, 1757, 360, 2540, 1414, 26, 450, 83, 297, 283, 1987, 904, 8, 29942, 14, 3513, 8, 67, 9, 367, 286, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
egenerat/flight-manager
django/contrib/gis/db/backends/postgis/adapter.py
12
1200
""" This object provides quoting for GEOS geometries into PostgreSQL/PostGIS. """ from psycopg2 import Binary from psycopg2.extensions import ISQLQuote class PostGISAdapter(object): def __init__(self, geom): "Initializes on the geometry." # Getting the WKB (in string form, to allow easy pickling of # the adaptor) and the SRID from the geometry. self.ewkb = str(geom.ewkb) self.srid = geom.srid def __conform__(self, proto): # Does the given protocol conform to what Psycopg2 expects? if proto == ISQLQuote: return self else: raise Exception('Error implementing psycopg2 protocol. Is psycopg2 installed?') def __eq__(self, other): return (self.ewkb == other.ewkb) and (self.srid == other.srid) def __str__(self): return self.getquoted() def getquoted(self): "Returns a properly quoted string for use in PostgreSQL/PostGIS." # Want to use WKB, so wrap with psycopg2 Binary() to quote properly. return 'ST_GeomFromEWKB(E%s)' % Binary(self.ewkb) def prepare_database_save(self, unused): return self
mit
[ 624, 1223, 961, 909, 6571, 18593, 367, 11920, 24883, 1901, 20175, 15, 6564, 11092, 14, 202, 199, 624, 2999, 199, 504, 15492, 18, 492, 14161, 202, 199, 504, 15492, 18, 14, 5359, 492, 2281, 2940, 12838, 2999, 199, 533, 20929, 10200, 8, 785, 304, 1128, 347, 636, 826, 721, 277, 12, 9671, 304, 1039, 298, 23489, 641, 314, 3400, 2122, 1039, 327, 20703, 314, 644, 12780, 334, 262, 1059, 1824, 12, 370, 2040, 8837, 24394, 402, 1039, 327, 314, 19520, 269, 9, 436, 314, 22425, 687, 314, 3400, 14, 1039, 291, 14, 546, 7862, 275, 620, 8, 6481, 14, 546, 7862, 9, 1039, 291, 14, 10498, 275, 9671, 14, 10498, 2958, 347, 636, 388, 964, 721, 277, 12, 4104, 304, 1039, 327, 12078, 314, 1627, 4113, 26449, 370, 4052, 510, 1786, 11476, 18, 14292, 31, 1039, 340, 4104, 508, 2281, 2940, 12838, 26, 1675, 372, 291, 1039, 587, 26, 1675, 746, 2186, 360, 547, 18234, 15492, 18, 4113, 14, 6596, 15492, 18, 4903, 18478, 2958, 347, 636, 4077, 721, 277, 12, 1163, 304, 1039, 372, 334, 277, 14, 546, 7862, 508, 1163, 14, 546, 7862, 9, 436, 334, 277, 14, 10498, 508, 1163, 14, 10498, 9, 2958, 347, 636, 495, 721, 277, 304, 1039, 372, 291, 14, 362, 9888, 342, 2958, 347, 664, 9888, 8, 277, 304, 1039, 298, 3407, 282, 7684, 10999, 1059, 367, 675, 315, 20175, 15, 6564, 11092, 2122, 1039, 327, 644, 867, 370, 675, 644, 12780, 12, 880, 4816, 543, 15492, 18, 14161, 342, 370, 6313, 7684, 14, 1039, 372, 283, 840, 63, 13427, 2532, 37, 28328, 8, 37, 5, 83, 3171, 450, 14161, 8, 277, 14, 546, 7862, 9, 2958, 347, 9275, 63, 4659, 63, 2117, 8, 277, 12, 9563, 304, 1039, 372, 291, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1223, 961, 909, 6571, 18593, 367, 11920, 24883, 1901, 20175, 15, 6564, 11092, 14, 202, 199, 624, 2999, 199, 504, 15492, 18, 492, 14161, 202, 199, 504, 15492, 18, 14, 5359, 492, 2281, 2940, 12838, 2999, 199, 533, 20929, 10200, 8, 785, 304, 1128, 347, 636, 826, 721, 277, 12, 9671, 304, 1039, 298, 23489, 641, 314, 3400, 2122, 1039, 327, 20703, 314, 644, 12780, 334, 262, 1059, 1824, 12, 370, 2040, 8837, 24394, 402, 1039, 327, 314, 19520, 269, 9, 436, 314, 22425, 687, 314, 3400, 14, 1039, 291, 14, 546, 7862, 275, 620, 8, 6481, 14, 546, 7862, 9, 1039, 291, 14, 10498, 275, 9671, 14, 10498, 2958, 347, 636, 388, 964, 721, 277, 12, 4104, 304, 1039, 327, 12078, 314, 1627, 4113, 26449, 370, 4052, 510, 1786, 11476, 18, 14292, 31, 1039, 340, 4104, 508, 2281, 2940, 12838, 26, 1675, 372, 291, 1039, 587, 26, 1675, 746, 2186, 360, 547, 18234, 15492, 18, 4113, 14, 6596, 15492, 18, 4903, 18478, 2958, 347, 636, 4077, 721, 277, 12, 1163, 304, 1039, 372, 334, 277, 14, 546, 7862, 508, 1163, 14, 546, 7862, 9, 436, 334, 277, 14, 10498, 508, 1163, 14, 10498, 9, 2958, 347, 636, 495, 721, 277, 304, 1039, 372, 291, 14, 362, 9888, 342, 2958, 347, 664, 9888, 8, 277, 304, 1039, 298, 3407, 282, 7684, 10999, 1059, 367, 675, 315, 20175, 15, 6564, 11092, 2122, 1039, 327, 644, 867, 370, 675, 644, 12780, 12, 880, 4816, 543, 15492, 18, 14161, 342, 370, 6313, 7684, 14, 1039, 372, 283, 840, 63, 13427, 2532, 37, 28328, 8, 37, 5, 83, 3171, 450, 14161, 8, 277, 14, 546, 7862, 9, 2958, 347, 9275, 63, 4659, 63, 2117, 8, 277, 12, 9563, 304, 1039, 372, 291, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
0x90sled/catapult
tracing/third_party/tvcm/third_party/rcssmin/_setup/py2/dist.py
43
1436
# -*- coding: ascii -*- # # Copyright 2007, 2008, 2009, 2010, 2011 # Andr\xe9 Malo or his licensors, as applicable # # 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. """ ================ dist utilities ================ dist utilities. """ __author__ = u"Andr\xe9 Malo" __docformat__ = "restructuredtext en" import sys as _sys from _setup import shell as _shell def run_setup(*args, **kwargs): """ Run setup """ if 'setup' in kwargs: script = kwargs.get('setup') or 'setup.py' del kwargs['setup'] else: script = 'setup.py' if 'fakeroot' in kwargs: fakeroot = kwargs['fakeroot'] del kwargs['fakeroot'] else: fakeroot = None if kwargs: raise TypeError("Unrecognized keyword parameters") script = _shell.native(script) argv = [_sys.executable, script] + list(args) if fakeroot: argv.insert(0, fakeroot) return not _shell.spawn(*argv)
bsd-3-clause
[ 3, 1882, 2803, 26, 13294, 1882, 199, 3, 199, 3, 1898, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 199, 3, 6061, 82, 60, 1845, 25, 603, 12201, 503, 17049, 23854, 17564, 12, 465, 3964, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 199, 1280, 199, 2917, 15841, 199, 1280, 199, 199, 2686, 15841, 14, 199, 624, 199, 363, 2502, 363, 275, 399, 2, 3325, 82, 60, 1845, 25, 603, 12201, 2, 199, 363, 21841, 363, 275, 298, 26854, 655, 2, 199, 199, 646, 984, 465, 485, 1274, 199, 199, 504, 485, 2758, 492, 5218, 465, 485, 5641, 421, 199, 318, 1255, 63, 2758, 2031, 589, 12, 1011, 958, 304, 272, 408, 3378, 3272, 408, 272, 340, 283, 2758, 7, 315, 2074, 26, 267, 2884, 275, 2074, 14, 362, 360, 2758, 358, 503, 283, 2758, 14, 647, 7, 267, 2150, 2074, 459, 2758, 418, 272, 587, 26, 267, 2884, 275, 283, 2758, 14, 647, 7, 272, 340, 283, 667, 2570, 26974, 7, 315, 2074, 26, 267, 289, 1151, 3478, 357, 275, 2074, 459, 667, 2570, 26974, 418, 267, 2150, 2074, 459, 667, 2570, 26974, 418, 272, 587, 26, 267, 289, 1151, 3478, 357, 275, 488, 272, 340, 2074, 26, 267, 746, 3146, 480, 22517, 4252, 2633, 531, 339, 2884, 275, 485, 5641, 14, 6106, 8, 1579, 9, 272, 9238, 275, 15500, 1274, 14, 5904, 12, 2884, 61, 435, 769, 8, 589, 9, 272, 340, 289, 1151, 3478, 357, 26, 267, 9238, 14, 3176, 8, 16, 12, 289, 1151, 3478, 357, 9, 272, 372, 440, 485, 5641, 14, 10212, 2031, 3020, 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 ]
[ 1882, 2803, 26, 13294, 1882, 199, 3, 199, 3, 1898, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 199, 3, 6061, 82, 60, 1845, 25, 603, 12201, 503, 17049, 23854, 17564, 12, 465, 3964, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 199, 1280, 199, 2917, 15841, 199, 1280, 199, 199, 2686, 15841, 14, 199, 624, 199, 363, 2502, 363, 275, 399, 2, 3325, 82, 60, 1845, 25, 603, 12201, 2, 199, 363, 21841, 363, 275, 298, 26854, 655, 2, 199, 199, 646, 984, 465, 485, 1274, 199, 199, 504, 485, 2758, 492, 5218, 465, 485, 5641, 421, 199, 318, 1255, 63, 2758, 2031, 589, 12, 1011, 958, 304, 272, 408, 3378, 3272, 408, 272, 340, 283, 2758, 7, 315, 2074, 26, 267, 2884, 275, 2074, 14, 362, 360, 2758, 358, 503, 283, 2758, 14, 647, 7, 267, 2150, 2074, 459, 2758, 418, 272, 587, 26, 267, 2884, 275, 283, 2758, 14, 647, 7, 272, 340, 283, 667, 2570, 26974, 7, 315, 2074, 26, 267, 289, 1151, 3478, 357, 275, 2074, 459, 667, 2570, 26974, 418, 267, 2150, 2074, 459, 667, 2570, 26974, 418, 272, 587, 26, 267, 289, 1151, 3478, 357, 275, 488, 272, 340, 2074, 26, 267, 746, 3146, 480, 22517, 4252, 2633, 531, 339, 2884, 275, 485, 5641, 14, 6106, 8, 1579, 9, 272, 9238, 275, 15500, 1274, 14, 5904, 12, 2884, 61, 435, 769, 8, 589, 9, 272, 340, 289, 1151, 3478, 357, 26, 267, 9238, 14, 3176, 8, 16, 12, 289, 1151, 3478, 357, 9, 272, 372, 440, 485, 5641, 14, 10212, 2031, 3020, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hivam/doctor_dental_care
models/doctor_list_report_odontologia.py
1
6674
# -*- encoding: 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.osv import fields, osv from openerp.tools.translate import _ import logging _logger = logging.getLogger(__name__) import base64 import sys, os from datetime import date, datetime, timedelta class doctor_list_report_odontologia(osv.osv): _name= 'doctor.list_report_odontologia' _columns = { 'professional_id': fields.many2one('doctor.professional', 'Doctor'), 'attentions_odontology_ids': fields.one2many('doctor.hc.odontologia', 'list_report_odontologia_id', 'Attentions'), 'patient_id': fields.many2one('doctor.patient', 'Paciente', required=True), 'fecha_inicio':fields.datetime(u'Inicio Atención'), 'fecha_fin':fields.datetime(u'Fin Atención'), 'especialidad_id':fields.many2one('doctor.speciality', 'Especialidad'), 'ultimas_citas' :fields.boolean('Ultima Cita'), } _defaults = { 'patient_id' : lambda self, cr, uid, context: context.get('default_patient_id', False), 'professional_id' : lambda self, cr, uid, context: context.get('default_professional_id', False), 'ultimas_citas' : lambda self, cr, uid, context: context.get('default_ultimas_citas', False), #'fecha_fin' : lambda *a: datetime.now().strftime('%Y-%m-%d %H:%M:%S'), } #Funcion para cargar la especialidad del profesional en la salud def onchange_cargar_especialidad_doctor(self, cr, uid, ids, patient_id, professional_id, date_begin, date_end, context=None): if patient_id and professional_id: return self.cargar_datos_impresion_atencion(cr, uid, patient_id, professional_id, None, date_begin, date_end, "1", context=context) return False #Funcion para cargar las atenciones por especialidad def onchange_cargar_por_especialidad(self, cr, uid, ids, patient_id, professional_id, especialidad_id, date_begin, date_end, context=None): if especialidad_id and patient_id and professional_id: return self.cargar_datos_impresion_atencion(cr, uid, patient_id, professional_id, especialidad_id, date_begin, date_end, "1", context=context) return False #Funcion para cargar las atenciones por fecha inicio y fecha fin def onchange_cargar_por_fechas(self, cr, uid, ids, patient_id, professional_id, date_begin, date_end, context=None): return False def cargar_datos_impresion_atencion(self, cr, uid, patient_id, professional_id, especialidad_id, date_begin, date_end, opcion, context=None): atenciones='' atenciones_psicologia='' nombre_especialidad='' fecha_inicial='' fecha_final='' nombre_especialidad_id='' #Almacenamos la fecha en la variable fecha_inicial dependiendo si tiene o no el date_begin if date_begin: fecha_inicial=date_begin else: fecha_inicial= "2010-11-30 00:27:09" #Almacenamos la fecha en la variable fecha_final dependiendo si tiene o no el date_begin if date_end: fecha_final=date_end else: fecha_final= datetime.now().strftime('%Y-%m-%d %H:%M:%S') #Almacenamos el nombre de la especialidad en la varianle nombre_especialidad dependiendo si ha escogido un doctor o no if professional_id: nombre_especialidad = self.pool.get('doctor.professional').browse(cr, uid, professional_id ).speciality_id.name nombre_especialidad_id= self.pool.get('doctor.professional').browse(cr, uid, professional_id ).speciality_id.id else: nombre_especialidad = self.pool.get('doctor.speciality').browse(cr, uid, especialidad_id ).name nombre_especialidad_id = especialidad_id #Opcion donde hay paciente y doctor, como tambien la posible fecha inicial y final if opcion == "1": _logger.info('Capturando desde cualquier historia') atenciones = self.pool.get('doctor.hc.odontologia').search(cr, uid, [('patient_id', '=', patient_id), ('professional_id', '=', professional_id), ('date_attention', '>=', fecha_inicial), ('date_attention', '<=', fecha_final)]) return {'value': {'attentions_odontology_ids': atenciones, 'especialidad_id': nombre_especialidad_id}} return False #Funcion para cargar las ultimas atenciones def onchange_cargar_ultimas_atenciones(self, cr, uid, ids, patient_id, professional_id, ultimas_citas, context=None): _logger.info('aqui') if ultimas_citas: atenciones='' if patient_id and professional_id: atenciones = self.pool.get('doctor.hc.odontologia').search(cr, uid, [('patient_id', '=', patient_id), ('professional_id', '=', professional_id)]) atenciones_id=[] if len(atenciones) > 4: for x in range(1, 4): _logger.info(atenciones[x]) atenciones_id.append(atenciones[x]) return {'value': {'attentions_odontology_ids': atenciones_id}} else: for x in range(len(atenciones)): atenciones_id.append(atenciones[x]) return {'value': {'attentions_odontology_ids': atenciones_id}} return False #Funcion que permite cargar las ultimas tres atenciones que tenga el paciente en el momento. def button_cargar_ultimas_atenciones(self, cr, uid, ids, context=None): _logger.info('Estamos imprimiendo ultimas tres atenciones: ') data = self.read(cr, uid, ids)[0] if data['attentions_odontology_ids']: return self.export_report_print(cr, uid, ids, 'doctor_attention_odontologia_report') return False def button_imprimir_algunos_informes(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids)[0] if data['attentions_odontology_ids']: return self.export_report_print(cr, uid, ids, 'doctor_attention_odontologia_report') return False def export_report_print(self, cr, uid, ids, name_report, context=None): if context is None: context = {} data = self.read(cr, uid, ids)[0] _logger.info('entro') _logger.info(data) return { 'type': 'ir.actions.report.xml', 'report_name': name_report, } doctor_list_report_odontologia()
agpl-3.0
[ 199, 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 23441, 8776, 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, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 2050, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 646, 1300, 772, 199, 646, 984, 12, 747, 199, 504, 2197, 492, 1434, 12, 2197, 12, 6871, 6905, 199, 533, 886, 630, 63, 513, 63, 3070, 63, 364, 26296, 793, 4674, 8, 4795, 14, 4795, 304, 421, 198, 63, 354, 29, 283, 1117, 630, 14, 513, 63, 3070, 63, 364, 26296, 793, 4674, 7, 4388, 198, 63, 3406, 275, 469, 507, 198, 7, 14979, 28661, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 1117, 630, 14, 14979, 28661, 297, 283, 2585, 630, 659, 507, 198, 7, 4867, 852, 63, 364, 26296, 4956, 63, 1580, 356, 1504, 14, 368, 18, 3479, 360, 1117, 630, 14, 15907, 14, 364, 26296, 793, 4674, 297, 283, 513, 63, 3070, 63, 364, 26296, 793, 4674, 63, 344, 297, 283, 1271, 724, 852, 659, 507, 198, 7, 25067, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 1117, 630, 14, 25067, 297, 283, 4232, 559, 27036, 297, 1415, 29, 549, 395, 507, 198, 7, 771, 9518, 63, 26715, 2308, 356, 955, 14, 2083, 8, 85, 7, 607, 530, 2308, 437, 724, 27064, 659, 507, 198, 7, 771, 9518, 63, 2408, 356, 955, 14, 2083, 8, 85, 7, 8694, 437, 724, 27064, 659, 507, 198, 7, 397, 910, 2555, 350, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 1117, 630, 14, 6664, 1209, 297, 283, 37, 3017, 2555, 350, 659, 507, 198, 7, 1141, 5892, 63, 14422, 305, 7, 520, 955, 14, 4871, 360, 18505, 280, 391, 445, 21492, 659, 199, 198, 93, 421, 198, 63, 4322, 275, 469, 507, 198, 7, 25067, 63, 344, 7, 520, 2400, 291, 12, 2467, 12, 1747, 12, 1067, 26, 1067, 14, 362, 360, 885, 63, 25067, 63, 344, 297, 756, 395, 507, 198, 7, 14979, 28661, 63, 344, 7, 520, 2400, 291, 12, 2467, 12, 1747, 12, 1067, 26, 1067, 14, 362, 360, 885, 63, 14979, 28661, 63, 344, 297, 756, 395, 507, 198, 7, 1141, 5892, 63, 14422, 305, 7, 520, 2400, 291, 12, 2467, 12, 1747, 12, 1067, 26, 1067, 14, 362, 360, 885, 63, 1141, 5892, 63, 14422, 305, 297, 756, 395, 507, 198, 19367, 771, 9518, 63, 2408, 7, 520, 2400, 627, 65, 26, 2197, 14, 2131, 1252, 6205, 3508, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 659, 199, 198, 93, 198, 421, 198, 3, 19941, 9718, 12665, 286, 1273, 285, 1127, 325, 3017, 2555, 350, 2150, 557, 771, 438, 279, 655, 1127, 18641, 1181, 199, 198, 318, 20258, 63, 67, 1273, 285, 63, 397, 910, 2555, 350, 63, 1117, 630, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 1067, 29, 403, 304, 2742, 198, 692, 30905, 63, 344, 436, 22398, 28661, 63, 344, 26, 686, 198, 1107, 291, 14, 67, 1273, 285, 63, 4616, 736, 63, 3236, 264, 438, 63, 323, 78, 9718, 8, 1556, 12, 1747, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 488, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 298, 17, 401, 1067, 29, 1100, 9, 2742, 198, 1107, 756, 421, 198, 3, 19941, 9718, 12665, 286, 1273, 285, 23325, 282, 724, 559, 4548, 8706, 325, 3017, 2555, 350, 199, 198, 318, 20258, 63, 67, 1273, 285, 63, 7314, 63, 397, 910, 2555, 350, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 325, 3017, 2555, 350, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 1067, 29, 403, 304, 2742, 198, 692, 325, 3017, 2555, 350, 63, 344, 436, 30905, 63, 344, 436, 22398, 28661, 63, 344, 26, 686, 198, 1107, 291, 14, 67, 1273, 285, 63, 4616, 736, 63, 3236, 264, 438, 63, 323, 78, 9718, 8, 1556, 12, 1747, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 325, 3017, 2555, 350, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 298, 17, 401, 1067, 29, 1100, 9, 2742, 198, 1107, 756, 421, 198, 3, 19941, 9718, 12665, 286, 1273, 285, 23325, 282, 724, 559, 4548, 8706, 1964, 9518, 315, 530, 2308, 612, 1964, 9518, 2583, 199, 198, 318, 20258, 63, 67, 1273, 285, 63, 7314, 63, 771, 335, 305, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 1067, 29, 403, 304, 2742, 198, 1107, 756, 421, 198, 318, 286, 1273, 285, 63, 4616, 736, 63, 3236, 264, 438, 63, 323, 78, 9718, 8, 277, 12, 2467, 12, 1747, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 325, 3017, 2555, 350, 63, 344, 12, 1434, 63, 5037 ]
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 23441, 8776, 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, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 2050, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 646, 1300, 772, 199, 646, 984, 12, 747, 199, 504, 2197, 492, 1434, 12, 2197, 12, 6871, 6905, 199, 533, 886, 630, 63, 513, 63, 3070, 63, 364, 26296, 793, 4674, 8, 4795, 14, 4795, 304, 421, 198, 63, 354, 29, 283, 1117, 630, 14, 513, 63, 3070, 63, 364, 26296, 793, 4674, 7, 4388, 198, 63, 3406, 275, 469, 507, 198, 7, 14979, 28661, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 1117, 630, 14, 14979, 28661, 297, 283, 2585, 630, 659, 507, 198, 7, 4867, 852, 63, 364, 26296, 4956, 63, 1580, 356, 1504, 14, 368, 18, 3479, 360, 1117, 630, 14, 15907, 14, 364, 26296, 793, 4674, 297, 283, 513, 63, 3070, 63, 364, 26296, 793, 4674, 63, 344, 297, 283, 1271, 724, 852, 659, 507, 198, 7, 25067, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 1117, 630, 14, 25067, 297, 283, 4232, 559, 27036, 297, 1415, 29, 549, 395, 507, 198, 7, 771, 9518, 63, 26715, 2308, 356, 955, 14, 2083, 8, 85, 7, 607, 530, 2308, 437, 724, 27064, 659, 507, 198, 7, 771, 9518, 63, 2408, 356, 955, 14, 2083, 8, 85, 7, 8694, 437, 724, 27064, 659, 507, 198, 7, 397, 910, 2555, 350, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 1117, 630, 14, 6664, 1209, 297, 283, 37, 3017, 2555, 350, 659, 507, 198, 7, 1141, 5892, 63, 14422, 305, 7, 520, 955, 14, 4871, 360, 18505, 280, 391, 445, 21492, 659, 199, 198, 93, 421, 198, 63, 4322, 275, 469, 507, 198, 7, 25067, 63, 344, 7, 520, 2400, 291, 12, 2467, 12, 1747, 12, 1067, 26, 1067, 14, 362, 360, 885, 63, 25067, 63, 344, 297, 756, 395, 507, 198, 7, 14979, 28661, 63, 344, 7, 520, 2400, 291, 12, 2467, 12, 1747, 12, 1067, 26, 1067, 14, 362, 360, 885, 63, 14979, 28661, 63, 344, 297, 756, 395, 507, 198, 7, 1141, 5892, 63, 14422, 305, 7, 520, 2400, 291, 12, 2467, 12, 1747, 12, 1067, 26, 1067, 14, 362, 360, 885, 63, 1141, 5892, 63, 14422, 305, 297, 756, 395, 507, 198, 19367, 771, 9518, 63, 2408, 7, 520, 2400, 627, 65, 26, 2197, 14, 2131, 1252, 6205, 3508, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 659, 199, 198, 93, 198, 421, 198, 3, 19941, 9718, 12665, 286, 1273, 285, 1127, 325, 3017, 2555, 350, 2150, 557, 771, 438, 279, 655, 1127, 18641, 1181, 199, 198, 318, 20258, 63, 67, 1273, 285, 63, 397, 910, 2555, 350, 63, 1117, 630, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 1067, 29, 403, 304, 2742, 198, 692, 30905, 63, 344, 436, 22398, 28661, 63, 344, 26, 686, 198, 1107, 291, 14, 67, 1273, 285, 63, 4616, 736, 63, 3236, 264, 438, 63, 323, 78, 9718, 8, 1556, 12, 1747, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 488, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 298, 17, 401, 1067, 29, 1100, 9, 2742, 198, 1107, 756, 421, 198, 3, 19941, 9718, 12665, 286, 1273, 285, 23325, 282, 724, 559, 4548, 8706, 325, 3017, 2555, 350, 199, 198, 318, 20258, 63, 67, 1273, 285, 63, 7314, 63, 397, 910, 2555, 350, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 325, 3017, 2555, 350, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 1067, 29, 403, 304, 2742, 198, 692, 325, 3017, 2555, 350, 63, 344, 436, 30905, 63, 344, 436, 22398, 28661, 63, 344, 26, 686, 198, 1107, 291, 14, 67, 1273, 285, 63, 4616, 736, 63, 3236, 264, 438, 63, 323, 78, 9718, 8, 1556, 12, 1747, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 325, 3017, 2555, 350, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 298, 17, 401, 1067, 29, 1100, 9, 2742, 198, 1107, 756, 421, 198, 3, 19941, 9718, 12665, 286, 1273, 285, 23325, 282, 724, 559, 4548, 8706, 1964, 9518, 315, 530, 2308, 612, 1964, 9518, 2583, 199, 198, 318, 20258, 63, 67, 1273, 285, 63, 7314, 63, 771, 335, 305, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 1434, 63, 5037, 12, 1434, 63, 500, 12, 1067, 29, 403, 304, 2742, 198, 1107, 756, 421, 198, 318, 286, 1273, 285, 63, 4616, 736, 63, 3236, 264, 438, 63, 323, 78, 9718, 8, 277, 12, 2467, 12, 1747, 12, 30905, 63, 344, 12, 22398, 28661, 63, 344, 12, 325, 3017, 2555, 350, 63, 344, 12, 1434, 63, 5037, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
0k/odoo
addons/portal/tests/test_portal.py
116
14150
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.addons.mail.tests.common import TestMail from openerp.exceptions import AccessError from openerp.osv.orm import except_orm from openerp.tools.misc import mute_logger class test_portal(TestMail): def setUp(self): super(test_portal, self).setUp() cr, uid = self.cr, self.uid # Find Portal group group_portal = self.registry('ir.model.data').get_object(cr, uid, 'base', 'group_portal') self.group_portal_id = group_portal.id # Create Chell (portal user) self.user_chell_id = self.res_users.create(cr, uid, {'name': 'Chell Gladys', 'login': 'chell', 'email': 'chell@gladys.portal', 'groups_id': [(6, 0, [self.group_portal_id])]}) self.user_chell = self.res_users.browse(cr, uid, self.user_chell_id) self.partner_chell_id = self.user_chell.partner_id.id # Create a PigsPortal group self.group_port_id = self.mail_group.create(cr, uid, {'name': 'PigsPortal', 'public': 'groups', 'group_public_id': self.group_portal_id}, {'mail_create_nolog': True}) # Set an email address for the user running the tests, used as Sender for outgoing mails self.res_users.write(cr, uid, uid, {'email': 'test@localhost'}) @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.models') def test_00_mail_access_rights(self): """ Test basic mail_message and mail_group access rights for portal users. """ cr, uid = self.cr, self.uid mail_compose = self.registry('mail.compose.message') # Prepare group: Pigs and PigsPortal pigs_msg_id = self.mail_group.message_post(cr, uid, self.group_pigs_id, body='Message') port_msg_id = self.mail_group.message_post(cr, uid, self.group_port_id, body='Message') # Do: Chell browses Pigs -> ko, employee group chell_pigs = self.mail_group.browse(cr, self.user_chell_id, self.group_pigs_id) with self.assertRaises(except_orm): trigger_read = chell_pigs.name # Do: Chell posts a message on Pigs, crash because can not write on group or is not in the followers with self.assertRaises(AccessError): self.mail_group.message_post(cr, self.user_chell_id, self.group_pigs_id, body='Message') # Do: Chell is added into Pigs followers and browse it -> ok for messages, ko for partners (no read permission) self.mail_group.message_subscribe_users(cr, uid, [self.group_pigs_id], [self.user_chell_id]) chell_pigs = self.mail_group.browse(cr, self.user_chell_id, self.group_pigs_id) trigger_read = chell_pigs.name for message in chell_pigs.message_ids: trigger_read = message.subject for partner in chell_pigs.message_follower_ids: if partner.id == self.partner_chell_id: # Chell can read her own partner record continue with self.assertRaises(except_orm): trigger_read = partner.name # Do: Chell comments Pigs, ok because he is now in the followers self.mail_group.message_post(cr, self.user_chell_id, self.group_pigs_id, body='I love Pigs') # Do: Chell creates a mail.compose.message record on Pigs, because he uses the wizard compose_id = mail_compose.create(cr, self.user_chell_id, {'subject': 'Subject', 'body': 'Body text', 'partner_ids': []}, {'default_composition_mode': 'comment', 'default_model': 'mail.group', 'default_res_id': self.group_pigs_id}) mail_compose.send_mail(cr, self.user_chell_id, [compose_id]) # Do: Chell replies to a Pigs message using the composer compose_id = mail_compose.create(cr, self.user_chell_id, {'subject': 'Subject', 'body': 'Body text'}, {'default_composition_mode': 'comment', 'default_parent_id': pigs_msg_id}) mail_compose.send_mail(cr, self.user_chell_id, [compose_id]) # Do: Chell browses PigsPortal -> ok because groups security, ko for partners (no read permission) chell_port = self.mail_group.browse(cr, self.user_chell_id, self.group_port_id) trigger_read = chell_port.name for message in chell_port.message_ids: trigger_read = message.subject for partner in chell_port.message_follower_ids: with self.assertRaises(except_orm): trigger_read = partner.name def test_10_mail_invite(self): cr, uid = self.cr, self.uid mail_invite = self.registry('mail.wizard.invite') base_url = self.registry('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='') # Carine Poilvache, with email, should receive emails for comments and emails partner_carine_id = self.res_partner.create(cr, uid, {'name': 'Carine Poilvache', 'email': 'c@c'}) # Do: create a mail_wizard_invite, validate it self._init_mock_build_email() context = {'default_res_model': 'mail.group', 'default_res_id': self.group_pigs_id} mail_invite_id = mail_invite.create(cr, uid, {'partner_ids': [(4, partner_carine_id)], 'send_mail': True}, context) mail_invite.add_followers(cr, uid, [mail_invite_id]) # Test: Pigs followers should contain Admin and Bert group_pigs = self.mail_group.browse(cr, uid, self.group_pigs_id) follower_ids = [follower.id for follower in group_pigs.message_follower_ids] self.assertEqual(set(follower_ids), set([self.partner_admin_id, partner_carine_id]), 'Pigs followers after invite is incorrect') # Test: partner must have been prepared for signup partner_carine = self.res_partner.browse(cr, uid, partner_carine_id) self.assertTrue(partner_carine.signup_valid, 'partner has not been prepared for signup') self.assertTrue(base_url in partner_carine.signup_url, 'signup url is incorrect') self.assertTrue(cr.dbname in partner_carine.signup_url, 'signup url is incorrect') self.assertTrue(partner_carine.signup_token in partner_carine.signup_url, 'signup url is incorrect') # Test: (pretend to) send email and check subject, body self.assertEqual(len(self._build_email_kwargs_list), 1, 'sent email number incorrect, should be only for Bert') for sent_email in self._build_email_kwargs_list: self.assertEqual(sent_email.get('subject'), 'Invitation to follow Discussion group: Pigs', 'invite: subject of invitation email is incorrect') self.assertIn('Administrator invited you to follow Discussion group document: Pigs', sent_email.get('body'), 'invite: body of invitation email is incorrect') self.assertIn(partner_carine.signup_token, sent_email.get('body'), 'invite: body of invitation email does not contain signup token') def test_20_notification_url(self): """ Tests designed to test the URL added in notification emails. """ cr, uid, group_pigs = self.cr, self.uid, self.group_pigs # Partner data partner_raoul = self.res_partner.browse(cr, uid, self.partner_raoul_id) partner_bert_id = self.res_partner.create(cr, uid, {'name': 'bert'}) partner_bert = self.res_partner.browse(cr, uid, partner_bert_id) # Mail data mail_mail_id = self.mail_mail.create(cr, uid, {'state': 'exception'}) mail = self.mail_mail.browse(cr, uid, mail_mail_id) # Test: link for nobody -> None url = self.mail_mail._get_partner_access_link(cr, uid, mail) self.assertEqual(url, None, 'notification email: mails not send to a specific partner should not have any URL') # Test: link for partner -> signup URL url = self.mail_mail._get_partner_access_link(cr, uid, mail, partner=partner_bert) self.assertIn(partner_bert.signup_token, url, 'notification email: mails send to a not-user partner should contain the signup token') # Test: link for user -> signin url = self.mail_mail._get_partner_access_link(cr, uid, mail, partner=partner_raoul) self.assertIn('action=mail.action_mail_redirect', url, 'notification email: link should contain the redirect action') self.assertIn('login=%s' % partner_raoul.user_ids[0].login, url, 'notification email: link should contain the user login') @mute_logger('openerp.addons.mail.mail_thread', 'openerp.models') def test_21_inbox_redirection(self): """ Tests designed to test the inbox redirection of emails notification URLs. """ cr, uid, user_admin, group_pigs = self.cr, self.uid, self.user_admin, self.group_pigs model, act_id = self.ir_model_data.get_object_reference(cr, uid, 'mail', 'action_mail_inbox_feeds') model, port_act_id = self.ir_model_data.get_object_reference(cr, uid, 'portal', 'action_mail_inbox_feeds_portal') # Data: post a message on pigs msg_id = self.group_pigs.message_post(body='My body', partner_ids=[self.partner_bert_id, self.partner_chell_id], type='comment', subtype='mail.mt_comment') # No specific parameters -> should redirect to Inbox action = self.mail_thread.message_redirect_action(cr, self.user_raoul_id, {'params': {}}) self.assertEqual(action.get('type'), 'ir.actions.client', 'URL redirection: action without parameters should redirect to client action Inbox') self.assertEqual(action.get('id'), act_id, 'URL redirection: action without parameters should redirect to client action Inbox') # Bert has read access to Pigs -> should redirect to form view of Pigs action = self.mail_thread.message_redirect_action(cr, self.user_raoul_id, {'params': {'message_id': msg_id}}) self.assertEqual(action.get('type'), 'ir.actions.act_window', 'URL redirection: action with message_id for read-accredited user should redirect to Pigs') self.assertEqual(action.get('res_id'), group_pigs.id, 'URL redirection: action with message_id for read-accredited user should redirect to Pigs') # Bert has no read access to Pigs -> should redirect to Inbox action = self.mail_thread.message_redirect_action(cr, self.user_bert_id, {'params': {'message_id': msg_id}}) self.assertEqual(action.get('type'), 'ir.actions.client', 'URL redirection: action without parameters should redirect to client action Inbox') self.assertEqual(action.get('id'), act_id, 'URL redirection: action without parameters should redirect to client action Inbox') # Chell has no read access to pigs -> should redirect to Portal Inbox action = self.mail_thread.message_redirect_action(cr, self.user_chell_id, {'params': {'message_id': msg_id}}) self.assertEqual(action.get('type'), 'ir.actions.client', 'URL redirection: action without parameters should redirect to client action Inbox') self.assertEqual(action.get('id'), port_act_id, 'URL redirection: action without parameters should redirect to client action Inbox') def test_30_message_read(self): cr, uid, group_port_id = self.cr, self.uid, self.group_port_id # Data: custom subtypes mt_group_public_id = self.mail_message_subtype.create(cr, uid, {'name': 'group_public', 'description': 'Group changed'}) self.ir_model_data.create(cr, uid, {'name': 'mt_group_public', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_group_public_id}) # Data: post messages with various subtypes msg1_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body1', type='comment', subtype='mail.mt_comment') msg2_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body2', type='comment', subtype='mail.mt_group_public') msg3_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body3', type='comment', subtype='mail.mt_comment') msg4_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body4', type='comment') # msg5_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body5', type='notification') # Do: Chell search messages: should not see internal notes (comment without subtype) msg_ids = self.mail_message.search(cr, self.user_chell_id, [('model', '=', 'mail.group'), ('res_id', '=', group_port_id)]) self.assertEqual(set(msg_ids), set([msg1_id, msg2_id, msg3_id]), 'mail_message: portal user has access to messages he should not read') # Do: Chell read messages she can read self.mail_message.read(cr, self.user_chell_id, msg_ids, ['body', 'type', 'subtype_id']) # Do: Chell read a message she should not be able to read with self.assertRaises(except_orm): self.mail_message.read(cr, self.user_chell_id, [msg4_id], ['body', 'type', 'subtype_id'])
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 10788, 14, 1198, 14, 2219, 14, 2330, 492, 1379, 13681, 199, 504, 5166, 14, 3924, 492, 11003, 547, 199, 504, 5166, 14, 4795, 14, 1025, 492, 871, 63, 1025, 199, 504, 5166, 14, 2537, 14, 9923, 492, 333, 938, 63, 2921, 421, 199, 533, 511, 63, 8707, 8, 774, 13681, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 396, 63, 8707, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 6668, 10977, 279, 1572, 267, 1572, 63, 8707, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 8707, 358, 267, 291, 14, 923, 63, 8707, 63, 344, 275, 1572, 63, 8707, 14, 344, 398, 327, 2790, 2799, 1697, 334, 8707, 922, 9, 267, 291, 14, 751, 63, 335, 1697, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 791, 354, 356, 283, 1049, 1697, 598, 76, 350, 588, 297, 283, 2886, 356, 283, 335, 1697, 297, 283, 2123, 356, 283, 335, 1697, 32, 3528, 350, 588, 14, 8707, 297, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 359, 277, 14, 923, 63, 8707, 63, 344, 12457, 1552, 267, 291, 14, 751, 63, 335, 1697, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 9, 267, 291, 14, 3899, 63, 335, 1697, 63, 344, 275, 291, 14, 751, 63, 335, 1697, 14, 3899, 63, 344, 14, 344, 398, 327, 2790, 282, 19835, 458, 26708, 1572, 267, 291, 14, 923, 63, 719, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 981, 8, 1556, 12, 1747, 12, 717, 791, 354, 356, 283, 10542, 458, 26708, 297, 283, 3455, 356, 283, 2634, 297, 283, 923, 63, 3455, 63, 344, 356, 291, 14, 923, 63, 8707, 63, 344, 1386, 717, 791, 1198, 63, 981, 63, 889, 793, 356, 715, 1552, 398, 327, 2494, 376, 3031, 2287, 367, 314, 922, 3879, 314, 2295, 12, 1202, 465, 428, 13747, 367, 21507, 6016, 83, 267, 291, 14, 470, 63, 3707, 14, 952, 8, 1556, 12, 1747, 12, 1747, 12, 791, 2123, 356, 283, 396, 32, 5967, 3071, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 383, 63, 1198, 63, 2732, 63, 17307, 8, 277, 304, 267, 408, 1379, 5678, 6016, 63, 1188, 436, 6016, 63, 923, 2879, 4481, 367, 18428, 4390, 14, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 6016, 63, 12607, 275, 291, 14, 5189, 360, 1198, 14, 12607, 14, 1188, 358, 398, 327, 17008, 1572, 26, 19835, 458, 436, 19835, 458, 26708, 267, 6682, 458, 63, 1328, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 291, 14, 923, 63, 20389, 63, 344, 12, 2396, 534, 2209, 358, 267, 1844, 63, 1328, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 291, 14, 923, 63, 719, 63, 344, 12, 2396, 534, 2209, 358, 398, 327, 4226, 26, 2799, 1697, 330, 1143, 874, 19835, 458, 1035, 20817, 12, 15778, 1572, 267, 682, 1697, 63, 20389, 275, 291, 14, 1198, 63, 923, 14, 4570, 8, 1556, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 12, 291, 14, 923, 63, 20389, 63, 344, 9, 267, 543, 291, 14, 1855, 8, 2590, 63, 1025, 304, 288, 6804, 63, 739, 275, 682, 1697, 63, 20389, 14, 354, 398, 327, 4226, 26, 2799, 1697, 22238, 282, 1245, 641, 19835, 458, 12, 12420, 2952, 883, 440, 2218, 641, 1572, 503, 365, 440, 315, 314, 31474, 267, 543, 291, 14, 1855, 8, 3946, 547, 304, 288, 291, 14, 1198, 63, 923, 14, 1188, 63, 1932, 8, 1556, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 12, 291, 14, 923, 63, 20389, 63, 344, 12, 2396, 534, 2209, 358, 398, 327, 4226, 26, 2799, 1697, 365, 3483, 1901, 19835, 458, 31474, 436, 19249, 652, 1035, 4112, 367, 3788, 12, 20817, 367, 18943, 334, 889, 1586, 4983, 9, 267, 291, 14, 1198, 63, 923, 14, 1188, 63, 10108, 63, 3707, 8, 1556, 12, 1747, 12, 359, 277, 14, 923, 63, 20389, 63, 344, 467, 359, 277, 14, 751, 63, 335, 1697, 63, 344, 566, 267, 682, 1697, 63, 20389, 275, 291, 14, 1198, 63, 923, 14, 4570, 8, 1556, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 12, 291, 14, 923, 63, 20389, 63, 344, 9, 267, 6804, 63, 739, 275, 682, 1697, 63, 20389, 14, 354, 267, 367, 1245, 315, 682, 1697, 63, 20389, 14, 1188, 63, 1580, 26, 288, 6804, 63, 739, 275, 1245, 14, 5875, 267 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 10788, 14, 1198, 14, 2219, 14, 2330, 492, 1379, 13681, 199, 504, 5166, 14, 3924, 492, 11003, 547, 199, 504, 5166, 14, 4795, 14, 1025, 492, 871, 63, 1025, 199, 504, 5166, 14, 2537, 14, 9923, 492, 333, 938, 63, 2921, 421, 199, 533, 511, 63, 8707, 8, 774, 13681, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 396, 63, 8707, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 6668, 10977, 279, 1572, 267, 1572, 63, 8707, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 8, 1556, 12, 1747, 12, 283, 1095, 297, 283, 923, 63, 8707, 358, 267, 291, 14, 923, 63, 8707, 63, 344, 275, 1572, 63, 8707, 14, 344, 398, 327, 2790, 2799, 1697, 334, 8707, 922, 9, 267, 291, 14, 751, 63, 335, 1697, 63, 344, 275, 291, 14, 470, 63, 3707, 14, 981, 8, 1556, 12, 1747, 12, 791, 354, 356, 283, 1049, 1697, 598, 76, 350, 588, 297, 283, 2886, 356, 283, 335, 1697, 297, 283, 2123, 356, 283, 335, 1697, 32, 3528, 350, 588, 14, 8707, 297, 283, 2634, 63, 344, 356, 3842, 22, 12, 378, 12, 359, 277, 14, 923, 63, 8707, 63, 344, 12457, 1552, 267, 291, 14, 751, 63, 335, 1697, 275, 291, 14, 470, 63, 3707, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 9, 267, 291, 14, 3899, 63, 335, 1697, 63, 344, 275, 291, 14, 751, 63, 335, 1697, 14, 3899, 63, 344, 14, 344, 398, 327, 2790, 282, 19835, 458, 26708, 1572, 267, 291, 14, 923, 63, 719, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 981, 8, 1556, 12, 1747, 12, 717, 791, 354, 356, 283, 10542, 458, 26708, 297, 283, 3455, 356, 283, 2634, 297, 283, 923, 63, 3455, 63, 344, 356, 291, 14, 923, 63, 8707, 63, 344, 1386, 717, 791, 1198, 63, 981, 63, 889, 793, 356, 715, 1552, 398, 327, 2494, 376, 3031, 2287, 367, 314, 922, 3879, 314, 2295, 12, 1202, 465, 428, 13747, 367, 21507, 6016, 83, 267, 291, 14, 470, 63, 3707, 14, 952, 8, 1556, 12, 1747, 12, 1747, 12, 791, 2123, 356, 283, 396, 32, 5967, 3071, 339, 768, 12423, 63, 2921, 360, 11267, 14, 10788, 14, 1095, 14, 723, 14, 723, 63, 1238, 297, 283, 11267, 14, 992, 358, 272, 347, 511, 63, 383, 63, 1198, 63, 2732, 63, 17307, 8, 277, 304, 267, 408, 1379, 5678, 6016, 63, 1188, 436, 6016, 63, 923, 2879, 4481, 367, 18428, 4390, 14, 408, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 267, 6016, 63, 12607, 275, 291, 14, 5189, 360, 1198, 14, 12607, 14, 1188, 358, 398, 327, 17008, 1572, 26, 19835, 458, 436, 19835, 458, 26708, 267, 6682, 458, 63, 1328, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 291, 14, 923, 63, 20389, 63, 344, 12, 2396, 534, 2209, 358, 267, 1844, 63, 1328, 63, 344, 275, 291, 14, 1198, 63, 923, 14, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 291, 14, 923, 63, 719, 63, 344, 12, 2396, 534, 2209, 358, 398, 327, 4226, 26, 2799, 1697, 330, 1143, 874, 19835, 458, 1035, 20817, 12, 15778, 1572, 267, 682, 1697, 63, 20389, 275, 291, 14, 1198, 63, 923, 14, 4570, 8, 1556, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 12, 291, 14, 923, 63, 20389, 63, 344, 9, 267, 543, 291, 14, 1855, 8, 2590, 63, 1025, 304, 288, 6804, 63, 739, 275, 682, 1697, 63, 20389, 14, 354, 398, 327, 4226, 26, 2799, 1697, 22238, 282, 1245, 641, 19835, 458, 12, 12420, 2952, 883, 440, 2218, 641, 1572, 503, 365, 440, 315, 314, 31474, 267, 543, 291, 14, 1855, 8, 3946, 547, 304, 288, 291, 14, 1198, 63, 923, 14, 1188, 63, 1932, 8, 1556, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 12, 291, 14, 923, 63, 20389, 63, 344, 12, 2396, 534, 2209, 358, 398, 327, 4226, 26, 2799, 1697, 365, 3483, 1901, 19835, 458, 31474, 436, 19249, 652, 1035, 4112, 367, 3788, 12, 20817, 367, 18943, 334, 889, 1586, 4983, 9, 267, 291, 14, 1198, 63, 923, 14, 1188, 63, 10108, 63, 3707, 8, 1556, 12, 1747, 12, 359, 277, 14, 923, 63, 20389, 63, 344, 467, 359, 277, 14, 751, 63, 335, 1697, 63, 344, 566, 267, 682, 1697, 63, 20389, 275, 291, 14, 1198, 63, 923, 14, 4570, 8, 1556, 12, 291, 14, 751, 63, 335, 1697, 63, 344, 12, 291, 14, 923, 63, 20389, 63, 344, 9, 267, 6804, 63, 739, 275, 682, 1697, 63, 20389, 14, 354, 267, 367, 1245, 315, 682, 1697, 63, 20389, 14, 1188, 63, 1580, 26, 288, 6804, 63, 739, 275, 1245, 14, 5875, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
rajathkumarmp/numpy
numpy/testing/decorators.py
66
8409
""" Decorators for labeling and modifying behavior of test objects. Decorators that merely return a modified version of the original function object are straightforward. Decorators that return a new function object need to use :: nose.tools.make_decorator(original_function)(decorator) in returning the decorator, in order to preserve meta-data such as function name, setup and teardown functions and so on - see ``nose.tools`` for more information. """ from __future__ import division, absolute_import, print_function import warnings import collections def slow(t): """ Label a test as 'slow'. The exact definition of a slow test is obviously both subjective and hardware-dependent, but in general any individual test that requires more than a second or two should be labeled as slow (the whole suite consits of thousands of tests, so even a second is significant). Parameters ---------- t : callable The test to label as slow. Returns ------- t : callable The decorated test `t`. Examples -------- The `numpy.testing` module includes ``import decorators as dec``. A test can be decorated as slow like this:: from numpy.testing import * @dec.slow def test_big(self): print 'Big, slow test' """ t.slow = True return t def setastest(tf=True): """ Signals to nose that this function is or is not a test. Parameters ---------- tf : bool If True, specifies that the decorated callable is a test. If False, specifies that the decorated callable is not a test. Default is True. Notes ----- This decorator can't use the nose namespace, because it can be called from a non-test module. See also ``istest`` and ``nottest`` in ``nose.tools``. Examples -------- `setastest` can be used in the following way:: from numpy.testing.decorators import setastest @setastest(False) def func_with_test_in_name(arg1, arg2): pass """ def set_test(t): t.__test__ = tf return t return set_test def skipif(skip_condition, msg=None): """ Make function raise SkipTest exception if a given condition is true. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until the test suite is actually executed. Parameters ---------- skip_condition : bool or callable Flag to determine whether to skip the decorated test. msg : str, optional Message to give on raising a SkipTest exception. Default is None. Returns ------- decorator : function Decorator which, when applied to a function, causes SkipTest to be raised when `skip_condition` is True, and the function to be called normally otherwise. Notes ----- The decorator itself is decorated with the ``nose.tools.make_decorator`` function in order to transmit function name, and various other metadata. """ def skip_decorator(f): # Local import to avoid a hard nose dependency and only incur the # import time overhead at actual test-time. import nose # Allow for both boolean or callable skip conditions. if isinstance(skip_condition, collections.Callable): skip_val = lambda: skip_condition() else: skip_val = lambda: skip_condition def get_msg(func,msg=None): """Skip message with information about function being skipped.""" if msg is None: out = 'Test skipped due to test condition' else: out = msg return "Skipping test: %s: %s" % (func.__name__, out) # We need to define *two* skippers because Python doesn't allow both # return with value and yield inside the same function. def skipper_func(*args, **kwargs): """Skipper for normal test functions.""" if skip_val(): raise nose.SkipTest(get_msg(f, msg)) else: return f(*args, **kwargs) def skipper_gen(*args, **kwargs): """Skipper for test generators.""" if skip_val(): raise nose.SkipTest(get_msg(f, msg)) else: for x in f(*args, **kwargs): yield x # Choose the right skipper to use when building the actual decorator. if nose.util.isgenerator(f): skipper = skipper_gen else: skipper = skipper_func return nose.tools.make_decorator(f)(skipper) return skip_decorator def knownfailureif(fail_condition, msg=None): """ Make function raise KnownFailureTest exception if given condition is true. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until the test suite is actually executed. Parameters ---------- fail_condition : bool or callable Flag to determine whether to mark the decorated test as a known failure (if True) or not (if False). msg : str, optional Message to give on raising a KnownFailureTest exception. Default is None. Returns ------- decorator : function Decorator, which, when applied to a function, causes SkipTest to be raised when `skip_condition` is True, and the function to be called normally otherwise. Notes ----- The decorator itself is decorated with the ``nose.tools.make_decorator`` function in order to transmit function name, and various other metadata. """ if msg is None: msg = 'Test skipped due to known failure' # Allow for both boolean or callable known failure conditions. if isinstance(fail_condition, collections.Callable): fail_val = lambda: fail_condition() else: fail_val = lambda: fail_condition def knownfail_decorator(f): # Local import to avoid a hard nose dependency and only incur the # import time overhead at actual test-time. import nose from .noseclasses import KnownFailureTest def knownfailer(*args, **kwargs): if fail_val(): raise KnownFailureTest(msg) else: return f(*args, **kwargs) return nose.tools.make_decorator(f)(knownfailer) return knownfail_decorator def deprecated(conditional=True): """ Filter deprecation warnings while running the test suite. This decorator can be used to filter DeprecationWarning's, to avoid printing them during the test suite run, while checking that the test actually raises a DeprecationWarning. Parameters ---------- conditional : bool or callable, optional Flag to determine whether to mark test as deprecated or not. If the condition is a callable, it is used at runtime to dynamically make the decision. Default is True. Returns ------- decorator : function The `deprecated` decorator itself. Notes ----- .. versionadded:: 1.4.0 """ def deprecate_decorator(f): # Local import to avoid a hard nose dependency and only incur the # import time overhead at actual test-time. import nose def _deprecated_imp(*args, **kwargs): # Poor man's replacement for the with statement with warnings.catch_warnings(record=True) as l: warnings.simplefilter('always') f(*args, **kwargs) if not len(l) > 0: raise AssertionError("No warning raised when calling %s" % f.__name__) if not l[0].category is DeprecationWarning: raise AssertionError("First warning for %s is not a " "DeprecationWarning( is %s)" % (f.__name__, l[0])) if isinstance(conditional, collections.Callable): cond = conditional() else: cond = conditional if cond: return nose.tools.make_decorator(f)(_deprecated_imp) else: return f return deprecate_decorator
bsd-3-clause
[ 624, 199, 8584, 269, 2750, 367, 1768, 316, 436, 24662, 5953, 402, 511, 2251, 14, 199, 199, 8584, 269, 2750, 626, 562, 264, 590, 372, 282, 6042, 1015, 402, 314, 3379, 199, 1593, 909, 787, 23669, 6688, 14, 13966, 269, 2750, 626, 372, 282, 892, 199, 1593, 909, 1929, 370, 675, 199, 447, 819, 11354, 14, 2537, 14, 1875, 63, 11547, 8, 5043, 63, 1593, 5130, 11547, 9, 199, 199, 262, 8152, 314, 7531, 12, 315, 1865, 370, 11211, 3404, 13, 576, 4066, 465, 199, 1593, 536, 12, 3272, 436, 17558, 3423, 436, 880, 641, 446, 1937, 199, 1040, 21085, 14, 2537, 1040, 367, 1655, 2556, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 646, 5055, 421, 199, 318, 11999, 8, 84, 304, 272, 408, 272, 10354, 282, 511, 465, 283, 14362, 1370, 339, 710, 5835, 5492, 402, 282, 11999, 511, 365, 25259, 590, 3865, 1007, 74, 6850, 436, 272, 14991, 13, 7106, 12, 1325, 315, 8605, 1263, 8212, 511, 626, 5074, 1655, 272, 2419, 282, 3499, 503, 2877, 1077, 506, 23677, 465, 11999, 334, 1589, 8852, 5241, 7399, 1086, 402, 272, 294, 29737, 402, 2295, 12, 880, 2755, 282, 3499, 365, 16474, 680, 339, 3897, 272, 4143, 272, 307, 520, 4550, 267, 710, 511, 370, 1768, 465, 11999, 14, 339, 1803, 272, 5514, 272, 307, 520, 4550, 267, 710, 16225, 511, 658, 84, 2313, 339, 6058, 272, 3001, 272, 710, 658, 4714, 14, 4776, 64, 859, 6952, 1124, 646, 20419, 465, 9700, 4345, 272, 437, 511, 883, 506, 16225, 465, 11999, 2839, 642, 447, 2541, 687, 2680, 14, 4776, 492, 627, 2541, 768, 7778, 14, 14362, 489, 347, 511, 63, 5076, 8, 277, 304, 881, 870, 283, 7279, 12, 11999, 511, 7, 339, 408, 339, 307, 14, 14362, 275, 715, 272, 372, 307, 199, 199, 318, 663, 32645, 8, 3249, 29, 549, 304, 272, 408, 272, 6632, 2551, 370, 11354, 626, 642, 805, 365, 503, 365, 440, 282, 511, 14, 339, 3897, 272, 4143, 272, 2833, 520, 2155, 267, 982, 715, 12, 9314, 626, 314, 16225, 4550, 365, 282, 511, 14, 267, 982, 756, 12, 9314, 626, 314, 16225, 4550, 365, 440, 282, 511, 14, 267, 3758, 365, 715, 14, 339, 8144, 272, 9063, 272, 961, 7531, 883, 1133, 675, 314, 11354, 3231, 12, 2952, 652, 883, 506, 272, 2797, 687, 282, 2222, 13, 396, 859, 14, 1666, 2597, 1124, 374, 396, 1040, 436, 1124, 1397, 396, 1040, 315, 272, 1124, 21085, 14, 2537, 4345, 339, 6058, 272, 3001, 272, 658, 409, 32645, 64, 883, 506, 1202, 315, 314, 2569, 4340, 447, 2541, 687, 2680, 14, 4776, 14, 11582, 492, 663, 32645, 2541, 768, 409, 32645, 8, 797, 9, 489, 347, 2562, 63, 1045, 63, 396, 63, 262, 63, 354, 8, 1273, 17, 12, 1680, 18, 304, 881, 986, 339, 408, 272, 347, 663, 63, 396, 8, 84, 304, 267, 307, 855, 396, 363, 275, 2833, 267, 372, 307, 272, 372, 663, 63, 396, 199, 199, 318, 3372, 692, 8, 2759, 63, 5394, 12, 1499, 29, 403, 304, 272, 408, 272, 4155, 805, 746, 18795, 1919, 340, 282, 1627, 5558, 365, 2549, 14, 339, 982, 314, 5558, 365, 282, 4550, 12, 652, 365, 1202, 737, 8836, 370, 18774, 272, 1852, 314, 14692, 14, 961, 365, 2997, 367, 2295, 626, 1443, 4409, 7918, 590, 272, 8925, 12, 370, 7339, 314, 7918, 5133, 314, 511, 5241, 365, 5965, 7934, 14, 339, 3897, 272, 4143, 272, 3372, 63, 5394, 520, 2155, 503, 4550, 267, 18241, 370, 6705, 3775, 370, 3372, 314, 16225, 511, 14, 272, 1499, 520, 620, 12, 2716, 267, 6430, 370, 8120, 641, 17026, 282, 18795, 1919, 14, 3758, 365, 488, 14, 339, 1803, 272, 5514, 272, 7531, 520, 805, 267, 30684, 1314, 12, 1380, 6781, 370, 282, 805, 12, 14486, 18795, 267, 370, 506, 4915, 1380, 658, 2759, 63, 5394, 64, 365, 715, 12, 436, 314, 805, 267, 370, 506, 2797, 12252, 4257, 14, 339, 8144, 272, 9063, 272, 710, 7531, 6337, 365, 16225, 543, 314, 1124, 21085, 14, 2537, 14, 1875, 63, 11547, 1040, 272, 805, 315, 1865, 370, 27754, 805, 536, 12, 436, 7750, 1163, 3341, 14, 339, 408, 339, 347, 3372, 63, 11547, 8, 70, 304, 267, 327, 10111, 492, 370, 5126, 282, 7508, 11354, 5936, 436, 1454, 315, 895, 314, 267, 327, 492, 900, 24075, 737, 3503, 511, 13, 521, 14, 267, 492, 11354, 398, 327, 9812, 367, 3865, 5046, 503, 4550, 3372, 3704, 14, 267, 340, 1228, 8, 2759, 63, 5394, 12, 5055, 14, 16410, 304, 288, 3372, 63, 637, 275, 2400, 26, 3372, 63, 5394, 342, 267, 587, 26, 288, 3372, 63, 637, 275, 2400, 26, 3372, 63, 5394, 398, 347, 664, 63, 1328, 8, 1532, 12, 1328, 29, 403, 304, 288, 408, 7738, 1245, 543, 2556, 3595, 805, 3769, 9645, 1041, 288, 340, 1499, 365, 488, 26, 355, 734, 275, 283, 774, 9645, 7037, 370, 511, 5558, 7, 288, 587, 26, 355, 734, 275, 1499, 953, 372, 298, 18297, 511, 26, 450, 83, 26, 450, 83, 2, 450, 334, 1532, 855, 354, 3108, 734, 9, 398, 327, 2136, 1929, 370, 5627, 627, 5601, 10, 3372, 32206, 2952, 2018, 3181, 1133, 2040, 3865, 267, 327, 372, 543, 574, 436, 1995, 6272, 314, 2011, 805, 14, 267, 347, 3372, 529, 63, 1532, 2031, 589, 12, 1011, 958, 304, 288, 408, 7738, 529, 367, 3293, 511, 3423, 1041, 288, 340, 3372, 63, 637, 837, 355, 746, 11354, 14, 25755, 8, 362, 63, 1328, 8, 70, 12, 1499, 430, 288, 587, 26, 355, 372, 289, 2031, 589, 12, 1011, 958, 9, 398, 347, 3372, 529, 63, 2268, 2031, 589, 12, 1011, 958, 304, 288, 408, 7738, 529, 367, 511, 16952, 1041, 288, 340, 3372, 63, 637, 837, 355, 746, 11354, 14, 25755, 8, 362, 63, 1328, 8, 70, 12, 1499, 430, 288, 587, 26, 355, 367, 671, 315, 289, 2031, 589, 12, 1011, 958, 304, 490, 1995, 671, 398, 327, 29826, 314, 2451, 3372, 529, 370, 675, 1380, 10015, 314, 3503, 7531, 14, 267, 340, 11354, 14, 1974, 14, 374, 4679, 8, 70, 304, 288, 3372, 529, 275, 3372, 529, 63, 2268, 267, 587 ]
[ 199, 8584, 269, 2750, 367, 1768, 316, 436, 24662, 5953, 402, 511, 2251, 14, 199, 199, 8584, 269, 2750, 626, 562, 264, 590, 372, 282, 6042, 1015, 402, 314, 3379, 199, 1593, 909, 787, 23669, 6688, 14, 13966, 269, 2750, 626, 372, 282, 892, 199, 1593, 909, 1929, 370, 675, 199, 447, 819, 11354, 14, 2537, 14, 1875, 63, 11547, 8, 5043, 63, 1593, 5130, 11547, 9, 199, 199, 262, 8152, 314, 7531, 12, 315, 1865, 370, 11211, 3404, 13, 576, 4066, 465, 199, 1593, 536, 12, 3272, 436, 17558, 3423, 436, 880, 641, 446, 1937, 199, 1040, 21085, 14, 2537, 1040, 367, 1655, 2556, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 3598, 199, 646, 5055, 421, 199, 318, 11999, 8, 84, 304, 272, 408, 272, 10354, 282, 511, 465, 283, 14362, 1370, 339, 710, 5835, 5492, 402, 282, 11999, 511, 365, 25259, 590, 3865, 1007, 74, 6850, 436, 272, 14991, 13, 7106, 12, 1325, 315, 8605, 1263, 8212, 511, 626, 5074, 1655, 272, 2419, 282, 3499, 503, 2877, 1077, 506, 23677, 465, 11999, 334, 1589, 8852, 5241, 7399, 1086, 402, 272, 294, 29737, 402, 2295, 12, 880, 2755, 282, 3499, 365, 16474, 680, 339, 3897, 272, 4143, 272, 307, 520, 4550, 267, 710, 511, 370, 1768, 465, 11999, 14, 339, 1803, 272, 5514, 272, 307, 520, 4550, 267, 710, 16225, 511, 658, 84, 2313, 339, 6058, 272, 3001, 272, 710, 658, 4714, 14, 4776, 64, 859, 6952, 1124, 646, 20419, 465, 9700, 4345, 272, 437, 511, 883, 506, 16225, 465, 11999, 2839, 642, 447, 2541, 687, 2680, 14, 4776, 492, 627, 2541, 768, 7778, 14, 14362, 489, 347, 511, 63, 5076, 8, 277, 304, 881, 870, 283, 7279, 12, 11999, 511, 7, 339, 408, 339, 307, 14, 14362, 275, 715, 272, 372, 307, 199, 199, 318, 663, 32645, 8, 3249, 29, 549, 304, 272, 408, 272, 6632, 2551, 370, 11354, 626, 642, 805, 365, 503, 365, 440, 282, 511, 14, 339, 3897, 272, 4143, 272, 2833, 520, 2155, 267, 982, 715, 12, 9314, 626, 314, 16225, 4550, 365, 282, 511, 14, 267, 982, 756, 12, 9314, 626, 314, 16225, 4550, 365, 440, 282, 511, 14, 267, 3758, 365, 715, 14, 339, 8144, 272, 9063, 272, 961, 7531, 883, 1133, 675, 314, 11354, 3231, 12, 2952, 652, 883, 506, 272, 2797, 687, 282, 2222, 13, 396, 859, 14, 1666, 2597, 1124, 374, 396, 1040, 436, 1124, 1397, 396, 1040, 315, 272, 1124, 21085, 14, 2537, 4345, 339, 6058, 272, 3001, 272, 658, 409, 32645, 64, 883, 506, 1202, 315, 314, 2569, 4340, 447, 2541, 687, 2680, 14, 4776, 14, 11582, 492, 663, 32645, 2541, 768, 409, 32645, 8, 797, 9, 489, 347, 2562, 63, 1045, 63, 396, 63, 262, 63, 354, 8, 1273, 17, 12, 1680, 18, 304, 881, 986, 339, 408, 272, 347, 663, 63, 396, 8, 84, 304, 267, 307, 855, 396, 363, 275, 2833, 267, 372, 307, 272, 372, 663, 63, 396, 199, 199, 318, 3372, 692, 8, 2759, 63, 5394, 12, 1499, 29, 403, 304, 272, 408, 272, 4155, 805, 746, 18795, 1919, 340, 282, 1627, 5558, 365, 2549, 14, 339, 982, 314, 5558, 365, 282, 4550, 12, 652, 365, 1202, 737, 8836, 370, 18774, 272, 1852, 314, 14692, 14, 961, 365, 2997, 367, 2295, 626, 1443, 4409, 7918, 590, 272, 8925, 12, 370, 7339, 314, 7918, 5133, 314, 511, 5241, 365, 5965, 7934, 14, 339, 3897, 272, 4143, 272, 3372, 63, 5394, 520, 2155, 503, 4550, 267, 18241, 370, 6705, 3775, 370, 3372, 314, 16225, 511, 14, 272, 1499, 520, 620, 12, 2716, 267, 6430, 370, 8120, 641, 17026, 282, 18795, 1919, 14, 3758, 365, 488, 14, 339, 1803, 272, 5514, 272, 7531, 520, 805, 267, 30684, 1314, 12, 1380, 6781, 370, 282, 805, 12, 14486, 18795, 267, 370, 506, 4915, 1380, 658, 2759, 63, 5394, 64, 365, 715, 12, 436, 314, 805, 267, 370, 506, 2797, 12252, 4257, 14, 339, 8144, 272, 9063, 272, 710, 7531, 6337, 365, 16225, 543, 314, 1124, 21085, 14, 2537, 14, 1875, 63, 11547, 1040, 272, 805, 315, 1865, 370, 27754, 805, 536, 12, 436, 7750, 1163, 3341, 14, 339, 408, 339, 347, 3372, 63, 11547, 8, 70, 304, 267, 327, 10111, 492, 370, 5126, 282, 7508, 11354, 5936, 436, 1454, 315, 895, 314, 267, 327, 492, 900, 24075, 737, 3503, 511, 13, 521, 14, 267, 492, 11354, 398, 327, 9812, 367, 3865, 5046, 503, 4550, 3372, 3704, 14, 267, 340, 1228, 8, 2759, 63, 5394, 12, 5055, 14, 16410, 304, 288, 3372, 63, 637, 275, 2400, 26, 3372, 63, 5394, 342, 267, 587, 26, 288, 3372, 63, 637, 275, 2400, 26, 3372, 63, 5394, 398, 347, 664, 63, 1328, 8, 1532, 12, 1328, 29, 403, 304, 288, 408, 7738, 1245, 543, 2556, 3595, 805, 3769, 9645, 1041, 288, 340, 1499, 365, 488, 26, 355, 734, 275, 283, 774, 9645, 7037, 370, 511, 5558, 7, 288, 587, 26, 355, 734, 275, 1499, 953, 372, 298, 18297, 511, 26, 450, 83, 26, 450, 83, 2, 450, 334, 1532, 855, 354, 3108, 734, 9, 398, 327, 2136, 1929, 370, 5627, 627, 5601, 10, 3372, 32206, 2952, 2018, 3181, 1133, 2040, 3865, 267, 327, 372, 543, 574, 436, 1995, 6272, 314, 2011, 805, 14, 267, 347, 3372, 529, 63, 1532, 2031, 589, 12, 1011, 958, 304, 288, 408, 7738, 529, 367, 3293, 511, 3423, 1041, 288, 340, 3372, 63, 637, 837, 355, 746, 11354, 14, 25755, 8, 362, 63, 1328, 8, 70, 12, 1499, 430, 288, 587, 26, 355, 372, 289, 2031, 589, 12, 1011, 958, 9, 398, 347, 3372, 529, 63, 2268, 2031, 589, 12, 1011, 958, 304, 288, 408, 7738, 529, 367, 511, 16952, 1041, 288, 340, 3372, 63, 637, 837, 355, 746, 11354, 14, 25755, 8, 362, 63, 1328, 8, 70, 12, 1499, 430, 288, 587, 26, 355, 367, 671, 315, 289, 2031, 589, 12, 1011, 958, 304, 490, 1995, 671, 398, 327, 29826, 314, 2451, 3372, 529, 370, 675, 1380, 10015, 314, 3503, 7531, 14, 267, 340, 11354, 14, 1974, 14, 374, 4679, 8, 70, 304, 288, 3372, 529, 275, 3372, 529, 63, 2268, 267, 587, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sotdjin/glibglab
venv/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.py
335
14810
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2013 Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # """ Class representing the list of files in a distribution. Equivalent to distutils.filelist, but fixes some problems. """ import fnmatch import logging import os import re import sys from . import DistlibException from .compat import fsdecode from .util import convert_path __all__ = ['Manifest'] logger = logging.getLogger(__name__) # a \ followed by some spaces + EOL _COLLAPSE_PATTERN = re.compile('\\\w*\n', re.M) _COMMENTED_LINE = re.compile('#.*?(?=\n)|\n(?=$)', re.M | re.S) # # Due to the different results returned by fnmatch.translate, we need # to do slightly different processing for Python 2.7 and 3.2 ... this needed # to be brought in for Python 3.6 onwards. # _PYTHON_VERSION = sys.version_info[:2] class Manifest(object): """A list of files built by on exploring the filesystem and filtered by applying various patterns to what we find there. """ def __init__(self, base=None): """ Initialise an instance. :param base: The base directory to explore under. """ self.base = os.path.abspath(os.path.normpath(base or os.getcwd())) self.prefix = self.base + os.sep self.allfiles = None self.files = set() # # Public API # def findall(self): """Find all files under the base and set ``allfiles`` to the absolute pathnames of files found. """ from stat import S_ISREG, S_ISDIR, S_ISLNK self.allfiles = allfiles = [] root = self.base stack = [root] pop = stack.pop push = stack.append while stack: root = pop() names = os.listdir(root) for name in names: fullname = os.path.join(root, name) # Avoid excess stat calls -- just one will do, thank you! stat = os.stat(fullname) mode = stat.st_mode if S_ISREG(mode): allfiles.append(fsdecode(fullname)) elif S_ISDIR(mode) and not S_ISLNK(mode): push(fullname) def add(self, item): """ Add a file to the manifest. :param item: The pathname to add. This can be relative to the base. """ if not item.startswith(self.prefix): item = os.path.join(self.base, item) self.files.add(os.path.normpath(item)) def add_many(self, items): """ Add a list of files to the manifest. :param items: The pathnames to add. These can be relative to the base. """ for item in items: self.add(item) def sorted(self, wantdirs=False): """ Return sorted files in directory order """ def add_dir(dirs, d): dirs.add(d) logger.debug('add_dir added %s', d) if d != self.base: parent, _ = os.path.split(d) assert parent not in ('', '/') add_dir(dirs, parent) result = set(self.files) # make a copy! if wantdirs: dirs = set() for f in result: add_dir(dirs, os.path.dirname(f)) result |= dirs return [os.path.join(*path_tuple) for path_tuple in sorted(os.path.split(path) for path in result)] def clear(self): """Clear all collected files.""" self.files = set() self.allfiles = [] def process_directive(self, directive): """ Process a directive which either adds some files from ``allfiles`` to ``files``, or removes some files from ``files``. :param directive: The directive to process. This should be in a format compatible with distutils ``MANIFEST.in`` files: http://docs.python.org/distutils/sourcedist.html#commands """ # Parse the line: split it up, make sure the right number of words # is there, and return the relevant words. 'action' is always # defined: it's the first word of the line. Which of the other # three are defined depends on the action; it'll be either # patterns, (dir and patterns), or (dirpattern). action, patterns, thedir, dirpattern = self._parse_directive(directive) # OK, now we know that the action is valid and we have the # right number of words on the line for that action -- so we # can proceed with minimal error-checking. if action == 'include': for pattern in patterns: if not self._include_pattern(pattern, anchor=True): logger.warning('no files found matching %r', pattern) elif action == 'exclude': for pattern in patterns: found = self._exclude_pattern(pattern, anchor=True) #if not found: # logger.warning('no previously-included files ' # 'found matching %r', pattern) elif action == 'global-include': for pattern in patterns: if not self._include_pattern(pattern, anchor=False): logger.warning('no files found matching %r ' 'anywhere in distribution', pattern) elif action == 'global-exclude': for pattern in patterns: found = self._exclude_pattern(pattern, anchor=False) #if not found: # logger.warning('no previously-included files ' # 'matching %r found anywhere in ' # 'distribution', pattern) elif action == 'recursive-include': for pattern in patterns: if not self._include_pattern(pattern, prefix=thedir): logger.warning('no files found matching %r ' 'under directory %r', pattern, thedir) elif action == 'recursive-exclude': for pattern in patterns: found = self._exclude_pattern(pattern, prefix=thedir) #if not found: # logger.warning('no previously-included files ' # 'matching %r found under directory %r', # pattern, thedir) elif action == 'graft': if not self._include_pattern(None, prefix=dirpattern): logger.warning('no directories found matching %r', dirpattern) elif action == 'prune': if not self._exclude_pattern(None, prefix=dirpattern): logger.warning('no previously-included directories found ' 'matching %r', dirpattern) else: # pragma: no cover # This should never happen, as it should be caught in # _parse_template_line raise DistlibException( 'invalid action %r' % action) # # Private API # def _parse_directive(self, directive): """ Validate a directive. :param directive: The directive to validate. :return: A tuple of action, patterns, thedir, dir_patterns """ words = directive.split() if len(words) == 1 and words[0] not in ('include', 'exclude', 'global-include', 'global-exclude', 'recursive-include', 'recursive-exclude', 'graft', 'prune'): # no action given, let's use the default 'include' words.insert(0, 'include') action = words[0] patterns = thedir = dir_pattern = None if action in ('include', 'exclude', 'global-include', 'global-exclude'): if len(words) < 2: raise DistlibException( '%r expects <pattern1> <pattern2> ...' % action) patterns = [convert_path(word) for word in words[1:]] elif action in ('recursive-include', 'recursive-exclude'): if len(words) < 3: raise DistlibException( '%r expects <dir> <pattern1> <pattern2> ...' % action) thedir = convert_path(words[1]) patterns = [convert_path(word) for word in words[2:]] elif action in ('graft', 'prune'): if len(words) != 2: raise DistlibException( '%r expects a single <dir_pattern>' % action) dir_pattern = convert_path(words[1]) else: raise DistlibException('unknown action %r' % action) return action, patterns, thedir, dir_pattern def _include_pattern(self, pattern, anchor=True, prefix=None, is_regex=False): """Select strings (presumably filenames) from 'self.files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not quite the same as implemented by the 'fnmatch' module: '*' and '?' match non-special characters, where "special" is platform-dependent: slash on Unix; colon, slash, and backslash on DOS/Windows; and colon on Mac OS. If 'anchor' is true (the default), then the pattern match is more stringent: "*.py" will match "foo.py" but not "foo/bar.py". If 'anchor' is false, both of these will match. If 'prefix' is supplied, then only filenames starting with 'prefix' (itself a pattern) and ending with 'pattern', with anything in between them, will match. 'anchor' is ignored in this case. If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and 'pattern' is assumed to be either a string containing a regex or a regex object -- no translation is done, the regex is just compiled and used as-is. Selected strings will be added to self.files. Return True if files are found. """ # XXX docstring lying about what the special chars are? found = False pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex) # delayed loading of allfiles list if self.allfiles is None: self.findall() for name in self.allfiles: if pattern_re.search(name): self.files.add(name) found = True return found def _exclude_pattern(self, pattern, anchor=True, prefix=None, is_regex=False): """Remove strings (presumably filenames) from 'files' that match 'pattern'. Other parameters are the same as for 'include_pattern()', above. The list 'self.files' is modified in place. Return True if files are found. This API is public to allow e.g. exclusion of SCM subdirs, e.g. when packaging source distributions """ found = False pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex) for f in list(self.files): if pattern_re.search(f): self.files.remove(f) found = True return found def _translate_pattern(self, pattern, anchor=True, prefix=None, is_regex=False): """Translate a shell-like wildcard pattern to a compiled regular expression. Return the compiled regex. If 'is_regex' true, then 'pattern' is directly compiled to a regex (if it's a string) or just returned as-is (assumes it's a regex object). """ if is_regex: if isinstance(pattern, str): return re.compile(pattern) else: return pattern if _PYTHON_VERSION > (3, 2): # ditch start and end characters start, _, end = self._glob_to_re('_').partition('_') if pattern: pattern_re = self._glob_to_re(pattern) if _PYTHON_VERSION > (3, 2): assert pattern_re.startswith(start) and pattern_re.endswith(end) else: pattern_re = '' base = re.escape(os.path.join(self.base, '')) if prefix is not None: # ditch end of pattern character if _PYTHON_VERSION <= (3, 2): empty_pattern = self._glob_to_re('') prefix_re = self._glob_to_re(prefix)[:-len(empty_pattern)] else: prefix_re = self._glob_to_re(prefix) assert prefix_re.startswith(start) and prefix_re.endswith(end) prefix_re = prefix_re[len(start): len(prefix_re) - len(end)] sep = os.sep if os.sep == '\\': sep = r'\\' if _PYTHON_VERSION <= (3, 2): pattern_re = '^' + base + sep.join((prefix_re, '.*' + pattern_re)) else: pattern_re = pattern_re[len(start): len(pattern_re) - len(end)] pattern_re = r'%s%s%s%s.*%s%s' % (start, base, prefix_re, sep, pattern_re, end) else: # no prefix -- respect anchor flag if anchor: if _PYTHON_VERSION <= (3, 2): pattern_re = '^' + base + pattern_re else: pattern_re = r'%s%s%s' % (start, base, pattern_re[len(start):]) return re.compile(pattern_re) def _glob_to_re(self, pattern): """Translate a shell-like glob pattern to a regular expression. Return a string containing the regex. Differs from 'fnmatch.translate()' in that '*' does not match "special characters" (which are platform-specific). """ pattern_re = fnmatch.translate(pattern) # '?' and '*' in the glob pattern become '.' and '.*' in the RE, which # IMHO is wrong -- '?' and '*' aren't supposed to match slash in Unix, # and by extension they shouldn't match such "special characters" under # any OS. So change all non-escaped dots in the RE to match any # character except the special characters (currently: just os.sep). sep = os.sep if os.sep == '\\': # we're using a regex to manipulate a regex, so we need # to escape the backslash twice sep = r'\\\\' escaped = r'\1[^%s]' % sep pattern_re = re.sub(r'((?<!\\)(\\\\)*)\.', escaped, pattern_re) return pattern_re
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 6965, 2018, 2290, 2752, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 624, 199, 2543, 6144, 314, 769, 402, 1584, 315, 282, 4084, 14, 199, 199, 37, 6190, 370, 7065, 14, 14964, 12, 1325, 25079, 2005, 8826, 14, 199, 624, 199, 646, 15951, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 504, 1275, 492, 28801, 199, 504, 1275, 5819, 492, 7449, 2708, 199, 504, 1275, 1974, 492, 3957, 63, 515, 421, 199, 363, 452, 363, 275, 788, 11038, 418, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3, 282, 971, 9437, 701, 2005, 7883, 435, 662, 2228, 199, 63, 3978, 44, 1282, 899, 63, 10764, 275, 295, 14, 2014, 360, 9780, 87, 7590, 78, 297, 295, 14, 45, 9, 199, 63, 10973, 1149, 63, 6174, 275, 295, 14, 2014, 7863, 6697, 2229, 9529, 78, 9, 6113, 78, 2229, 28617, 3196, 295, 14, 45, 1204, 295, 14, 51, 9, 199, 199, 3, 199, 3, 25855, 370, 314, 3365, 2058, 2138, 701, 15951, 14, 5275, 12, 781, 1929, 199, 3, 370, 886, 18023, 3365, 6661, 367, 2018, 499, 14, 23, 436, 650, 14, 18, 2263, 642, 4346, 199, 3, 370, 506, 330, 7930, 913, 315, 367, 2018, 650, 14, 22, 641, 4751, 14, 199, 3, 199, 63, 11720, 63, 4612, 275, 984, 14, 1023, 63, 815, 1491, 18, 61, 199, 199, 533, 4688, 3944, 8, 785, 304, 272, 408, 33, 769, 402, 1584, 6137, 701, 641, 29278, 6854, 314, 10036, 436, 9806, 701, 272, 18876, 7750, 7970, 370, 4052, 781, 2342, 2337, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1300, 29, 403, 304, 267, 408, 267, 6026, 572, 376, 1256, 14, 398, 520, 635, 1300, 26, 710, 1300, 2082, 370, 15868, 264, 1334, 14, 267, 408, 267, 291, 14, 1095, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 9267, 8, 1095, 503, 747, 14, 9458, 4059, 267, 291, 14, 1861, 275, 291, 14, 1095, 435, 747, 14, 4127, 267, 291, 14, 279, 12059, 83, 275, 488, 267, 291, 14, 1725, 275, 663, 342, 339, 327, 272, 327, 1684, 3261, 272, 327, 339, 347, 2342, 452, 8, 277, 304, 267, 408, 6591, 1006, 1584, 1334, 314, 1300, 436, 663, 1124, 279, 12059, 83, 1040, 370, 314, 3679, 267, 931, 1247, 402, 1584, 1911, 14, 267, 408, 267, 687, 5672, 492, 428, 63, 1311, 5616, 12, 428, 63, 1311, 3022, 12, 428, 63, 1311, 44, 22780, 398, 291, 14, 279, 12059, 83, 275, 741, 12059, 83, 275, 942, 267, 1738, 275, 291, 14, 1095, 267, 3464, 275, 359, 1231, 61, 267, 4560, 275, 3464, 14, 1935, 267, 6675, 275, 3464, 14, 740, 398, 1830, 3464, 26, 288, 1738, 275, 4560, 342, 288, 1561, 275, 747, 14, 7374, 8, 1231, 9, 953, 367, 536, 315, 1561, 26, 355, 11064, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 536, 9, 2234, 327, 19503, 444, 670, 5672, 4882, 1553, 2951, 1373, 911, 886, 12, 2419, 75, 1265, 1, 355, 5672, 275, 747, 14, 3736, 8, 9930, 9, 355, 818, 275, 5672, 14, 270, 63, 632, 355, 340, 428, 63, 1311, 5616, 8, 632, 304, 490, 741, 12059, 83, 14, 740, 8, 2319, 2708, 8, 9930, 430, 355, 916, 428, 63, 1311, 3022, 8, 632, 9, 436, 440, 428, 63, 1311, 44, 22780, 8, 632, 304, 490, 6675, 8, 9930, 9, 339, 347, 1050, 8, 277, 12, 1242, 304, 267, 408, 267, 2654, 282, 570, 370, 314, 7712, 14, 398, 520, 635, 1242, 26, 710, 11776, 370, 1050, 14, 961, 883, 506, 3847, 370, 314, 1300, 14, 267, 408, 267, 340, 440, 1242, 14, 2460, 8, 277, 14, 1861, 304, 288, 1242, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1095, 12, 1242, 9, 267, 291, 14, 1725, 14, 525, 8, 736, 14, 515, 14, 9267, 8, 1053, 430, 339, 347, 1050, 63, 3479, 8, 277, 12, 2974, 304, 267, 408, 267, 2654, 282, 769, 402, 1584, 370, 314, 7712, 14, 398, 520, 635, 2974, 26, 710, 931, 1247, 370, 1050, 14, 5723, 883, 506, 3847, 370, 314, 1300, 14, 267, 408, 267, 367, 1242, 315, 2974, 26, 288, 291, 14, 525, 8, 1053, 9, 339, 347, 3355, 8, 277, 12, 2934, 3220, 29, 797, 304, 267, 408, 267, 1432, 3355, 1584, 315, 2082, 1865, 267, 408, 398, 347, 1050, 63, 694, 8, 3220, 12, 366, 304, 288, 7606, 14, 525, 8, 68, 9, 288, 2512, 14, 1757, 360, 525, 63, 694, 3483, 450, 83, 297, 366, 9, 288, 340, 366, 1137, 291, 14, 1095, 26, 355, 1676, 12, 485, 275, 747, 14, 515, 14, 1294, 8, 68, 9, 355, 702, 1676, 440, 315, 13134, 15107, 355, 1050, 63, 694, 8, 3220, 12, 1676, 9, 398, 754, 275, 663, 8, 277, 14, 1725, 9, 259, 327, 1852, 282, 1331, 1, 267, 340, 2934, 3220, 26, 288, 7606, 275, 663, 342, 288, 367, 289, 315, 754, 26, 355, 1050, 63, 694, 8, 3220, 12, 747, 14, 515, 14, 3475, 8, 70, 430, 288, 754, 8901, 7606, 267, 372, 359, 736, 14, 515, 14, 904, 2031, 515, 63, 2960, 9, 367, 931, 63, 2960, 315, 355, 3355, 8, 736, 14, 515, 14, 1294, 8, 515, 9, 367, 931, 315, 754, 1874, 339, 347, 5436, 8, 277, 304, 267, 408, 9721, 1006, 13736, 1584, 1041, 267, 291, 14, 1725, 275, 663, 342, 267, 291, 14, 279, 12059, 83, 275, 942, 339, 347, 2112, 63, 15047, 8, 277, 12, 13613, 304, 267, 408, 267, 7132, 282, 13613, 1314, 1902, 9584, 2005, 1584, 687, 1124, 279, 12059, 83, 1040, 370, 267, 1124, 1725, 4542, 503, 14185, 2005, 1584, 687, 1124, 1725, 4345, 398, 520, 635, 13613, 26, 710, 13613, 370, 2112, 14, 961, 1077, 506, 315, 282, 1475, 2151, 9025, 543, 7065, 1124, 24067, 14, 262, 1040, 1584, 26, 199, 2151, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 13350, 15, 1365, 2686, 14, 1360, 3, 4405, 267, 408, 267, 327, 6077, 314, 1004, 26, 3715, 652, 1536, 12, 1852, 3238, 314, 2451, 1329 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 13, 6965, 2018, 2290, 2752, 14, 199, 3, 1666, 5113, 14, 2424, 436, 6483, 14, 2424, 14, 199, 3, 199, 624, 199, 2543, 6144, 314, 769, 402, 1584, 315, 282, 4084, 14, 199, 199, 37, 6190, 370, 7065, 14, 14964, 12, 1325, 25079, 2005, 8826, 14, 199, 624, 199, 646, 15951, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 504, 1275, 492, 28801, 199, 504, 1275, 5819, 492, 7449, 2708, 199, 504, 1275, 1974, 492, 3957, 63, 515, 421, 199, 363, 452, 363, 275, 788, 11038, 418, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3, 282, 971, 9437, 701, 2005, 7883, 435, 662, 2228, 199, 63, 3978, 44, 1282, 899, 63, 10764, 275, 295, 14, 2014, 360, 9780, 87, 7590, 78, 297, 295, 14, 45, 9, 199, 63, 10973, 1149, 63, 6174, 275, 295, 14, 2014, 7863, 6697, 2229, 9529, 78, 9, 6113, 78, 2229, 28617, 3196, 295, 14, 45, 1204, 295, 14, 51, 9, 199, 199, 3, 199, 3, 25855, 370, 314, 3365, 2058, 2138, 701, 15951, 14, 5275, 12, 781, 1929, 199, 3, 370, 886, 18023, 3365, 6661, 367, 2018, 499, 14, 23, 436, 650, 14, 18, 2263, 642, 4346, 199, 3, 370, 506, 330, 7930, 913, 315, 367, 2018, 650, 14, 22, 641, 4751, 14, 199, 3, 199, 63, 11720, 63, 4612, 275, 984, 14, 1023, 63, 815, 1491, 18, 61, 199, 199, 533, 4688, 3944, 8, 785, 304, 272, 408, 33, 769, 402, 1584, 6137, 701, 641, 29278, 6854, 314, 10036, 436, 9806, 701, 272, 18876, 7750, 7970, 370, 4052, 781, 2342, 2337, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1300, 29, 403, 304, 267, 408, 267, 6026, 572, 376, 1256, 14, 398, 520, 635, 1300, 26, 710, 1300, 2082, 370, 15868, 264, 1334, 14, 267, 408, 267, 291, 14, 1095, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 9267, 8, 1095, 503, 747, 14, 9458, 4059, 267, 291, 14, 1861, 275, 291, 14, 1095, 435, 747, 14, 4127, 267, 291, 14, 279, 12059, 83, 275, 488, 267, 291, 14, 1725, 275, 663, 342, 339, 327, 272, 327, 1684, 3261, 272, 327, 339, 347, 2342, 452, 8, 277, 304, 267, 408, 6591, 1006, 1584, 1334, 314, 1300, 436, 663, 1124, 279, 12059, 83, 1040, 370, 314, 3679, 267, 931, 1247, 402, 1584, 1911, 14, 267, 408, 267, 687, 5672, 492, 428, 63, 1311, 5616, 12, 428, 63, 1311, 3022, 12, 428, 63, 1311, 44, 22780, 398, 291, 14, 279, 12059, 83, 275, 741, 12059, 83, 275, 942, 267, 1738, 275, 291, 14, 1095, 267, 3464, 275, 359, 1231, 61, 267, 4560, 275, 3464, 14, 1935, 267, 6675, 275, 3464, 14, 740, 398, 1830, 3464, 26, 288, 1738, 275, 4560, 342, 288, 1561, 275, 747, 14, 7374, 8, 1231, 9, 953, 367, 536, 315, 1561, 26, 355, 11064, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 536, 9, 2234, 327, 19503, 444, 670, 5672, 4882, 1553, 2951, 1373, 911, 886, 12, 2419, 75, 1265, 1, 355, 5672, 275, 747, 14, 3736, 8, 9930, 9, 355, 818, 275, 5672, 14, 270, 63, 632, 355, 340, 428, 63, 1311, 5616, 8, 632, 304, 490, 741, 12059, 83, 14, 740, 8, 2319, 2708, 8, 9930, 430, 355, 916, 428, 63, 1311, 3022, 8, 632, 9, 436, 440, 428, 63, 1311, 44, 22780, 8, 632, 304, 490, 6675, 8, 9930, 9, 339, 347, 1050, 8, 277, 12, 1242, 304, 267, 408, 267, 2654, 282, 570, 370, 314, 7712, 14, 398, 520, 635, 1242, 26, 710, 11776, 370, 1050, 14, 961, 883, 506, 3847, 370, 314, 1300, 14, 267, 408, 267, 340, 440, 1242, 14, 2460, 8, 277, 14, 1861, 304, 288, 1242, 275, 747, 14, 515, 14, 904, 8, 277, 14, 1095, 12, 1242, 9, 267, 291, 14, 1725, 14, 525, 8, 736, 14, 515, 14, 9267, 8, 1053, 430, 339, 347, 1050, 63, 3479, 8, 277, 12, 2974, 304, 267, 408, 267, 2654, 282, 769, 402, 1584, 370, 314, 7712, 14, 398, 520, 635, 2974, 26, 710, 931, 1247, 370, 1050, 14, 5723, 883, 506, 3847, 370, 314, 1300, 14, 267, 408, 267, 367, 1242, 315, 2974, 26, 288, 291, 14, 525, 8, 1053, 9, 339, 347, 3355, 8, 277, 12, 2934, 3220, 29, 797, 304, 267, 408, 267, 1432, 3355, 1584, 315, 2082, 1865, 267, 408, 398, 347, 1050, 63, 694, 8, 3220, 12, 366, 304, 288, 7606, 14, 525, 8, 68, 9, 288, 2512, 14, 1757, 360, 525, 63, 694, 3483, 450, 83, 297, 366, 9, 288, 340, 366, 1137, 291, 14, 1095, 26, 355, 1676, 12, 485, 275, 747, 14, 515, 14, 1294, 8, 68, 9, 355, 702, 1676, 440, 315, 13134, 15107, 355, 1050, 63, 694, 8, 3220, 12, 1676, 9, 398, 754, 275, 663, 8, 277, 14, 1725, 9, 259, 327, 1852, 282, 1331, 1, 267, 340, 2934, 3220, 26, 288, 7606, 275, 663, 342, 288, 367, 289, 315, 754, 26, 355, 1050, 63, 694, 8, 3220, 12, 747, 14, 515, 14, 3475, 8, 70, 430, 288, 754, 8901, 7606, 267, 372, 359, 736, 14, 515, 14, 904, 2031, 515, 63, 2960, 9, 367, 931, 63, 2960, 315, 355, 3355, 8, 736, 14, 515, 14, 1294, 8, 515, 9, 367, 931, 315, 754, 1874, 339, 347, 5436, 8, 277, 304, 267, 408, 9721, 1006, 13736, 1584, 1041, 267, 291, 14, 1725, 275, 663, 342, 267, 291, 14, 279, 12059, 83, 275, 942, 339, 347, 2112, 63, 15047, 8, 277, 12, 13613, 304, 267, 408, 267, 7132, 282, 13613, 1314, 1902, 9584, 2005, 1584, 687, 1124, 279, 12059, 83, 1040, 370, 267, 1124, 1725, 4542, 503, 14185, 2005, 1584, 687, 1124, 1725, 4345, 398, 520, 635, 13613, 26, 710, 13613, 370, 2112, 14, 961, 1077, 506, 315, 282, 1475, 2151, 9025, 543, 7065, 1124, 24067, 14, 262, 1040, 1584, 26, 199, 2151, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 13350, 15, 1365, 2686, 14, 1360, 3, 4405, 267, 408, 267, 327, 6077, 314, 1004, 26, 3715, 652, 1536, 12, 1852, 3238, 314, 2451, 1329, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jcfr/girder
plugins/mongo_search/plugin_tests/search_test.py
9
6301
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################### # Copyright 2013 Kitware Inc. # # Licensed under the Apache License, Version 2.0 ( the "License" ); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### import bson.json_util from tests import base from girder.constants import AccessType def setUpModule(): base.enabledPlugins.append('mongo_search') base.startServer() def tearDownModule(): base.stopServer() class MongoSearchTestCase(base.TestCase): def testMongoSearch(self): """ Test resource/mongo_search endpoint """ # Create a bunch of searchable documents admin = { 'email': 'admin@email.com', 'login': 'adminlogin', 'firstName': 'Admin', 'lastName': 'Last', 'password': 'adminpassword', 'admin': True } admin = self.model('user').createUser(**admin) user = { 'email': 'good@email.com', 'login': 'goodlogin', 'firstName': 'First', 'lastName': 'Last', 'password': 'goodpassword', 'admin': False } user = self.model('user').createUser(**user) coll1 = { 'name': 'Test Collection', 'description': 'magic words. And more magic.', 'public': True, 'creator': admin } coll1 = self.model('collection').createCollection(**coll1) coll2 = { 'name': 'Magic collection', 'description': 'private', 'public': False, 'creator': admin } coll2 = self.model('collection').createCollection(**coll2) self.model('collection').setUserAccess( coll2, user, level=AccessType.READ, save=True) folder1 = { 'parent': coll1, 'parentType': 'collection', 'name': 'Public test folder' } folder1 = self.model('folder').createFolder(**folder1) self.model('folder').setUserAccess( folder1, user, level=AccessType.READ, save=False) self.model('folder').setPublic(folder1, True, save=True) folder2 = { 'parent': coll2, 'parentType': 'collection', 'name': 'Private test folder' } folder2 = self.model('folder').createFolder(**folder2) self.model('folder').setUserAccess( folder2, user, level=AccessType.NONE, save=True) item1 = { 'name': 'Public object', 'creator': admin, 'folder': folder1 } item1 = self.model('item').createItem(**item1) item2 = { 'name': 'Secret object', 'creator': admin, 'folder': folder2 } item2 = self.model('item').createItem(**item2) # Grab the default user folders resp = self.request( path='/folder', method='GET', user=user, params={ 'parentType': 'user', 'parentId': user['_id'], 'sort': 'name', 'sortdir': 1 }) # First test all of the required parameters. self.ensureRequiredParams( path='/resource/search', required=['q', 'types']) # Now test parameter validation resp = self.request(path='/resource/mongo_search', params={ 'q': 'query', 'type': 'wrong type' }) self.assertStatus(resp, 400) self.assertEqual('Invalid resource type: wrong type', resp.json['message']) # Test validation of JSON input resp = self.request(path='/resource/mongo_search', params={ 'q': 'not_json', 'type': 'folder' }) self.assertStatus(resp, 400) self.assertEqual(resp.json['message'], 'The query parameter must be a JSON object.') # Ensure searching respects permissions resp = self.request(path='/resource/mongo_search', params={ 'q': bson.json_util.dumps({'name': 'Private'}), 'type': 'folder' }) self.assertStatusOk(resp) self.assertEqual(resp.json, []) resp = self.request(path='/resource/mongo_search', params={ 'q': bson.json_util.dumps({'name': 'Private'}), 'type': 'folder' }, user=user) self.assertStatusOk(resp) self.assertEqual(len(resp.json), 1) self.assertHasKeys(resp.json[0], ('_id', 'name', 'description')) self.assertEqual(len(resp.json[0]), 3) # Test item search resp = self.request(path='/resource/mongo_search', params={ 'q': bson.json_util.dumps({'folderId': folder1['_id']}), 'type': 'item' }) self.assertStatusOk(resp) self.assertEqual(resp.json, [{ '_id': str(item1['_id']), 'name': 'Public object', 'description': '', 'folderId': str(folder1['_id']) }]) resp = self.request(path='/resource/mongo_search', params={ 'q': bson.json_util.dumps({'folderId': folder2['_id']}), 'type': 'item' }) self.assertStatusOk(resp) self.assertEqual(resp.json, []) resp = self.request(path='/resource/mongo_search', params={ 'q': bson.json_util.dumps({'folderId': folder2['_id']}), 'type': 'item' }, user=admin) self.assertStatusOk(resp) self.assertEqual(resp.json, [{ '_id': str(item2['_id']), 'name': 'Secret object', 'description': '', 'folderId': str(folder2['_id']) }])
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 11490, 199, 3, 221, 1898, 6171, 1804, 390, 1068, 3277, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 314, 298, 3761, 2, 20682, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 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, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 11490, 199, 199, 646, 330, 834, 14, 1001, 63, 1974, 199, 199, 504, 2295, 492, 1300, 199, 504, 486, 723, 424, 14, 5559, 492, 11003, 804, 421, 199, 318, 3613, 2377, 837, 272, 1300, 14, 3827, 19330, 14, 740, 360, 9217, 63, 1733, 358, 272, 1300, 14, 928, 3120, 342, 421, 199, 318, 6766, 2377, 837, 272, 1300, 14, 2379, 3120, 342, 421, 199, 533, 13503, 5278, 1746, 8, 1095, 14, 1746, 304, 339, 347, 511, 20393, 5278, 8, 277, 304, 267, 408, 267, 1379, 2073, 15, 9217, 63, 1733, 6037, 267, 408, 267, 327, 2790, 282, 22219, 402, 2754, 461, 8247, 267, 4628, 275, 469, 288, 283, 2123, 356, 283, 2113, 32, 2123, 14, 957, 297, 288, 283, 2886, 356, 283, 2113, 2886, 297, 288, 283, 2246, 985, 356, 283, 4880, 297, 288, 283, 2019, 985, 356, 283, 6090, 297, 288, 283, 2060, 356, 283, 2113, 2060, 297, 288, 283, 2113, 356, 715, 267, 789, 267, 4628, 275, 291, 14, 1238, 360, 751, 1959, 981, 1899, 3682, 2113, 9, 398, 922, 275, 469, 288, 283, 2123, 356, 283, 8302, 32, 2123, 14, 957, 297, 288, 283, 2886, 356, 283, 8302, 2886, 297, 288, 283, 2246, 985, 356, 283, 7147, 297, 288, 283, 2019, 985, 356, 283, 6090, 297, 288, 283, 2060, 356, 283, 8302, 2060, 297, 288, 283, 2113, 356, 756, 267, 789, 267, 922, 275, 291, 14, 1238, 360, 751, 1959, 981, 1899, 3682, 751, 9, 398, 23721, 17, 275, 469, 288, 283, 354, 356, 283, 774, 18003, 297, 288, 283, 1802, 356, 283, 11523, 5932, 14, 6061, 1655, 10628, 3130, 288, 283, 3455, 356, 715, 12, 288, 283, 9986, 356, 4628, 267, 789, 267, 23721, 17, 275, 291, 14, 1238, 360, 3627, 1959, 981, 7768, 3682, 15772, 17, 9, 398, 23721, 18, 275, 469, 288, 283, 354, 356, 283, 45, 6573, 3245, 297, 288, 283, 1802, 356, 283, 4239, 297, 288, 283, 3455, 356, 756, 12, 288, 283, 9986, 356, 4628, 267, 789, 267, 23721, 18, 275, 291, 14, 1238, 360, 3627, 1959, 981, 7768, 3682, 15772, 18, 9, 267, 291, 14, 1238, 360, 3627, 1959, 409, 1899, 3946, 8, 288, 23721, 18, 12, 922, 12, 2166, 29, 3946, 804, 14, 5670, 12, 3354, 29, 549, 9, 398, 4922, 17, 275, 469, 288, 283, 1708, 356, 23721, 17, 12, 288, 283, 1708, 804, 356, 283, 3627, 297, 288, 283, 354, 356, 283, 9885, 511, 4922, 7, 267, 789, 267, 4922, 17, 275, 291, 14, 1238, 360, 3741, 1959, 981, 7850, 3682, 3741, 17, 9, 267, 291, 14, 1238, 360, 3741, 1959, 409, 1899, 3946, 8, 288, 4922, 17, 12, 922, 12, 2166, 29, 3946, 804, 14, 5670, 12, 3354, 29, 797, 9, 267, 291, 14, 1238, 360, 3741, 1959, 409, 9885, 8, 3741, 17, 12, 715, 12, 3354, 29, 549, 9, 398, 4922, 18, 275, 469, 288, 283, 1708, 356, 23721, 18, 12, 288, 283, 1708, 804, 356, 283, 3627, 297, 288, 283, 354, 356, 283, 12185, 511, 4922, 7, 267, 789, 267, 4922, 18, 275, 291, 14, 1238, 360, 3741, 1959, 981, 7850, 3682, 3741, 18, 9, 267, 291, 14, 1238, 360, 3741, 1959, 409, 1899, 3946, 8, 288, 4922, 18, 12, 922, 12, 2166, 29, 3946, 804, 14, 9185, 12, 3354, 29, 549, 9, 398, 1242, 17, 275, 469, 288, 283, 354, 356, 283, 9885, 909, 297, 288, 283, 9986, 356, 4628, 12, 288, 283, 3741, 356, 4922, 17, 267, 789, 267, 1242, 17, 275, 291, 14, 1238, 360, 1053, 1959, 981, 2081, 3682, 1053, 17, 9, 398, 1242, 18, 275, 469, 288, 283, 354, 356, 283, 13790, 909, 297, 288, 283, 9986, 356, 4628, 12, 288, 283, 3741, 356, 4922, 18, 267, 789, 267, 1242, 18, 275, 291, 14, 1238, 360, 1053, 1959, 981, 2081, 3682, 1053, 18, 9, 398, 327, 29225, 314, 849, 922, 16533, 267, 3085, 275, 291, 14, 1069, 8, 288, 931, 8805, 3741, 297, 1083, 534, 2970, 297, 922, 29, 751, 12, 1862, 3126, 355, 283, 1708, 804, 356, 283, 751, 297, 355, 283, 1708, 1304, 356, 922, 8680, 344, 995, 355, 283, 3191, 356, 283, 354, 297, 355, 283, 3191, 694, 356, 413, 288, 3828, 398, 327, 7758, 511, 1006, 402, 314, 1415, 2633, 14, 267, 291, 14, 7505, 8030, 6007, 8, 288, 931, 8805, 1927, 15, 1733, 297, 1415, 2968, 81, 297, 283, 1313, 1105, 398, 327, 7356, 511, 2725, 6411, 267, 3085, 275, 291, 14, 1069, 8, 515, 8805, 1927, 15, 9217, 63, 1733, 297, 1862, 3126, 288, 283, 81, 356, 283, 1131, 297, 288, 283, 466, 356, 283, 10603, 730, 7, 267, 3828, 267, 291, 14, 479, 3694, 8, 4518, 12, 8290, 9, 267, 291, 14, 629, 360, 3364, 2073, 730, 26, 6835, 730, 297, 586, 3085, 14, 1001, 459, 1188, 1105, 398, 327, 1379, 6411, 402, 4840, 1324, 267, 3085, 275, 291, 14, 1069, 8, 515, 8805, 1927, 15, 9217, 63, 1733, 297, 1862, 3126, 288, 283, 81, 356, 283, 1397, 63, 1001, 297, 288, 283, 466, 356, 283, 3741, 7, 267, 3828, 267, 291, 14, 479, 3694, 8, 4518, 12, 8290, 9, 267, 291, 14, 629, 8, 4518, 14, 1001, 459, 1188, 995, 586, 283, 1918, 1827, 2725 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 11490, 199, 3, 221, 1898, 6171, 1804, 390, 1068, 3277, 14, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 314, 298, 3761, 2, 20682, 199, 3, 221, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 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, 221, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 221, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 221, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 221, 4204, 1334, 314, 844, 14, 199, 11490, 199, 199, 646, 330, 834, 14, 1001, 63, 1974, 199, 199, 504, 2295, 492, 1300, 199, 504, 486, 723, 424, 14, 5559, 492, 11003, 804, 421, 199, 318, 3613, 2377, 837, 272, 1300, 14, 3827, 19330, 14, 740, 360, 9217, 63, 1733, 358, 272, 1300, 14, 928, 3120, 342, 421, 199, 318, 6766, 2377, 837, 272, 1300, 14, 2379, 3120, 342, 421, 199, 533, 13503, 5278, 1746, 8, 1095, 14, 1746, 304, 339, 347, 511, 20393, 5278, 8, 277, 304, 267, 408, 267, 1379, 2073, 15, 9217, 63, 1733, 6037, 267, 408, 267, 327, 2790, 282, 22219, 402, 2754, 461, 8247, 267, 4628, 275, 469, 288, 283, 2123, 356, 283, 2113, 32, 2123, 14, 957, 297, 288, 283, 2886, 356, 283, 2113, 2886, 297, 288, 283, 2246, 985, 356, 283, 4880, 297, 288, 283, 2019, 985, 356, 283, 6090, 297, 288, 283, 2060, 356, 283, 2113, 2060, 297, 288, 283, 2113, 356, 715, 267, 789, 267, 4628, 275, 291, 14, 1238, 360, 751, 1959, 981, 1899, 3682, 2113, 9, 398, 922, 275, 469, 288, 283, 2123, 356, 283, 8302, 32, 2123, 14, 957, 297, 288, 283, 2886, 356, 283, 8302, 2886, 297, 288, 283, 2246, 985, 356, 283, 7147, 297, 288, 283, 2019, 985, 356, 283, 6090, 297, 288, 283, 2060, 356, 283, 8302, 2060, 297, 288, 283, 2113, 356, 756, 267, 789, 267, 922, 275, 291, 14, 1238, 360, 751, 1959, 981, 1899, 3682, 751, 9, 398, 23721, 17, 275, 469, 288, 283, 354, 356, 283, 774, 18003, 297, 288, 283, 1802, 356, 283, 11523, 5932, 14, 6061, 1655, 10628, 3130, 288, 283, 3455, 356, 715, 12, 288, 283, 9986, 356, 4628, 267, 789, 267, 23721, 17, 275, 291, 14, 1238, 360, 3627, 1959, 981, 7768, 3682, 15772, 17, 9, 398, 23721, 18, 275, 469, 288, 283, 354, 356, 283, 45, 6573, 3245, 297, 288, 283, 1802, 356, 283, 4239, 297, 288, 283, 3455, 356, 756, 12, 288, 283, 9986, 356, 4628, 267, 789, 267, 23721, 18, 275, 291, 14, 1238, 360, 3627, 1959, 981, 7768, 3682, 15772, 18, 9, 267, 291, 14, 1238, 360, 3627, 1959, 409, 1899, 3946, 8, 288, 23721, 18, 12, 922, 12, 2166, 29, 3946, 804, 14, 5670, 12, 3354, 29, 549, 9, 398, 4922, 17, 275, 469, 288, 283, 1708, 356, 23721, 17, 12, 288, 283, 1708, 804, 356, 283, 3627, 297, 288, 283, 354, 356, 283, 9885, 511, 4922, 7, 267, 789, 267, 4922, 17, 275, 291, 14, 1238, 360, 3741, 1959, 981, 7850, 3682, 3741, 17, 9, 267, 291, 14, 1238, 360, 3741, 1959, 409, 1899, 3946, 8, 288, 4922, 17, 12, 922, 12, 2166, 29, 3946, 804, 14, 5670, 12, 3354, 29, 797, 9, 267, 291, 14, 1238, 360, 3741, 1959, 409, 9885, 8, 3741, 17, 12, 715, 12, 3354, 29, 549, 9, 398, 4922, 18, 275, 469, 288, 283, 1708, 356, 23721, 18, 12, 288, 283, 1708, 804, 356, 283, 3627, 297, 288, 283, 354, 356, 283, 12185, 511, 4922, 7, 267, 789, 267, 4922, 18, 275, 291, 14, 1238, 360, 3741, 1959, 981, 7850, 3682, 3741, 18, 9, 267, 291, 14, 1238, 360, 3741, 1959, 409, 1899, 3946, 8, 288, 4922, 18, 12, 922, 12, 2166, 29, 3946, 804, 14, 9185, 12, 3354, 29, 549, 9, 398, 1242, 17, 275, 469, 288, 283, 354, 356, 283, 9885, 909, 297, 288, 283, 9986, 356, 4628, 12, 288, 283, 3741, 356, 4922, 17, 267, 789, 267, 1242, 17, 275, 291, 14, 1238, 360, 1053, 1959, 981, 2081, 3682, 1053, 17, 9, 398, 1242, 18, 275, 469, 288, 283, 354, 356, 283, 13790, 909, 297, 288, 283, 9986, 356, 4628, 12, 288, 283, 3741, 356, 4922, 18, 267, 789, 267, 1242, 18, 275, 291, 14, 1238, 360, 1053, 1959, 981, 2081, 3682, 1053, 18, 9, 398, 327, 29225, 314, 849, 922, 16533, 267, 3085, 275, 291, 14, 1069, 8, 288, 931, 8805, 3741, 297, 1083, 534, 2970, 297, 922, 29, 751, 12, 1862, 3126, 355, 283, 1708, 804, 356, 283, 751, 297, 355, 283, 1708, 1304, 356, 922, 8680, 344, 995, 355, 283, 3191, 356, 283, 354, 297, 355, 283, 3191, 694, 356, 413, 288, 3828, 398, 327, 7758, 511, 1006, 402, 314, 1415, 2633, 14, 267, 291, 14, 7505, 8030, 6007, 8, 288, 931, 8805, 1927, 15, 1733, 297, 1415, 2968, 81, 297, 283, 1313, 1105, 398, 327, 7356, 511, 2725, 6411, 267, 3085, 275, 291, 14, 1069, 8, 515, 8805, 1927, 15, 9217, 63, 1733, 297, 1862, 3126, 288, 283, 81, 356, 283, 1131, 297, 288, 283, 466, 356, 283, 10603, 730, 7, 267, 3828, 267, 291, 14, 479, 3694, 8, 4518, 12, 8290, 9, 267, 291, 14, 629, 360, 3364, 2073, 730, 26, 6835, 730, 297, 586, 3085, 14, 1001, 459, 1188, 1105, 398, 327, 1379, 6411, 402, 4840, 1324, 267, 3085, 275, 291, 14, 1069, 8, 515, 8805, 1927, 15, 9217, 63, 1733, 297, 1862, 3126, 288, 283, 81, 356, 283, 1397, 63, 1001, 297, 288, 283, 466, 356, 283, 3741, 7, 267, 3828, 267, 291, 14, 479, 3694, 8, 4518, 12, 8290, 9, 267, 291, 14, 629, 8, 4518, 14, 1001, 459, 1188, 995, 586, 283,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1, 1, 1, 1, 1, 1, 1 ]
qc88209818/JHGame
JHGame/external/emscripten/tests/poppler/poppler/gen-unicode-tables.py
61
1234
UNICODE_LAST_CHAR_PART1 = 0x2FAFF HANGUL_S_BASE = 0xAC00 HANGUL_S_COUNT = 19 * 21 * 28 import unicodedata print """// Generated by gen-unicode-tables.py typedef struct { Unicode character; int length; int offset; } decomposition; """ decomp_table = [] max_index = 0 decomp_expansion_index = {} decomp_expansion = [] for u in xrange(0, UNICODE_LAST_CHAR_PART1): if (u >= HANGUL_S_BASE and u < HANGUL_S_BASE + HANGUL_S_COUNT): continue norm = tuple(map(ord, unicodedata.normalize("NFKD", unichr(u)))) if norm != (u,): try: i = decomp_expansion_index[norm] decomp_table.append((u, len(norm), i)) except KeyError: decomp_table.append((u, len(norm), max_index)) decomp_expansion_index[norm] = max_index decomp_expansion.append((norm, max_index)) max_index += len(norm) print "#define DECOMP_TABLE_LENGTH %d\n" % len(decomp_table) print "static const decomposition decomp_table[] = {\n%s\n};\n" % ", \n".join( " { 0x%x, %d, %d }" % (character, length, offset) for character, length, offset in decomp_table) print "static const Unicode decomp_expansion[] = {\n%s\n};\n" % ", \n".join( " %s /* offset %d */ " % (", ".join("0x%x" % u for u in norm), index) for norm, index in decomp_expansion)
gpl-2.0
[ 12819, 63, 16901, 63, 5901, 63, 14848, 17, 275, 378, 88, 18, 2078, 1665, 199, 40, 3986, 1293, 63, 51, 63, 5825, 275, 378, 88, 1348, 383, 199, 40, 3986, 1293, 63, 51, 63, 8760, 275, 5851, 627, 7829, 627, 7294, 199, 646, 23128, 199, 199, 1361, 408, 501, 17065, 701, 3805, 13, 2975, 13, 5987, 14, 647, 199, 199, 9594, 2702, 469, 523, 6140, 4528, 27, 523, 1109, 2582, 27, 523, 1109, 3268, 27, 199, 93, 22706, 27, 199, 624, 199, 199, 271, 863, 63, 1224, 275, 942, 199, 988, 63, 1080, 275, 378, 199, 271, 863, 63, 24651, 63, 1080, 275, 1052, 199, 271, 863, 63, 24651, 275, 942, 199, 509, 399, 315, 4945, 8, 16, 12, 6778, 948, 9125, 63, 16901, 63, 5901, 63, 14848, 17, 304, 199, 198, 692, 334, 85, 2356, 869, 3986, 1293, 63, 51, 63, 5825, 436, 399, 665, 869, 3986, 1293, 63, 51, 63, 5825, 435, 869, 3986, 1293, 63, 51, 63, 8760, 304, 507, 198, 6958, 199, 198, 4791, 275, 2008, 8, 1130, 8, 2181, 12, 23128, 14, 7721, 480, 19749, 13368, 401, 17742, 8, 85, 7845, 199, 198, 692, 6316, 1137, 334, 85, 16095, 507, 198, 893, 26, 20866, 198, 73, 275, 477, 863, 63, 24651, 63, 1080, 59, 4791, 61, 686, 198, 271, 863, 63, 1224, 14, 740, 1332, 85, 12, 822, 8, 4791, 395, 284, 430, 507, 198, 2590, 4067, 26, 686, 198, 271, 863, 63, 1224, 14, 740, 1332, 85, 12, 822, 8, 4791, 395, 1390, 63, 1080, 430, 686, 198, 271, 863, 63, 24651, 63, 1080, 59, 4791, 61, 275, 1390, 63, 1080, 686, 198, 271, 863, 63, 24651, 14, 740, 1332, 4791, 12, 1390, 63, 1080, 430, 686, 198, 988, 63, 1080, 847, 822, 8, 4791, 9, 199, 1361, 5426, 4640, 3265, 6790, 63, 8723, 63, 9127, 450, 68, 60, 78, 2, 450, 822, 8, 271, 863, 63, 1224, 9, 199, 1361, 298, 1986, 950, 22706, 477, 863, 63, 1224, 8607, 275, 9459, 78, 5, 83, 60, 78, 16055, 78, 2, 450, 3872, 971, 78, 1674, 904, 8, 507, 198, 2, 221, 469, 378, 88, 5, 88, 12, 450, 68, 12, 450, 68, 789, 2, 450, 334, 10856, 12, 2582, 12, 3268, 9, 507, 198, 509, 4528, 12, 2582, 12, 3268, 315, 477, 863, 63, 1224, 9, 199, 1361, 298, 1986, 950, 6140, 477, 863, 63, 24651, 8607, 275, 9459, 78, 5, 83, 60, 78, 16055, 78, 2, 450, 3872, 971, 78, 1674, 904, 8, 507, 198, 2, 221, 450, 83, 13505, 3268, 450, 68, 11589, 298, 450, 334, 401, 3680, 904, 480, 16, 88, 5, 88, 2, 450, 399, 367, 399, 315, 6316, 395, 20866, 198, 1080, 9, 367, 6316, 12, 1478, 315, 477, 863, 63, 24651, 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 ]
[ 63, 16901, 63, 5901, 63, 14848, 17, 275, 378, 88, 18, 2078, 1665, 199, 40, 3986, 1293, 63, 51, 63, 5825, 275, 378, 88, 1348, 383, 199, 40, 3986, 1293, 63, 51, 63, 8760, 275, 5851, 627, 7829, 627, 7294, 199, 646, 23128, 199, 199, 1361, 408, 501, 17065, 701, 3805, 13, 2975, 13, 5987, 14, 647, 199, 199, 9594, 2702, 469, 523, 6140, 4528, 27, 523, 1109, 2582, 27, 523, 1109, 3268, 27, 199, 93, 22706, 27, 199, 624, 199, 199, 271, 863, 63, 1224, 275, 942, 199, 988, 63, 1080, 275, 378, 199, 271, 863, 63, 24651, 63, 1080, 275, 1052, 199, 271, 863, 63, 24651, 275, 942, 199, 509, 399, 315, 4945, 8, 16, 12, 6778, 948, 9125, 63, 16901, 63, 5901, 63, 14848, 17, 304, 199, 198, 692, 334, 85, 2356, 869, 3986, 1293, 63, 51, 63, 5825, 436, 399, 665, 869, 3986, 1293, 63, 51, 63, 5825, 435, 869, 3986, 1293, 63, 51, 63, 8760, 304, 507, 198, 6958, 199, 198, 4791, 275, 2008, 8, 1130, 8, 2181, 12, 23128, 14, 7721, 480, 19749, 13368, 401, 17742, 8, 85, 7845, 199, 198, 692, 6316, 1137, 334, 85, 16095, 507, 198, 893, 26, 20866, 198, 73, 275, 477, 863, 63, 24651, 63, 1080, 59, 4791, 61, 686, 198, 271, 863, 63, 1224, 14, 740, 1332, 85, 12, 822, 8, 4791, 395, 284, 430, 507, 198, 2590, 4067, 26, 686, 198, 271, 863, 63, 1224, 14, 740, 1332, 85, 12, 822, 8, 4791, 395, 1390, 63, 1080, 430, 686, 198, 271, 863, 63, 24651, 63, 1080, 59, 4791, 61, 275, 1390, 63, 1080, 686, 198, 271, 863, 63, 24651, 14, 740, 1332, 4791, 12, 1390, 63, 1080, 430, 686, 198, 988, 63, 1080, 847, 822, 8, 4791, 9, 199, 1361, 5426, 4640, 3265, 6790, 63, 8723, 63, 9127, 450, 68, 60, 78, 2, 450, 822, 8, 271, 863, 63, 1224, 9, 199, 1361, 298, 1986, 950, 22706, 477, 863, 63, 1224, 8607, 275, 9459, 78, 5, 83, 60, 78, 16055, 78, 2, 450, 3872, 971, 78, 1674, 904, 8, 507, 198, 2, 221, 469, 378, 88, 5, 88, 12, 450, 68, 12, 450, 68, 789, 2, 450, 334, 10856, 12, 2582, 12, 3268, 9, 507, 198, 509, 4528, 12, 2582, 12, 3268, 315, 477, 863, 63, 1224, 9, 199, 1361, 298, 1986, 950, 6140, 477, 863, 63, 24651, 8607, 275, 9459, 78, 5, 83, 60, 78, 16055, 78, 2, 450, 3872, 971, 78, 1674, 904, 8, 507, 198, 2, 221, 450, 83, 13505, 3268, 450, 68, 11589, 298, 450, 334, 401, 3680, 904, 480, 16, 88, 5, 88, 2, 450, 399, 367, 399, 315, 6316, 395, 20866, 198, 1080, 9, 367, 6316, 12, 1478, 315, 477, 863, 63, 24651, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
marios-zindilis/musicbrainz-django-models
musicbrainz_django_models/models/release_status.py
1
2847
""" .. module:: release_status The **Release Status** is one of: 1. Official 2. Promotion 3. Bootleg 4. Pseudo-Release The Release Status is referenced by the Release model. Read more at the `Release documentation on MusicBrainz`_. .. _Release documentation on MusicBrainz: https://musicbrainz.org/doc/Release PostreSQL Definition -------------------- The :code:`release_status` table is defined in the MusicBrainz Server as: .. code-block:: sql CREATE TABLE release_status ( -- replicate id SERIAL, name VARCHAR(255) NOT NULL, parent INTEGER, -- references release_status.id child_order INTEGER NOT NULL DEFAULT 0, description TEXT, gid uuid NOT NULL ); """ from django.db import models from django.utils.encoding import python_2_unicode_compatible import uuid def pre_save_release_status(sender, instance, **kwargs): if instance.name not in sender.NAME_CHOICE_LIST: from django.core.exceptions import ValidationError raise ValidationError( 'Release Status Name "{}" is not one of: {}'.format( instance.name, ', '.join(sender.NAME_CHOICE_LIST))) @python_2_unicode_compatible class release_status(models.Model): """ Not all parameters are listed here, only those that present some interest in their Django implementation. :param str name: the name can be one of a range of values. This is not restricted in the SQL, but it is documented in `the Release documentation <https://musicbrainz.org/doc/Release>`_. In Django, this is implemented as a `choices` parameter to the `name` field, and a `pre_save` signal that performs the validation. :param gid: This cannot be NULL but a default is not defined in SQL. The `default=uuid.uuid4` in Django will generate a UUID during the creation of an instance. """ OFFICIAL = 'Official' PROMOTION = 'Promotion' BOOTLEG = 'Bootleg' PSEUDO_RELEASE = 'Pseudo-Release' NAME_CHOICES = ( (OFFICIAL, OFFICIAL), (PROMOTION, PROMOTION), (BOOTLEG, BOOTLEG), (PSEUDO_RELEASE, PSEUDO_RELEASE),) NAME_CHOICE_LIST = [_[0] for _ in NAME_CHOICES] id = models.AutoField(primary_key=True) name = models.CharField(max_length=255, choices=NAME_CHOICES) parent = models.ForeignKey('self', null=True) child_order = models.IntegerField(default=0) description = models.TextField(null=True) gid = models.UUIDField(default=uuid.uuid4) def __str__(self): return self.name class Meta: db_table = 'release_status' verbose_name_plural = 'Release Statuses' models.signals.pre_save.connect(pre_save_release_status, sender=release_status)
gpl-2.0
[ 624, 199, 703, 859, 447, 4683, 63, 1205, 199, 199, 1918, 1011, 9625, 9795, 538, 365, 1373, 402, 26, 199, 199, 17, 14, 24545, 16714, 199, 18, 14, 27724, 23193, 199, 19, 14, 27324, 4170, 199, 20, 14, 510, 9917, 13, 9625, 199, 199, 1918, 17646, 9795, 365, 11812, 701, 314, 17646, 1402, 14, 5574, 1655, 737, 314, 199, 64, 9625, 3794, 641, 28919, 9916, 34, 6322, 90, 32578, 199, 199, 703, 485, 9625, 3794, 641, 28919, 9916, 34, 6322, 90, 26, 4178, 921, 6553, 338, 2894, 6322, 90, 14, 1308, 15, 1301, 15, 9625, 199, 199, 6564, 264, 4657, 29398, 199, 777, 375, 199, 199, 1918, 520, 600, 1705, 3221, 63, 1205, 64, 1817, 365, 3247, 315, 314, 28919, 9916, 34, 6322, 90, 7146, 465, 26, 199, 199, 703, 1233, 13, 1457, 447, 3875, 339, 16999, 9934, 4683, 63, 1205, 334, 1553, 29738, 267, 1305, 8295, 7017, 4938, 12, 267, 536, 4483, 28490, 8, 2299, 9, 2845, 5962, 12, 267, 1676, 4519, 17086, 12, 1553, 6941, 4683, 63, 1205, 14, 344, 267, 1982, 63, 1648, 260, 17086, 2845, 5962, 6186, 378, 12, 267, 1369, 260, 11951, 12, 267, 15122, 463, 5377, 2845, 5962, 272, 20682, 199, 199, 624, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 646, 5377, 421, 199, 318, 876, 63, 2117, 63, 3221, 63, 1205, 8, 8114, 12, 1256, 12, 1011, 958, 304, 272, 340, 1256, 14, 354, 440, 315, 8904, 14, 2339, 63, 22544, 63, 4924, 26, 267, 687, 1639, 14, 1018, 14, 3924, 492, 8505, 267, 746, 8505, 8, 288, 283, 9625, 9795, 2812, 28168, 365, 440, 1373, 402, 26, 9499, 908, 8, 355, 1256, 14, 354, 12, 355, 1656, 1987, 904, 8, 8114, 14, 2339, 63, 22544, 63, 4924, 1724, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 4683, 63, 1205, 8, 992, 14, 1685, 304, 272, 408, 272, 2832, 1006, 2633, 787, 10532, 2348, 12, 1454, 5204, 626, 3451, 2005, 13518, 272, 315, 3932, 5634, 4514, 14, 339, 520, 635, 620, 536, 26, 314, 536, 883, 506, 1373, 402, 282, 1425, 402, 1338, 14, 961, 365, 440, 267, 15297, 315, 314, 5385, 12, 1325, 652, 365, 22751, 315, 267, 658, 1589, 17646, 3794, 665, 2859, 921, 6553, 338, 2894, 6322, 90, 14, 1308, 15, 1301, 15, 9625, 8637, 3754, 267, 1010, 5634, 12, 642, 365, 6366, 465, 282, 658, 4577, 64, 2725, 370, 314, 658, 354, 64, 267, 901, 12, 436, 282, 658, 657, 63, 2117, 64, 4673, 626, 18628, 314, 6411, 14, 272, 520, 635, 15122, 26, 961, 3913, 506, 5962, 1325, 282, 849, 365, 440, 3247, 315, 5385, 14, 710, 267, 658, 885, 29, 2580, 14, 2580, 20, 64, 315, 5634, 911, 3550, 282, 11134, 5309, 314, 7143, 267, 402, 376, 1256, 14, 272, 408, 339, 1634, 23380, 4938, 275, 283, 3466, 16714, 7, 272, 3611, 27235, 1075, 275, 283, 19250, 23193, 7, 272, 4367, 1387, 25086, 275, 283, 17989, 4170, 7, 272, 510, 899, 53, 1649, 63, 19736, 275, 283, 23414, 13, 9625, 7, 272, 13637, 63, 16236, 275, 334, 267, 334, 28487, 4938, 12, 1634, 23380, 4938, 395, 267, 334, 2514, 27235, 1075, 12, 3611, 27235, 1075, 395, 267, 334, 22679, 25086, 12, 4367, 1387, 25086, 395, 267, 334, 48, 899, 53, 1649, 63, 19736, 12, 510, 899, 53, 1649, 63, 19736, 16945, 272, 13637, 63, 22544, 63, 4924, 275, 359, 9925, 16, 61, 367, 485, 315, 13637, 63, 16236, 61, 339, 1305, 275, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3415, 29, 2339, 63, 16236, 9, 272, 1676, 275, 1709, 14, 3190, 360, 277, 297, 2973, 29, 549, 9, 272, 1982, 63, 1648, 275, 1709, 14, 3901, 8, 885, 29, 16, 9, 272, 1369, 275, 1709, 14, 6254, 8, 2307, 29, 549, 9, 272, 15122, 275, 1709, 14, 8757, 792, 8, 885, 29, 2580, 14, 2580, 20, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 1592, 63, 1224, 275, 283, 3221, 63, 1205, 7, 267, 3376, 63, 354, 63, 10019, 275, 283, 9625, 27673, 5589, 7, 421, 199, 992, 14, 10458, 14, 657, 63, 2117, 14, 2242, 8, 657, 63, 2117, 63, 3221, 63, 1205, 12, 8904, 29, 3221, 63, 1205, 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 ]
[ 199, 703, 859, 447, 4683, 63, 1205, 199, 199, 1918, 1011, 9625, 9795, 538, 365, 1373, 402, 26, 199, 199, 17, 14, 24545, 16714, 199, 18, 14, 27724, 23193, 199, 19, 14, 27324, 4170, 199, 20, 14, 510, 9917, 13, 9625, 199, 199, 1918, 17646, 9795, 365, 11812, 701, 314, 17646, 1402, 14, 5574, 1655, 737, 314, 199, 64, 9625, 3794, 641, 28919, 9916, 34, 6322, 90, 32578, 199, 199, 703, 485, 9625, 3794, 641, 28919, 9916, 34, 6322, 90, 26, 4178, 921, 6553, 338, 2894, 6322, 90, 14, 1308, 15, 1301, 15, 9625, 199, 199, 6564, 264, 4657, 29398, 199, 777, 375, 199, 199, 1918, 520, 600, 1705, 3221, 63, 1205, 64, 1817, 365, 3247, 315, 314, 28919, 9916, 34, 6322, 90, 7146, 465, 26, 199, 199, 703, 1233, 13, 1457, 447, 3875, 339, 16999, 9934, 4683, 63, 1205, 334, 1553, 29738, 267, 1305, 8295, 7017, 4938, 12, 267, 536, 4483, 28490, 8, 2299, 9, 2845, 5962, 12, 267, 1676, 4519, 17086, 12, 1553, 6941, 4683, 63, 1205, 14, 344, 267, 1982, 63, 1648, 260, 17086, 2845, 5962, 6186, 378, 12, 267, 1369, 260, 11951, 12, 267, 15122, 463, 5377, 2845, 5962, 272, 20682, 199, 199, 624, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 199, 646, 5377, 421, 199, 318, 876, 63, 2117, 63, 3221, 63, 1205, 8, 8114, 12, 1256, 12, 1011, 958, 304, 272, 340, 1256, 14, 354, 440, 315, 8904, 14, 2339, 63, 22544, 63, 4924, 26, 267, 687, 1639, 14, 1018, 14, 3924, 492, 8505, 267, 746, 8505, 8, 288, 283, 9625, 9795, 2812, 28168, 365, 440, 1373, 402, 26, 9499, 908, 8, 355, 1256, 14, 354, 12, 355, 1656, 1987, 904, 8, 8114, 14, 2339, 63, 22544, 63, 4924, 1724, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 4683, 63, 1205, 8, 992, 14, 1685, 304, 272, 408, 272, 2832, 1006, 2633, 787, 10532, 2348, 12, 1454, 5204, 626, 3451, 2005, 13518, 272, 315, 3932, 5634, 4514, 14, 339, 520, 635, 620, 536, 26, 314, 536, 883, 506, 1373, 402, 282, 1425, 402, 1338, 14, 961, 365, 440, 267, 15297, 315, 314, 5385, 12, 1325, 652, 365, 22751, 315, 267, 658, 1589, 17646, 3794, 665, 2859, 921, 6553, 338, 2894, 6322, 90, 14, 1308, 15, 1301, 15, 9625, 8637, 3754, 267, 1010, 5634, 12, 642, 365, 6366, 465, 282, 658, 4577, 64, 2725, 370, 314, 658, 354, 64, 267, 901, 12, 436, 282, 658, 657, 63, 2117, 64, 4673, 626, 18628, 314, 6411, 14, 272, 520, 635, 15122, 26, 961, 3913, 506, 5962, 1325, 282, 849, 365, 440, 3247, 315, 5385, 14, 710, 267, 658, 885, 29, 2580, 14, 2580, 20, 64, 315, 5634, 911, 3550, 282, 11134, 5309, 314, 7143, 267, 402, 376, 1256, 14, 272, 408, 339, 1634, 23380, 4938, 275, 283, 3466, 16714, 7, 272, 3611, 27235, 1075, 275, 283, 19250, 23193, 7, 272, 4367, 1387, 25086, 275, 283, 17989, 4170, 7, 272, 510, 899, 53, 1649, 63, 19736, 275, 283, 23414, 13, 9625, 7, 272, 13637, 63, 16236, 275, 334, 267, 334, 28487, 4938, 12, 1634, 23380, 4938, 395, 267, 334, 2514, 27235, 1075, 12, 3611, 27235, 1075, 395, 267, 334, 22679, 25086, 12, 4367, 1387, 25086, 395, 267, 334, 48, 899, 53, 1649, 63, 19736, 12, 510, 899, 53, 1649, 63, 19736, 16945, 272, 13637, 63, 22544, 63, 4924, 275, 359, 9925, 16, 61, 367, 485, 315, 13637, 63, 16236, 61, 339, 1305, 275, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3415, 29, 2339, 63, 16236, 9, 272, 1676, 275, 1709, 14, 3190, 360, 277, 297, 2973, 29, 549, 9, 272, 1982, 63, 1648, 275, 1709, 14, 3901, 8, 885, 29, 16, 9, 272, 1369, 275, 1709, 14, 6254, 8, 2307, 29, 549, 9, 272, 15122, 275, 1709, 14, 8757, 792, 8, 885, 29, 2580, 14, 2580, 20, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 1592, 63, 1224, 275, 283, 3221, 63, 1205, 7, 267, 3376, 63, 354, 63, 10019, 275, 283, 9625, 27673, 5589, 7, 421, 199, 992, 14, 10458, 14, 657, 63, 2117, 14, 2242, 8, 657, 63, 2117, 63, 3221, 63, 1205, 12, 8904, 29, 3221, 63, 1205, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lberruti/ansible
lib/ansible/runner/connection_plugins/funcd.py
110
3517
# Based on local.py (c) 2012, Michael DeHaan <michael.dehaan@gmail.com> # Based on chroot.py (c) 2013, Maykel Moya <mmoya@speedyrails.com> # (c) 2013, Michael Scherer <misc@zarb.org> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # --- # The func transport permit to use ansible over func. For people who have already setup # func and that wish to play with ansible, this permit to move gradually to ansible # without having to redo completely the setup of the network. HAVE_FUNC=False try: import func.overlord.client as fc HAVE_FUNC=True except ImportError: pass import os from ansible.callbacks import vvv from ansible import errors import tempfile import shutil class Connection(object): ''' Func-based connections ''' def __init__(self, runner, host, port, *args, **kwargs): self.runner = runner self.host = host self.has_pipelining = False # port is unused, this go on func self.port = port def connect(self, port=None): if not HAVE_FUNC: raise errors.AnsibleError("func is not installed") self.client = fc.Client(self.host) return self def exec_command(self, cmd, tmp_path, become_user=None, sudoable=False, executable='/bin/sh', in_data=None): ''' run a command on the remote minion ''' if in_data: raise errors.AnsibleError("Internal Error: this module does not support optimized module pipelining") # totally ignores privlege escalation vvv("EXEC %s" % (cmd), host=self.host) p = self.client.command.run(cmd)[self.host] return (p[0], '', p[1], p[2]) def _normalize_path(self, path, prefix): if not path.startswith(os.path.sep): path = os.path.join(os.path.sep, path) normpath = os.path.normpath(path) return os.path.join(prefix, normpath[1:]) def put_file(self, in_path, out_path): ''' transfer a file from local to remote ''' out_path = self._normalize_path(out_path, '/') vvv("PUT %s TO %s" % (in_path, out_path), host=self.host) self.client.local.copyfile.send(in_path, out_path) def fetch_file(self, in_path, out_path): ''' fetch a file from remote to local ''' in_path = self._normalize_path(in_path, '/') vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host) # need to use a tmp dir due to difference of semantic for getfile # ( who take a # directory as destination) and fetch_file, who # take a file directly tmpdir = tempfile.mkdtemp(prefix="func_ansible") self.client.local.getfile.get(in_path, tmpdir) shutil.move(os.path.join(tmpdir, self.host, os.path.basename(in_path)), out_path) shutil.rmtree(tmpdir) def close(self): ''' terminate the connection; nothing to do here ''' pass
gpl-3.0
[ 3, 21311, 641, 2257, 14, 647, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 21311, 641, 32028, 14, 647, 334, 67, 9, 6171, 12, 10162, 75, 352, 3930, 11552, 665, 77, 573, 11552, 32, 7625, 89, 345, 17841, 14, 957, 30, 199, 3, 334, 67, 9, 6171, 12, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 10894, 199, 3, 710, 2562, 7773, 11291, 370, 675, 3242, 1806, 2562, 14, 2104, 13135, 3963, 1172, 2575, 3272, 199, 3, 2562, 436, 626, 13809, 370, 5232, 543, 3242, 12, 642, 11291, 370, 4057, 1999, 2033, 1183, 370, 3242, 199, 3, 1928, 9445, 370, 295, 1117, 14793, 314, 3272, 402, 314, 2784, 14, 199, 199, 10767, 63, 19587, 29, 797, 199, 893, 26, 272, 492, 2562, 14, 1883, 76, 2181, 14, 1258, 465, 10821, 272, 25227, 63, 19587, 29, 549, 199, 2590, 3545, 26, 272, 986, 199, 199, 646, 747, 199, 504, 3242, 14, 11948, 492, 373, 8958, 199, 504, 3242, 492, 2552, 199, 646, 5549, 199, 646, 5145, 421, 199, 533, 8113, 8, 785, 304, 272, 1449, 28794, 13, 6788, 6947, 1449, 339, 347, 636, 826, 721, 277, 12, 7876, 12, 1591, 12, 1844, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 5933, 275, 7876, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 1989, 63, 4990, 30176, 275, 756, 267, 327, 1844, 365, 9563, 12, 642, 2621, 641, 2562, 267, 291, 14, 719, 275, 1844, 339, 347, 4907, 8, 277, 12, 1844, 29, 403, 304, 267, 340, 440, 25227, 63, 19587, 26, 288, 746, 2552, 14, 29107, 480, 1532, 365, 440, 4903, 531, 398, 291, 14, 1258, 275, 10821, 14, 3041, 8, 277, 14, 1102, 9, 267, 372, 291, 339, 347, 2146, 63, 1531, 8, 277, 12, 2088, 12, 3529, 63, 515, 12, 8649, 63, 751, 29, 403, 12, 14682, 461, 29, 797, 12, 2151, 7286, 8805, 1393, 15, 609, 297, 315, 63, 576, 29, 403, 304, 267, 1449, 1255, 282, 1414, 641, 314, 3982, 1748, 1636, 1449, 398, 340, 315, 63, 576, 26, 288, 746, 2552, 14, 29107, 480, 8405, 4520, 26, 642, 859, 1630, 440, 2291, 20212, 859, 5200, 30176, 531, 398, 327, 12657, 1183, 24010, 16254, 274, 303, 325, 4732, 425, 267, 373, 8958, 480, 10276, 450, 83, 2, 450, 334, 1760, 395, 1591, 29, 277, 14, 1102, 9, 267, 299, 275, 291, 14, 1258, 14, 1531, 14, 1065, 8, 1760, 2788, 277, 14, 1102, 61, 267, 372, 334, 80, 59, 16, 467, 3260, 299, 59, 17, 467, 299, 59, 18, 566, 339, 347, 485, 7721, 63, 515, 8, 277, 12, 931, 12, 2403, 304, 267, 340, 440, 931, 14, 2460, 8, 736, 14, 515, 14, 4127, 304, 288, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4127, 12, 931, 9, 267, 25962, 275, 747, 14, 515, 14, 9267, 8, 515, 9, 267, 372, 747, 14, 515, 14, 904, 8, 1861, 12, 25962, 59, 17, 5728, 339, 347, 5324, 63, 493, 8, 277, 12, 315, 63, 515, 12, 734, 63, 515, 304, 267, 1449, 9307, 282, 570, 687, 2257, 370, 3982, 1449, 398, 734, 63, 515, 275, 291, 423, 7721, 63, 515, 8, 548, 63, 515, 12, 15107, 267, 373, 8958, 480, 4013, 450, 83, 2296, 450, 83, 2, 450, 334, 262, 63, 515, 12, 734, 63, 515, 395, 1591, 29, 277, 14, 1102, 9, 267, 291, 14, 1258, 14, 1832, 14, 21997, 14, 2254, 8, 262, 63, 515, 12, 734, 63, 515, 9, 339, 347, 5267, 63, 493, 8, 277, 12, 315, 63, 515, 12, 734, 63, 515, 304, 267, 1449, 5267, 282, 570, 687, 3982, 370, 2257, 1449, 398, 315, 63, 515, 275, 291, 423, 7721, 63, 515, 8, 262, 63, 515, 12, 15107, 267, 373, 8958, 480, 32097, 450, 83, 2296, 450, 83, 2, 450, 334, 262, 63, 515, 12, 734, 63, 515, 395, 1591, 29, 277, 14, 1102, 9, 267, 327, 1929, 370, 675, 282, 3529, 2935, 7037, 370, 8865, 402, 32451, 367, 664, 493, 267, 327, 334, 3963, 5452, 282, 327, 2082, 465, 5724, 9, 436, 5267, 63, 493, 12, 3963, 267, 327, 5452, 282, 570, 5370, 267, 12885, 275, 5549, 14, 11983, 8, 1861, 628, 1532, 63, 4853, 531, 267, 291, 14, 1258, 14, 1832, 14, 23462, 14, 362, 8, 262, 63, 515, 12, 12885, 9, 267, 5145, 14, 1185, 8, 736, 14, 515, 14, 904, 8, 8616, 12, 291, 14, 1102, 12, 747, 14, 515, 14, 4846, 8, 262, 63, 515, 1826, 490, 734, 63, 515, 9, 267, 5145, 14, 9242, 8, 8616, 9, 339, 347, 4002, 8, 277, 304, 267, 1449, 15095, 314, 1950, 27, 6548, 370, 886, 2348, 1449, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 21311, 641, 2257, 14, 647, 334, 67, 9, 6029, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 21311, 641, 32028, 14, 647, 334, 67, 9, 6171, 12, 10162, 75, 352, 3930, 11552, 665, 77, 573, 11552, 32, 7625, 89, 345, 17841, 14, 957, 30, 199, 3, 334, 67, 9, 6171, 12, 16922, 428, 595, 3859, 665, 9923, 32, 90, 10325, 14, 1308, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 10894, 199, 3, 710, 2562, 7773, 11291, 370, 675, 3242, 1806, 2562, 14, 2104, 13135, 3963, 1172, 2575, 3272, 199, 3, 2562, 436, 626, 13809, 370, 5232, 543, 3242, 12, 642, 11291, 370, 4057, 1999, 2033, 1183, 370, 3242, 199, 3, 1928, 9445, 370, 295, 1117, 14793, 314, 3272, 402, 314, 2784, 14, 199, 199, 10767, 63, 19587, 29, 797, 199, 893, 26, 272, 492, 2562, 14, 1883, 76, 2181, 14, 1258, 465, 10821, 272, 25227, 63, 19587, 29, 549, 199, 2590, 3545, 26, 272, 986, 199, 199, 646, 747, 199, 504, 3242, 14, 11948, 492, 373, 8958, 199, 504, 3242, 492, 2552, 199, 646, 5549, 199, 646, 5145, 421, 199, 533, 8113, 8, 785, 304, 272, 1449, 28794, 13, 6788, 6947, 1449, 339, 347, 636, 826, 721, 277, 12, 7876, 12, 1591, 12, 1844, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 5933, 275, 7876, 267, 291, 14, 1102, 275, 1591, 267, 291, 14, 1989, 63, 4990, 30176, 275, 756, 267, 327, 1844, 365, 9563, 12, 642, 2621, 641, 2562, 267, 291, 14, 719, 275, 1844, 339, 347, 4907, 8, 277, 12, 1844, 29, 403, 304, 267, 340, 440, 25227, 63, 19587, 26, 288, 746, 2552, 14, 29107, 480, 1532, 365, 440, 4903, 531, 398, 291, 14, 1258, 275, 10821, 14, 3041, 8, 277, 14, 1102, 9, 267, 372, 291, 339, 347, 2146, 63, 1531, 8, 277, 12, 2088, 12, 3529, 63, 515, 12, 8649, 63, 751, 29, 403, 12, 14682, 461, 29, 797, 12, 2151, 7286, 8805, 1393, 15, 609, 297, 315, 63, 576, 29, 403, 304, 267, 1449, 1255, 282, 1414, 641, 314, 3982, 1748, 1636, 1449, 398, 340, 315, 63, 576, 26, 288, 746, 2552, 14, 29107, 480, 8405, 4520, 26, 642, 859, 1630, 440, 2291, 20212, 859, 5200, 30176, 531, 398, 327, 12657, 1183, 24010, 16254, 274, 303, 325, 4732, 425, 267, 373, 8958, 480, 10276, 450, 83, 2, 450, 334, 1760, 395, 1591, 29, 277, 14, 1102, 9, 267, 299, 275, 291, 14, 1258, 14, 1531, 14, 1065, 8, 1760, 2788, 277, 14, 1102, 61, 267, 372, 334, 80, 59, 16, 467, 3260, 299, 59, 17, 467, 299, 59, 18, 566, 339, 347, 485, 7721, 63, 515, 8, 277, 12, 931, 12, 2403, 304, 267, 340, 440, 931, 14, 2460, 8, 736, 14, 515, 14, 4127, 304, 288, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4127, 12, 931, 9, 267, 25962, 275, 747, 14, 515, 14, 9267, 8, 515, 9, 267, 372, 747, 14, 515, 14, 904, 8, 1861, 12, 25962, 59, 17, 5728, 339, 347, 5324, 63, 493, 8, 277, 12, 315, 63, 515, 12, 734, 63, 515, 304, 267, 1449, 9307, 282, 570, 687, 2257, 370, 3982, 1449, 398, 734, 63, 515, 275, 291, 423, 7721, 63, 515, 8, 548, 63, 515, 12, 15107, 267, 373, 8958, 480, 4013, 450, 83, 2296, 450, 83, 2, 450, 334, 262, 63, 515, 12, 734, 63, 515, 395, 1591, 29, 277, 14, 1102, 9, 267, 291, 14, 1258, 14, 1832, 14, 21997, 14, 2254, 8, 262, 63, 515, 12, 734, 63, 515, 9, 339, 347, 5267, 63, 493, 8, 277, 12, 315, 63, 515, 12, 734, 63, 515, 304, 267, 1449, 5267, 282, 570, 687, 3982, 370, 2257, 1449, 398, 315, 63, 515, 275, 291, 423, 7721, 63, 515, 8, 262, 63, 515, 12, 15107, 267, 373, 8958, 480, 32097, 450, 83, 2296, 450, 83, 2, 450, 334, 262, 63, 515, 12, 734, 63, 515, 395, 1591, 29, 277, 14, 1102, 9, 267, 327, 1929, 370, 675, 282, 3529, 2935, 7037, 370, 8865, 402, 32451, 367, 664, 493, 267, 327, 334, 3963, 5452, 282, 327, 2082, 465, 5724, 9, 436, 5267, 63, 493, 12, 3963, 267, 327, 5452, 282, 570, 5370, 267, 12885, 275, 5549, 14, 11983, 8, 1861, 628, 1532, 63, 4853, 531, 267, 291, 14, 1258, 14, 1832, 14, 23462, 14, 362, 8, 262, 63, 515, 12, 12885, 9, 267, 5145, 14, 1185, 8, 736, 14, 515, 14, 904, 8, 8616, 12, 291, 14, 1102, 12, 747, 14, 515, 14, 4846, 8, 262, 63, 515, 1826, 490, 734, 63, 515, 9, 267, 5145, 14, 9242, 8, 8616, 9, 339, 347, 4002, 8, 277, 304, 267, 1449, 15095, 314, 1950, 27, 6548, 370, 886, 2348, 1449, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mollstam/UnrealPy
UnrealPyEmbed/Development/Python/2015.08.07-Python2710-x64-Source-vs2015/Python27/Source/boto-2.38.0/boto/ec2/address.py
147
5348
# Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ # # 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.ec2.ec2object import EC2Object class Address(EC2Object): """ Represents an EC2 Elastic IP Address :ivar public_ip: The Elastic IP address. :ivar instance_id: The instance the address is associated with (if any). :ivar domain: Indicates whether the address is a EC2 address or a VPC address (standard|vpc). :ivar allocation_id: The allocation ID for the address (VPC addresses only). :ivar association_id: The association ID for the address (VPC addresses only). :ivar network_interface_id: The network interface (if any) that the address is associated with (VPC addresses only). :ivar network_interface_owner_id: The owner IID (VPC addresses only). :ivar private_ip_address: The private IP address associated with the Elastic IP address (VPC addresses only). """ def __init__(self, connection=None, public_ip=None, instance_id=None): super(Address, self).__init__(connection) self.connection = connection self.public_ip = public_ip self.instance_id = instance_id self.domain = None self.allocation_id = None self.association_id = None self.network_interface_id = None self.network_interface_owner_id = None self.private_ip_address = None def __repr__(self): return 'Address:%s' % self.public_ip def endElement(self, name, value, connection): if name == 'publicIp': self.public_ip = value elif name == 'instanceId': self.instance_id = value elif name == 'domain': self.domain = value elif name == 'allocationId': self.allocation_id = value elif name == 'associationId': self.association_id = value elif name == 'networkInterfaceId': self.network_interface_id = value elif name == 'networkInterfaceOwnerId': self.network_interface_owner_id = value elif name == 'privateIpAddress': self.private_ip_address = value else: setattr(self, name, value) def release(self, dry_run=False): """ Free up this Elastic IP address. :see: :meth:`boto.ec2.connection.EC2Connection.release_address` """ if self.allocation_id: return self.connection.release_address( allocation_id=self.allocation_id, dry_run=dry_run) else: return self.connection.release_address( public_ip=self.public_ip, dry_run=dry_run ) delete = release def associate(self, instance_id=None, network_interface_id=None, private_ip_address=None, allow_reassociation=False, dry_run=False): """ Associate this Elastic IP address with a currently running instance. :see: :meth:`boto.ec2.connection.EC2Connection.associate_address` """ if self.allocation_id: return self.connection.associate_address( instance_id=instance_id, public_ip=self.public_ip, allocation_id=self.allocation_id, network_interface_id=network_interface_id, private_ip_address=private_ip_address, allow_reassociation=allow_reassociation, dry_run=dry_run ) return self.connection.associate_address( instance_id=instance_id, public_ip=self.public_ip, network_interface_id=network_interface_id, private_ip_address=private_ip_address, allow_reassociation=allow_reassociation, dry_run=dry_run ) def disassociate(self, dry_run=False): """ Disassociate this Elastic IP address from a currently running instance. :see: :meth:`boto.ec2.connection.EC2Connection.disassociate_address` """ if self.association_id: return self.connection.disassociate_address( association_id=self.association_id, dry_run=dry_run ) else: return self.connection.disassociate_address( public_ip=self.public_ip, dry_run=dry_run )
mit
[ 3, 1898, 334, 67, 9, 8315, 13, 8664, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 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, 421, 199, 504, 6055, 14, 825, 18, 14, 825, 18, 785, 492, 15352, 18, 1692, 421, 199, 533, 9906, 8, 4220, 18, 1692, 304, 272, 408, 272, 21591, 376, 15352, 18, 19509, 3531, 9906, 339, 520, 7725, 4575, 63, 711, 26, 710, 19509, 3531, 2287, 14, 272, 520, 7725, 1256, 63, 344, 26, 710, 1256, 314, 2287, 365, 4568, 543, 334, 692, 1263, 680, 272, 520, 7725, 2881, 26, 19334, 3775, 314, 2287, 365, 282, 15352, 18, 2287, 503, 282, 19209, 2287, 334, 6807, 92, 11742, 680, 272, 520, 7725, 18723, 63, 344, 26, 710, 18723, 2870, 367, 314, 2287, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 20640, 63, 344, 26, 710, 20640, 2870, 367, 314, 2287, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 2784, 63, 3266, 63, 344, 26, 710, 2784, 3217, 334, 692, 1263, 9, 626, 314, 2287, 365, 4568, 543, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 2784, 63, 3266, 63, 4597, 63, 344, 26, 710, 5771, 473, 998, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 5726, 63, 711, 63, 1562, 26, 710, 5726, 3531, 2287, 4568, 543, 314, 19509, 3531, 2287, 334, 54, 4222, 7149, 1454, 680, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1950, 29, 403, 12, 4575, 63, 711, 29, 403, 12, 1256, 63, 344, 29, 403, 304, 267, 1613, 8, 1476, 12, 291, 2843, 826, 721, 2105, 9, 267, 291, 14, 2105, 275, 1950, 267, 291, 14, 3455, 63, 711, 275, 4575, 63, 711, 267, 291, 14, 842, 63, 344, 275, 1256, 63, 344, 267, 291, 14, 2261, 275, 488, 267, 291, 14, 14940, 63, 344, 275, 488, 267, 291, 14, 20252, 63, 344, 275, 488, 267, 291, 14, 1200, 63, 3266, 63, 344, 275, 488, 267, 291, 14, 1200, 63, 3266, 63, 4597, 63, 344, 275, 488, 267, 291, 14, 4239, 63, 711, 63, 1562, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 1476, 2689, 83, 7, 450, 291, 14, 3455, 63, 711, 339, 347, 28920, 8, 277, 12, 536, 12, 574, 12, 1950, 304, 267, 340, 536, 508, 283, 3455, 6583, 356, 288, 291, 14, 3455, 63, 711, 275, 574, 267, 916, 536, 508, 283, 842, 1304, 356, 288, 291, 14, 842, 63, 344, 275, 574, 267, 916, 536, 508, 283, 2261, 356, 288, 291, 14, 2261, 275, 574, 267, 916, 536, 508, 283, 14940, 1304, 356, 288, 291, 14, 14940, 63, 344, 275, 574, 267, 916, 536, 508, 283, 20252, 1304, 356, 288, 291, 14, 20252, 63, 344, 275, 574, 267, 916, 536, 508, 283, 1200, 4267, 1304, 356, 288, 291, 14, 1200, 63, 3266, 63, 344, 275, 574, 267, 916, 536, 508, 283, 1200, 4267, 14919, 1304, 356, 288, 291, 14, 1200, 63, 3266, 63, 4597, 63, 344, 275, 574, 267, 916, 536, 508, 283, 4239, 23211, 356, 288, 291, 14, 4239, 63, 711, 63, 1562, 275, 574, 267, 587, 26, 288, 5371, 8, 277, 12, 536, 12, 574, 9, 339, 347, 4683, 8, 277, 12, 9951, 63, 1065, 29, 797, 304, 267, 408, 267, 2868, 1536, 642, 19509, 3531, 2287, 14, 267, 520, 3239, 26, 520, 5247, 1705, 10914, 14, 825, 18, 14, 2105, 14, 4220, 18, 3225, 14, 3221, 63, 1562, 64, 267, 408, 267, 340, 291, 14, 14940, 63, 344, 26, 288, 372, 291, 14, 2105, 14, 3221, 63, 1562, 8, 355, 18723, 63, 344, 29, 277, 14, 14940, 63, 344, 12, 355, 9951, 63, 1065, 29, 10481, 63, 1065, 9, 267, 587, 26, 288, 372, 291, 14, 2105, 14, 3221, 63, 1562, 8, 355, 4575, 63, 711, 29, 277, 14, 3455, 63, 711, 12, 355, 9951, 63, 1065, 29, 10481, 63, 1065, 288, 776, 339, 3145, 275, 4683, 339, 347, 20133, 8, 277, 12, 1256, 63, 344, 29, 403, 12, 2784, 63, 3266, 63, 344, 29, 403, 12, 5726, 63, 711, 63, 1562, 29, 403, 12, 2040, 63, 264, 20252, 29, 797, 12, 9951, 63, 1065, 29, 797, 304, 267, 408, 267, 24207, 323, 642, 19509, 3531, 2287, 543, 282, 5544, 3879, 1256, 14, 267, 520, 3239, 26, 520, 5247, 1705, 10914, 14, 825, 18, 14, 2105, 14, 4220, 18, 3225, 14, 16021, 63, 1562, 64, 267, 408, 267, 340, 291, 14, 14940, 63, 344, 26, 288, 372, 291, 14, 2105, 14, 16021, 63, 1562, 8, 355, 1256, 63, 344, 29, 842, 63, 344, 12, 355, 4575, 63, 711, 29, 277, 14, 3455, 63, 711, 12, 355, 18723, 63, 344, 29, 277, 14, 14940, 63, 344, 12, 355, 2784, 63, 3266, 63, 344, 29, 1200, 63, 3266, 63, 344, 12, 355, 5726, 63, 711, 63, 1562, 29, 4239, 63, 711, 63, 1562 ]
[ 1898, 334, 67, 9, 8315, 13, 8664, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 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, 421, 199, 504, 6055, 14, 825, 18, 14, 825, 18, 785, 492, 15352, 18, 1692, 421, 199, 533, 9906, 8, 4220, 18, 1692, 304, 272, 408, 272, 21591, 376, 15352, 18, 19509, 3531, 9906, 339, 520, 7725, 4575, 63, 711, 26, 710, 19509, 3531, 2287, 14, 272, 520, 7725, 1256, 63, 344, 26, 710, 1256, 314, 2287, 365, 4568, 543, 334, 692, 1263, 680, 272, 520, 7725, 2881, 26, 19334, 3775, 314, 2287, 365, 282, 15352, 18, 2287, 503, 282, 19209, 2287, 334, 6807, 92, 11742, 680, 272, 520, 7725, 18723, 63, 344, 26, 710, 18723, 2870, 367, 314, 2287, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 20640, 63, 344, 26, 710, 20640, 2870, 367, 314, 2287, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 2784, 63, 3266, 63, 344, 26, 710, 2784, 3217, 334, 692, 1263, 9, 626, 314, 2287, 365, 4568, 543, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 2784, 63, 3266, 63, 4597, 63, 344, 26, 710, 5771, 473, 998, 334, 54, 4222, 7149, 1454, 680, 272, 520, 7725, 5726, 63, 711, 63, 1562, 26, 710, 5726, 3531, 2287, 4568, 543, 314, 19509, 3531, 2287, 334, 54, 4222, 7149, 1454, 680, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1950, 29, 403, 12, 4575, 63, 711, 29, 403, 12, 1256, 63, 344, 29, 403, 304, 267, 1613, 8, 1476, 12, 291, 2843, 826, 721, 2105, 9, 267, 291, 14, 2105, 275, 1950, 267, 291, 14, 3455, 63, 711, 275, 4575, 63, 711, 267, 291, 14, 842, 63, 344, 275, 1256, 63, 344, 267, 291, 14, 2261, 275, 488, 267, 291, 14, 14940, 63, 344, 275, 488, 267, 291, 14, 20252, 63, 344, 275, 488, 267, 291, 14, 1200, 63, 3266, 63, 344, 275, 488, 267, 291, 14, 1200, 63, 3266, 63, 4597, 63, 344, 275, 488, 267, 291, 14, 4239, 63, 711, 63, 1562, 275, 488, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 1476, 2689, 83, 7, 450, 291, 14, 3455, 63, 711, 339, 347, 28920, 8, 277, 12, 536, 12, 574, 12, 1950, 304, 267, 340, 536, 508, 283, 3455, 6583, 356, 288, 291, 14, 3455, 63, 711, 275, 574, 267, 916, 536, 508, 283, 842, 1304, 356, 288, 291, 14, 842, 63, 344, 275, 574, 267, 916, 536, 508, 283, 2261, 356, 288, 291, 14, 2261, 275, 574, 267, 916, 536, 508, 283, 14940, 1304, 356, 288, 291, 14, 14940, 63, 344, 275, 574, 267, 916, 536, 508, 283, 20252, 1304, 356, 288, 291, 14, 20252, 63, 344, 275, 574, 267, 916, 536, 508, 283, 1200, 4267, 1304, 356, 288, 291, 14, 1200, 63, 3266, 63, 344, 275, 574, 267, 916, 536, 508, 283, 1200, 4267, 14919, 1304, 356, 288, 291, 14, 1200, 63, 3266, 63, 4597, 63, 344, 275, 574, 267, 916, 536, 508, 283, 4239, 23211, 356, 288, 291, 14, 4239, 63, 711, 63, 1562, 275, 574, 267, 587, 26, 288, 5371, 8, 277, 12, 536, 12, 574, 9, 339, 347, 4683, 8, 277, 12, 9951, 63, 1065, 29, 797, 304, 267, 408, 267, 2868, 1536, 642, 19509, 3531, 2287, 14, 267, 520, 3239, 26, 520, 5247, 1705, 10914, 14, 825, 18, 14, 2105, 14, 4220, 18, 3225, 14, 3221, 63, 1562, 64, 267, 408, 267, 340, 291, 14, 14940, 63, 344, 26, 288, 372, 291, 14, 2105, 14, 3221, 63, 1562, 8, 355, 18723, 63, 344, 29, 277, 14, 14940, 63, 344, 12, 355, 9951, 63, 1065, 29, 10481, 63, 1065, 9, 267, 587, 26, 288, 372, 291, 14, 2105, 14, 3221, 63, 1562, 8, 355, 4575, 63, 711, 29, 277, 14, 3455, 63, 711, 12, 355, 9951, 63, 1065, 29, 10481, 63, 1065, 288, 776, 339, 3145, 275, 4683, 339, 347, 20133, 8, 277, 12, 1256, 63, 344, 29, 403, 12, 2784, 63, 3266, 63, 344, 29, 403, 12, 5726, 63, 711, 63, 1562, 29, 403, 12, 2040, 63, 264, 20252, 29, 797, 12, 9951, 63, 1065, 29, 797, 304, 267, 408, 267, 24207, 323, 642, 19509, 3531, 2287, 543, 282, 5544, 3879, 1256, 14, 267, 520, 3239, 26, 520, 5247, 1705, 10914, 14, 825, 18, 14, 2105, 14, 4220, 18, 3225, 14, 16021, 63, 1562, 64, 267, 408, 267, 340, 291, 14, 14940, 63, 344, 26, 288, 372, 291, 14, 2105, 14, 16021, 63, 1562, 8, 355, 1256, 63, 344, 29, 842, 63, 344, 12, 355, 4575, 63, 711, 29, 277, 14, 3455, 63, 711, 12, 355, 18723, 63, 344, 29, 277, 14, 14940, 63, 344, 12, 355, 2784, 63, 3266, 63, 344, 29, 1200, 63, 3266, 63, 344, 12, 355, 5726, 63, 711, 63, 1562, 29, 4239, 63, 711, 63, 1562, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Mistobaan/tensorflow
tensorflow/tools/dist_test/scripts/k8s_tensorflow_lib.py
131
9280
# Copyright 2016 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. # ============================================================================== """Generates YAML configuration files for distributed TensorFlow workers. The workers will be run in a Kubernetes (k8s) container cluster. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function # Note: It is intentional that we do not import tensorflow in this script. The # machine that launches a TensorFlow k8s cluster does not have to have the # Python package of TensorFlow installed on it. # TODO(cais): Consider adding resource requests/limits to the pods. # Worker pods will mount host volume /shared, as a convenient way to create # shared storage among workers during local tests. WORKER_RC = ( """apiVersion: v1 kind: ReplicationController metadata: name: {name_prefix}-worker{worker_id} spec: replicas: 1 template: metadata: labels: tf-worker: "{worker_id}" name-prefix: "{name_prefix}" job: "worker" spec: containers: - name: tf-worker{worker_id} image: {docker_image} args: [{args}] ports: - containerPort: {port} env: [{env_vars}] volumeMounts: [{volume_mounts}] volumes: [{volumes}] """) WORKER_SVC = ( """apiVersion: v1 kind: Service metadata: name: {name_prefix}-worker{worker_id} labels: tf-worker: "{worker_id}" spec: ports: - port: {port} targetPort: {port} selector: tf-worker: "{worker_id}" """) WORKER_LB_SVC = ( """apiVersion: v1 kind: Service metadata: name: {name_prefix}-worker{worker_id} labels: tf-worker: "{worker_id}" spec: type: LoadBalancer ports: - port: {port} selector: tf-worker: "{worker_id}" """) PARAM_SERVER_RC = ( """apiVersion: v1 kind: ReplicationController metadata: name: {name_prefix}-ps{param_server_id} spec: replicas: 1 template: metadata: labels: tf-ps: "{param_server_id}" name-prefix: "{name_prefix}" job: "ps" spec: containers: - name: tf-ps{param_server_id} image: {docker_image} args: [{args}] ports: - containerPort: {port} env: [{env_vars}] volumeMounts: [{volume_mounts}] volumes: [{volumes}] """) PARAM_SERVER_SVC = ( """apiVersion: v1 kind: Service metadata: name: {name_prefix}-ps{param_server_id} labels: tf-ps: "{param_server_id}" spec: ports: - port: {port} selector: tf-ps: "{param_server_id}" """) PARAM_LB_SVC = ("""apiVersion: v1 kind: Service metadata: name: {name_prefix}-ps{param_server_id} labels: tf-ps: "{param_server_id}" spec: type: LoadBalancer ports: - port: {port} selector: tf-ps: "{param_server_id}" """) VOLUME_MOUNTS = '{name: shared, mountPath: /shared}' VOLUMES = '{name: shared, hostPath: {path: /shared}}' _ENV_VAR_TEMPLATE = '{name: "%s", value: "%s"}' _ARG_TEMPLATE = '"--%s=%s"' def GenerateConfig(num_workers, num_param_servers, port, request_load_balancer, docker_image, name_prefix, env_vars=None, use_shared_volume=True, use_cluster_spec=True): """Generate configuration strings. Args: num_workers: number of worker jobs. num_param_servers: number of ps server jobs. port: GRPC server port. request_load_balancer: request worker0 to be exposed on a public IP address via an external load balancer. docker_image: docker image to use. name_prefix: name to prepend to pod job names. env_vars: dictionary of environment variables to set. use_shared_volume: whether to add hostPath to /shared directory to the kubernetes config. use_cluster_spec: if true, pass --cluster_spec to worker and ps jobs. If false, pass --worker_hosts and --ps_hosts to worker and ps jobs. Returns: Kubernetes yaml config. """ if env_vars is None: env_vars = {} env_str = ', '.join([_ENV_VAR_TEMPLATE % (name, value) for name, value in env_vars.items()]) config = '' common_args = GetCommonArgs( num_workers, num_param_servers, port, name_prefix, use_cluster_spec) for worker in range(num_workers): worker_args = { 'job_name': 'worker', 'task_id': worker } worker_args.update(common_args) arg_str = ', '.join([_ARG_TEMPLATE % (name, value) for name, value in worker_args.items()]) config += WORKER_RC.format( port=port, worker_id=worker, docker_image=docker_image, name_prefix=name_prefix, volume_mounts=VOLUME_MOUNTS if use_shared_volume else '', volumes=VOLUMES if use_shared_volume else '', args=arg_str, env_vars=env_str) config += '---\n' if request_load_balancer: config += WORKER_LB_SVC.format(port=port, worker_id=worker, name_prefix=name_prefix) else: config += WORKER_SVC.format(port=port, worker_id=worker, name_prefix=name_prefix) config += '---\n' for param_server in range(num_param_servers): ps_args = { 'job_name': 'ps', 'task_id': param_server } ps_args.update(common_args) arg_str = ', '.join([_ARG_TEMPLATE % (name, value) for name, value in ps_args.items()]) config += PARAM_SERVER_RC.format( port=port, param_server_id=param_server, docker_image=docker_image, name_prefix=name_prefix, volume_mounts=VOLUME_MOUNTS if use_shared_volume else '', volumes=VOLUMES if use_shared_volume else '', args=arg_str, env_vars=env_str) config += '---\n' if request_load_balancer: config += PARAM_LB_SVC.format( port=port, param_server_id=param_server, name_prefix=name_prefix) else: config += PARAM_SERVER_SVC.format( port=port, param_server_id=param_server, name_prefix=name_prefix) config += '---\n' return config def WorkerClusterSpecString(num_workers, num_param_servers, port, name_prefix): """Generates worker cluster spec.""" return ClusterSpecString(num_workers, num_param_servers, port, name_prefix) def ParamServerClusterSpecString(num_workers, num_param_servers, port, name_prefix): """Generates parameter server spec.""" return ClusterSpecString(num_workers, num_param_servers, port, name_prefix) def ClusterSpecString(num_workers, num_param_servers, port, name_prefix): """Generates general cluster spec.""" spec = 'worker|' for worker in range(num_workers): spec += '%s-worker%d:%d' % (name_prefix, worker, port) if worker != num_workers-1: spec += ';' spec += ',ps|' for param_server in range(num_param_servers): spec += '%s-ps%d:%d' % (name_prefix, param_server, port) if param_server != num_param_servers-1: spec += ';' return spec def GetCommonArgs(num_workers, num_param_servers, port, name_prefix, use_cluster_spec): """Get arguments common to both worker and ps jobs. Args: num_workers: number of workers. num_param_servers: number of ps servers. port: worker and ps port number. name_prefix: prefix to prepend to job names. use_cluster_spec: if true, pass --cluster_spec argument. If false, parse --worker_hosts and --ps_hosts arguments. Returns: A dictionary of argument names mapping to argument values. """ common_args = {} if use_cluster_spec: common_args['cluster_spec'] = WorkerClusterSpecString( num_workers, num_param_servers, port, name_prefix) else: common_args['worker_hosts'] = WorkerHosts(num_workers, port, name_prefix) common_args['ps_hosts'] = PsHosts(num_param_servers, port, name_prefix) return common_args def WorkerHosts(num_workers, port, name_prefix): worker_hosts = ['%s-worker%d:%d' % (name_prefix, i, port) for i in range(num_workers)] return ','.join(worker_hosts) def PsHosts(num_ps, port, name_prefix): ps_hosts = ['%s-ps%d:%d' % (name_prefix, i, port) for i in range(num_ps)] return ','.join(ps_hosts)
apache-2.0
[ 3, 1898, 7800, 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, 20551, 18916, 2897, 1584, 367, 1854, 9134, 14123, 14, 199, 199, 1918, 14123, 911, 506, 1255, 315, 282, 28723, 334, 75, 24, 83, 9, 3970, 4350, 14, 199, 624, 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, 3, 3390, 26, 2779, 365, 25343, 279, 626, 781, 886, 440, 492, 3228, 315, 642, 2884, 14, 710, 199, 3, 6844, 626, 10623, 397, 282, 9134, 1022, 24, 83, 4350, 1630, 440, 1172, 370, 1172, 314, 199, 3, 2018, 2559, 402, 9134, 4903, 641, 652, 14, 199, 199, 3, 3254, 8, 696, 374, 304, 24413, 7791, 2073, 4145, 15, 9368, 370, 314, 15329, 83, 14, 199, 199, 3, 23886, 15329, 83, 911, 10760, 1591, 3301, 1182, 5555, 12, 465, 282, 22700, 4340, 370, 1218, 199, 3, 5709, 4887, 16885, 14123, 5309, 2257, 2295, 14, 199, 8406, 540, 63, 8205, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 16000, 1863, 7506, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 6599, 91, 6599, 63, 344, 93, 199, 1650, 26, 523, 22413, 26, 413, 523, 1978, 26, 272, 3341, 26, 489, 3628, 26, 267, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 267, 536, 13, 1861, 26, 5310, 354, 63, 1861, 7063, 267, 3906, 26, 298, 6599, 2, 272, 3158, 26, 489, 15333, 26, 489, 446, 536, 26, 2833, 13, 6599, 91, 6599, 63, 344, 93, 267, 1834, 26, 469, 9991, 63, 1569, 93, 267, 1249, 26, 8910, 589, 11049, 267, 8873, 26, 267, 446, 3970, 4313, 26, 469, 719, 93, 267, 2589, 26, 8910, 1813, 63, 2936, 11049, 267, 3301, 24467, 83, 26, 8910, 2405, 63, 25810, 11049, 489, 12158, 26, 8910, 8838, 11049, 199, 6141, 199, 8406, 540, 63, 17675, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 6599, 91, 6599, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 1650, 26, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 272, 1347, 4313, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 6141, 199, 8406, 540, 63, 11568, 63, 17675, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 6599, 91, 6599, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 1650, 26, 523, 730, 26, 7190, 22249, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 6141, 199, 7258, 63, 6613, 63, 8205, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 16000, 1863, 7506, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 1190, 91, 635, 63, 1000, 63, 344, 93, 199, 1650, 26, 523, 22413, 26, 413, 523, 1978, 26, 272, 3341, 26, 489, 3628, 26, 267, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 267, 536, 13, 1861, 26, 5310, 354, 63, 1861, 7063, 267, 3906, 26, 298, 1190, 2, 272, 3158, 26, 489, 15333, 26, 489, 446, 536, 26, 2833, 13, 1190, 91, 635, 63, 1000, 63, 344, 93, 267, 1834, 26, 469, 9991, 63, 1569, 93, 267, 1249, 26, 8910, 589, 11049, 267, 8873, 26, 267, 446, 3970, 4313, 26, 469, 719, 93, 267, 2589, 26, 8910, 1813, 63, 2936, 11049, 267, 3301, 24467, 83, 26, 8910, 2405, 63, 25810, 11049, 489, 12158, 26, 8910, 8838, 11049, 199, 6141, 199, 7258, 63, 6613, 63, 17675, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 1190, 91, 635, 63, 1000, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 1650, 26, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 6141, 199, 7258, 63, 11568, 63, 17675, 275, 334, 624, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 1190, 91, 635, 63, 1000, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 1650, 26, 523, 730, 26, 7190, 22249, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 6141, 199, 16689, 63, 2679, 1734, 9730, 275, 5041, 354, 26, 5709, 12, 10760, 2042, 26, 1182, 5555, 6834, 199, 12209, 2639, 654, 275, 5041, 354, 26, 5709, 12, 1591, 2042, 26, 469, 515, 26, 1182, 5555, 4863, 7, 199, 63, 9984, 63, 5568, 63, 7433, 275, 5041, 354, 26, 2071, 83, 401, 574, 26, 2071, 83, 3570, 7, 199, 63, 11611, 63, 7433, 275, 5522, 306, 5, 83, 2458, 83, 4507, 421, 199, 318, 7958, 2028, 8, 1507, 63, 11009, 12, 673, 1967, 63, 635, 63, 5871 ]
[ 1898, 7800, 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, 20551, 18916, 2897, 1584, 367, 1854, 9134, 14123, 14, 199, 199, 1918, 14123, 911, 506, 1255, 315, 282, 28723, 334, 75, 24, 83, 9, 3970, 4350, 14, 199, 624, 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, 3, 3390, 26, 2779, 365, 25343, 279, 626, 781, 886, 440, 492, 3228, 315, 642, 2884, 14, 710, 199, 3, 6844, 626, 10623, 397, 282, 9134, 1022, 24, 83, 4350, 1630, 440, 1172, 370, 1172, 314, 199, 3, 2018, 2559, 402, 9134, 4903, 641, 652, 14, 199, 199, 3, 3254, 8, 696, 374, 304, 24413, 7791, 2073, 4145, 15, 9368, 370, 314, 15329, 83, 14, 199, 199, 3, 23886, 15329, 83, 911, 10760, 1591, 3301, 1182, 5555, 12, 465, 282, 22700, 4340, 370, 1218, 199, 3, 5709, 4887, 16885, 14123, 5309, 2257, 2295, 14, 199, 8406, 540, 63, 8205, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 16000, 1863, 7506, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 6599, 91, 6599, 63, 344, 93, 199, 1650, 26, 523, 22413, 26, 413, 523, 1978, 26, 272, 3341, 26, 489, 3628, 26, 267, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 267, 536, 13, 1861, 26, 5310, 354, 63, 1861, 7063, 267, 3906, 26, 298, 6599, 2, 272, 3158, 26, 489, 15333, 26, 489, 446, 536, 26, 2833, 13, 6599, 91, 6599, 63, 344, 93, 267, 1834, 26, 469, 9991, 63, 1569, 93, 267, 1249, 26, 8910, 589, 11049, 267, 8873, 26, 267, 446, 3970, 4313, 26, 469, 719, 93, 267, 2589, 26, 8910, 1813, 63, 2936, 11049, 267, 3301, 24467, 83, 26, 8910, 2405, 63, 25810, 11049, 489, 12158, 26, 8910, 8838, 11049, 199, 6141, 199, 8406, 540, 63, 17675, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 6599, 91, 6599, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 1650, 26, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 272, 1347, 4313, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 6141, 199, 8406, 540, 63, 11568, 63, 17675, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 6599, 91, 6599, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 1650, 26, 523, 730, 26, 7190, 22249, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 6599, 26, 5310, 6599, 63, 344, 7063, 199, 6141, 199, 7258, 63, 6613, 63, 8205, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 16000, 1863, 7506, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 1190, 91, 635, 63, 1000, 63, 344, 93, 199, 1650, 26, 523, 22413, 26, 413, 523, 1978, 26, 272, 3341, 26, 489, 3628, 26, 267, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 267, 536, 13, 1861, 26, 5310, 354, 63, 1861, 7063, 267, 3906, 26, 298, 1190, 2, 272, 3158, 26, 489, 15333, 26, 489, 446, 536, 26, 2833, 13, 1190, 91, 635, 63, 1000, 63, 344, 93, 267, 1834, 26, 469, 9991, 63, 1569, 93, 267, 1249, 26, 8910, 589, 11049, 267, 8873, 26, 267, 446, 3970, 4313, 26, 469, 719, 93, 267, 2589, 26, 8910, 1813, 63, 2936, 11049, 267, 3301, 24467, 83, 26, 8910, 2405, 63, 25810, 11049, 489, 12158, 26, 8910, 8838, 11049, 199, 6141, 199, 7258, 63, 6613, 63, 17675, 275, 334, 272, 408, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 1190, 91, 635, 63, 1000, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 1650, 26, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 6141, 199, 7258, 63, 11568, 63, 17675, 275, 334, 624, 1246, 3353, 26, 373, 17, 199, 5091, 26, 7591, 199, 2343, 26, 523, 536, 26, 469, 354, 63, 1861, 17063, 1190, 91, 635, 63, 1000, 63, 344, 93, 523, 3628, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 1650, 26, 523, 730, 26, 7190, 22249, 523, 8873, 26, 523, 446, 1844, 26, 469, 719, 93, 523, 9759, 26, 272, 2833, 13, 1190, 26, 5310, 635, 63, 1000, 63, 344, 7063, 199, 6141, 199, 16689, 63, 2679, 1734, 9730, 275, 5041, 354, 26, 5709, 12, 10760, 2042, 26, 1182, 5555, 6834, 199, 12209, 2639, 654, 275, 5041, 354, 26, 5709, 12, 1591, 2042, 26, 469, 515, 26, 1182, 5555, 4863, 7, 199, 63, 9984, 63, 5568, 63, 7433, 275, 5041, 354, 26, 2071, 83, 401, 574, 26, 2071, 83, 3570, 7, 199, 63, 11611, 63, 7433, 275, 5522, 306, 5, 83, 2458, 83, 4507, 421, 199, 318, 7958, 2028, 8, 1507, 63, 11009, 12, 673, 1967, 63, 635, 63, 5871, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cristian69/KernotekV3
venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/chardet/cp949prober.py
2801
1782
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .mbcharsetprober import MultiByteCharSetProber from .codingstatemachine import CodingStateMachine from .chardistribution import EUCKRDistributionAnalysis from .mbcssm import CP949SMModel class CP949Prober(MultiByteCharSetProber): def __init__(self): MultiByteCharSetProber.__init__(self) self._mCodingSM = CodingStateMachine(CP949SMModel) # NOTE: CP949 is a superset of EUC-KR, so the distribution should be # not different. self._mDistributionAnalyzer = EUCKRDistributionAnalysis() self.reset() def get_charset_name(self): return "CP949"
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 26007, 27373, 24906, 199, 504, 1275, 887, 3919, 77, 492, 19701, 15674, 25335, 421, 199, 533, 19701, 15674, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 2890, 15674, 25335, 9, 267, 327, 6944, 26, 19701, 15674, 365, 282, 1613, 409, 402, 662, 13371, 13, 23063, 12, 880, 314, 4084, 1077, 506, 267, 327, 755, 440, 3365, 14, 267, 291, 423, 77, 8580, 17606, 275, 26007, 27373, 24906, 342, 267, 291, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 2890, 15674, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 26007, 27373, 24906, 199, 504, 1275, 887, 3919, 77, 492, 19701, 15674, 25335, 421, 199, 533, 19701, 15674, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 2890, 15674, 25335, 9, 267, 327, 6944, 26, 19701, 15674, 365, 282, 1613, 409, 402, 662, 13371, 13, 23063, 12, 880, 314, 4084, 1077, 506, 267, 327, 755, 440, 3365, 14, 267, 291, 423, 77, 8580, 17606, 275, 26007, 27373, 24906, 342, 267, 291, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 2890, 15674, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
berkeley-stat159/project-delta
code/utils/hrf.py
1
1130
""" This script contains the hrf() function, which is a utility for computing values of the hemodynamic response function at given times. This is a necessary tool for predicting BOLD signals. Future Python scripts can take advantage of the hrf() function by including the command sys.path.append("code/utils") from hrf import * """ from __future__ import absolute_import, division, print_function import numpy as np from scipy.stats import gamma def hrf(times): """ Computes values for the canonical hemodynamic response function at the specified times Parameters ---------- times : np.ndarray 1-D array of time points Return: ------ hrf : np.ndarray Array of shape (len(times),) that represents the hemodynamic response function for the specified time points """ # Gamma pdf for the peak peak_values = gamma.pdf(times, 6) # Gamma pdf for the undershoot undershoot_values = gamma.pdf(times, 12) # Combine them values = peak_values - 0.35 * undershoot_values # Scale max to 0.6 return values / np.max(values) * 0.6
bsd-3-clause
[ 624, 199, 2765, 2884, 3509, 314, 394, 3941, 342, 805, 12, 1314, 365, 282, 11420, 367, 17226, 1338, 199, 1618, 314, 946, 1494, 4495, 1177, 805, 737, 1627, 5431, 14, 961, 365, 282, 5784, 4744, 199, 509, 12610, 316, 699, 5104, 10166, 14, 20799, 2018, 10554, 883, 5452, 30268, 402, 314, 199, 72, 3941, 342, 805, 701, 5893, 314, 1414, 272, 984, 14, 515, 14, 740, 480, 600, 15, 1208, 531, 272, 687, 394, 3941, 492, 627, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 3200, 492, 10169, 199, 199, 318, 394, 3941, 8, 4508, 304, 272, 408, 272, 28040, 1338, 367, 314, 11358, 946, 1494, 4495, 1177, 805, 737, 314, 272, 2013, 5431, 221, 2286, 3897, 272, 4143, 272, 5431, 520, 980, 14, 8237, 267, 413, 13, 36, 1625, 402, 900, 4501, 339, 1432, 26, 272, 21397, 272, 394, 3941, 520, 980, 14, 8237, 267, 8725, 402, 2215, 334, 552, 8, 4508, 16945, 626, 8469, 314, 946, 1494, 4495, 1177, 267, 805, 367, 314, 2013, 900, 4501, 272, 408, 272, 327, 598, 4746, 11249, 367, 314, 21441, 272, 21441, 63, 1459, 275, 10169, 14, 5607, 8, 4508, 12, 1227, 9, 272, 327, 598, 4746, 11249, 367, 314, 1334, 13927, 357, 272, 1334, 13927, 357, 63, 1459, 275, 10169, 14, 5607, 8, 4508, 12, 3144, 9, 272, 327, 26353, 3062, 272, 1338, 275, 21441, 63, 1459, 446, 378, 14, 1276, 627, 1334, 13927, 357, 63, 1459, 272, 327, 22869, 1390, 370, 378, 14, 22, 272, 372, 1338, 1182, 980, 14, 988, 8, 1459, 9, 627, 378, 14, 22, 1362, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2765, 2884, 3509, 314, 394, 3941, 342, 805, 12, 1314, 365, 282, 11420, 367, 17226, 1338, 199, 1618, 314, 946, 1494, 4495, 1177, 805, 737, 1627, 5431, 14, 961, 365, 282, 5784, 4744, 199, 509, 12610, 316, 699, 5104, 10166, 14, 20799, 2018, 10554, 883, 5452, 30268, 402, 314, 199, 72, 3941, 342, 805, 701, 5893, 314, 1414, 272, 984, 14, 515, 14, 740, 480, 600, 15, 1208, 531, 272, 687, 394, 3941, 492, 627, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 504, 7026, 14, 3200, 492, 10169, 199, 199, 318, 394, 3941, 8, 4508, 304, 272, 408, 272, 28040, 1338, 367, 314, 11358, 946, 1494, 4495, 1177, 805, 737, 314, 272, 2013, 5431, 221, 2286, 3897, 272, 4143, 272, 5431, 520, 980, 14, 8237, 267, 413, 13, 36, 1625, 402, 900, 4501, 339, 1432, 26, 272, 21397, 272, 394, 3941, 520, 980, 14, 8237, 267, 8725, 402, 2215, 334, 552, 8, 4508, 16945, 626, 8469, 314, 946, 1494, 4495, 1177, 267, 805, 367, 314, 2013, 900, 4501, 272, 408, 272, 327, 598, 4746, 11249, 367, 314, 21441, 272, 21441, 63, 1459, 275, 10169, 14, 5607, 8, 4508, 12, 1227, 9, 272, 327, 598, 4746, 11249, 367, 314, 1334, 13927, 357, 272, 1334, 13927, 357, 63, 1459, 275, 10169, 14, 5607, 8, 4508, 12, 3144, 9, 272, 327, 26353, 3062, 272, 1338, 275, 21441, 63, 1459, 446, 378, 14, 1276, 627, 1334, 13927, 357, 63, 1459, 272, 327, 22869, 1390, 370, 378, 14, 22, 272, 372, 1338, 1182, 980, 14, 988, 8, 1459, 9, 627, 378, 14, 22, 1362, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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y as np import tempfile import subprocess from .sfminittypes import EG, write_EGs_file, read_rot_file def solve_global_rotations(indices, pairwise_rotations, cc=None): """ Solve the multiple rotations averaging problem using Chatterjee and Govindu's L1_IRLS method. The implementation is in Matlab, so this is a wrapper that writes the problem to temporary text files and calls Matlab through the command line. Input: indices: a list of pairs (i,j) pairwise_rotations: a list of rotation matrices Rij cc: a list of integers {i}. Only compute global rotations on indices in cc Returns: ind: a list of indices (vertex numbers) R: rotation matrices corresponding to ind, which are approximately consistent with the pairwise rotations, ie Rij ~ Ri * Rj' """ ############ # Path to rot solver Matlab source dir ROT_SOLVER_DIR = os.path.abspath(os.path.join( os.path.dirname(__file__),'..','rotsolver')) ############ # get a working temp directory tmpdir = tempfile.mkdtemp() # write the input files ccfile = os.path.join(tmpdir, 'cc.txt') np.savetxt(ccfile, cc, fmt='%d') egfile = os.path.join(tmpdir, 'eg.txt') EGs = [] for (i,j), Rij in zip(indices, pairwise_rotations): # tij isn't used, so just spoof it to 0's EGs.append(EG(i, j, Rij, np.zeros((3,1)))) write_EGs_file(egfile, EGs) # call the rot solver log = os.path.join(tmpdir, 'log.txt') rotfile = os.path.join(tmpdir, 'rots.txt') with open(os.devnull, 'wb') as devnul: subprocess.call(['matlab', '-nodisplay', '-nojvm', '-logfile', log, '-r', "try; " + "rot_driver('{}', '{}', '{}');".format(egfile, rotfile, ccfile) + "catch err; " + "disp(getReport(err)); " + "end; " + "exit;" ], cwd=ROT_SOLVER_DIR, stdout=devnul, stderr=devnul) # if the rot solver wasn't successful (ie, a bug), give a message and an error if not os.path.exists(rotfile): print '[rotsolver:solve_global_rotations] Error! The Matlab rotsolver did not complete.' print 'LOG:' with open(log, 'r') as fin: print fin.read() shutil.rmtree(tmpdir) raise Exception("Global Rotations solver was not successful!") # read the result and clean up ind, R = read_rot_file(rotfile) shutil.rmtree(tmpdir) return ind, R
bsd-2-clause
[ 646, 747, 199, 646, 5145, 199, 646, 2680, 465, 980, 199, 646, 5549, 199, 646, 3873, 199, 504, 1275, 7646, 77, 826, 1313, 492, 662, 39, 12, 2218, 63, 4680, 83, 63, 493, 12, 1586, 63, 4571, 63, 493, 199, 199, 318, 14241, 63, 2966, 63, 4571, 1298, 8, 4108, 12, 24859, 63, 4571, 1298, 12, 7429, 29, 403, 304, 272, 408, 272, 428, 3344, 314, 3663, 7513, 1298, 282, 422, 7407, 5160, 1808, 2799, 3760, 74, 1024, 436, 3971, 86, 688, 85, 1159, 5591, 491, 17, 63, 41, 2431, 51, 1083, 14, 710, 4514, 365, 315, 18619, 5561, 12, 880, 642, 365, 282, 4975, 626, 14511, 272, 314, 5160, 370, 7937, 1318, 1584, 436, 4882, 18619, 5561, 4012, 314, 1414, 1004, 14, 339, 6924, 26, 267, 4918, 26, 259, 282, 769, 402, 6342, 334, 73, 12, 74, 9, 267, 24859, 63, 4571, 1298, 26, 282, 769, 402, 13038, 12627, 820, 7879, 267, 7429, 26, 282, 769, 402, 9446, 469, 73, 5565, 5972, 4526, 2288, 7513, 1298, 641, 4918, 315, 7429, 339, 1803, 26, 267, 7654, 26, 282, 769, 402, 4918, 334, 11417, 5579, 9, 267, 820, 26, 13038, 12627, 5226, 370, 7654, 12, 1314, 787, 19917, 590, 7205, 12137, 543, 314, 24859, 7513, 1298, 12, 13446, 820, 7879, 6146, 820, 73, 627, 820, 74, 7, 272, 408, 272, 21937, 381, 272, 327, 6912, 370, 7513, 10196, 18619, 5561, 1350, 2935, 272, 820, 1387, 63, 15096, 2111, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 7, 703, 1673, 293, 1086, 3725, 1333, 272, 21937, 381, 339, 327, 664, 282, 6449, 2388, 2082, 272, 12885, 275, 5549, 14, 11983, 342, 339, 327, 2218, 314, 1324, 1584, 272, 7429, 493, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 2055, 14, 2424, 358, 272, 980, 14, 23374, 386, 400, 8, 2055, 493, 12, 7429, 12, 7104, 9569, 68, 358, 272, 11837, 493, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 5902, 14, 2424, 358, 272, 662, 32394, 275, 942, 272, 367, 334, 73, 12, 74, 395, 820, 7879, 315, 3482, 8, 4108, 12, 24859, 63, 4571, 1298, 304, 267, 327, 3367, 74, 5712, 1133, 1202, 12, 880, 2951, 25664, 1618, 652, 370, 378, 1159, 267, 662, 32394, 14, 740, 8, 4680, 8, 73, 12, 1335, 12, 820, 7879, 12, 980, 14, 4250, 1332, 19, 12, 17, 7845, 272, 2218, 63, 4680, 83, 63, 493, 8, 5902, 493, 12, 662, 32394, 9, 339, 327, 1240, 314, 7513, 10196, 272, 943, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 793, 14, 2424, 358, 272, 7513, 493, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 293, 1086, 14, 2424, 358, 339, 543, 1551, 8, 736, 14, 19778, 12, 283, 6603, 358, 465, 4866, 78, 348, 26, 267, 3873, 14, 1250, 2941, 569, 5561, 297, 2475, 889, 2918, 297, 2475, 889, 15813, 297, 2475, 12804, 297, 943, 12, 2475, 82, 297, 7205, 298, 893, 27, 298, 435, 355, 298, 4571, 63, 3090, 17519, 297, 9005, 297, 9005, 11339, 1674, 908, 8, 5902, 493, 12, 7513, 493, 12, 7429, 493, 9, 435, 288, 298, 9341, 2329, 27, 298, 435, 355, 298, 13654, 8, 362, 7457, 8, 1508, 16674, 298, 435, 288, 298, 500, 27, 298, 435, 288, 298, 2224, 9426, 2156, 288, 8288, 29, 31075, 63, 15096, 2111, 63, 3022, 12, 3839, 29, 2374, 78, 348, 12, 4635, 29, 2374, 78, 348, 9, 339, 327, 340, 314, 7513, 10196, 17373, 1133, 9512, 334, 1873, 12, 282, 6519, 395, 8120, 282, 1245, 436, 376, 1125, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 4571, 493, 304, 267, 870, 6730, 293, 1086, 3725, 26, 11356, 63, 2966, 63, 4571, 1298, 61, 4520, 1, 710, 18619, 5561, 882, 1086, 3725, 8103, 440, 4890, 3530, 267, 870, 283, 4947, 4881, 267, 543, 1551, 8, 793, 12, 283, 82, 358, 465, 2583, 26, 288, 870, 2583, 14, 739, 342, 267, 5145, 14, 9242, 8, 8616, 9, 267, 746, 2186, 480, 7025, 20423, 1298, 10196, 1990, 440, 9512, 9124, 339, 327, 1586, 314, 754, 436, 3633, 1536, 272, 7654, 12, 820, 275, 1586, 63, 4571, 63, 493, 8, 4571, 493, 9, 272, 5145, 14, 9242, 8, 8616, 9, 272, 372, 7654, 12, 820, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 5145, 199, 646, 2680, 465, 980, 199, 646, 5549, 199, 646, 3873, 199, 504, 1275, 7646, 77, 826, 1313, 492, 662, 39, 12, 2218, 63, 4680, 83, 63, 493, 12, 1586, 63, 4571, 63, 493, 199, 199, 318, 14241, 63, 2966, 63, 4571, 1298, 8, 4108, 12, 24859, 63, 4571, 1298, 12, 7429, 29, 403, 304, 272, 408, 272, 428, 3344, 314, 3663, 7513, 1298, 282, 422, 7407, 5160, 1808, 2799, 3760, 74, 1024, 436, 3971, 86, 688, 85, 1159, 5591, 491, 17, 63, 41, 2431, 51, 1083, 14, 710, 4514, 365, 315, 18619, 5561, 12, 880, 642, 365, 282, 4975, 626, 14511, 272, 314, 5160, 370, 7937, 1318, 1584, 436, 4882, 18619, 5561, 4012, 314, 1414, 1004, 14, 339, 6924, 26, 267, 4918, 26, 259, 282, 769, 402, 6342, 334, 73, 12, 74, 9, 267, 24859, 63, 4571, 1298, 26, 282, 769, 402, 13038, 12627, 820, 7879, 267, 7429, 26, 282, 769, 402, 9446, 469, 73, 5565, 5972, 4526, 2288, 7513, 1298, 641, 4918, 315, 7429, 339, 1803, 26, 267, 7654, 26, 282, 769, 402, 4918, 334, 11417, 5579, 9, 267, 820, 26, 13038, 12627, 5226, 370, 7654, 12, 1314, 787, 19917, 590, 7205, 12137, 543, 314, 24859, 7513, 1298, 12, 13446, 820, 7879, 6146, 820, 73, 627, 820, 74, 7, 272, 408, 272, 21937, 381, 272, 327, 6912, 370, 7513, 10196, 18619, 5561, 1350, 2935, 272, 820, 1387, 63, 15096, 2111, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 7, 703, 1673, 293, 1086, 3725, 1333, 272, 21937, 381, 339, 327, 664, 282, 6449, 2388, 2082, 272, 12885, 275, 5549, 14, 11983, 342, 339, 327, 2218, 314, 1324, 1584, 272, 7429, 493, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 2055, 14, 2424, 358, 272, 980, 14, 23374, 386, 400, 8, 2055, 493, 12, 7429, 12, 7104, 9569, 68, 358, 272, 11837, 493, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 5902, 14, 2424, 358, 272, 662, 32394, 275, 942, 272, 367, 334, 73, 12, 74, 395, 820, 7879, 315, 3482, 8, 4108, 12, 24859, 63, 4571, 1298, 304, 267, 327, 3367, 74, 5712, 1133, 1202, 12, 880, 2951, 25664, 1618, 652, 370, 378, 1159, 267, 662, 32394, 14, 740, 8, 4680, 8, 73, 12, 1335, 12, 820, 7879, 12, 980, 14, 4250, 1332, 19, 12, 17, 7845, 272, 2218, 63, 4680, 83, 63, 493, 8, 5902, 493, 12, 662, 32394, 9, 339, 327, 1240, 314, 7513, 10196, 272, 943, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 793, 14, 2424, 358, 272, 7513, 493, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 293, 1086, 14, 2424, 358, 339, 543, 1551, 8, 736, 14, 19778, 12, 283, 6603, 358, 465, 4866, 78, 348, 26, 267, 3873, 14, 1250, 2941, 569, 5561, 297, 2475, 889, 2918, 297, 2475, 889, 15813, 297, 2475, 12804, 297, 943, 12, 2475, 82, 297, 7205, 298, 893, 27, 298, 435, 355, 298, 4571, 63, 3090, 17519, 297, 9005, 297, 9005, 11339, 1674, 908, 8, 5902, 493, 12, 7513, 493, 12, 7429, 493, 9, 435, 288, 298, 9341, 2329, 27, 298, 435, 355, 298, 13654, 8, 362, 7457, 8, 1508, 16674, 298, 435, 288, 298, 500, 27, 298, 435, 288, 298, 2224, 9426, 2156, 288, 8288, 29, 31075, 63, 15096, 2111, 63, 3022, 12, 3839, 29, 2374, 78, 348, 12, 4635, 29, 2374, 78, 348, 9, 339, 327, 340, 314, 7513, 10196, 17373, 1133, 9512, 334, 1873, 12, 282, 6519, 395, 8120, 282, 1245, 436, 376, 1125, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 4571, 493, 304, 267, 870, 6730, 293, 1086, 3725, 26, 11356, 63, 2966, 63, 4571, 1298, 61, 4520, 1, 710, 18619, 5561, 882, 1086, 3725, 8103, 440, 4890, 3530, 267, 870, 283, 4947, 4881, 267, 543, 1551, 8, 793, 12, 283, 82, 358, 465, 2583, 26, 288, 870, 2583, 14, 739, 342, 267, 5145, 14, 9242, 8, 8616, 9, 267, 746, 2186, 480, 7025, 20423, 1298, 10196, 1990, 440, 9512, 9124, 339, 327, 1586, 314, 754, 436, 3633, 1536, 272, 7654, 12, 820, 275, 1586, 63, 4571, 63, 493, 8, 4571, 493, 9, 272, 5145, 14, 9242, 8, 8616, 9, 272, 372, 7654, 12, 820, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
somcom3x/android_kernel_motorola_msm8992
Documentation/target/tcm_mod_builder.py
2358
40707
#!/usr/bin/python # The TCM v4 multi-protocol fabric module generation script for drivers/target/$NEW_MOD # # Copyright (c) 2010 Rising Tide Systems # Copyright (c) 2010 Linux-iSCSI.org # # Author: nab@kernel.org # import os, sys import subprocess as sub import string import re import optparse tcm_dir = "" fabric_ops = [] fabric_mod_dir = "" fabric_mod_port = "" fabric_mod_init_port = "" def tcm_mod_err(msg): print msg sys.exit(1) def tcm_mod_create_module_subdir(fabric_mod_dir_var): if os.path.isdir(fabric_mod_dir_var) == True: return 1 print "Creating fabric_mod_dir: " + fabric_mod_dir_var ret = os.mkdir(fabric_mod_dir_var) if ret: tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var) return def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for FC Initiator Nport */\n" buf += " u64 nport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Initiator Nport */\n" buf += " char nport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* FC lport target portal group tag for TCM */\n" buf += " u16 lport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n" buf += " struct " + fabric_mod_name + "_lport *lport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_lport {\n" buf += " /* SCSI protocol the lport is providing */\n" buf += " u8 lport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n" buf += " u64 lport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Target Lport */\n" buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n" buf += " struct se_wwn lport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "lport" fabric_mod_init_port = "nport" return def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for SAS Initiator port */\n" buf += " u64 iport_wwpn;\n" buf += " /* ASCII formatted WWPN for Sas Initiator port */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* SAS port target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for SAS Target port */\n" buf += " u64 tport_wwpn;\n" buf += " /* ASCII formatted WWPN for SAS Target port */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* ASCII formatted InitiatorName */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* iSCSI target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* ASCII formatted TargetName for IQN */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_base_includes(proto_ident, fabric_mod_dir_val, fabric_mod_name): if proto_ident == "FC": tcm_mod_build_FC_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "SAS": tcm_mod_build_SAS_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "iSCSI": tcm_mod_build_iSCSI_include(fabric_mod_dir_val, fabric_mod_name) else: print "Unsupported proto_ident: " + proto_ident sys.exit(1) return def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_configfs.c" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#include <linux/module.h>\n" buf += "#include <linux/moduleparam.h>\n" buf += "#include <linux/version.h>\n" buf += "#include <generated/utsrelease.h>\n" buf += "#include <linux/utsname.h>\n" buf += "#include <linux/init.h>\n" buf += "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/configfs.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_fabric.h>\n" buf += "#include <target/target_core_fabric_configfs.h>\n" buf += "#include <target/target_core_configfs.h>\n" buf += "#include <target/configfs_macros.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "/* Local pointer to allocated TCM configfs fabric module */\n" buf += "struct target_fabric_configfs *" + fabric_mod_name + "_fabric_configfs;\n\n" buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct se_node_acl *se_nacl, *se_nacl_new;\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n" buf += " u32 nexus_depth;\n\n" buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n" buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n" buf += " if (!se_nacl_new)\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n" buf += " nexus_depth = 1;\n" buf += " /*\n" buf += " * se_nacl_new may be released by core_tpg_add_initiator_node_acl()\n" buf += " * when converting a NodeACL from demo mode -> explict\n" buf += " */\n" buf += " se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,\n" buf += " name, nexus_depth);\n" buf += " if (IS_ERR(se_nacl)) {\n" buf += " " + fabric_mod_name + "_release_fabric_acl(se_tpg, se_nacl_new);\n" buf += " return se_nacl;\n" buf += " }\n" buf += " /*\n" buf += " * Locate our struct " + fabric_mod_name + "_nacl and set the FC Nport WWPN\n" buf += " */\n" buf += " nacl = container_of(se_nacl, struct " + fabric_mod_name + "_nacl, se_node_acl);\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " nacl->" + fabric_mod_init_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&nacl->" + fabric_mod_init_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n" buf += " return se_nacl;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_nodeacl(struct se_node_acl *se_acl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_acl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);\n" buf += " kfree(nacl);\n" buf += "}\n\n" buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n" buf += " struct se_wwn *wwn,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + "*" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n\n" buf += " struct " + fabric_mod_name + "_tpg *tpg;\n" buf += " unsigned long tpgt;\n" buf += " int ret;\n\n" buf += " if (strstr(name, \"tpgt_\") != name)\n" buf += " return ERR_PTR(-EINVAL);\n" buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n" buf += " return ERR_PTR(-EINVAL);\n\n" buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n" buf += " if (!tpg) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n" buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n" buf += " ret = core_tpg_register(&" + fabric_mod_name + "_fabric_configfs->tf_ops, wwn,\n" buf += " &tpg->se_tpg, (void *)tpg,\n" buf += " TRANSPORT_TPG_TYPE_NORMAL);\n" buf += " if (ret < 0) {\n" buf += " kfree(tpg);\n" buf += " return NULL;\n" buf += " }\n" buf += " return &tpg->se_tpg;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_tpg(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n\n" buf += " core_tpg_deregister(se_tpg);\n" buf += " kfree(tpg);\n" buf += "}\n\n" buf += "static struct se_wwn *" + fabric_mod_name + "_make_" + fabric_mod_port + "(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + ";\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n\n" buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n\n" buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n" buf += " if (!" + fabric_mod_port + ") {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n" buf += " kfree(" + fabric_mod_port + ");\n" buf += "}\n\n" buf += "static ssize_t " + fabric_mod_name + "_wwn_show_attr_version(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " char *page)\n" buf += "{\n" buf += " return sprintf(page, \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \"on \"UTS_RELEASE\"\\n\", " + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += "}\n\n" buf += "TF_WWN_ATTR_RO(" + fabric_mod_name + ", version);\n\n" buf += "static struct configfs_attribute *" + fabric_mod_name + "_wwn_attrs[] = {\n" buf += " &" + fabric_mod_name + "_wwn_version.attr,\n" buf += " NULL,\n" buf += "};\n\n" buf += "static struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n" buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n" buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n" buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n" buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n" buf += " .tpg_get_default_depth = " + fabric_mod_name + "_get_default_depth,\n" buf += " .tpg_get_pr_transport_id = " + fabric_mod_name + "_get_pr_transport_id,\n" buf += " .tpg_get_pr_transport_id_len = " + fabric_mod_name + "_get_pr_transport_id_len,\n" buf += " .tpg_parse_pr_out_transport_id = " + fabric_mod_name + "_parse_pr_out_transport_id,\n" buf += " .tpg_check_demo_mode = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n" buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n" buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n" buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" buf += " .close_session = " + fabric_mod_name + "_close_session,\n" buf += " .stop_session = " + fabric_mod_name + "_stop_session,\n" buf += " .fall_back_to_erl0 = " + fabric_mod_name + "_reset_nexus,\n" buf += " .sess_logged_in = " + fabric_mod_name + "_sess_logged_in,\n" buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n" buf += " .sess_get_initiator_sid = NULL,\n" buf += " .write_pending = " + fabric_mod_name + "_write_pending,\n" buf += " .write_pending_status = " + fabric_mod_name + "_write_pending_status,\n" buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n" buf += " .get_task_tag = " + fabric_mod_name + "_get_task_tag,\n" buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n" buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n" buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n" buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n" buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n" buf += " /*\n" buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n" buf += " */\n" buf += " .fabric_make_wwn = " + fabric_mod_name + "_make_" + fabric_mod_port + ",\n" buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n" buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n" buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n" buf += " .fabric_post_link = NULL,\n" buf += " .fabric_pre_unlink = NULL,\n" buf += " .fabric_make_np = NULL,\n" buf += " .fabric_drop_np = NULL,\n" buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n" buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n" buf += "};\n\n" buf += "static int " + fabric_mod_name + "_register_configfs(void)\n" buf += "{\n" buf += " struct target_fabric_configfs *fabric;\n" buf += " int ret;\n\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \" on \"UTS_RELEASE\"\\n\"," + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += " /*\n" buf += " * Register the top level struct config_item_type with TCM core\n" buf += " */\n" buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n" buf += " if (IS_ERR(fabric)) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n" buf += " return PTR_ERR(fabric);\n" buf += " }\n" buf += " /*\n" buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n" buf += " */\n" buf += " fabric->tf_ops = " + fabric_mod_name + "_ops;\n" buf += " /*\n" buf += " * Setup default attribute lists for various fabric->tf_cit_tmpl\n" buf += " */\n" buf += " TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n" buf += " /*\n" buf += " * Register the fabric for use within TCM\n" buf += " */\n" buf += " ret = target_fabric_configfs_register(fabric);\n" buf += " if (ret < 0) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_register() failed\"\n" buf += " \" for " + fabric_mod_name.upper() + "\\n\");\n" buf += " return ret;\n" buf += " }\n" buf += " /*\n" buf += " * Setup our local pointer to *fabric\n" buf += " */\n" buf += " " + fabric_mod_name + "_fabric_configfs = fabric;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void __exit " + fabric_mod_name + "_deregister_configfs(void)\n" buf += "{\n" buf += " if (!" + fabric_mod_name + "_fabric_configfs)\n" buf += " return;\n\n" buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n" buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Cleared " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += "};\n\n" buf += "static int __init " + fabric_mod_name + "_init(void)\n" buf += "{\n" buf += " int ret;\n\n" buf += " ret = " + fabric_mod_name + "_register_configfs();\n" buf += " if (ret < 0)\n" buf += " return ret;\n\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void __exit " + fabric_mod_name + "_exit(void)\n" buf += "{\n" buf += " " + fabric_mod_name + "_deregister_configfs();\n" buf += "};\n\n" buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" buf += "MODULE_LICENSE(\"GPL\");\n" buf += "module_init(" + fabric_mod_name + "_init);\n" buf += "module_exit(" + fabric_mod_name + "_exit);\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_scan_fabric_ops(tcm_dir): fabric_ops_api = tcm_dir + "include/target/target_core_fabric.h" print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api process_fo = 0; p = open(fabric_ops_api, 'r') line = p.readline() while line: if process_fo == 0 and re.search('struct target_core_fabric_ops {', line): line = p.readline() continue if process_fo == 0: process_fo = 1; line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) continue line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) p.close() return def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" bufi = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.c" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) fi = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.h" print "Writing file: " + fi pi = open(fi, 'w') if not pi: tcm_mod_err("Unable to open file: " + fi) buf = "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/list.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n" buf += "#include <scsi/scsi.h>\n" buf += "#include <scsi/scsi_host.h>\n" buf += "#include <scsi/scsi_device.h>\n" buf += "#include <scsi/scsi_cmnd.h>\n" buf += "#include <scsi/libfc.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_fabric.h>\n" buf += "#include <target/target_core_configfs.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "int " + fabric_mod_name + "_check_true(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_true(struct se_portal_group *);\n" buf += "int " + fabric_mod_name + "_check_false(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_false(struct se_portal_group *);\n" total_fabric_ops = len(fabric_ops) i = 0 while i < total_fabric_ops: fo = fabric_ops[i] i += 1 # print "fabric_ops: " + fo if re.search('get_fabric_name', fo): buf += "char *" + fabric_mod_name + "_get_fabric_name(void)\n" buf += "{\n" buf += " return \"" + fabric_mod_name[4:] + "\";\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_name(void);\n" continue if re.search('get_fabric_proto_ident', fo): buf += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " u8 proto_id;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " proto_id = fc_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " proto_id = sas_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " proto_id = iscsi_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" buf += " }\n\n" buf += " return proto_id;\n" buf += "}\n\n" bufi += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *);\n" if re.search('get_wwn', fo): buf += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_name[0];\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *);\n" if re.search('get_tag', fo): buf += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " return tpg->" + fabric_mod_port + "_tpgt;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *);\n" if re.search('get_default_depth', fo): buf += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *);\n" if re.search('get_pr_transport_id\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code,\n" buf += " unsigned char *buf)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *, unsigned char *);\n" if re.search('get_pr_transport_id_len\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *);\n" if re.search('parse_pr_out_transport_id\)\(', fo): buf += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " const char *buf,\n" buf += " u32 *out_tid_len,\n" buf += " char **port_nexus_ptr)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " char *tid = NULL;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " tid = fc_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " tid = sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " tid = iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" buf += " }\n\n" buf += " return tid;\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n" bufi += " const char *, u32 *, char **);\n" if re.search('alloc_fabric_acl\)\(', fo): buf += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n" buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n" buf += " if (!nacl) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_nacl\\n\");\n" buf += " return NULL;\n" buf += " }\n\n" buf += " return &nacl->se_node_acl;\n" buf += "}\n\n" bufi += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *);\n" if re.search('release_fabric_acl\)\(', fo): buf += "void " + fabric_mod_name + "_release_fabric_acl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_nacl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " kfree(nacl);\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_fabric_acl(struct se_portal_group *,\n" bufi += " struct se_node_acl *);\n" if re.search('tpg_get_inst_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *);\n" if re.search('\*release_cmd\)\(', fo): buf += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n" if re.search('shutdown_session\)\(', fo): buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n" if re.search('close_session\)\(', fo): buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_close_session(struct se_session *);\n" if re.search('stop_session\)\(', fo): buf += "void " + fabric_mod_name + "_stop_session(struct se_session *se_sess, int sess_sleep , int conn_sleep)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_stop_session(struct se_session *, int, int);\n" if re.search('fall_back_to_erl0\)\(', fo): buf += "void " + fabric_mod_name + "_reset_nexus(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_reset_nexus(struct se_session *);\n" if re.search('sess_logged_in\)\(', fo): buf += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *);\n" if re.search('sess_get_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *);\n" if re.search('write_pending\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending(struct se_cmd *);\n" if re.search('write_pending_status\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *);\n" if re.search('set_default_node_attributes\)\(', fo): buf += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *nacl)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *);\n" if re.search('get_task_tag\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *);\n" if re.search('get_cmd_state\)\(', fo): buf += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *);\n" if re.search('queue_data_in\)\(', fo): buf += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *);\n" if re.search('queue_status\)\(', fo): buf += "int " + fabric_mod_name + "_queue_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_status(struct se_cmd *);\n" if re.search('queue_tm_rsp\)\(', fo): buf += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *);\n" if re.search('is_state_remove\)\(', fo): buf += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *);\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() ret = pi.write(bufi) if ret: tcm_mod_err("Unable to write fi: " + fi) pi.close() return def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Makefile" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf += fabric_mod_name + "-objs := " + fabric_mod_name + "_fabric.o \\\n" buf += " " + fabric_mod_name + "_configfs.o\n" buf += "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name + ".o\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_build_kconfig(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Kconfig" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf = "config " + fabric_mod_name.upper() + "\n" buf += " tristate \"" + fabric_mod_name.upper() + " fabric module\"\n" buf += " depends on TARGET_CORE && CONFIGFS_FS\n" buf += " default n\n" buf += " ---help---\n" buf += " Say Y here to enable the " + fabric_mod_name.upper() + " fabric module\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_add_kbuild(tcm_dir, fabric_mod_name): buf = "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name.lower() + "/\n" kbuild = tcm_dir + "/drivers/target/Makefile" f = open(kbuild, 'a') f.write(buf) f.close() return def tcm_mod_add_kconfig(tcm_dir, fabric_mod_name): buf = "source \"drivers/target/" + fabric_mod_name.lower() + "/Kconfig\"\n" kconfig = tcm_dir + "/drivers/target/Kconfig" f = open(kconfig, 'a') f.write(buf) f.close() return def main(modname, proto_ident): # proto_ident = "FC" # proto_ident = "SAS" # proto_ident = "iSCSI" tcm_dir = os.getcwd(); tcm_dir += "/../../" print "tcm_dir: " + tcm_dir fabric_mod_name = modname fabric_mod_dir = tcm_dir + "drivers/target/" + fabric_mod_name print "Set fabric_mod_name: " + fabric_mod_name print "Set fabric_mod_dir: " + fabric_mod_dir print "Using proto_ident: " + proto_ident if proto_ident != "FC" and proto_ident != "SAS" and proto_ident != "iSCSI": print "Unsupported proto_ident: " + proto_ident sys.exit(1) ret = tcm_mod_create_module_subdir(fabric_mod_dir) if ret: print "tcm_mod_create_module_subdir() failed because module already exists!" sys.exit(1) tcm_mod_build_base_includes(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_scan_fabric_ops(tcm_dir) tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_configfs(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_kbuild(fabric_mod_dir, fabric_mod_name) tcm_mod_build_kconfig(fabric_mod_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Makefile..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kbuild(tcm_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Kconfig..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kconfig(tcm_dir, fabric_mod_name) return parser = optparse.OptionParser() parser.add_option('-m', '--modulename', help='Module name', dest='modname', action='store', nargs=1, type='string') parser.add_option('-p', '--protoident', help='Protocol Ident', dest='protoident', action='store', nargs=1, type='string') (opts, args) = parser.parse_args() mandatories = ['modname', 'protoident'] for m in mandatories: if not opts.__dict__[m]: print "mandatory option is missing\n" parser.print_help() exit(-1) if __name__ == "__main__": main(str(opts.modname), opts.protoident)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
idrogeno/IdroMips
lib/python/Plugins/Extensions/CutListEditor/plugin.py
4
13188
from Plugins.Plugin import PluginDescriptor from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ServicePosition import ServicePositionGauge from Components.ActionMap import HelpableActionMap from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase from Components.VideoWindow import VideoWindow from Components.Label import Label from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport from enigma import getDesktop, iPlayableService from Screens.FixedMenu import FixedMenu from Screens.HelpMenu import HelpableScreen from Components.Sources.List import List import bisect def CutListEntry(where, what): w = where / 90 ms = w % 1000 s = (w / 1000) % 60 m = (w / 60000) % 60 h = w / 3600000 if what == 0: type = "IN" type_col = 0x004000 elif what == 1: type = "OUT" type_col = 0x400000 elif what == 2: type = "MARK" type_col = 0x000040 elif what == 3: type = "LAST" type_col = 0x000000 return ((where, what), "%dh:%02dm:%02ds:%03d" % (h, m, s, ms), type, type_col) class CutListContextMenu(FixedMenu): RET_STARTCUT = 0 RET_ENDCUT = 1 RET_DELETECUT = 2 RET_MARK = 3 RET_DELETEMARK = 4 RET_REMOVEBEFORE = 5 RET_REMOVEAFTER = 6 RET_GRABFRAME = 7 SHOW_STARTCUT = 0 SHOW_ENDCUT = 1 SHOW_DELETECUT = 2 def __init__(self, session, state, nearmark): menu = [(_("back"), self.close)] #, (None, )] if state == self.SHOW_STARTCUT: menu.append((_("start cut here"), self.startCut)) else: menu.append((_("start cut here"), )) if state == self.SHOW_ENDCUT: menu.append((_("end cut here"), self.endCut)) else: menu.append((_("end cut here"), )) if state == self.SHOW_DELETECUT: menu.append((_("delete cut"), self.deleteCut)) else: menu.append((_("delete cut"), )) menu.append((_("remove before this position"), self.removeBefore)) menu.append((_("remove after this position"), self.removeAfter)) # menu.append((None, )) if not nearmark: menu.append((_("insert mark here"), self.insertMark)) else: menu.append((_("remove this mark"), self.removeMark)) menu.append((_("grab this frame as bitmap"), self.grabFrame)) FixedMenu.__init__(self, session, _("Cut"), menu) self.skinName = ["CutListContextMenu", "Menu" ] def startCut(self): self.close(self.RET_STARTCUT) def endCut(self): self.close(self.RET_ENDCUT) def deleteCut(self): self.close(self.RET_DELETECUT) def insertMark(self): self.close(self.RET_MARK) def removeMark(self): self.close(self.RET_DELETEMARK) def removeBefore(self): self.close(self.RET_REMOVEBEFORE) def removeAfter(self): self.close(self.RET_REMOVEAFTER) def grabFrame(self): self.close(self.RET_GRABFRAME) class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, HelpableScreen): skin = """ <screen position="0,0" size="720,576" title="Cutlist editor" flags="wfNoBorder"> <eLabel text="Cutlist editor" position="65,60" size="300,25" font="Regular;20" /> <widget source="global.CurrentTime" render="Label" position="268,60" size="394,20" font="Regular;20" halign="right"> <convert type="ClockToText">Format:%A %B %d, %H:%M</convert> </widget> <eLabel position="268,98" size="394,304" backgroundColor="#505555" /> <widget name="Video" position="270,100" zPosition="1" size="390,300" backgroundColor="transparent" /> <widget source="session.CurrentService" render="Label" position="135,405" size="450,50" font="Regular;22" halign="center" valign="center"> <convert type="ServiceName">Name</convert> </widget> <widget source="session.CurrentService" render="Label" position="320,450" zPosition="1" size="420,25" font="Regular;20" halign="left" valign="center"> <convert type="ServicePosition">Position,Detailed</convert> </widget> <widget name="SeekState" position="210,450" zPosition="1" size="100,25" halign="right" font="Regular;20" valign="center" /> <eLabel position="48,98" size="204,274" backgroundColor="#505555" /> <eLabel position="50,100" size="200,270" backgroundColor="#000000" /> <widget source="cutlist" position="50,100" zPosition="1" size="200,270" scrollbarMode="showOnDemand" transparent="1" render="Listbox" > <convert type="TemplatedMultiContent"> {"template": [ MultiContentEntryText(size=(125, 20), text = 1, backcolor = MultiContentTemplateColor(3)), MultiContentEntryText(pos=(125,0), size=(50, 20), text = 2, flags = RT_HALIGN_RIGHT, backcolor = MultiContentTemplateColor(3)) ], "fonts": [gFont("Regular", 18)], "itemHeight": 20 } </convert> </widget> <widget name="Timeline" position="50,485" size="615,20" backgroundColor="#505555" pointer="skin_default/position_arrow.png:3,5" foregroundColor="black" /> <ePixmap pixmap="skin_default/icons/mp_buttons.png" position="305,515" size="109,13" alphatest="on" /> </screen>""" def __init__(self, session, service): self.skin = CutListEditor.skin Screen.__init__(self, session) InfoBarSeek.__init__(self, actionmap = "CutlistSeekActions") InfoBarCueSheetSupport.__init__(self) InfoBarBase.__init__(self, steal_current_service = True) HelpableScreen.__init__(self) self.old_service = session.nav.getCurrentlyPlayingServiceReference() session.nav.playService(service) service = session.nav.getCurrentService() cue = service and service.cueSheet() if cue is not None: # disable cutlists. we want to freely browse around in the movie print "cut lists disabled!" cue.setCutListEnable(0) self.downloadCuesheet() self["Timeline"] = ServicePositionGauge(self.session.nav) self["cutlist"] = List(self.getCutlist()) self["cutlist"].onSelectionChanged.append(self.selectionChanged) self["SeekState"] = Label() self.onPlayStateChanged.append(self.updateStateLabel) self.updateStateLabel(self.seekstate) desktopSize = getDesktop(0).size() self["Video"] = VideoWindow(decoder = 0, fb_width=desktopSize.width(), fb_height=desktopSize.height()) self["actions"] = HelpableActionMap(self, "CutListEditorActions", { "setIn": (self.setIn, _("Make this mark an 'in' point")), "setOut": (self.setOut, _("Make this mark an 'out' point")), "setMark": (self.setMark, _("Make this mark just a mark")), "addMark": (self.__addMark, _("Add a mark")), "removeMark": (self.__removeMark, _("Remove a mark")), "leave": (self.exit, _("Exit editor")), "showMenu": (self.showMenu, _("menu")), }, prio=-4) self.tutorial_seen = False self.onExecBegin.append(self.showTutorial) self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { iPlayableService.evCuesheetChanged: self.refillList }) # to track new entries we save the last version of the cutlist self.last_cuts = self.getCutlist() self.cut_start = None self.inhibit_seek = False self.onClose.append(self.__onClose) def __onClose(self): self.session.nav.playService(self.old_service, forceRestart=True) def updateStateLabel(self, state): self["SeekState"].setText(state[3].strip()) def showTutorial(self): if not self.tutorial_seen: self.tutorial_seen = True self.session.open(MessageBox,_("Welcome to the Cutlist editor.\n\nSeek to the start of the stuff you want to cut away. Press OK, select 'start cut'.\n\nThen seek to the end, press OK, select 'end cut'. That's it."), MessageBox.TYPE_INFO) def checkSkipShowHideLock(self): pass def setType(self, index, type): if len(self.cut_list): self.cut_list[index] = (self.cut_list[index][0], type) self["cutlist"].modifyEntry(index, CutListEntry(*self.cut_list[index])) def setIn(self): m = self["cutlist"].getIndex() self.setType(m, 0) self.uploadCuesheet() def setOut(self): m = self["cutlist"].getIndex() self.setType(m, 1) self.uploadCuesheet() def setMark(self): m = self["cutlist"].getIndex() self.setType(m, 2) self.uploadCuesheet() def __addMark(self): self.toggleMark(onlyadd=True, tolerance=90000) # do not allow two marks in <1s def __removeMark(self): m = self["cutlist"].getCurrent() m = m and m[0] if m is not None: self.removeMark(m) def exit(self): self.close() def getCutlist(self): r = [ ] for e in self.cut_list: r.append(CutListEntry(*e)) return r def selectionChanged(self): if not self.inhibit_seek: where = self["cutlist"].getCurrent() if where is None: print "no selection" return pts = where[0][0] seek = self.getSeek() if seek is None: print "no seek" return seek.seekTo(pts) def refillList(self): print "cue sheet changed, refilling" self.downloadCuesheet() # get the first changed entry, counted from the end, and select it new_list = self.getCutlist() self["cutlist"].list = new_list l1 = len(new_list) l2 = len(self.last_cuts) for i in range(min(l1, l2)): if new_list[l1-i-1] != self.last_cuts[l2-i-1]: self["cutlist"].setIndex(l1-i-1) break self.last_cuts = new_list def getStateForPosition(self, pos): state = -1 for (where, what) in self.cut_list: if what in [0, 1]: if where < pos: state = what elif where == pos: state = 1 elif state == -1: state = 1 - what if state == -1: state = 0 return state def showMenu(self): curpos = self.cueGetCurrentPosition() if curpos is None: return self.setSeekState(self.SEEK_STATE_PAUSE) self.context_position = curpos self.context_nearest_mark = self.toggleMark(onlyreturn=True) cur_state = self.getStateForPosition(curpos) if cur_state == 0: print "currently in 'IN'" if self.cut_start is None or self.context_position < self.cut_start: state = CutListContextMenu.SHOW_STARTCUT else: state = CutListContextMenu.SHOW_ENDCUT else: print "currently in 'OUT'" state = CutListContextMenu.SHOW_DELETECUT if self.context_nearest_mark is None: nearmark = False else: nearmark = True self.session.openWithCallback(self.menuCallback, CutListContextMenu, state, nearmark) def menuCallback(self, *result): if not len(result): return result = result[0] if result == CutListContextMenu.RET_STARTCUT: self.cut_start = self.context_position elif result == CutListContextMenu.RET_ENDCUT: # remove in/out marks between the new cut for (where, what) in self.cut_list[:]: if self.cut_start <= where <= self.context_position and what in (0,1): self.cut_list.remove((where, what)) bisect.insort(self.cut_list, (self.cut_start, 1)) bisect.insort(self.cut_list, (self.context_position, 0)) self.uploadCuesheet() self.cut_start = None elif result == CutListContextMenu.RET_DELETECUT: out_before = None in_after = None for (where, what) in self.cut_list: if what == 1 and where <= self.context_position: # out out_before = (where, what) elif what == 0 and where < self.context_position: # in, before out out_before = None elif what == 0 and where >= self.context_position and in_after is None: in_after = (where, what) if out_before is not None: self.cut_list.remove(out_before) if in_after is not None: self.cut_list.remove(in_after) self.inhibit_seek = True self.uploadCuesheet() self.inhibit_seek = False elif result == CutListContextMenu.RET_MARK: self.__addMark() elif result == CutListContextMenu.RET_DELETEMARK: self.cut_list.remove(self.context_nearest_mark) self.inhibit_seek = True self.uploadCuesheet() self.inhibit_seek = False elif result == CutListContextMenu.RET_REMOVEBEFORE: # remove in/out marks before current position for (where, what) in self.cut_list[:]: if where <= self.context_position and what in (0,1): self.cut_list.remove((where, what)) # add 'in' point bisect.insort(self.cut_list, (self.context_position, 0)) self.inhibit_seek = True self.uploadCuesheet() self.inhibit_seek = False elif result == CutListContextMenu.RET_REMOVEAFTER: # remove in/out marks after current position for (where, what) in self.cut_list[:]: if where >= self.context_position and what in (0,1): self.cut_list.remove((where, what)) # add 'out' point bisect.insort(self.cut_list, (self.context_position, 1)) self.inhibit_seek = True self.uploadCuesheet() self.inhibit_seek = False elif result == CutListContextMenu.RET_GRABFRAME: self.grabFrame() # we modify the "play" behavior a bit: # if we press pause while being in slowmotion, we will pause (and not play) def playpauseService(self): if self.seekstate != self.SEEK_STATE_PLAY and not self.isStateSlowMotion(self.seekstate): self.unPauseService() else: self.pauseService() def grabFrame(self): path = self.session.nav.getCurrentlyPlayingServiceReference().getPath() from Components.Console import Console grabConsole = Console() cmd = 'grab -vblpr%d "%s"' % (180, path.rsplit('.',1)[0] + ".png") grabConsole.ePopen(cmd) self.playpauseService() def main(session, service, **kwargs): session.open(CutListEditor, service) def Plugins(**kwargs): return PluginDescriptor(name= _("Cutlist editor"), description=_("Cutlist editor..."), where = PluginDescriptor.WHERE_MOVIELIST, needsRestart = False, fnc=main)
gpl-2.0
[ 504, 30317, 14, 5061, 492, 11349, 4311, 199, 199, 504, 29372, 14, 9616, 492, 17804, 199, 504, 29372, 14, 13695, 492, 28923, 199, 504, 17823, 14, 3167, 5625, 492, 7591, 5625, 39, 30949, 199, 504, 17823, 14, 3310, 2956, 492, 15456, 461, 3310, 2956, 199, 504, 17823, 14, 3167, 2390, 13652, 492, 7591, 2390, 13652, 12, 32767, 1563, 199, 504, 17823, 14, 9166, 4301, 492, 15709, 4301, 199, 504, 17823, 14, 4314, 492, 10354, 199, 504, 29372, 14, 2354, 5281, 3139, 2932, 492, 32767, 19168, 12, 32767, 35, 310, 16715, 11532, 199, 504, 655, 27021, 492, 664, 20436, 12, 284, 25261, 3167, 199, 504, 29372, 14, 9515, 5977, 492, 18659, 5977, 199, 504, 29372, 14, 8673, 5977, 492, 15456, 461, 9616, 199, 504, 17823, 14, 13959, 14, 1296, 492, 3820, 199, 199, 646, 19063, 199, 199, 318, 445, 337, 16934, 8, 4509, 12, 4052, 304, 199, 198, 87, 275, 2382, 1182, 9137, 199, 198, 706, 275, 336, 450, 5198, 199, 198, 83, 275, 334, 87, 1182, 5198, 9, 450, 5212, 199, 198, 77, 275, 334, 87, 1182, 1227, 993, 9, 450, 5212, 199, 198, 72, 275, 336, 1182, 8780, 5345, 199, 198, 692, 4052, 508, 378, 26, 507, 198, 466, 275, 298, 568, 2, 507, 198, 466, 63, 761, 275, 378, 88, 7979, 1493, 199, 198, 4164, 4052, 508, 413, 26, 507, 198, 466, 275, 298, 1877, 2, 507, 198, 466, 63, 761, 275, 378, 88, 20, 5345, 199, 198, 4164, 4052, 508, 499, 26, 507, 198, 466, 275, 298, 10520, 2, 507, 198, 466, 63, 761, 275, 378, 88, 993, 2167, 199, 198, 4164, 4052, 508, 650, 26, 507, 198, 466, 275, 298, 16901, 2, 507, 198, 466, 63, 761, 275, 378, 88, 3273, 199, 198, 1107, 3666, 4509, 12, 4052, 395, 2071, 7821, 2689, 996, 6428, 2689, 996, 795, 2689, 1644, 68, 2, 450, 334, 72, 12, 333, 12, 308, 12, 6605, 395, 730, 12, 730, 63, 761, 9, 199, 199, 533, 445, 337, 1296, 2998, 5977, 8, 9515, 5977, 304, 199, 198, 7341, 63, 7363, 24678, 275, 378, 199, 198, 7341, 63, 3902, 24678, 275, 413, 199, 198, 7341, 63, 4424, 775, 4220, 934, 275, 499, 199, 198, 7341, 63, 10520, 275, 650, 199, 198, 7341, 63, 4424, 775, 2769, 5748, 275, 841, 199, 198, 7341, 63, 25856, 31481, 275, 959, 199, 198, 7341, 63, 25856, 31883, 275, 1227, 199, 198, 7341, 63, 3975, 1217, 12683, 275, 1520, 421, 198, 19085, 63, 7363, 24678, 275, 378, 199, 198, 19085, 63, 3902, 24678, 275, 413, 199, 198, 19085, 63, 4424, 775, 4220, 934, 275, 499, 421, 198, 318, 636, 826, 721, 277, 12, 2351, 12, 1174, 12, 17429, 1657, 304, 507, 198, 4470, 275, 359, 6115, 894, 1288, 291, 14, 1600, 1874, 327, 12, 334, 403, 12, 776, 61, 2742, 198, 692, 1174, 508, 291, 14, 19085, 63, 7363, 24678, 26, 686, 198, 4470, 14, 740, 1332, 14332, 928, 10415, 2348, 1288, 291, 14, 928, 23498, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 928, 10415, 2348, 1288, 5082, 2742, 198, 692, 1174, 508, 291, 14, 19085, 63, 3902, 24678, 26, 686, 198, 4470, 14, 740, 1332, 14332, 500, 10415, 2348, 1288, 291, 14, 500, 23498, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 500, 10415, 2348, 1288, 5082, 2742, 198, 692, 1174, 508, 291, 14, 19085, 63, 4424, 775, 4220, 934, 26, 686, 198, 4470, 14, 740, 1332, 14332, 1807, 10415, 1288, 291, 14, 1807, 23498, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 1807, 10415, 1288, 5082, 2742, 198, 4470, 14, 740, 1332, 14332, 2168, 2544, 642, 3421, 1288, 291, 14, 2168, 13569, 430, 507, 198, 4470, 14, 740, 1332, 14332, 2168, 2410, 642, 3421, 1288, 291, 14, 2168, 10881, 430, 199, 199, 3, 198, 198, 4470, 14, 740, 1332, 403, 12, 5082, 2742, 198, 692, 440, 17429, 1657, 26, 686, 198, 4470, 14, 740, 1332, 14332, 3176, 2216, 2348, 1288, 291, 14, 3176, 6470, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 2168, 642, 2216, 1288, 291, 14, 2168, 6470, 430, 2742, 198, 4470, 14, 740, 1332, 14332, 22090, 642, 2787, 465, 20810, 1288, 291, 14, 22090, 3160, 430, 2742, 198, 9515, 5977, 855, 826, 721, 277, 12, 2351, 12, 3824, 23498, 1288, 6269, 9, 507, 198, 277, 14, 16409, 985, 275, 2097, 23498, 1296, 2998, 5977, 401, 298, 5977, 2, 1622, 421, 198, 318, 1343, 23498, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 7363, 24678, 9, 421, 198, 318, 1284, 23498, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 3902, 24678, 9, 421, 198, 318, 3145, 23498, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 4424, 775, 4220, 934, 9, 421, 198, 318, 5518, 6470, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 10520, 9, 421, 198, 318, 2813, 6470, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 4424, 775, 2769, 5748, 9, 421, 198, 318, 2813, 13569, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 25856, 31481, 9, 421, 198, 318, 2813, 10881, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 25856, 31883, 9, 421, 198, 318, 18200, 3160, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 3975, 1217, 12683, 9, 199, 199, 533, 445, 337, 1296, 10423, 8, 9616, 12, 32767, 1563, 12, 32767, 19168, 12, 32767, 35, 310, 16715, 11532, 12, 15456, 461, 9616, 304, 199, 198, 16409, 275, 408, 199, 198, 28, 5410, 3421, 628, 16, 12, 16, 2, 1568, 628, 18386, 12, 12255, 2, 2538, 628, 23498, 513, 8823, 2, 3285, 628, 14114, 1944, 22590, 1743, 507, 198, 28, 69, 4314, 1318, 628, 23498, 513, 8823, 2, 3421, 628, 2182, 12, 2259, 2, 1568, 628, 5863, 12, 821, 2, 5023, 628, 16038, 27, 1165, 2, 7082, 507, 198, 28, 3440, 1350, 628, 2966, 14, 5639, 1366, 2, 3795, 628, 4314, 2, 3421, 628, 13731, 12, 2259, 2, 1568, 628, 13549, 12, 1165, 2, 5023, 628, 16038 ]
[ 30317, 14, 5061, 492, 11349, 4311, 199, 199, 504, 29372, 14, 9616, 492, 17804, 199, 504, 29372, 14, 13695, 492, 28923, 199, 504, 17823, 14, 3167, 5625, 492, 7591, 5625, 39, 30949, 199, 504, 17823, 14, 3310, 2956, 492, 15456, 461, 3310, 2956, 199, 504, 17823, 14, 3167, 2390, 13652, 492, 7591, 2390, 13652, 12, 32767, 1563, 199, 504, 17823, 14, 9166, 4301, 492, 15709, 4301, 199, 504, 17823, 14, 4314, 492, 10354, 199, 504, 29372, 14, 2354, 5281, 3139, 2932, 492, 32767, 19168, 12, 32767, 35, 310, 16715, 11532, 199, 504, 655, 27021, 492, 664, 20436, 12, 284, 25261, 3167, 199, 504, 29372, 14, 9515, 5977, 492, 18659, 5977, 199, 504, 29372, 14, 8673, 5977, 492, 15456, 461, 9616, 199, 504, 17823, 14, 13959, 14, 1296, 492, 3820, 199, 199, 646, 19063, 199, 199, 318, 445, 337, 16934, 8, 4509, 12, 4052, 304, 199, 198, 87, 275, 2382, 1182, 9137, 199, 198, 706, 275, 336, 450, 5198, 199, 198, 83, 275, 334, 87, 1182, 5198, 9, 450, 5212, 199, 198, 77, 275, 334, 87, 1182, 1227, 993, 9, 450, 5212, 199, 198, 72, 275, 336, 1182, 8780, 5345, 199, 198, 692, 4052, 508, 378, 26, 507, 198, 466, 275, 298, 568, 2, 507, 198, 466, 63, 761, 275, 378, 88, 7979, 1493, 199, 198, 4164, 4052, 508, 413, 26, 507, 198, 466, 275, 298, 1877, 2, 507, 198, 466, 63, 761, 275, 378, 88, 20, 5345, 199, 198, 4164, 4052, 508, 499, 26, 507, 198, 466, 275, 298, 10520, 2, 507, 198, 466, 63, 761, 275, 378, 88, 993, 2167, 199, 198, 4164, 4052, 508, 650, 26, 507, 198, 466, 275, 298, 16901, 2, 507, 198, 466, 63, 761, 275, 378, 88, 3273, 199, 198, 1107, 3666, 4509, 12, 4052, 395, 2071, 7821, 2689, 996, 6428, 2689, 996, 795, 2689, 1644, 68, 2, 450, 334, 72, 12, 333, 12, 308, 12, 6605, 395, 730, 12, 730, 63, 761, 9, 199, 199, 533, 445, 337, 1296, 2998, 5977, 8, 9515, 5977, 304, 199, 198, 7341, 63, 7363, 24678, 275, 378, 199, 198, 7341, 63, 3902, 24678, 275, 413, 199, 198, 7341, 63, 4424, 775, 4220, 934, 275, 499, 199, 198, 7341, 63, 10520, 275, 650, 199, 198, 7341, 63, 4424, 775, 2769, 5748, 275, 841, 199, 198, 7341, 63, 25856, 31481, 275, 959, 199, 198, 7341, 63, 25856, 31883, 275, 1227, 199, 198, 7341, 63, 3975, 1217, 12683, 275, 1520, 421, 198, 19085, 63, 7363, 24678, 275, 378, 199, 198, 19085, 63, 3902, 24678, 275, 413, 199, 198, 19085, 63, 4424, 775, 4220, 934, 275, 499, 421, 198, 318, 636, 826, 721, 277, 12, 2351, 12, 1174, 12, 17429, 1657, 304, 507, 198, 4470, 275, 359, 6115, 894, 1288, 291, 14, 1600, 1874, 327, 12, 334, 403, 12, 776, 61, 2742, 198, 692, 1174, 508, 291, 14, 19085, 63, 7363, 24678, 26, 686, 198, 4470, 14, 740, 1332, 14332, 928, 10415, 2348, 1288, 291, 14, 928, 23498, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 928, 10415, 2348, 1288, 5082, 2742, 198, 692, 1174, 508, 291, 14, 19085, 63, 3902, 24678, 26, 686, 198, 4470, 14, 740, 1332, 14332, 500, 10415, 2348, 1288, 291, 14, 500, 23498, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 500, 10415, 2348, 1288, 5082, 2742, 198, 692, 1174, 508, 291, 14, 19085, 63, 4424, 775, 4220, 934, 26, 686, 198, 4470, 14, 740, 1332, 14332, 1807, 10415, 1288, 291, 14, 1807, 23498, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 1807, 10415, 1288, 5082, 2742, 198, 4470, 14, 740, 1332, 14332, 2168, 2544, 642, 3421, 1288, 291, 14, 2168, 13569, 430, 507, 198, 4470, 14, 740, 1332, 14332, 2168, 2410, 642, 3421, 1288, 291, 14, 2168, 10881, 430, 199, 199, 3, 198, 198, 4470, 14, 740, 1332, 403, 12, 5082, 2742, 198, 692, 440, 17429, 1657, 26, 686, 198, 4470, 14, 740, 1332, 14332, 3176, 2216, 2348, 1288, 291, 14, 3176, 6470, 430, 507, 198, 2836, 26, 686, 198, 4470, 14, 740, 1332, 14332, 2168, 642, 2216, 1288, 291, 14, 2168, 6470, 430, 2742, 198, 4470, 14, 740, 1332, 14332, 22090, 642, 2787, 465, 20810, 1288, 291, 14, 22090, 3160, 430, 2742, 198, 9515, 5977, 855, 826, 721, 277, 12, 2351, 12, 3824, 23498, 1288, 6269, 9, 507, 198, 277, 14, 16409, 985, 275, 2097, 23498, 1296, 2998, 5977, 401, 298, 5977, 2, 1622, 421, 198, 318, 1343, 23498, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 7363, 24678, 9, 421, 198, 318, 1284, 23498, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 3902, 24678, 9, 421, 198, 318, 3145, 23498, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 4424, 775, 4220, 934, 9, 421, 198, 318, 5518, 6470, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 10520, 9, 421, 198, 318, 2813, 6470, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 4424, 775, 2769, 5748, 9, 421, 198, 318, 2813, 13569, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 25856, 31481, 9, 421, 198, 318, 2813, 10881, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 25856, 31883, 9, 421, 198, 318, 18200, 3160, 8, 277, 304, 507, 198, 277, 14, 1600, 8, 277, 14, 7341, 63, 3975, 1217, 12683, 9, 199, 199, 533, 445, 337, 1296, 10423, 8, 9616, 12, 32767, 1563, 12, 32767, 19168, 12, 32767, 35, 310, 16715, 11532, 12, 15456, 461, 9616, 304, 199, 198, 16409, 275, 408, 199, 198, 28, 5410, 3421, 628, 16, 12, 16, 2, 1568, 628, 18386, 12, 12255, 2, 2538, 628, 23498, 513, 8823, 2, 3285, 628, 14114, 1944, 22590, 1743, 507, 198, 28, 69, 4314, 1318, 628, 23498, 513, 8823, 2, 3421, 628, 2182, 12, 2259, 2, 1568, 628, 5863, 12, 821, 2, 5023, 628, 16038, 27, 1165, 2, 7082, 507, 198, 28, 3440, 1350, 628, 2966, 14, 5639, 1366, 2, 3795, 628, 4314, 2, 3421, 628, 13731, 12, 2259, 2, 1568, 628, 13549, 12, 1165, 2, 5023, 628, 16038, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tbetbetbe/grpc
src/objective-c/change-comments.py
52
3621
#!/usr/bin/env python2.7 # Copyright 2015, 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. """Change comments style of source files from // to /** */""" import re import sys if len(sys.argv) < 2: print("Please provide at least one source file name as argument.") sys.exit() for file_name in sys.argv[1:]: print("Modifying format of {file} comments in place...".format( file=file_name, )) # Input with open(file_name, "r") as input_file: lines = input_file.readlines() def peek(): return lines[0] def read_line(): return lines.pop(0) def more_input_available(): return lines # Output output_lines = [] def write(line): output_lines.append(line) def flush_output(): with open(file_name, "w") as output_file: for line in output_lines: output_file.write(line) # Pattern matching comment_regex = r'^(\s*)//\s(.*)$' def is_comment(line): return re.search(comment_regex, line) def isnt_comment(line): return not is_comment(line) def next_line(predicate): return more_input_available() and predicate(peek()) # Transformation def indentation_of(line): match = re.search(comment_regex, line) return match.group(1) def content(line): match = re.search(comment_regex, line) return match.group(2) def format_as_block(comment_block): if len(comment_block) == 0: return [] indent = indentation_of(comment_block[0]) if len(comment_block) == 1: return [indent + "/** " + content(comment_block[0]) + " */\n"] block = ["/**"] + [" * " + content(line) for line in comment_block] + [" */"] return [indent + line.rstrip() + "\n" for line in block] # Main algorithm while more_input_available(): while next_line(isnt_comment): write(read_line()) comment_block = [] # Get all lines in the same comment block. We could restrict the indentation # to be the same as the first line of the block, but it's probably ok. while (next_line(is_comment)): comment_block.append(read_line()) for line in format_as_block(comment_block): write(line) flush_output()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 3, 1898, 6900, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 4001, 6786, 3449, 402, 1350, 1584, 687, 5001, 370, 1182, 538, 11589, 624, 199, 199, 646, 295, 199, 646, 984, 421, 199, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 523, 870, 480, 8254, 5647, 737, 5210, 1373, 1350, 570, 536, 465, 1423, 2685, 523, 984, 14, 2224, 342, 199, 199, 509, 570, 63, 354, 315, 984, 14, 3020, 59, 17, 10688, 819, 870, 480, 18357, 316, 1475, 402, 469, 493, 93, 6786, 315, 4192, 1396, 1674, 908, 8, 489, 570, 29, 493, 63, 354, 12, 523, 5082, 8330, 327, 6924, 819, 543, 1551, 8, 493, 63, 354, 12, 298, 82, 531, 465, 1324, 63, 493, 26, 272, 2385, 275, 1324, 63, 493, 14, 9684, 342, 819, 347, 15094, 837, 272, 372, 2385, 59, 16, 61, 819, 347, 1586, 63, 604, 837, 272, 372, 2385, 14, 1935, 8, 16, 9, 819, 347, 1655, 63, 1210, 63, 4561, 837, 272, 372, 2385, 8330, 327, 7242, 819, 1072, 63, 1278, 275, 942, 819, 347, 2218, 8, 604, 304, 272, 1072, 63, 1278, 14, 740, 8, 604, 9, 819, 347, 8976, 63, 1199, 837, 272, 543, 1551, 8, 493, 63, 354, 12, 298, 87, 531, 465, 1072, 63, 493, 26, 489, 367, 1004, 315, 1072, 63, 1278, 26, 267, 1072, 63, 493, 14, 952, 8, 604, 9, 8330, 327, 27019, 4877, 819, 3721, 63, 3821, 275, 519, 31344, 83, 13278, 501, 60, 83, 8, 12432, 12913, 819, 347, 365, 63, 3349, 8, 604, 304, 272, 372, 295, 14, 1733, 8, 3349, 63, 3821, 12, 1004, 9, 819, 347, 365, 343, 63, 3349, 8, 604, 304, 272, 372, 440, 365, 63, 3349, 8, 604, 9, 819, 347, 2163, 63, 604, 8, 14463, 304, 272, 372, 1655, 63, 1210, 63, 4561, 342, 436, 11944, 8, 13164, 1012, 8330, 327, 6266, 1869, 819, 347, 14311, 63, 1618, 8, 604, 304, 272, 1336, 275, 295, 14, 1733, 8, 3349, 63, 3821, 12, 1004, 9, 272, 372, 1336, 14, 923, 8, 17, 9, 819, 347, 1564, 8, 604, 304, 272, 1336, 275, 295, 14, 1733, 8, 3349, 63, 3821, 12, 1004, 9, 272, 372, 1336, 14, 923, 8, 18, 9, 819, 347, 1475, 63, 305, 63, 1457, 8, 3349, 63, 1457, 304, 272, 340, 822, 8, 3349, 63, 1457, 9, 508, 378, 26, 489, 372, 942, 339, 4363, 275, 14311, 63, 1618, 8, 3349, 63, 1457, 59, 16, 566, 339, 340, 822, 8, 3349, 63, 1457, 9, 508, 413, 26, 489, 372, 359, 3724, 435, 3286, 538, 298, 435, 1564, 8, 3349, 63, 1457, 59, 16, 566, 435, 298, 9399, 78, 937, 339, 1853, 275, 2097, 15, 538, 937, 435, 2097, 627, 298, 435, 1564, 8, 604, 9, 367, 1004, 315, 3721, 63, 1457, 61, 435, 2097, 11589, 937, 272, 372, 359, 3724, 435, 1004, 14, 6735, 342, 435, 1867, 78, 2, 367, 1004, 315, 1853, 61, 8330, 327, 11298, 5563, 819, 1830, 1655, 63, 1210, 63, 4561, 837, 272, 1830, 2163, 63, 604, 8, 374, 343, 63, 3349, 304, 489, 2218, 8, 739, 63, 604, 1012, 339, 3721, 63, 1457, 275, 942, 272, 327, 2372, 1006, 2385, 315, 314, 2011, 3721, 1853, 14, 2136, 4293, 18152, 314, 14311, 272, 327, 370, 506, 314, 2011, 465, 314, 1642, 1004, 402, 314, 1853, 12, 1325, 652, 1159, 8646, 4112, 14, 272, 1830, 334, 2184, 63, 604, 8, 374, 63, 3349, 2298, 489, 3721, 63, 1457, 14, 740, 8, 739, 63, 604, 1012, 339, 367, 1004, 315, 1475, 63, 305, 63, 1457, 8, 3349, 63, 1457, 304, 489, 2218, 8, 604, 9, 819, 8976, 63, 1199, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 14, 23, 199, 3, 1898, 6900, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 4001, 6786, 3449, 402, 1350, 1584, 687, 5001, 370, 1182, 538, 11589, 624, 199, 199, 646, 295, 199, 646, 984, 421, 199, 692, 822, 8, 1274, 14, 3020, 9, 665, 499, 26, 523, 870, 480, 8254, 5647, 737, 5210, 1373, 1350, 570, 536, 465, 1423, 2685, 523, 984, 14, 2224, 342, 199, 199, 509, 570, 63, 354, 315, 984, 14, 3020, 59, 17, 10688, 819, 870, 480, 18357, 316, 1475, 402, 469, 493, 93, 6786, 315, 4192, 1396, 1674, 908, 8, 489, 570, 29, 493, 63, 354, 12, 523, 5082, 8330, 327, 6924, 819, 543, 1551, 8, 493, 63, 354, 12, 298, 82, 531, 465, 1324, 63, 493, 26, 272, 2385, 275, 1324, 63, 493, 14, 9684, 342, 819, 347, 15094, 837, 272, 372, 2385, 59, 16, 61, 819, 347, 1586, 63, 604, 837, 272, 372, 2385, 14, 1935, 8, 16, 9, 819, 347, 1655, 63, 1210, 63, 4561, 837, 272, 372, 2385, 8330, 327, 7242, 819, 1072, 63, 1278, 275, 942, 819, 347, 2218, 8, 604, 304, 272, 1072, 63, 1278, 14, 740, 8, 604, 9, 819, 347, 8976, 63, 1199, 837, 272, 543, 1551, 8, 493, 63, 354, 12, 298, 87, 531, 465, 1072, 63, 493, 26, 489, 367, 1004, 315, 1072, 63, 1278, 26, 267, 1072, 63, 493, 14, 952, 8, 604, 9, 8330, 327, 27019, 4877, 819, 3721, 63, 3821, 275, 519, 31344, 83, 13278, 501, 60, 83, 8, 12432, 12913, 819, 347, 365, 63, 3349, 8, 604, 304, 272, 372, 295, 14, 1733, 8, 3349, 63, 3821, 12, 1004, 9, 819, 347, 365, 343, 63, 3349, 8, 604, 304, 272, 372, 440, 365, 63, 3349, 8, 604, 9, 819, 347, 2163, 63, 604, 8, 14463, 304, 272, 372, 1655, 63, 1210, 63, 4561, 342, 436, 11944, 8, 13164, 1012, 8330, 327, 6266, 1869, 819, 347, 14311, 63, 1618, 8, 604, 304, 272, 1336, 275, 295, 14, 1733, 8, 3349, 63, 3821, 12, 1004, 9, 272, 372, 1336, 14, 923, 8, 17, 9, 819, 347, 1564, 8, 604, 304, 272, 1336, 275, 295, 14, 1733, 8, 3349, 63, 3821, 12, 1004, 9, 272, 372, 1336, 14, 923, 8, 18, 9, 819, 347, 1475, 63, 305, 63, 1457, 8, 3349, 63, 1457, 304, 272, 340, 822, 8, 3349, 63, 1457, 9, 508, 378, 26, 489, 372, 942, 339, 4363, 275, 14311, 63, 1618, 8, 3349, 63, 1457, 59, 16, 566, 339, 340, 822, 8, 3349, 63, 1457, 9, 508, 413, 26, 489, 372, 359, 3724, 435, 3286, 538, 298, 435, 1564, 8, 3349, 63, 1457, 59, 16, 566, 435, 298, 9399, 78, 937, 339, 1853, 275, 2097, 15, 538, 937, 435, 2097, 627, 298, 435, 1564, 8, 604, 9, 367, 1004, 315, 3721, 63, 1457, 61, 435, 2097, 11589, 937, 272, 372, 359, 3724, 435, 1004, 14, 6735, 342, 435, 1867, 78, 2, 367, 1004, 315, 1853, 61, 8330, 327, 11298, 5563, 819, 1830, 1655, 63, 1210, 63, 4561, 837, 272, 1830, 2163, 63, 604, 8, 374, 343, 63, 3349, 304, 489, 2218, 8, 739, 63, 604, 1012, 339, 3721, 63, 1457, 275, 942, 272, 327, 2372, 1006, 2385, 315, 314, 2011, 3721, 1853, 14, 2136, 4293, 18152, 314, 14311, 272, 327, 370, 506, 314, 2011, 465, 314, 1642, 1004, 402, 314, 1853, 12, 1325, 652, 1159, 8646, 4112, 14, 272, 1830, 334, 2184, 63, 604, 8, 374, 63, 3349, 2298, 489, 3721, 63, 1457, 14, 740, 8, 739, 63, 604, 1012, 339, 367, 1004, 315, 1475, 63, 305, 63, 1457, 8, 3349, 63, 1457, 304, 489, 2218, 8, 604, 9, 819, 8976, 63, 1199, 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, 0 ]
[ 1, 1, 1, 1, 1,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niorCode
lib/python2.7/site-packages/django/contrib/auth/admin.py
83
8318
from django.conf import settings from django.conf.urls import url from django.contrib import admin, messages from django.contrib.admin.options import IS_POPUP_VAR from django.contrib.admin.utils import unquote from django.contrib.auth import update_session_auth_hash from django.contrib.auth.forms import ( AdminPasswordChangeForm, UserChangeForm, UserCreationForm, ) from django.contrib.auth.models import Group, User from django.core.exceptions import PermissionDenied from django.db import transaction from django.http import Http404, HttpResponseRedirect from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.utils.encoding import force_text from django.utils.html import escape from django.utils.translation import ugettext, ugettext_lazy as _ from django.views.decorators.csrf import csrf_protect from django.views.decorators.debug import sensitive_post_parameters csrf_protect_m = method_decorator(csrf_protect) sensitive_post_parameters_m = method_decorator(sensitive_post_parameters()) class GroupAdmin(admin.ModelAdmin): search_fields = ('name',) ordering = ('name',) filter_horizontal = ('permissions',) def formfield_for_manytomany(self, db_field, request=None, **kwargs): if db_field.name == 'permissions': qs = kwargs.get('queryset', db_field.rel.to.objects) # Avoid a major performance hit resolving permission names which # triggers a content_type load: kwargs['queryset'] = qs.select_related('content_type') return super(GroupAdmin, self).formfield_for_manytomany( db_field, request=request, **kwargs) class UserAdmin(admin.ModelAdmin): add_form_template = 'admin/auth/user/add_form.html' change_user_password_template = None fieldsets = ( (None, {'fields': ('username', 'password')}), (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions')}), (_('Important dates'), {'fields': ('last_login', 'date_joined')}), ) add_fieldsets = ( (None, { 'classes': ('wide',), 'fields': ('username', 'password1', 'password2'), }), ) form = UserChangeForm add_form = UserCreationForm change_password_form = AdminPasswordChangeForm list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff') list_filter = ('is_staff', 'is_superuser', 'is_active', 'groups') search_fields = ('username', 'first_name', 'last_name', 'email') ordering = ('username',) filter_horizontal = ('groups', 'user_permissions',) def get_fieldsets(self, request, obj=None): if not obj: return self.add_fieldsets return super(UserAdmin, self).get_fieldsets(request, obj) def get_form(self, request, obj=None, **kwargs): """ Use special form during user creation """ defaults = {} if obj is None: defaults['form'] = self.add_form defaults.update(kwargs) return super(UserAdmin, self).get_form(request, obj, **defaults) def get_urls(self): return [ url(r'^(.+)/password/$', self.admin_site.admin_view(self.user_change_password), name='auth_user_password_change'), ] + super(UserAdmin, self).get_urls() def lookup_allowed(self, lookup, value): # See #20078: we don't want to allow any lookups involving passwords. if lookup.startswith('password'): return False return super(UserAdmin, self).lookup_allowed(lookup, value) @sensitive_post_parameters_m @csrf_protect_m @transaction.atomic def add_view(self, request, form_url='', extra_context=None): # It's an error for a user to have add permission but NOT change # permission for users. If we allowed such users to add users, they # could create superusers, which would mean they would essentially have # the permission to change users. To avoid the problem entirely, we # disallow users from adding users if they don't have change # permission. if not self.has_change_permission(request): if self.has_add_permission(request) and settings.DEBUG: # Raise Http404 in debug mode so that the user gets a helpful # error message. raise Http404( 'Your user does not have the "Change user" permission. In ' 'order to add users, Django requires that your user ' 'account have both the "Add user" and "Change user" ' 'permissions set.') raise PermissionDenied if extra_context is None: extra_context = {} username_field = self.model._meta.get_field(self.model.USERNAME_FIELD) defaults = { 'auto_populated_fields': (), 'username_help_text': username_field.help_text, } extra_context.update(defaults) return super(UserAdmin, self).add_view(request, form_url, extra_context) @sensitive_post_parameters_m def user_change_password(self, request, id, form_url=''): if not self.has_change_permission(request): raise PermissionDenied user = self.get_object(request, unquote(id)) if user is None: raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % { 'name': force_text(self.model._meta.verbose_name), 'key': escape(id), }) if request.method == 'POST': form = self.change_password_form(user, request.POST) if form.is_valid(): form.save() change_message = self.construct_change_message(request, form, None) self.log_change(request, user, change_message) msg = ugettext('Password changed successfully.') messages.success(request, msg) update_session_auth_hash(request, form.user) return HttpResponseRedirect('..') else: form = self.change_password_form(user) fieldsets = [(None, {'fields': list(form.base_fields)})] adminForm = admin.helpers.AdminForm(form, fieldsets, {}) context = { 'title': _('Change password: %s') % escape(user.get_username()), 'adminForm': adminForm, 'form_url': form_url, 'form': form, 'is_popup': (IS_POPUP_VAR in request.POST or IS_POPUP_VAR in request.GET), 'add': True, 'change': False, 'has_delete_permission': False, 'has_change_permission': True, 'has_absolute_url': False, 'opts': self.model._meta, 'original': user, 'save_as': False, 'show_save': True, } context.update(admin.site.each_context(request)) request.current_app = self.admin_site.name return TemplateResponse(request, self.change_user_password_template or 'admin/auth/user/change_password.html', context) def response_add(self, request, obj, post_url_continue=None): """ Determines the HttpResponse for the add_view stage. It mostly defers to its superclass implementation but is customized because the User model has a slightly different workflow. """ # We should allow further modification of the user just added i.e. the # 'Save' button should behave like the 'Save and continue editing' # button except in two scenarios: # * The user has pressed the 'Save and add another' button # * We are adding a user in a popup if '_addanother' not in request.POST and IS_POPUP_VAR not in request.POST: request.POST['_continue'] = 1 return super(UserAdmin, self).response_add(request, obj, post_url_continue) admin.site.register(Group, GroupAdmin) admin.site.register(User, UserAdmin)
mit
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 2828, 492, 4628, 12, 3788, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 2281, 63, 13531, 2160, 63, 5568, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 14342, 199, 504, 1639, 14, 2828, 14, 1178, 492, 1678, 63, 1730, 63, 1178, 63, 2227, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 334, 272, 9516, 6139, 32523, 12, 2876, 32523, 12, 2876, 13921, 2821, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 5611, 12, 2876, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 1639, 14, 697, 492, 6008, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 12, 14935, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 1208, 14, 11582, 492, 1083, 63, 11547, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 1360, 492, 4772, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 12, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 18292, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1757, 492, 18423, 63, 1932, 63, 3214, 199, 199, 10088, 63, 18292, 63, 77, 275, 1083, 63, 11547, 8, 10088, 63, 18292, 9, 199, 7361, 63, 1932, 63, 3214, 63, 77, 275, 1083, 63, 11547, 8, 7361, 63, 1932, 63, 3214, 1012, 421, 199, 533, 5611, 4880, 8, 2113, 14, 12976, 304, 272, 2754, 63, 955, 275, 661, 354, 9538, 272, 7794, 275, 661, 354, 9538, 272, 2457, 63, 11392, 275, 661, 6060, 9538, 339, 347, 21388, 63, 509, 63, 3479, 475, 3479, 8, 277, 12, 1592, 63, 698, 12, 1056, 29, 403, 12, 1011, 958, 304, 267, 340, 1592, 63, 698, 14, 354, 508, 283, 6060, 356, 288, 6377, 275, 2074, 14, 362, 360, 7924, 297, 1592, 63, 698, 14, 3369, 14, 475, 14, 1462, 9, 288, 327, 19503, 282, 12160, 10238, 9793, 30685, 4983, 1561, 1314, 288, 327, 18899, 282, 1564, 63, 466, 2248, 26, 288, 2074, 459, 7924, 418, 275, 6377, 14, 2416, 63, 2407, 360, 1317, 63, 466, 358, 267, 372, 1613, 8, 2448, 4880, 12, 291, 680, 20015, 63, 509, 63, 3479, 475, 3479, 8, 288, 1592, 63, 698, 12, 1056, 29, 1069, 12, 1011, 958, 9, 421, 199, 533, 2876, 4880, 8, 2113, 14, 12976, 304, 272, 1050, 63, 964, 63, 1160, 275, 283, 2113, 15, 1178, 15, 751, 15, 525, 63, 964, 14, 1360, 7, 272, 1570, 63, 751, 63, 2060, 63, 1160, 275, 488, 272, 901, 2193, 275, 334, 267, 334, 403, 12, 791, 955, 356, 661, 2473, 297, 283, 2060, 358, 8688, 267, 21790, 7344, 279, 2256, 659, 791, 955, 356, 661, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 2123, 358, 8688, 267, 21790, 17004, 659, 791, 955, 356, 661, 374, 63, 2682, 297, 283, 374, 63, 7018, 297, 283, 374, 63, 11434, 297, 4318, 283, 2634, 297, 283, 751, 63, 6060, 358, 8688, 267, 21790, 6295, 867, 10831, 659, 791, 955, 356, 661, 2019, 63, 2886, 297, 283, 602, 63, 11806, 358, 8688, 272, 776, 272, 1050, 63, 23501, 275, 334, 267, 334, 403, 12, 469, 288, 283, 2888, 356, 661, 13062, 5529, 288, 283, 955, 356, 661, 2473, 297, 283, 2060, 17, 297, 283, 2060, 18, 659, 267, 9998, 272, 776, 272, 1824, 275, 2876, 32523, 272, 1050, 63, 964, 275, 2876, 13921, 2821, 272, 1570, 63, 2060, 63, 964, 275, 9516, 6139, 32523, 272, 769, 63, 2918, 275, 661, 2473, 297, 283, 2123, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 374, 63, 7018, 358, 272, 769, 63, 1541, 275, 661, 374, 63, 7018, 297, 283, 374, 63, 11434, 297, 283, 374, 63, 2682, 297, 283, 2634, 358, 272, 2754, 63, 955, 275, 661, 2473, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 2123, 358, 272, 7794, 275, 661, 2473, 9538, 272, 2457, 63, 11392, 275, 661, 2634, 297, 283, 751, 63, 6060, 9538, 339, 347, 664, 63, 23501, 8, 277, 12, 1056, 12, 1559, 29, 403, 304, 267, 340, 440, 1559, 26, 288, 372, 291, 14, 525, 63, 23501, 267, 372, 1613, 8, 1899, 4880, 12, 291, 680, 362, 63, 23501, 8, 1069, 12, 1559, 9, 339, 347, 664, 63, 964, 8, 277, 12, 1056, 12, 1559, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 3645, 4539, 1824, 5309, 922, 7143, 267, 408, 267, 4243, 275, 1052, 267, 340, 1559, 365, 488, 26, 288, 4243, 459, 964, 418, 275, 291, 14, 525, 63, 964, 267, 4243, 14, 873, 8, 958, 9, 267, 372, 1613, 8, 1899, 4880, 12, 291, 680, 362, 63, 964, 8, 1069, 12, 1559, 12, 1011, 4322, 9, 339, 347, 664, 63, 3603, 8, 277, 304, 267, 372, 359, 288, 1166, 8, 82, 31996, 6977, 2447, 2060, 10884, 291, 14, 2113, 63, 2124, 14, 2113, 63, 1345, 8, 277, 14, 751, 63, 1461, 63, 2060, 395, 536, 534, 1178, 63, 751, 63, 2060, 63, 1461, 659, 267, 1622, 435, 1613, 8, 1899, 4880, 12, 291, 680, 362, 63, 3603, 342, 339, 347, 4237, 63, 6541, 8, 277, 12, 4237, 12, 574, 304, 267, 327, 1666, 327, 1840, 2277, 26, 781, 2793, 1133, 2934, 370, 2040, 1263, 16807, 25613, 4007, 19572, 14, 267, 340, 4237, 14, 2460, 360, 2060, 735, 288, 372, 756, 267, 372, 1613, 8, 1899, 4880, 12, 291, 680, 3892, 63, 6541, 8, 3892, 12, 574, 9, 339, 768, 7361, 63, 1932, 63, 3214, 63, 77, 272, 768, 10088, 63, 18292, 63, 77, 272, 768, 5945, 14, 10910, 272, 347, 1050, 63, 1345, 8, 277, 12, 1056, 12, 1824, 63, 633, 4581, 2402, 63, 1100, 29, 403, 304, 267, 327, 2779, 1159, 376, 1125, 367, 282, 922, 370, 1172, 1050, 4983, 1325, 2845, 1570, 267, 327, 4983, 367, 4390, 14, 982, 781, 4370, 4066, 4390, 370, 1050, 4390, 12, 2985, 267, 327, 4293, 1218, 1613, 3707, 12, 1314, 3955, 4615, 2985, 3955, 28891, 1172, 267, 327, 314, 4983, 370, 1570, 4390, 14, 4005, 5126, 314, 5160, 21926, 12 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 2828, 492, 4628, 12, 3788, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1419, 492, 2281, 63, 13531, 2160, 63, 5568, 199, 504, 1639, 14, 2828, 14, 2113, 14, 1208, 492, 14342, 199, 504, 1639, 14, 2828, 14, 1178, 492, 1678, 63, 1730, 63, 1178, 63, 2227, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 334, 272, 9516, 6139, 32523, 12, 2876, 32523, 12, 2876, 13921, 2821, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 5611, 12, 2876, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 1639, 14, 697, 492, 6008, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 12, 14935, 199, 504, 1639, 14, 1160, 14, 1310, 492, 29264, 199, 504, 1639, 14, 1208, 14, 11582, 492, 1083, 63, 11547, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 1360, 492, 4772, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 12, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 4196, 14, 11582, 14, 10088, 492, 19213, 63, 18292, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1757, 492, 18423, 63, 1932, 63, 3214, 199, 199, 10088, 63, 18292, 63, 77, 275, 1083, 63, 11547, 8, 10088, 63, 18292, 9, 199, 7361, 63, 1932, 63, 3214, 63, 77, 275, 1083, 63, 11547, 8, 7361, 63, 1932, 63, 3214, 1012, 421, 199, 533, 5611, 4880, 8, 2113, 14, 12976, 304, 272, 2754, 63, 955, 275, 661, 354, 9538, 272, 7794, 275, 661, 354, 9538, 272, 2457, 63, 11392, 275, 661, 6060, 9538, 339, 347, 21388, 63, 509, 63, 3479, 475, 3479, 8, 277, 12, 1592, 63, 698, 12, 1056, 29, 403, 12, 1011, 958, 304, 267, 340, 1592, 63, 698, 14, 354, 508, 283, 6060, 356, 288, 6377, 275, 2074, 14, 362, 360, 7924, 297, 1592, 63, 698, 14, 3369, 14, 475, 14, 1462, 9, 288, 327, 19503, 282, 12160, 10238, 9793, 30685, 4983, 1561, 1314, 288, 327, 18899, 282, 1564, 63, 466, 2248, 26, 288, 2074, 459, 7924, 418, 275, 6377, 14, 2416, 63, 2407, 360, 1317, 63, 466, 358, 267, 372, 1613, 8, 2448, 4880, 12, 291, 680, 20015, 63, 509, 63, 3479, 475, 3479, 8, 288, 1592, 63, 698, 12, 1056, 29, 1069, 12, 1011, 958, 9, 421, 199, 533, 2876, 4880, 8, 2113, 14, 12976, 304, 272, 1050, 63, 964, 63, 1160, 275, 283, 2113, 15, 1178, 15, 751, 15, 525, 63, 964, 14, 1360, 7, 272, 1570, 63, 751, 63, 2060, 63, 1160, 275, 488, 272, 901, 2193, 275, 334, 267, 334, 403, 12, 791, 955, 356, 661, 2473, 297, 283, 2060, 358, 8688, 267, 21790, 7344, 279, 2256, 659, 791, 955, 356, 661, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 2123, 358, 8688, 267, 21790, 17004, 659, 791, 955, 356, 661, 374, 63, 2682, 297, 283, 374, 63, 7018, 297, 283, 374, 63, 11434, 297, 4318, 283, 2634, 297, 283, 751, 63, 6060, 358, 8688, 267, 21790, 6295, 867, 10831, 659, 791, 955, 356, 661, 2019, 63, 2886, 297, 283, 602, 63, 11806, 358, 8688, 272, 776, 272, 1050, 63, 23501, 275, 334, 267, 334, 403, 12, 469, 288, 283, 2888, 356, 661, 13062, 5529, 288, 283, 955, 356, 661, 2473, 297, 283, 2060, 17, 297, 283, 2060, 18, 659, 267, 9998, 272, 776, 272, 1824, 275, 2876, 32523, 272, 1050, 63, 964, 275, 2876, 13921, 2821, 272, 1570, 63, 2060, 63, 964, 275, 9516, 6139, 32523, 272, 769, 63, 2918, 275, 661, 2473, 297, 283, 2123, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 374, 63, 7018, 358, 272, 769, 63, 1541, 275, 661, 374, 63, 7018, 297, 283, 374, 63, 11434, 297, 283, 374, 63, 2682, 297, 283, 2634, 358, 272, 2754, 63, 955, 275, 661, 2473, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 2123, 358, 272, 7794, 275, 661, 2473, 9538, 272, 2457, 63, 11392, 275, 661, 2634, 297, 283, 751, 63, 6060, 9538, 339, 347, 664, 63, 23501, 8, 277, 12, 1056, 12, 1559, 29, 403, 304, 267, 340, 440, 1559, 26, 288, 372, 291, 14, 525, 63, 23501, 267, 372, 1613, 8, 1899, 4880, 12, 291, 680, 362, 63, 23501, 8, 1069, 12, 1559, 9, 339, 347, 664, 63, 964, 8, 277, 12, 1056, 12, 1559, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 3645, 4539, 1824, 5309, 922, 7143, 267, 408, 267, 4243, 275, 1052, 267, 340, 1559, 365, 488, 26, 288, 4243, 459, 964, 418, 275, 291, 14, 525, 63, 964, 267, 4243, 14, 873, 8, 958, 9, 267, 372, 1613, 8, 1899, 4880, 12, 291, 680, 362, 63, 964, 8, 1069, 12, 1559, 12, 1011, 4322, 9, 339, 347, 664, 63, 3603, 8, 277, 304, 267, 372, 359, 288, 1166, 8, 82, 31996, 6977, 2447, 2060, 10884, 291, 14, 2113, 63, 2124, 14, 2113, 63, 1345, 8, 277, 14, 751, 63, 1461, 63, 2060, 395, 536, 534, 1178, 63, 751, 63, 2060, 63, 1461, 659, 267, 1622, 435, 1613, 8, 1899, 4880, 12, 291, 680, 362, 63, 3603, 342, 339, 347, 4237, 63, 6541, 8, 277, 12, 4237, 12, 574, 304, 267, 327, 1666, 327, 1840, 2277, 26, 781, 2793, 1133, 2934, 370, 2040, 1263, 16807, 25613, 4007, 19572, 14, 267, 340, 4237, 14, 2460, 360, 2060, 735, 288, 372, 756, 267, 372, 1613, 8, 1899, 4880, 12, 291, 680, 3892, 63, 6541, 8, 3892, 12, 574, 9, 339, 768, 7361, 63, 1932, 63, 3214, 63, 77, 272, 768, 10088, 63, 18292, 63, 77, 272, 768, 5945, 14, 10910, 272, 347, 1050, 63, 1345, 8, 277, 12, 1056, 12, 1824, 63, 633, 4581, 2402, 63, 1100, 29, 403, 304, 267, 327, 2779, 1159, 376, 1125, 367, 282, 922, 370, 1172, 1050, 4983, 1325, 2845, 1570, 267, 327, 4983, 367, 4390, 14, 982, 781, 4370, 4066, 4390, 370, 1050, 4390, 12, 2985, 267, 327, 4293, 1218, 1613, 3707, 12, 1314, 3955, 4615, 2985, 3955, 28891, 1172, 267, 327, 314, 4983, 370, 1570, 4390, 14, 4005, 5126, 314, 5160, 21926, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jmerkow/VTK
ThirdParty/Twisted/twisted/trial/test/test_script.py
28
29651
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. import StringIO import gc import re import sys import textwrap import types from twisted.trial import unittest from twisted.trial.runner import ( TrialRunner, TestSuite, DestructiveTestSuite, TestLoader) from twisted.trial._dist.disttrial import DistTrialRunner from twisted.scripts import trial from twisted.python import util from twisted.python.usage import UsageError from twisted.python.filepath import FilePath from twisted.trial.test.test_loader import testNames pyunit = __import__('unittest') def sibpath(filename): """ For finding files in twisted/trial/test """ return util.sibpath(__file__, filename) class ForceGarbageCollection(unittest.SynchronousTestCase): """ Tests for the --force-gc option. """ def setUp(self): self.config = trial.Options() self.log = [] self.patch(gc, 'collect', self.collect) test = pyunit.FunctionTestCase(self.simpleTest) self.test = TestSuite([test, test]) def simpleTest(self): """ A simple test method that records that it was run. """ self.log.append('test') def collect(self): """ A replacement for gc.collect that logs calls to itself. """ self.log.append('collect') def makeRunner(self): """ Return a L{TrialRunner} object that is safe to use in tests. """ runner = trial._makeRunner(self.config) runner.stream = StringIO.StringIO() return runner def test_forceGc(self): """ Passing the --force-gc option to the trial script forces the garbage collector to run before and after each test. """ self.config['force-gc'] = True self.config.postOptions() runner = self.makeRunner() runner.run(self.test) self.assertEqual(self.log, ['collect', 'test', 'collect', 'collect', 'test', 'collect']) def test_unforceGc(self): """ By default, no garbage collection is forced. """ self.config.postOptions() runner = self.makeRunner() runner.run(self.test) self.assertEqual(self.log, ['test', 'test']) class TestSuiteUsed(unittest.SynchronousTestCase): """ Check the category of tests suite used by the loader. """ def setUp(self): """ Create a trial configuration object. """ self.config = trial.Options() def test_defaultSuite(self): """ By default, the loader should use L{DestructiveTestSuite} """ loader = trial._getLoader(self.config) self.assertEqual(loader.suiteFactory, DestructiveTestSuite) def test_untilFailureSuite(self): """ The C{until-failure} configuration uses the L{TestSuite} to keep instances alive across runs. """ self.config['until-failure'] = True loader = trial._getLoader(self.config) self.assertEqual(loader.suiteFactory, TestSuite) class TestModuleTest(unittest.SynchronousTestCase): def setUp(self): self.config = trial.Options() def tearDown(self): self.config = None def test_testNames(self): """ Check that the testNames helper method accurately collects the names of tests in suite. """ self.assertEqual(testNames(self), [self.id()]) def assertSuitesEqual(self, test1, names): loader = TestLoader() names1 = testNames(test1) names2 = testNames(TestSuite(map(loader.loadByName, names))) names1.sort() names2.sort() self.assertEqual(names1, names2) def test_baseState(self): self.assertEqual(0, len(self.config['tests'])) def test_testmoduleOnModule(self): """ Check that --testmodule loads a suite which contains the tests referred to in test-case-name inside its parameter. """ self.config.opt_testmodule(sibpath('moduletest.py')) self.assertSuitesEqual(trial._getSuite(self.config), ['twisted.trial.test.test_log']) def test_testmoduleTwice(self): """ When the same module is specified with two --testmodule flags, it should only appear once in the suite. """ self.config.opt_testmodule(sibpath('moduletest.py')) self.config.opt_testmodule(sibpath('moduletest.py')) self.assertSuitesEqual(trial._getSuite(self.config), ['twisted.trial.test.test_log']) def test_testmoduleOnSourceAndTarget(self): """ If --testmodule is specified twice, once for module A and once for a module which refers to module A, then make sure module A is only added once. """ self.config.opt_testmodule(sibpath('moduletest.py')) self.config.opt_testmodule(sibpath('test_log.py')) self.assertSuitesEqual(trial._getSuite(self.config), ['twisted.trial.test.test_log']) def test_testmoduleOnSelfModule(self): """ When given a module that refers to *itself* in the test-case-name variable, check that --testmodule only adds the tests once. """ self.config.opt_testmodule(sibpath('moduleself.py')) self.assertSuitesEqual(trial._getSuite(self.config), ['twisted.trial.test.moduleself']) def test_testmoduleOnScript(self): """ Check that --testmodule loads tests referred to in test-case-name buffer variables. """ self.config.opt_testmodule(sibpath('scripttest.py')) self.assertSuitesEqual(trial._getSuite(self.config), ['twisted.trial.test.test_log', 'twisted.trial.test.test_class']) def test_testmoduleOnNonexistentFile(self): """ Check that --testmodule displays a meaningful error message when passed a non-existent filename. """ buffy = StringIO.StringIO() stderr, sys.stderr = sys.stderr, buffy filename = 'test_thisbetternoteverexist.py' try: self.config.opt_testmodule(filename) self.assertEqual(0, len(self.config['tests'])) self.assertEqual("File %r doesn't exist\n" % (filename,), buffy.getvalue()) finally: sys.stderr = stderr def test_testmoduleOnEmptyVars(self): """ Check that --testmodule adds no tests to the suite for modules which lack test-case-name buffer variables. """ self.config.opt_testmodule(sibpath('novars.py')) self.assertEqual(0, len(self.config['tests'])) def test_testmoduleOnModuleName(self): """ Check that --testmodule does *not* support module names as arguments and that it displays a meaningful error message. """ buffy = StringIO.StringIO() stderr, sys.stderr = sys.stderr, buffy moduleName = 'twisted.trial.test.test_script' try: self.config.opt_testmodule(moduleName) self.assertEqual(0, len(self.config['tests'])) self.assertEqual("File %r doesn't exist\n" % (moduleName,), buffy.getvalue()) finally: sys.stderr = stderr def test_parseLocalVariable(self): declaration = '-*- test-case-name: twisted.trial.test.test_tests -*-' localVars = trial._parseLocalVariables(declaration) self.assertEqual({'test-case-name': 'twisted.trial.test.test_tests'}, localVars) def test_trailingSemicolon(self): declaration = '-*- test-case-name: twisted.trial.test.test_tests; -*-' localVars = trial._parseLocalVariables(declaration) self.assertEqual({'test-case-name': 'twisted.trial.test.test_tests'}, localVars) def test_parseLocalVariables(self): declaration = ('-*- test-case-name: twisted.trial.test.test_tests; ' 'foo: bar -*-') localVars = trial._parseLocalVariables(declaration) self.assertEqual({'test-case-name': 'twisted.trial.test.test_tests', 'foo': 'bar'}, localVars) def test_surroundingGuff(self): declaration = ('## -*- test-case-name: ' 'twisted.trial.test.test_tests -*- #') localVars = trial._parseLocalVariables(declaration) self.assertEqual({'test-case-name': 'twisted.trial.test.test_tests'}, localVars) def test_invalidLine(self): self.failUnlessRaises(ValueError, trial._parseLocalVariables, 'foo') def test_invalidDeclaration(self): self.failUnlessRaises(ValueError, trial._parseLocalVariables, '-*- foo -*-') self.failUnlessRaises(ValueError, trial._parseLocalVariables, '-*- foo: bar; qux -*-') self.failUnlessRaises(ValueError, trial._parseLocalVariables, '-*- foo: bar: baz; qux: qax -*-') def test_variablesFromFile(self): localVars = trial.loadLocalVariables(sibpath('moduletest.py')) self.assertEqual({'test-case-name': 'twisted.trial.test.test_log'}, localVars) def test_noVariablesInFile(self): localVars = trial.loadLocalVariables(sibpath('novars.py')) self.assertEqual({}, localVars) def test_variablesFromScript(self): localVars = trial.loadLocalVariables(sibpath('scripttest.py')) self.assertEqual( {'test-case-name': ('twisted.trial.test.test_log,' 'twisted.trial.test.test_class')}, localVars) def test_getTestModules(self): modules = trial.getTestModules(sibpath('moduletest.py')) self.assertEqual(modules, ['twisted.trial.test.test_log']) def test_getTestModules_noVars(self): modules = trial.getTestModules(sibpath('novars.py')) self.assertEqual(len(modules), 0) def test_getTestModules_multiple(self): modules = trial.getTestModules(sibpath('scripttest.py')) self.assertEqual(set(modules), set(['twisted.trial.test.test_log', 'twisted.trial.test.test_class'])) def test_looksLikeTestModule(self): for filename in ['test_script.py', 'twisted/trial/test/test_script.py']: self.failUnless(trial.isTestFile(filename), "%r should be a test file" % (filename,)) for filename in ['twisted/trial/test/moduletest.py', sibpath('scripttest.py'), sibpath('test_foo.bat')]: self.failIf(trial.isTestFile(filename), "%r should *not* be a test file" % (filename,)) class WithoutModuleTests(unittest.SynchronousTestCase): """ Test the C{without-module} flag. """ def setUp(self): """ Create a L{trial.Options} object to be used in the tests, and save C{sys.modules}. """ self.config = trial.Options() self.savedModules = dict(sys.modules) def tearDown(self): """ Restore C{sys.modules}. """ for module in ('imaplib', 'smtplib'): if module in self.savedModules: sys.modules[module] = self.savedModules[module] else: sys.modules.pop(module, None) def _checkSMTP(self): """ Try to import the C{smtplib} module, and return it. """ import smtplib return smtplib def _checkIMAP(self): """ Try to import the C{imaplib} module, and return it. """ import imaplib return imaplib def test_disableOneModule(self): """ Check that after disabling a module, it can't be imported anymore. """ self.config.parseOptions(["--without-module", "smtplib"]) self.assertRaises(ImportError, self._checkSMTP) # Restore sys.modules del sys.modules["smtplib"] # Then the function should succeed self.assertIsInstance(self._checkSMTP(), types.ModuleType) def test_disableMultipleModules(self): """ Check that several modules can be disabled at once. """ self.config.parseOptions(["--without-module", "smtplib,imaplib"]) self.assertRaises(ImportError, self._checkSMTP) self.assertRaises(ImportError, self._checkIMAP) # Restore sys.modules del sys.modules["smtplib"] del sys.modules["imaplib"] # Then the functions should succeed self.assertIsInstance(self._checkSMTP(), types.ModuleType) self.assertIsInstance(self._checkIMAP(), types.ModuleType) def test_disableAlreadyImportedModule(self): """ Disabling an already imported module should produce a warning. """ self.assertIsInstance(self._checkSMTP(), types.ModuleType) self.assertWarns(RuntimeWarning, "Module 'smtplib' already imported, disabling anyway.", trial.__file__, self.config.parseOptions, ["--without-module", "smtplib"]) self.assertRaises(ImportError, self._checkSMTP) class CoverageTests(unittest.SynchronousTestCase): """ Tests for the I{coverage} option. """ if getattr(sys, 'gettrace', None) is None: skip = ( "Cannot test trace hook installation without inspection API.") def setUp(self): """ Arrange for the current trace hook to be restored when the test is complete. """ self.addCleanup(sys.settrace, sys.gettrace()) def test_tracerInstalled(self): """ L{trial.Options} handles C{"--coverage"} by installing a trace hook to record coverage information. """ options = trial.Options() options.parseOptions(["--coverage"]) self.assertEqual(sys.gettrace(), options.tracer.globaltrace) def test_coverdirDefault(self): """ L{trial.Options.coverdir} returns a L{FilePath} based on the default for the I{temp-directory} option if that option is not specified. """ options = trial.Options() self.assertEqual( options.coverdir(), FilePath(".").descendant([options["temp-directory"], "coverage"])) def test_coverdirOverridden(self): """ If a value is specified for the I{temp-directory} option, L{trial.Options.coverdir} returns a child of that path. """ path = self.mktemp() options = trial.Options() options.parseOptions(["--temp-directory", path]) self.assertEqual( options.coverdir(), FilePath(path).child("coverage")) class OptionsTestCase(unittest.TestCase): """ Tests for L{trial.Options}. """ def setUp(self): """ Build an L{Options} object to be used in the tests. """ self.options = trial.Options() def test_getWorkerArguments(self): """ C{_getWorkerArguments} discards options like C{random} as they only matter in the manager, and forwards options like C{recursionlimit} or C{disablegc}. """ self.addCleanup(sys.setrecursionlimit, sys.getrecursionlimit()) if gc.isenabled(): self.addCleanup(gc.enable) self.options.parseOptions(["--recursionlimit", "2000", "--random", "4", "--disablegc"]) args = self.options._getWorkerArguments() self.assertIn("--disablegc", args) args.remove("--disablegc") self.assertEqual(["--recursionlimit", "2000"], args) def test_jobsConflictWithDebug(self): """ C{parseOptions} raises a C{UsageError} when C{--debug} is passed along C{--jobs} as it's not supported yet. @see: U{http://twistedmatrix.com/trac/ticket/5825} """ error = self.assertRaises( UsageError, self.options.parseOptions, ["--jobs", "4", "--debug"]) self.assertEqual("You can't specify --debug when using --jobs", str(error)) def test_jobsConflictWithProfile(self): """ C{parseOptions} raises a C{UsageError} when C{--profile} is passed along C{--jobs} as it's not supported yet. @see: U{http://twistedmatrix.com/trac/ticket/5827} """ error = self.assertRaises( UsageError, self.options.parseOptions, ["--jobs", "4", "--profile"]) self.assertEqual("You can't specify --profile when using --jobs", str(error)) def test_jobsConflictWithDebugStackTraces(self): """ C{parseOptions} raises a C{UsageError} when C{--debug-stacktraces} is passed along C{--jobs} as it's not supported yet. @see: U{http://twistedmatrix.com/trac/ticket/5826} """ error = self.assertRaises( UsageError, self.options.parseOptions, ["--jobs", "4", "--debug-stacktraces"]) self.assertEqual( "You can't specify --debug-stacktraces when using --jobs", str(error)) def test_jobsConflictWithExitFirst(self): """ C{parseOptions} raises a C{UsageError} when C{--exitfirst} is passed along C{--jobs} as it's not supported yet. @see: U{http://twistedmatrix.com/trac/ticket/6436} """ error = self.assertRaises( UsageError, self.options.parseOptions, ["--jobs", "4", "--exitfirst"]) self.assertEqual( "You can't specify --exitfirst when using --jobs", str(error)) def test_orderConflictWithRandom(self): """ C{parseOptions} raises a C{UsageError} when C{--order} is passed along with C{--random}. """ error = self.assertRaises( UsageError, self.options.parseOptions, ["--order", "alphabetical", "--random", "1234"]) self.assertEqual("You can't specify --random when using --order", str(error)) class MakeRunnerTestCase(unittest.TestCase): """ Tests for the L{_makeRunner} helper. """ def setUp(self): self.options = trial.Options() def test_jobs(self): """ L{_makeRunner} returns a L{DistTrialRunner} instance when the C{--jobs} option is passed, and passes the C{workerNumber} and C{workerArguments} parameters to it. """ self.options.parseOptions(["--jobs", "4", "--force-gc"]) runner = trial._makeRunner(self.options) self.assertIsInstance(runner, DistTrialRunner) self.assertEqual(4, runner._workerNumber) self.assertEqual(["--force-gc"], runner._workerArguments) def test_dryRunWithJobs(self): """ L{_makeRunner} returns a L{TrialRunner} instance in C{DRY_RUN} mode when the C{--dry-run} option is passed, even if C{--jobs} is set. """ self.options.parseOptions(["--jobs", "4", "--dry-run"]) runner = trial._makeRunner(self.options) self.assertIsInstance(runner, TrialRunner) self.assertEqual(TrialRunner.DRY_RUN, runner.mode) def test_DebuggerNotFound(self): namedAny = trial.reflect.namedAny def namedAnyExceptdoNotFind(fqn): if fqn == "doNotFind": raise trial.reflect.ModuleNotFound(fqn) return namedAny(fqn) self.patch(trial.reflect, "namedAny", namedAnyExceptdoNotFind) options = trial.Options() options.parseOptions(["--debug", "--debugger", "doNotFind"]) self.assertRaises(trial._DebuggerNotFound, trial._makeRunner, options) def test_exitfirst(self): """ Passing C{--exitfirst} wraps the reporter with a L{reporter._ExitWrapper} that stops on any non-success. """ self.options.parseOptions(["--exitfirst"]) runner = trial._makeRunner(self.options) self.assertTrue(runner._exitFirst) class TestRun(unittest.TestCase): """ Tests for the L{run} function. """ def setUp(self): # don't re-parse cmdline options, because if --reactor was passed to # the test run trial will try to restart the (already running) reactor self.patch(trial.Options, "parseOptions", lambda self: None) def test_debuggerNotFound(self): """ When a debugger is not found, an error message is printed to the user. """ def _makeRunner(*args, **kwargs): raise trial._DebuggerNotFound('foo') self.patch(trial, "_makeRunner", _makeRunner) try: trial.run() except SystemExit as e: self.assertIn("foo", str(e)) else: self.fail("Should have exited due to non-existent debugger!") class TestArgumentOrderTests(unittest.TestCase): """ Tests for the order-preserving behavior on provided command-line tests. """ def setUp(self): self.config = trial.Options() self.loader = TestLoader() def test_preserveArgumentOrder(self): """ Multiple tests passed on the command line are not reordered. """ tests = [ "twisted.trial.test.test_tests", "twisted.trial.test.test_assertions", "twisted.trial.test.test_deferreds", ] self.config.parseOptions(tests) suite = trial._getSuite(self.config) names = testNames(suite) expectedSuite = TestSuite(map(self.loader.loadByName, tests)) expectedNames = testNames(expectedSuite) self.assertEqual(names, expectedNames) class OrderTests(unittest.TestCase): """ Tests for the --order option. """ def setUp(self): self.config = trial.Options() def test_alphabetical(self): """ --order=alphabetical causes trial to run tests alphabetically within each test case. """ self.config.parseOptions([ "--order", "alphabetical", "twisted.trial.test.ordertests.FooTest"]) loader = trial._getLoader(self.config) suite = loader.loadByNames(self.config['tests']) self.assertEqual( testNames(suite), [ 'twisted.trial.test.ordertests.FooTest.test_first', 'twisted.trial.test.ordertests.FooTest.test_fourth', 'twisted.trial.test.ordertests.FooTest.test_second', 'twisted.trial.test.ordertests.FooTest.test_third']) def test_alphabeticalModule(self): """ --order=alphabetical causes trial to run test classes within a given module alphabetically. """ self.config.parseOptions([ "--order", "alphabetical", "twisted.trial.test.ordertests"]) loader = trial._getLoader(self.config) suite = loader.loadByNames(self.config['tests']) self.assertEqual( testNames(suite), [ 'twisted.trial.test.ordertests.BarTest.test_bar', 'twisted.trial.test.ordertests.BazTest.test_baz', 'twisted.trial.test.ordertests.FooTest.test_first', 'twisted.trial.test.ordertests.FooTest.test_fourth', 'twisted.trial.test.ordertests.FooTest.test_second', 'twisted.trial.test.ordertests.FooTest.test_third']) def test_alphabeticalPackage(self): """ --order=alphabetical causes trial to run test modules within a given package alphabetically, with tests within each module alphabetized. """ self.config.parseOptions([ "--order", "alphabetical", "twisted.trial.test"]) loader = trial._getLoader(self.config) suite = loader.loadByNames(self.config['tests']) names = testNames(suite) self.assertTrue(names, msg="Failed to load any tests!") self.assertEqual(names, sorted(names)) def test_toptobottom(self): """ --order=toptobottom causes trial to run test methods within a given test case from top to bottom as they are defined in the body of the class. """ self.config.parseOptions([ "--order", "toptobottom", "twisted.trial.test.ordertests.FooTest"]) loader = trial._getLoader(self.config) suite = loader.loadByNames(self.config['tests']) self.assertEqual( testNames(suite), [ 'twisted.trial.test.ordertests.FooTest.test_first', 'twisted.trial.test.ordertests.FooTest.test_second', 'twisted.trial.test.ordertests.FooTest.test_third', 'twisted.trial.test.ordertests.FooTest.test_fourth']) def test_toptobottomModule(self): """ --order=toptobottom causes trial to run test classes within a given module from top to bottom as they are defined in the module's source. """ self.config.parseOptions([ "--order", "toptobottom", "twisted.trial.test.ordertests"]) loader = trial._getLoader(self.config) suite = loader.loadByNames(self.config['tests']) self.assertEqual( testNames(suite), [ 'twisted.trial.test.ordertests.FooTest.test_first', 'twisted.trial.test.ordertests.FooTest.test_second', 'twisted.trial.test.ordertests.FooTest.test_third', 'twisted.trial.test.ordertests.FooTest.test_fourth', 'twisted.trial.test.ordertests.BazTest.test_baz', 'twisted.trial.test.ordertests.BarTest.test_bar']) def test_toptobottomPackage(self): """ --order=toptobottom causes trial to run test modules within a given package alphabetically, with tests within each module run top to bottom. """ self.config.parseOptions([ "--order", "toptobottom", "twisted.trial.test"]) loader = trial._getLoader(self.config) suite = loader.loadByNames(self.config['tests']) names = testNames(suite) # twisted.trial.test.test_module, so split and key on the first 4 to # get stable alphabetical sort on those self.assertEqual( names, sorted(names, key=lambda name : name.split(".")[:4]), ) def test_toptobottomMissingSource(self): """ --order=toptobottom detects the source line of methods from modules whose source file is missing. """ tempdir = self.mktemp().encode('utf-8') package = FilePath(tempdir).child(b'twisted_toptobottom_temp') package.makedirs() package.child(b'__init__.py').setContent(b'') package.child(b'test_missing.py').setContent(textwrap.dedent(b''' from twisted.trial.unittest import TestCase class TestMissing(TestCase): def test_second(self): pass def test_third(self): pass def test_fourth(self): pass def test_first(self): pass ''')) pathEntry = package.parent().path.decode('utf-8') sys.path.insert(0, pathEntry) self.addCleanup(sys.path.remove, pathEntry) from twisted_toptobottom_temp import test_missing self.addCleanup(sys.modules.pop, 'twisted_toptobottom_temp') self.addCleanup(sys.modules.pop, test_missing.__name__) package.child(b'test_missing.py').remove() self.config.parseOptions([ "--order", "toptobottom", "twisted.trial.test.ordertests"]) loader = trial._getLoader(self.config) suite = loader.loadModule(test_missing) self.assertEqual( testNames(suite), [ 'twisted_toptobottom_temp.test_missing.TestMissing.test_second', 'twisted_toptobottom_temp.test_missing.TestMissing.test_third', 'twisted_toptobottom_temp.test_missing.TestMissing.test_fourth', 'twisted_toptobottom_temp.test_missing.TestMissing.test_first']) def test_unknownOrder(self): """ An unknown order passed to --order raises a L{UsageError}. """ self.assertRaises( UsageError, self.config.parseOptions, ["--order", "I don't exist"]) class HelpOrderTests(unittest.TestCase): """ Tests for the --help-orders flag. """ def test_help_ordersPrintsSynopsisAndQuits(self): """ --help-orders prints each of the available orders and then exits. """ self.patch(sys, "stdout", StringIO.StringIO()) exc = self.assertRaises( SystemExit, trial.Options().parseOptions, ["--help-orders"]) self.assertEqual(exc.code, 0) output = sys.stdout.getvalue() msg = "%r with its description not properly described in %r" for orderName, (orderDesc, _) in trial._runOrders.items(): match = re.search( "%s.*%s" % (re.escape(orderName), re.escape(orderDesc)), output, ) self.assertTrue(match, msg=msg % (orderName, output))
bsd-3-clause
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 646, 5228, 199, 646, 9486, 199, 646, 295, 199, 646, 984, 199, 646, 13390, 199, 646, 2943, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 14443, 14, 5933, 492, 334, 272, 377, 1383, 7446, 12, 20979, 12, 1487, 9853, 857, 10591, 12, 1379, 5455, 9, 199, 504, 7390, 14, 14443, 423, 2686, 14, 2686, 14443, 492, 10113, 52, 1383, 7446, 199, 504, 7390, 14, 6429, 492, 16324, 199, 504, 7390, 14, 1548, 492, 4884, 199, 504, 7390, 14, 1548, 14, 3807, 492, 11028, 547, 199, 504, 7390, 14, 1548, 14, 7218, 492, 27961, 199, 199, 504, 7390, 14, 14443, 14, 396, 14, 396, 63, 3422, 492, 511, 5866, 199, 199, 647, 3248, 275, 636, 646, 19734, 2796, 358, 421, 199, 318, 20417, 515, 8, 1501, 304, 272, 408, 272, 2104, 17196, 1584, 315, 7390, 15, 14443, 15, 396, 272, 408, 272, 372, 4884, 14, 6637, 515, 3460, 493, 3108, 1788, 9, 4388, 199, 533, 18771, 39, 13094, 7768, 8, 2796, 14, 51, 9865, 1746, 304, 272, 408, 272, 6496, 367, 314, 1553, 3990, 13, 9493, 945, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 888, 275, 16324, 14, 4558, 342, 267, 291, 14, 793, 275, 942, 267, 291, 14, 2068, 8, 9493, 12, 283, 7112, 297, 291, 14, 7112, 9, 267, 511, 275, 1134, 3248, 14, 3481, 1746, 8, 277, 14, 4129, 774, 9, 267, 291, 14, 396, 275, 20979, 779, 396, 12, 511, 566, 2378, 347, 3486, 774, 8, 277, 304, 267, 408, 267, 437, 3486, 511, 1083, 626, 5767, 626, 652, 1990, 1255, 14, 267, 408, 267, 291, 14, 793, 14, 740, 360, 396, 358, 2378, 347, 8775, 8, 277, 304, 267, 408, 267, 437, 8343, 367, 9486, 14, 7112, 626, 9610, 4882, 370, 6337, 14, 267, 408, 267, 291, 14, 793, 14, 740, 360, 7112, 358, 2378, 347, 1852, 7446, 8, 277, 304, 267, 408, 267, 1432, 282, 491, 91, 52, 1383, 7446, 93, 909, 626, 365, 5048, 370, 675, 315, 2295, 14, 267, 408, 267, 7876, 275, 16324, 423, 1875, 7446, 8, 277, 14, 888, 9, 267, 7876, 14, 1745, 275, 5228, 14, 6424, 342, 267, 372, 7876, 2378, 347, 511, 63, 3990, 39, 67, 8, 277, 304, 267, 408, 267, 31755, 314, 1553, 3990, 13, 9493, 945, 370, 314, 16324, 2884, 25983, 314, 17516, 267, 14910, 370, 1255, 2544, 436, 2410, 1924, 511, 14, 267, 408, 267, 291, 14, 888, 459, 3990, 13, 9493, 418, 275, 715, 267, 291, 14, 888, 14, 1932, 4558, 342, 267, 7876, 275, 291, 14, 1875, 7446, 342, 267, 7876, 14, 1065, 8, 277, 14, 396, 9, 267, 291, 14, 629, 8, 277, 14, 793, 12, 788, 7112, 297, 283, 396, 297, 283, 7112, 297, 2511, 283, 7112, 297, 283, 396, 297, 283, 7112, 1105, 2378, 347, 511, 63, 324, 3990, 39, 67, 8, 277, 304, 267, 408, 267, 4885, 849, 12, 949, 17516, 3245, 365, 19565, 14, 267, 408, 267, 291, 14, 888, 14, 1932, 4558, 342, 267, 7876, 275, 291, 14, 1875, 7446, 342, 267, 7876, 14, 1065, 8, 277, 14, 396, 9, 267, 291, 14, 629, 8, 277, 14, 793, 12, 788, 396, 297, 283, 396, 1105, 4388, 199, 533, 20979, 9167, 8, 2796, 14, 51, 9865, 1746, 304, 272, 408, 272, 2670, 314, 4637, 402, 2295, 5241, 1202, 701, 314, 5077, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 16324, 2897, 909, 14, 267, 408, 267, 291, 14, 888, 275, 16324, 14, 4558, 342, 2378, 347, 511, 63, 885, 6207, 8, 277, 304, 267, 408, 267, 4885, 849, 12, 314, 5077, 1077, 675, 491, 91, 872, 9853, 857, 10591, 93, 267, 408, 267, 5077, 275, 16324, 423, 362, 5455, 8, 277, 14, 888, 9, 267, 291, 14, 629, 8, 3422, 14, 5768, 2927, 12, 1487, 9853, 857, 10591, 9, 2378, 347, 511, 63, 8111, 6782, 6207, 8, 277, 304, 267, 408, 267, 710, 445, 91, 8111, 13, 5328, 93, 2897, 4440, 314, 491, 91, 10591, 93, 370, 4215, 267, 4454, 19708, 9371, 7858, 14, 267, 408, 267, 291, 14, 888, 459, 8111, 13, 5328, 418, 275, 715, 267, 5077, 275, 16324, 423, 362, 5455, 8, 277, 14, 888, 9, 267, 291, 14, 629, 8, 3422, 14, 5768, 2927, 12, 20979, 9, 4388, 199, 533, 1379, 2377, 774, 8, 2796, 14, 51, 9865, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 888, 275, 16324, 14, 4558, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 888, 275, 488, 339, 347, 511, 63, 396, 5866, 8, 277, 304, 267, 408, 267, 2670, 626, 314, 511, 5866, 5922, 1083, 1066, 895, 13824, 8775, 83, 314, 267, 1561, 402, 2295, 315, 5241, 14, 267, 408, 267, 291, 14, 629, 8, 396, 5866, 8, 277, 395, 359, 277, 14, 344, 9383, 339, 347, 702, 24458, 591, 8, 277, 12, 511, 17, 12, 1561, 304, 267, 5077, 275, 1379, 5455, 342, 267, 1561, 17, 275, 511, 5866, 8, 396, 17, 9, 267, 1561, 18, 275, 511, 5866, 8, 10591, 8, 1130, 8, 3422, 14, 912, 11190, 12, 1561, 1724, 267, 1561, 17, 14, 3191, 342, 267, 1561, 18, 14, 3191, 342, 267, 291, 14, 629, 8, 1247, 17, 12, 1561, 18, 9, 339, 347, 511, 63, 1095, 2223, 8, 277, 304, 267, 291, 14, 629, 8, 16, 12, 822, 8, 277, 14, 888, 459, 2219, 5156, 339, 347, 511, 63, 396, 578, 3314, 2377, 8, 277, 304, 267, 408, 267, 2670, 626, 1553, 396, 578, 14404, 282, 5241, 1314, 3509, 314, 2295, 267, 25713, 370, 315, 511, 13, 2546, 13, 354, 6272, 2399, 2725, 14, 267, 408, 267, 291, 14, 888, 14, 2992, 63, 396, 578, 8, 6637, 515, 360, 578, 396, 14, 647, 1333, 267, 291, 14, 479, 24458, 591, 8, 14443, 423, 362, 6207, 8, 277, 14, 888, 395, 3044, 788, 12145, 14, 14443, 14, 396, 14, 396, 63, 793, 1105, 339, 347, 511, 63, 396, 578, 22879, 1885, 8, 277, 304, 267, 408, 267, 3979, 314, 2011, 859, 365, 2013, 543, 2877, 1553, 396, 578, 3285, 12 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 646, 5228, 199, 646, 9486, 199, 646, 295, 199, 646, 984, 199, 646, 13390, 199, 646, 2943, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 504, 7390, 14, 14443, 14, 5933, 492, 334, 272, 377, 1383, 7446, 12, 20979, 12, 1487, 9853, 857, 10591, 12, 1379, 5455, 9, 199, 504, 7390, 14, 14443, 423, 2686, 14, 2686, 14443, 492, 10113, 52, 1383, 7446, 199, 504, 7390, 14, 6429, 492, 16324, 199, 504, 7390, 14, 1548, 492, 4884, 199, 504, 7390, 14, 1548, 14, 3807, 492, 11028, 547, 199, 504, 7390, 14, 1548, 14, 7218, 492, 27961, 199, 199, 504, 7390, 14, 14443, 14, 396, 14, 396, 63, 3422, 492, 511, 5866, 199, 199, 647, 3248, 275, 636, 646, 19734, 2796, 358, 421, 199, 318, 20417, 515, 8, 1501, 304, 272, 408, 272, 2104, 17196, 1584, 315, 7390, 15, 14443, 15, 396, 272, 408, 272, 372, 4884, 14, 6637, 515, 3460, 493, 3108, 1788, 9, 4388, 199, 533, 18771, 39, 13094, 7768, 8, 2796, 14, 51, 9865, 1746, 304, 272, 408, 272, 6496, 367, 314, 1553, 3990, 13, 9493, 945, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 888, 275, 16324, 14, 4558, 342, 267, 291, 14, 793, 275, 942, 267, 291, 14, 2068, 8, 9493, 12, 283, 7112, 297, 291, 14, 7112, 9, 267, 511, 275, 1134, 3248, 14, 3481, 1746, 8, 277, 14, 4129, 774, 9, 267, 291, 14, 396, 275, 20979, 779, 396, 12, 511, 566, 2378, 347, 3486, 774, 8, 277, 304, 267, 408, 267, 437, 3486, 511, 1083, 626, 5767, 626, 652, 1990, 1255, 14, 267, 408, 267, 291, 14, 793, 14, 740, 360, 396, 358, 2378, 347, 8775, 8, 277, 304, 267, 408, 267, 437, 8343, 367, 9486, 14, 7112, 626, 9610, 4882, 370, 6337, 14, 267, 408, 267, 291, 14, 793, 14, 740, 360, 7112, 358, 2378, 347, 1852, 7446, 8, 277, 304, 267, 408, 267, 1432, 282, 491, 91, 52, 1383, 7446, 93, 909, 626, 365, 5048, 370, 675, 315, 2295, 14, 267, 408, 267, 7876, 275, 16324, 423, 1875, 7446, 8, 277, 14, 888, 9, 267, 7876, 14, 1745, 275, 5228, 14, 6424, 342, 267, 372, 7876, 2378, 347, 511, 63, 3990, 39, 67, 8, 277, 304, 267, 408, 267, 31755, 314, 1553, 3990, 13, 9493, 945, 370, 314, 16324, 2884, 25983, 314, 17516, 267, 14910, 370, 1255, 2544, 436, 2410, 1924, 511, 14, 267, 408, 267, 291, 14, 888, 459, 3990, 13, 9493, 418, 275, 715, 267, 291, 14, 888, 14, 1932, 4558, 342, 267, 7876, 275, 291, 14, 1875, 7446, 342, 267, 7876, 14, 1065, 8, 277, 14, 396, 9, 267, 291, 14, 629, 8, 277, 14, 793, 12, 788, 7112, 297, 283, 396, 297, 283, 7112, 297, 2511, 283, 7112, 297, 283, 396, 297, 283, 7112, 1105, 2378, 347, 511, 63, 324, 3990, 39, 67, 8, 277, 304, 267, 408, 267, 4885, 849, 12, 949, 17516, 3245, 365, 19565, 14, 267, 408, 267, 291, 14, 888, 14, 1932, 4558, 342, 267, 7876, 275, 291, 14, 1875, 7446, 342, 267, 7876, 14, 1065, 8, 277, 14, 396, 9, 267, 291, 14, 629, 8, 277, 14, 793, 12, 788, 396, 297, 283, 396, 1105, 4388, 199, 533, 20979, 9167, 8, 2796, 14, 51, 9865, 1746, 304, 272, 408, 272, 2670, 314, 4637, 402, 2295, 5241, 1202, 701, 314, 5077, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 408, 267, 2790, 282, 16324, 2897, 909, 14, 267, 408, 267, 291, 14, 888, 275, 16324, 14, 4558, 342, 2378, 347, 511, 63, 885, 6207, 8, 277, 304, 267, 408, 267, 4885, 849, 12, 314, 5077, 1077, 675, 491, 91, 872, 9853, 857, 10591, 93, 267, 408, 267, 5077, 275, 16324, 423, 362, 5455, 8, 277, 14, 888, 9, 267, 291, 14, 629, 8, 3422, 14, 5768, 2927, 12, 1487, 9853, 857, 10591, 9, 2378, 347, 511, 63, 8111, 6782, 6207, 8, 277, 304, 267, 408, 267, 710, 445, 91, 8111, 13, 5328, 93, 2897, 4440, 314, 491, 91, 10591, 93, 370, 4215, 267, 4454, 19708, 9371, 7858, 14, 267, 408, 267, 291, 14, 888, 459, 8111, 13, 5328, 418, 275, 715, 267, 5077, 275, 16324, 423, 362, 5455, 8, 277, 14, 888, 9, 267, 291, 14, 629, 8, 3422, 14, 5768, 2927, 12, 20979, 9, 4388, 199, 533, 1379, 2377, 774, 8, 2796, 14, 51, 9865, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 888, 275, 16324, 14, 4558, 342, 339, 347, 6766, 8, 277, 304, 267, 291, 14, 888, 275, 488, 339, 347, 511, 63, 396, 5866, 8, 277, 304, 267, 408, 267, 2670, 626, 314, 511, 5866, 5922, 1083, 1066, 895, 13824, 8775, 83, 314, 267, 1561, 402, 2295, 315, 5241, 14, 267, 408, 267, 291, 14, 629, 8, 396, 5866, 8, 277, 395, 359, 277, 14, 344, 9383, 339, 347, 702, 24458, 591, 8, 277, 12, 511, 17, 12, 1561, 304, 267, 5077, 275, 1379, 5455, 342, 267, 1561, 17, 275, 511, 5866, 8, 396, 17, 9, 267, 1561, 18, 275, 511, 5866, 8, 10591, 8, 1130, 8, 3422, 14, 912, 11190, 12, 1561, 1724, 267, 1561, 17, 14, 3191, 342, 267, 1561, 18, 14, 3191, 342, 267, 291, 14, 629, 8, 1247, 17, 12, 1561, 18, 9, 339, 347, 511, 63, 1095, 2223, 8, 277, 304, 267, 291, 14, 629, 8, 16, 12, 822, 8, 277, 14, 888, 459, 2219, 5156, 339, 347, 511, 63, 396, 578, 3314, 2377, 8, 277, 304, 267, 408, 267, 2670, 626, 1553, 396, 578, 14404, 282, 5241, 1314, 3509, 314, 2295, 267, 25713, 370, 315, 511, 13, 2546, 13, 354, 6272, 2399, 2725, 14, 267, 408, 267, 291, 14, 888, 14, 2992, 63, 396, 578, 8, 6637, 515, 360, 578, 396, 14, 647, 1333, 267, 291, 14, 479, 24458, 591, 8, 14443, 423, 362, 6207, 8, 277, 14, 888, 395, 3044, 788, 12145, 14, 14443, 14, 396, 14, 396, 63, 793, 1105, 339, 347, 511, 63, 396, 578, 22879, 1885, 8, 277, 304, 267, 408, 267, 3979, 314, 2011, 859, 365, 2013, 543, 2877, 1553, 396, 578, 3285, 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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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 ]
kodibrasil/xbmc
lib/libUPnP/Neptune/Extras/Scripts/GenTrustAnchorsTables.py
264
5364
#! /usr/bin/env python ### ### Generate trust anchor tables from a text file ### like, for example, TLS-Trust-Anchors-base.crt ## and TLS-Trust-Anchors-extended.crt located under Extras/Data ### ### imports import sys import base64 ### generate a C file with bult-in TLS trust anchors FILE_HEADER = """/***************************************************************** | | Neptune - Trust Anchors | | This file is automatically generated by a script, do not edit! | | Copyright (c) 2002-2010, Axiomatic Systems, LLC. | 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 Axiomatic Systems 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 AXIOMATIC SYSTEMS ''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 AXIOMATIC SYSTEMS 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. | ****************************************************************/ """ if len(sys.argv) != 3: print "usage: GenTrustAnchosTable.py <input-file> <category>" print " where category may be 'Base', 'Extended', or other" sys.exit(1) INPUT_FILE = sys.argv[1] CERT_CATEGORY = sys.argv[2] digest_oid_pattern = "\x2a\x86\x48\x86\xf7\x0d\x01\x01" in_cert = False prev = '' prev_prev = '' index = 0 Certs = [] CertNames = [] CertComments = [] for line in open(sys.argv[1]).readlines(): if line.startswith('-----BEGIN CERTIFICATE-----'): in_cert = True b64 = '' continue; if line.startswith('-----END CERTIFICATE-----'): cert = base64.decodestring(b64); if not digest_oid_pattern in cert: sys.stderr.write("-------- skipping cert (digest not supported) -------\n") continue Certs.append(cert) cert_name = 'NptTlsTrustAnchor_%s_%04d' % (CERT_CATEGORY, index) #cert_comment = eval('"'+prev_prev.rstrip('\r\n')+'"') cert_comment = prev_prev.rstrip('\r\n') CertNames.append(cert_name) CertComments.append(cert_comment) out = open(CERT_CATEGORY+'/'+cert_name+'.cpp', 'w+b') out.write(FILE_HEADER) out.write('/* %s */\n' % (cert_comment)) out.write('const unsigned char %s_Data[%d] = {\n' % (cert_name, len(cert))) counter = 0 sep = '' for byte in cert: out.write('%s0x%02x' % (sep, ord(byte))) counter += 1 sep = ',' if counter == 8: out.write('\n') counter = 0 in_cert = False out.write('};\n') out.write('const unsigned int %s_Size = %d;\n' % (cert_name, len(cert))) index += 1 out.close() continue if in_cert: b64 += line.rstrip('\r\n') else: prev_prev = prev prev = line out = open('NptTlsDefaultTrustAnchors'+CERT_CATEGORY+'.cpp', 'w+b') out.write(FILE_HEADER) out.write("/* This file is automatically generated by GenTrustAnchorsTables.py, do not edit */\n\n") out.write('#include "NptTls.h"\n') total_size = 0 for i in xrange(0, len(CertNames)): out.write('#include "'+CERT_CATEGORY+'/'+CertNames[i]+'.cpp" /* '+CertComments[i]+' */\n') total_size += len(Certs[i]) out.write("/* total anchors size ="+ str(total_size)+" */\n\n") out.write('const NPT_TlsTrustAnchorData NptTlsDefaultTrustAnchors%s[%s] = {\r\n' % (CERT_CATEGORY, 1+len(Certs))) sep = ' ' for i in xrange(0, len(Certs)): out.write('%s{ %s_Data, %s_Size} /* %s */' % (sep, CertNames[i], CertNames[i], CertComments[i])) sep = ',\r\n ' out.write(sep+'{0, 0} /* sentinel */\n') out.write('};\n') out.close() out = open('NptTlsDefaultTrustAnchors'+CERT_CATEGORY+'.h', 'w+b') out.write(FILE_HEADER) out.write("/* This file is automatically generated by GenTrustAnchorsTables.py, do not edit */\n\n") out.write('#include "NptTls.h"\n\n') out.write('extern const NPT_TlsTrustAnchorData NptTlsDefaultTrustAnchors%s[%d];\n\n' % (CERT_CATEGORY, 1+len(Certs))) for i in xrange(0, len(CertNames)): out.write('/* '+CertComments[i]+' */\n') out.write('extern const unsigned int %s_Size;\n' % (CertNames[i])) out.write('extern const unsigned char %s_Data[];\n\n' % (CertNames[i])) out.close()
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 5680, 199, 5680, 7958, 16822, 12514, 6716, 687, 282, 1318, 570, 199, 5680, 2839, 12, 367, 2893, 12, 12213, 13, 14064, 833, 13, 2493, 18506, 13, 1095, 14, 16617, 199, 309, 436, 12213, 13, 14064, 833, 13, 2493, 18506, 13, 10525, 14, 16617, 16180, 1334, 7255, 6360, 15, 1451, 199, 5680, 199, 199, 5680, 8925, 199, 646, 984, 199, 646, 1300, 772, 199, 199, 5680, 3550, 282, 445, 570, 543, 330, 427, 13, 262, 12213, 16822, 32682, 199, 3817, 63, 7311, 275, 408, 15, 12360, 10, 199, 92, 199, 92, 257, 5612, 541, 11474, 446, 377, 19622, 1626, 18506, 199, 92, 199, 92, 257, 961, 570, 365, 5847, 4046, 701, 282, 2884, 12, 886, 440, 5283, 1, 199, 92, 199, 92, 1898, 334, 67, 9, 14790, 13, 6542, 12, 437, 88, 2308, 3889, 15285, 12, 20376, 14, 199, 92, 2900, 4481, 4644, 14, 199, 92, 199, 92, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 92, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 92, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 92, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 92, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 92, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 92, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 92, 258, 627, 11443, 314, 536, 402, 437, 88, 2308, 3889, 15285, 6590, 314, 199, 92, 755, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 92, 755, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 92, 199, 92, 5749, 4141, 2281, 7049, 6515, 437, 56, 2090, 16996, 948, 29978, 2125, 1179, 2281, 891, 2401, 1821, 199, 92, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 92, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 92, 9706, 14, 1621, 4825, 6461, 7000, 437, 56, 2090, 16996, 948, 29978, 6262, 7024, 2381, 1821, 199, 92, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 92, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 92, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 92, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 92, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 92, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 92, 199, 1011, 5815, 30948, 26537, 15, 421, 408, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 272, 870, 298, 3807, 26, 18870, 14064, 833, 2493, 335, 736, 3186, 14, 647, 665, 1210, 13, 493, 30, 665, 3710, 4335, 272, 870, 298, 2382, 4637, 1443, 506, 283, 1563, 297, 283, 14107, 297, 503, 1163, 2, 272, 984, 14, 2224, 8, 17, 9, 1362, 199, 7321, 63, 3817, 275, 984, 14, 3020, 59, 17, 61, 199, 11163, 63, 22690, 275, 984, 14, 3020, 59, 18, 61, 199, 199, 5671, 63, 1170, 63, 3401, 275, 1867, 88, 18, 65, 60, 88, 1184, 60, 88, 2006, 60, 88, 1184, 60, 1949, 23, 60, 88, 16, 68, 60, 88, 614, 60, 88, 614, 2, 199, 199, 262, 63, 4736, 275, 756, 199, 5701, 275, 2125, 199, 5701, 63, 5701, 275, 2125, 199, 1080, 275, 378, 199, 7851, 1086, 275, 942, 199, 14768, 5866, 275, 942, 199, 14768, 18929, 275, 942, 199, 509, 1004, 315, 1551, 8, 1274, 14, 3020, 59, 17, 6575, 9684, 837, 272, 340, 1004, 14, 2460, 360, 9858, 15947, 28313, 29321, 9858, 735, 267, 315, 63, 4736, 275, 715, 267, 330, 772, 275, 2125, 267, 1980, 27, 272, 340, 1004, 14, 2460, 360, 9858, 3902, 28313, 29321, 9858, 735, 267, 6250, 275, 1300, 772, 14, 2708, 875, 8, 66, 772, 2736, 267, 340, 440, 10017, 63, 1170, 63, 3401, 315, 6250, 26, 288, 984, 14, 3083, 14, 952, 480, 518, 16068, 6250, 334, 5671, 440, 3748, 9, 5514, 60, 78, 531, 288, 1980, 267, 11002, 1086, 14, 740, 8, 4736, 9, 267, 6250, 63, 354, 275, 283, 46, 541, 52, 478, 14064, 833, 23517, 4970, 83, 4970, 966, 68, 7, 450, 334, 11163, 63, 22690, 12, 1478, 9, 267, 327, 4736, 63, 3349, 275, 3468, 360, 4507, 11, 5701, 63, 5701, 14, 6735, 2258, 82, 60, 78, 358, 11, 4065, 358, 267, 6250, 63, 3349, 275, 5071, 63, 5701, 14, 6735, 2258, 82, 60, 78, 358, 267, 11002, 84, 5866, 14, 740, 8, 4736, 63, 354, 9, 267, 11002, 84, 18929, 14, 740, 8, 4736, 63, 3349, 9, 267, 734, 275, 1551, 8, 11163, 63, 22690, 4786, 19047, 4736, 63, 354, 18098, 5910, 297, 283, 87, 11, 66, 358, 267, 734, 14, 952, 8, 3817, 63, 7311, 9, 267, 734, 14, 952, 2336, 10, 450, 83, 9399, 78, 7, 450, 334, 4736, 63, 3349, 430, 267, 734, 14, 952, 360, 1297, 7381, 1495, 450, 83, 63, 1451, 9722, 68, 61, 275, 9459, 78, 7, 450, 334, 4736, 63, 354, 12, 822, 8, 4736, 1724, 267, 7055, 275, 378, 267, 7375, 275, 2125, 267, 367, 3696, 315, 6250, 26, 288, 734, 14, 952, 3508, 83, 16, 88, 5, 996, 88, 7, 450, 334, 4127, 12, 6206, 8, 4414, 1724, 288, 7055, 847, 413, 288, 7375, 275, 13647, 288, 340, 7055, 508, 1695, 26, 355, 734, 14, 952, 2258, 78, 358, 355, 7055, 275, 378, 267, 315, 63, 4736, 275, 756, 267, 734, 14, 952, 360, 16055, 78, 358, 267, 734, 14, 952, 360, 1297, 7381, 1109, 221, 450, 83, 63, 2320, 275, 450, 68, 3779, 78, 7, 450, 334, 4736, 63, 354, 12, 822, 8, 4736, 1724, 267, 1478, 847, 413, 267, 734, 14, 1600, 342, 267, 1980, 272, 340, 315, 63, 4736, 26, 267, 330, 772, 847, 1004, 14, 6735, 2258, 82, 60, 78, 358, 272, 587, 26, 267 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 5680, 199, 5680, 7958, 16822, 12514, 6716, 687, 282, 1318, 570, 199, 5680, 2839, 12, 367, 2893, 12, 12213, 13, 14064, 833, 13, 2493, 18506, 13, 1095, 14, 16617, 199, 309, 436, 12213, 13, 14064, 833, 13, 2493, 18506, 13, 10525, 14, 16617, 16180, 1334, 7255, 6360, 15, 1451, 199, 5680, 199, 199, 5680, 8925, 199, 646, 984, 199, 646, 1300, 772, 199, 199, 5680, 3550, 282, 445, 570, 543, 330, 427, 13, 262, 12213, 16822, 32682, 199, 3817, 63, 7311, 275, 408, 15, 12360, 10, 199, 92, 199, 92, 257, 5612, 541, 11474, 446, 377, 19622, 1626, 18506, 199, 92, 199, 92, 257, 961, 570, 365, 5847, 4046, 701, 282, 2884, 12, 886, 440, 5283, 1, 199, 92, 199, 92, 1898, 334, 67, 9, 14790, 13, 6542, 12, 437, 88, 2308, 3889, 15285, 12, 20376, 14, 199, 92, 2900, 4481, 4644, 14, 199, 92, 199, 92, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 92, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 92, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 92, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 92, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 92, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 92, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 92, 258, 627, 11443, 314, 536, 402, 437, 88, 2308, 3889, 15285, 6590, 314, 199, 92, 755, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 92, 755, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 92, 199, 92, 5749, 4141, 2281, 7049, 6515, 437, 56, 2090, 16996, 948, 29978, 2125, 1179, 2281, 891, 2401, 1821, 199, 92, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 92, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 92, 9706, 14, 1621, 4825, 6461, 7000, 437, 56, 2090, 16996, 948, 29978, 6262, 7024, 2381, 1821, 199, 92, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 199, 92, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 199, 92, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 199, 92, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 92, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 199, 92, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 92, 199, 1011, 5815, 30948, 26537, 15, 421, 408, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 272, 870, 298, 3807, 26, 18870, 14064, 833, 2493, 335, 736, 3186, 14, 647, 665, 1210, 13, 493, 30, 665, 3710, 4335, 272, 870, 298, 2382, 4637, 1443, 506, 283, 1563, 297, 283, 14107, 297, 503, 1163, 2, 272, 984, 14, 2224, 8, 17, 9, 1362, 199, 7321, 63, 3817, 275, 984, 14, 3020, 59, 17, 61, 199, 11163, 63, 22690, 275, 984, 14, 3020, 59, 18, 61, 199, 199, 5671, 63, 1170, 63, 3401, 275, 1867, 88, 18, 65, 60, 88, 1184, 60, 88, 2006, 60, 88, 1184, 60, 1949, 23, 60, 88, 16, 68, 60, 88, 614, 60, 88, 614, 2, 199, 199, 262, 63, 4736, 275, 756, 199, 5701, 275, 2125, 199, 5701, 63, 5701, 275, 2125, 199, 1080, 275, 378, 199, 7851, 1086, 275, 942, 199, 14768, 5866, 275, 942, 199, 14768, 18929, 275, 942, 199, 509, 1004, 315, 1551, 8, 1274, 14, 3020, 59, 17, 6575, 9684, 837, 272, 340, 1004, 14, 2460, 360, 9858, 15947, 28313, 29321, 9858, 735, 267, 315, 63, 4736, 275, 715, 267, 330, 772, 275, 2125, 267, 1980, 27, 272, 340, 1004, 14, 2460, 360, 9858, 3902, 28313, 29321, 9858, 735, 267, 6250, 275, 1300, 772, 14, 2708, 875, 8, 66, 772, 2736, 267, 340, 440, 10017, 63, 1170, 63, 3401, 315, 6250, 26, 288, 984, 14, 3083, 14, 952, 480, 518, 16068, 6250, 334, 5671, 440, 3748, 9, 5514, 60, 78, 531, 288, 1980, 267, 11002, 1086, 14, 740, 8, 4736, 9, 267, 6250, 63, 354, 275, 283, 46, 541, 52, 478, 14064, 833, 23517, 4970, 83, 4970, 966, 68, 7, 450, 334, 11163, 63, 22690, 12, 1478, 9, 267, 327, 4736, 63, 3349, 275, 3468, 360, 4507, 11, 5701, 63, 5701, 14, 6735, 2258, 82, 60, 78, 358, 11, 4065, 358, 267, 6250, 63, 3349, 275, 5071, 63, 5701, 14, 6735, 2258, 82, 60, 78, 358, 267, 11002, 84, 5866, 14, 740, 8, 4736, 63, 354, 9, 267, 11002, 84, 18929, 14, 740, 8, 4736, 63, 3349, 9, 267, 734, 275, 1551, 8, 11163, 63, 22690, 4786, 19047, 4736, 63, 354, 18098, 5910, 297, 283, 87, 11, 66, 358, 267, 734, 14, 952, 8, 3817, 63, 7311, 9, 267, 734, 14, 952, 2336, 10, 450, 83, 9399, 78, 7, 450, 334, 4736, 63, 3349, 430, 267, 734, 14, 952, 360, 1297, 7381, 1495, 450, 83, 63, 1451, 9722, 68, 61, 275, 9459, 78, 7, 450, 334, 4736, 63, 354, 12, 822, 8, 4736, 1724, 267, 7055, 275, 378, 267, 7375, 275, 2125, 267, 367, 3696, 315, 6250, 26, 288, 734, 14, 952, 3508, 83, 16, 88, 5, 996, 88, 7, 450, 334, 4127, 12, 6206, 8, 4414, 1724, 288, 7055, 847, 413, 288, 7375, 275, 13647, 288, 340, 7055, 508, 1695, 26, 355, 734, 14, 952, 2258, 78, 358, 355, 7055, 275, 378, 267, 315, 63, 4736, 275, 756, 267, 734, 14, 952, 360, 16055, 78, 358, 267, 734, 14, 952, 360, 1297, 7381, 1109, 221, 450, 83, 63, 2320, 275, 450, 68, 3779, 78, 7, 450, 334, 4736, 63, 354, 12, 822, 8, 4736, 1724, 267, 1478, 847, 413, 267, 734, 14, 1600, 342, 267, 1980, 272, 340, 315, 63, 4736, 26, 267, 330, 772, 847, 1004, 14, 6735, 2258, 82, 60, 78, 358, 272, 587, 26, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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