repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
sequencelengths
1.02k
1.02k
labels
sequencelengths
1.02k
1.02k
attention_mask
sequencelengths
1.02k
1.02k
gridcf/gct
myproxy/oauth/source/myproxyoauth/views.py
4
14096
# # Copyright 2010-2011 University of Chicago # # 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 socket import cgi import random import base64 import httplib import json import time import oauth2 as oauth import Crypto.PublicKey.RSA import myproxy import pkgutil import os import sys from myproxyoauth import application from myproxyoauth.database import db_session, Admin, Client, Transaction from urllib import quote def bad_request(start_response): status = "400 Bad Request" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers, sys.exc_info()) return "Bad request\n" def get_template(name): template_data = None if hasattr(pkgutil, "get_data"): template_data = pkgutil.get_data("myproxyoauth.templates", name) else: template_path = os.path.join( os.path.dirname(__file__), 'templates', name) template_file = file(template_path, "r") try: template_data = template_file.read() finally: template_file.close() return template_data def render_template(name, **kwargs): template = get_template(name) for template_token in kwargs: template = template.replace( "{{ " + template_token + " }}", kwargs[template_token]) return str(template) def url_reconstruct(environ): url = environ['wsgi.url_scheme']+'://' if environ.get('HTTP_HOST'): url += environ['HTTP_HOST'] else: url += environ['SERVER_NAME'] if environ['wsgi.url_scheme'] == 'https': if environ['SERVER_PORT'] != '443': url += ':' + environ['SERVER_PORT'] else: if environ['SERVER_PORT'] != '80': url += ':' + environ['SERVER_PORT'] url += quote(environ.get('SCRIPT_NAME', '')) url += quote(environ.get('PATH_INFO', '')) if environ.get('QUERY_STRING'): url += '?' + environ['QUERY_STRING'] return url @application.route('/test') def test(environ, start_response): status = "403 Forbidden" headers = [("Content-Type", "text/plain")] start_response(status, headers) return "bad" @application.teardown_request def shutdown_session(exception=None): db_session.remove() """ Implementation of OAuth for MyProxy Protocol, https://docs.google.com/document/pub?id=10SC7oSURc-EgxMQjcCS50gz0u2HzDJAFiG5hEHiSdxA """ @application.route('/initiate', methods=['GET']) def initiate(environ, start_response): try: request = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) oauth_signature_method = request.getvalue('oauth_signature_method') if oauth_signature_method is None: oauth_signature_method='RSA-SHA1' oauth_signature = str(request.getvalue('oauth_signature')) oauth_timestamp = int(request.getvalue('oauth_timestamp')) oauth_nonce = int(request.getvalue('oauth_nonce')) oauth_version = str(request.getvalue('oauth_version')) oauth_consumer_key = str(request.getvalue('oauth_consumer_key')) oauth_callback = str(request.getvalue('oauth_callback')) certlifetime = request.getvalue('certlifetime') if certlifetime is not None: certlifetime = int(certlifetime) else: certlifetime = 86400 clients = db_session.get_client(Client(oauth_consumer_key=oauth_consumer_key)) client = None if len(clients) > 0: client = clients[0] if client is None: application.logger.error('Unregistered client requested a temporary token.') status = "403 Not authorized" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers) return "Uregistered client" if hasattr(Crypto.PublicKey.RSA, 'importKey'): key = Crypto.PublicKey.RSA.importKey(client.oauth_client_pubkey) else: import M2Crypto.RSA import M2Crypto.BIO import struct import sys bio = M2Crypto.BIO.MemoryBuffer(str(client.oauth_client_pubkey)) k = None try: k = M2Crypto.RSA.load_pub_key_bio(bio) def unpack_from(fmt, data, offs): unpack_len = struct.calcsize(fmt) return struct.unpack(fmt, data[offs:offs+unpack_len]) def decode(n): len = reduce(lambda x,y: long(x*256+y), unpack_from("4B", n, 0)) return reduce(lambda x,y: long(x*256+y), unpack_from(str(len)+"B", n, 4)) keytuple = (decode(k.n), decode(k.e)) except: application.logger.error(str(sys.exc_info())) raise key = Crypto.PublicKey.RSA.construct(keytuple) method = environ['REQUEST_METHOD'] url = url_reconstruct(environ) o_request = oauth.Request.from_request(method, url) o_consumer = oauth.Consumer(client.oauth_consumer_key, key) o_server = oauth.Server() o_server.add_signature_method(oauth.SignatureMethod_RSA_SHA1()) try: o_server.verify_request(o_request, o_consumer, None) except: e = sys.exc_info() application.logger.error(str(e[1])) status = "403 Not authorized" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers, e) return str(e[1]) certreq = str(request.getvalue('certreq')) oauth_temp_token = 'myproxy:oa4mp,2012:/tempCred/' \ + ''.join([random.choice('0123456789abcdef') for i in range(32)]) \ + '/' + str(int(time.time())) transaction = Transaction() transaction.temp_token = oauth_temp_token transaction.temp_token_valid = 1 transaction.oauth_callback = oauth_callback transaction.certreq = certreq transaction.oauth_consumer_key = oauth_consumer_key transaction.certlifetime = certlifetime transaction.timestamp = int(time.time()) db_session.add_transaction(transaction) db_session.commit() status = "200 Ok" headers = [ ("Content-Type", "app/x-www-form-urlencoded") ] start_response(status, headers) return "oauth_token=%s&oauth_callback_confirmed=true" % oauth_temp_token except: return bad_request(start_response) @application.route('/authorize', methods=['GET']) def get_authorize(environ, start_response): try: request = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) oauth_temp_token = str(request.getvalue('oauth_token')) transactions = db_session.get_transaction( Transaction(temp_token=oauth_temp_token, temp_token_valid=1)) if len(transactions) == 0: status = "403 Not authorized" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers) return 'Invalid temporary token' transaction = transactions[0] clients = db_session.get_client(Client(oauth_consumer_key=transaction.oauth_consumer_key)) if len(clients) == 0: status = "403 Not authorized" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers) return 'Unregistered client' client = clients[0] transaction.temp_token_valid = 0 db_session.update_transaction(transaction) db_session.commit() styles = ['static/oauth.css'] css_path = os.path.join( os.path.dirname(__file__), 'static', 'site.css') if os.path.exists(css_path): styles.append("static/site.css") res = render_template('authorize.html', client_name=client.name, client_url=client.home_url, temp_token=oauth_temp_token, retry_message="", stylesheets="\n".join( [("<link rel='stylesheet' type='text/css' href='%s' >" % x) for x in styles])) status = "200 Ok" headers = [ ("Content-Type", "text/html")] start_response(status, headers) return res except: return bad_request(start_response) @application.route('/authorize', methods=['POST']) def post_authorize(environ, start_response): try: request = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) oauth_temp_token = str(request.getvalue('oauth_token')) username = str(request.getvalue('username')) passphrase = str(request.getvalue('passphrase')) transactions = db_session.get_transaction(Transaction(temp_token=oauth_temp_token)) transaction = None if len(transactions) > 0: transaction = transactions[0] clients = db_session.get_client(Client(oauth_consumer_key=transaction.oauth_consumer_key)) client = None if len(clients) > 0: client = clients[0] cert = None try: certreq = "-----BEGIN CERTIFICATE REQUEST-----\n" + str(transaction.certreq) + "-----END CERTIFICATE REQUEST-----\n" cert = myproxy.myproxy_logon(certreq, transaction.certlifetime, username, passphrase, client.myproxy_server) except: e = sys.exc_info() application.logger.error(str(e[1])) status = "200 Ok" headers = [ ("Content-Type", "text/html") ] styles = ['static/oauth.css'] css_path = os.path.join( os.path.dirname(__file__), 'static', 'site.css') if os.path.exists(css_path): styles.append("static/site.css") res = render_template('authorize.html', client_name=client.name, client_url=client.home_url, temp_token=oauth_temp_token, retry_message=str(e[1]), stylesheets="\n".join( [("<link rel='stylesheet' type='text/css' href='%s' >" % x) for x in styles])) start_response(status, headers, e) return res oauth_verifier = 'myproxy:oa4mp,2012:/verifier/' \ + ''.join([random.choice('0123456789abcdef') for i in range(32)]) \ + '/' + str(int(time.time())) transaction.oauth_verifier = oauth_verifier transaction.certificate = cert transaction.username = username db_session.update_transaction(transaction) db_session.commit() status = "301 Moved Permanently" joiner = "?" if "?" in transaction.oauth_callback: joiner="&" headers = [ ("Location", str("%s%soauth_token=%s&oauth_verifier=%s" % \ (transaction.oauth_callback, joiner, oauth_temp_token, oauth_verifier)))] start_response(status, headers) return "" except: return bad_request(start_response) @application.route('/token', methods=['GET']) def token(environ, start_response): try: args = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) oauth_signature_method = args.getvalue('oauth_signature_method') if oauth_signature_method is None: oauth_signature_method='RSA-SHA1' else: oauth_signature_method=str(oauth_signature_method) oauth_signature = str(args.getvalue('oauth_signature')) oauth_timestamp = int(args.getvalue('oauth_timestamp')) oauth_nonce = int(args.getvalue('oauth_nonce')) oauth_version = str(args.getvalue('oauth_version')) oauth_consumer_key = str(args.getvalue('oauth_consumer_key')) oauth_temp_token = str(args.getvalue('oauth_token')) oauth_verifier = str(args.getvalue('oauth_verifier')) oauth_access_token = 'myproxy:oa4mp,2012:/accessToken/' \ + ''.join([random.choice('0123456789abcdef') for i in range(32)]) \ + '/' + str(int(time.time())) transactions = db_session.get_transaction(Transaction(temp_token=oauth_temp_token)) transaction = None if len(transactions) > 0: transaction = transactions[0] transaction.access_token = oauth_access_token db_session.update_transaction(transaction) db_session.commit() status = "200 Ok" headers = [('Content-Type', 'app/x-www-form-urlencoded')] resp = start_response(status, headers) return "oauth_token=%s" % str(oauth_access_token) except: return bad_request(start_response) @application.route('/getcert', methods=['GET']) def getcert(environ, start_response): try: args = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) oauth_signature_method = args.getvalue('oauth_signature_method') if oauth_signature_method is None: oauth_signature_method = 'RSA-SHA1' else: oauth_signature_method = str(oauth_signature_method) oauth_signature = str(args.getvalue('oauth_signature')) oauth_timestamp = int(args.getvalue('oauth_timestamp')) oauth_nonce = int(args.getvalue('oauth_nonce')) oauth_version = str(args.getvalue('oauth_version')) oauth_consumer_key = str(args.getvalue('oauth_consumer_key')) oauth_access_token = str(args.getvalue('oauth_token')) transactions = db_session.get_transaction( Transaction(access_token=oauth_access_token)) transaction = None if len(transactions) > 0: transaction = transactions[0] if transaction is None: status = "403 Forbidden" headers = [("Content-Type", "text/plain")] start_response(status, headers) return "Invalid access token" # Clear database old_transactions = [(t) for t in db_session.get_transaction() if t.timestamp < int(time.time())] db_session.delete_transactions(old_transactions) db_session.commit() status = "200 Ok" headers = [ ("Content-Type", "app/x-www-form-urlencoded") ] start_response(status, headers) return 'username=%s\n%s' % (str(transaction.username), str(transaction.certificate)) except: return bad_request(start_response) # vim: syntax=python: nospell:
apache-2.0
[ 3, 199, 3, 1898, 7129, 13, 8128, 15904, 402, 2799, 25751, 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, 199, 646, 2838, 199, 646, 16004, 199, 646, 2196, 199, 646, 1300, 772, 199, 646, 8809, 199, 646, 2022, 199, 646, 900, 199, 646, 9725, 18, 465, 9725, 199, 646, 18855, 14, 26238, 14, 12115, 199, 646, 3002, 3280, 199, 646, 28728, 199, 646, 747, 199, 646, 984, 199, 504, 3002, 3280, 6126, 492, 4223, 199, 504, 3002, 3280, 6126, 14, 4659, 492, 1592, 63, 1730, 12, 9516, 12, 6810, 12, 18244, 199, 504, 4011, 492, 6313, 199, 199, 318, 4875, 63, 1069, 8, 928, 63, 1310, 304, 272, 2004, 275, 298, 5303, 8857, 4784, 2, 272, 2323, 275, 359, 1689, 2714, 13, 804, 401, 298, 505, 15, 6104, 531, 1622, 272, 1343, 63, 1310, 8, 1205, 12, 2323, 12, 984, 14, 2804, 63, 815, 1012, 272, 372, 298, 5725, 1056, 60, 78, 2, 199, 199, 318, 664, 63, 1160, 8, 354, 304, 272, 1978, 63, 576, 275, 488, 272, 340, 2688, 8, 4600, 1974, 12, 298, 362, 63, 576, 2349, 267, 1978, 63, 576, 275, 28728, 14, 362, 63, 576, 480, 1662, 3280, 6126, 14, 5876, 401, 536, 9, 272, 587, 26, 267, 1978, 63, 515, 275, 747, 14, 515, 14, 904, 8, 288, 747, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 297, 536, 9, 267, 1978, 63, 493, 275, 570, 8, 1160, 63, 515, 12, 298, 82, 531, 267, 862, 26, 288, 1978, 63, 576, 275, 1978, 63, 493, 14, 739, 342, 267, 3753, 26, 288, 1978, 63, 493, 14, 1600, 342, 272, 372, 1978, 63, 576, 27844, 199, 318, 3795, 63, 1160, 8, 354, 12, 1011, 958, 304, 272, 1978, 275, 664, 63, 1160, 8, 354, 9, 272, 367, 1978, 63, 1418, 315, 2074, 26, 267, 1978, 275, 1978, 14, 1814, 8, 288, 7370, 298, 435, 1978, 63, 1418, 435, 298, 3586, 401, 2074, 59, 1160, 63, 1418, 566, 272, 372, 620, 8, 1160, 9, 199, 199, 318, 1166, 63, 264, 8514, 8, 2314, 304, 272, 1166, 275, 6160, 459, 6508, 14, 633, 63, 5512, 21899, 356, 501, 7, 339, 340, 6160, 14, 362, 360, 2856, 63, 5449, 735, 267, 1166, 847, 6160, 459, 2856, 63, 5449, 418, 272, 587, 26, 267, 1166, 847, 6160, 459, 6613, 63, 2339, 418, 398, 340, 6160, 459, 6508, 14, 633, 63, 5512, 418, 508, 283, 2859, 356, 288, 340, 6160, 459, 6613, 63, 3657, 418, 1137, 283, 16284, 356, 2049, 1166, 847, 10871, 435, 6160, 459, 6613, 63, 3657, 418, 267, 587, 26, 288, 340, 6160, 459, 6613, 63, 3657, 418, 1137, 283, 1257, 356, 2049, 1166, 847, 10871, 435, 6160, 459, 6613, 63, 3657, 418, 339, 1166, 847, 6313, 8, 2314, 14, 362, 360, 10484, 63, 2339, 297, 12381, 272, 1166, 847, 6313, 8, 2314, 14, 362, 360, 3243, 63, 4531, 297, 12381, 272, 340, 6160, 14, 362, 360, 11938, 63, 5353, 735, 267, 1166, 847, 15539, 435, 6160, 459, 11938, 63, 5353, 418, 272, 372, 1166, 199, 199, 32, 3578, 14, 4449, 2336, 396, 358, 199, 318, 511, 8, 2314, 12, 1343, 63, 1310, 304, 272, 2004, 275, 298, 13353, 2104, 10912, 2, 272, 2323, 275, 10003, 2714, 13, 804, 401, 298, 505, 15, 6104, 11323, 272, 1343, 63, 1310, 8, 1205, 12, 2323, 9, 272, 372, 298, 4087, 2, 199, 199, 32, 3578, 14, 15236, 63, 1069, 199, 318, 12842, 63, 1730, 8, 1971, 29, 403, 304, 272, 1592, 63, 1730, 14, 2168, 342, 199, 199, 624, 199, 7921, 402, 11715, 367, 4932, 4936, 11557, 12, 199, 2859, 921, 4757, 14, 3098, 14, 957, 15, 3554, 15, 5645, 31, 344, 29, 709, 5153, 23, 79, 51, 1230, 67, 13, 37, 20777, 14449, 22760, 3298, 1400, 6838, 16, 85, 18, 13026, 17239, 5699, 73, 39, 21, 72, 37, 16106, 51, 68, 7471, 199, 624, 199, 199, 32, 3578, 14, 4449, 2336, 14188, 323, 297, 3102, 2968, 2970, 1105, 199, 318, 11023, 323, 8, 2314, 12, 1343, 63, 1310, 304, 523, 862, 26, 272, 1056, 275, 16004, 14, 792, 6408, 8, 3997, 29, 2314, 459, 6508, 14, 1210, 995, 6160, 29, 2314, 9, 272, 9725, 63, 5233, 63, 765, 275, 1056, 14, 7150, 360, 6126, 63, 5233, 63, 765, 358, 272, 340, 9725, 63, 5233, 63, 765, 365, 488, 26, 267, 9725, 63, 5233, 63, 765, 534, 12115, 13, 8461, 17, 7, 272, 9725, 63, 5233, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 5233, 1333, 272, 9725, 63, 3954, 275, 1109, 8, 1069, 14, 7150, 360, 6126, 63, 3954, 1333, 272, 9725, 63, 10667, 275, 1109, 8, 1069, 14, 7150, 360, 6126, 63, 10667, 1333, 272, 9725, 63, 1023, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 1023, 1333, 272, 9725, 63, 8542, 63, 498, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 8542, 63, 498, 1333, 272, 9725, 63, 3058, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 3058, 1333, 272, 6250, 27674, 275, 1056, 14, 7150, 360, 4736, 27674, 358, 272, 340, 6250, 27674, 365, 440, 488, 26, 267, 6250, 27674, 275, 1109, 8, 4736, 27674, 9, 272, 587, 26, 267, 6250, 27674, 275, 31200, 339, 13431, 275, 1592, 63, 1730, 14, 362, 63, 1258, 8, 3041, 8, 6126, 63, 8542, 63, 498, 29, 6126, 63, 8542, 63, 498, 430, 272, 1890, 275, 488, 272, 340, 822, 8, 14555, 9, 690, 378, 26, 267, 1890, 275, 13431, 59, 16, 61 ]
[ 199, 3, 1898, 7129, 13, 8128, 15904, 402, 2799, 25751, 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, 199, 646, 2838, 199, 646, 16004, 199, 646, 2196, 199, 646, 1300, 772, 199, 646, 8809, 199, 646, 2022, 199, 646, 900, 199, 646, 9725, 18, 465, 9725, 199, 646, 18855, 14, 26238, 14, 12115, 199, 646, 3002, 3280, 199, 646, 28728, 199, 646, 747, 199, 646, 984, 199, 504, 3002, 3280, 6126, 492, 4223, 199, 504, 3002, 3280, 6126, 14, 4659, 492, 1592, 63, 1730, 12, 9516, 12, 6810, 12, 18244, 199, 504, 4011, 492, 6313, 199, 199, 318, 4875, 63, 1069, 8, 928, 63, 1310, 304, 272, 2004, 275, 298, 5303, 8857, 4784, 2, 272, 2323, 275, 359, 1689, 2714, 13, 804, 401, 298, 505, 15, 6104, 531, 1622, 272, 1343, 63, 1310, 8, 1205, 12, 2323, 12, 984, 14, 2804, 63, 815, 1012, 272, 372, 298, 5725, 1056, 60, 78, 2, 199, 199, 318, 664, 63, 1160, 8, 354, 304, 272, 1978, 63, 576, 275, 488, 272, 340, 2688, 8, 4600, 1974, 12, 298, 362, 63, 576, 2349, 267, 1978, 63, 576, 275, 28728, 14, 362, 63, 576, 480, 1662, 3280, 6126, 14, 5876, 401, 536, 9, 272, 587, 26, 267, 1978, 63, 515, 275, 747, 14, 515, 14, 904, 8, 288, 747, 14, 515, 14, 3475, 3460, 493, 10139, 283, 5876, 297, 536, 9, 267, 1978, 63, 493, 275, 570, 8, 1160, 63, 515, 12, 298, 82, 531, 267, 862, 26, 288, 1978, 63, 576, 275, 1978, 63, 493, 14, 739, 342, 267, 3753, 26, 288, 1978, 63, 493, 14, 1600, 342, 272, 372, 1978, 63, 576, 27844, 199, 318, 3795, 63, 1160, 8, 354, 12, 1011, 958, 304, 272, 1978, 275, 664, 63, 1160, 8, 354, 9, 272, 367, 1978, 63, 1418, 315, 2074, 26, 267, 1978, 275, 1978, 14, 1814, 8, 288, 7370, 298, 435, 1978, 63, 1418, 435, 298, 3586, 401, 2074, 59, 1160, 63, 1418, 566, 272, 372, 620, 8, 1160, 9, 199, 199, 318, 1166, 63, 264, 8514, 8, 2314, 304, 272, 1166, 275, 6160, 459, 6508, 14, 633, 63, 5512, 21899, 356, 501, 7, 339, 340, 6160, 14, 362, 360, 2856, 63, 5449, 735, 267, 1166, 847, 6160, 459, 2856, 63, 5449, 418, 272, 587, 26, 267, 1166, 847, 6160, 459, 6613, 63, 2339, 418, 398, 340, 6160, 459, 6508, 14, 633, 63, 5512, 418, 508, 283, 2859, 356, 288, 340, 6160, 459, 6613, 63, 3657, 418, 1137, 283, 16284, 356, 2049, 1166, 847, 10871, 435, 6160, 459, 6613, 63, 3657, 418, 267, 587, 26, 288, 340, 6160, 459, 6613, 63, 3657, 418, 1137, 283, 1257, 356, 2049, 1166, 847, 10871, 435, 6160, 459, 6613, 63, 3657, 418, 339, 1166, 847, 6313, 8, 2314, 14, 362, 360, 10484, 63, 2339, 297, 12381, 272, 1166, 847, 6313, 8, 2314, 14, 362, 360, 3243, 63, 4531, 297, 12381, 272, 340, 6160, 14, 362, 360, 11938, 63, 5353, 735, 267, 1166, 847, 15539, 435, 6160, 459, 11938, 63, 5353, 418, 272, 372, 1166, 199, 199, 32, 3578, 14, 4449, 2336, 396, 358, 199, 318, 511, 8, 2314, 12, 1343, 63, 1310, 304, 272, 2004, 275, 298, 13353, 2104, 10912, 2, 272, 2323, 275, 10003, 2714, 13, 804, 401, 298, 505, 15, 6104, 11323, 272, 1343, 63, 1310, 8, 1205, 12, 2323, 9, 272, 372, 298, 4087, 2, 199, 199, 32, 3578, 14, 15236, 63, 1069, 199, 318, 12842, 63, 1730, 8, 1971, 29, 403, 304, 272, 1592, 63, 1730, 14, 2168, 342, 199, 199, 624, 199, 7921, 402, 11715, 367, 4932, 4936, 11557, 12, 199, 2859, 921, 4757, 14, 3098, 14, 957, 15, 3554, 15, 5645, 31, 344, 29, 709, 5153, 23, 79, 51, 1230, 67, 13, 37, 20777, 14449, 22760, 3298, 1400, 6838, 16, 85, 18, 13026, 17239, 5699, 73, 39, 21, 72, 37, 16106, 51, 68, 7471, 199, 624, 199, 199, 32, 3578, 14, 4449, 2336, 14188, 323, 297, 3102, 2968, 2970, 1105, 199, 318, 11023, 323, 8, 2314, 12, 1343, 63, 1310, 304, 523, 862, 26, 272, 1056, 275, 16004, 14, 792, 6408, 8, 3997, 29, 2314, 459, 6508, 14, 1210, 995, 6160, 29, 2314, 9, 272, 9725, 63, 5233, 63, 765, 275, 1056, 14, 7150, 360, 6126, 63, 5233, 63, 765, 358, 272, 340, 9725, 63, 5233, 63, 765, 365, 488, 26, 267, 9725, 63, 5233, 63, 765, 534, 12115, 13, 8461, 17, 7, 272, 9725, 63, 5233, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 5233, 1333, 272, 9725, 63, 3954, 275, 1109, 8, 1069, 14, 7150, 360, 6126, 63, 3954, 1333, 272, 9725, 63, 10667, 275, 1109, 8, 1069, 14, 7150, 360, 6126, 63, 10667, 1333, 272, 9725, 63, 1023, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 1023, 1333, 272, 9725, 63, 8542, 63, 498, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 8542, 63, 498, 1333, 272, 9725, 63, 3058, 275, 620, 8, 1069, 14, 7150, 360, 6126, 63, 3058, 1333, 272, 6250, 27674, 275, 1056, 14, 7150, 360, 4736, 27674, 358, 272, 340, 6250, 27674, 365, 440, 488, 26, 267, 6250, 27674, 275, 1109, 8, 4736, 27674, 9, 272, 587, 26, 267, 6250, 27674, 275, 31200, 339, 13431, 275, 1592, 63, 1730, 14, 362, 63, 1258, 8, 3041, 8, 6126, 63, 8542, 63, 498, 29, 6126, 63, 8542, 63, 498, 430, 272, 1890, 275, 488, 272, 340, 822, 8, 14555, 9, 690, 378, 26, 267, 1890, 275, 13431, 59, 16, 61, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
abhinavmoudgil95/root
interpreter/llvm/src/utils/abtest/abtest.py
30
8132
#!/usr/bin/env python # # Given a previous good compile narrow down miscompiles. # Expects two directories named "before" and "after" each containing a set of # assembly or object files where the "after" version is assumed to be broken. # You also have to provide a script called "link_test". It is called with a list # of files which should be linked together and result tested. "link_test" should # returns with exitcode 0 if the linking and testing succeeded. # # abtest.py operates by taking all files from the "before" directory and # in each step replacing one of them with a file from the "bad" directory. # # Additionally you can perform the same steps with a single .s file. In this # mode functions are identified by "# -- Begin FunctionName" and # "# -- End FunctionName" markers. The abtest.py then takes all functions from # the file in the "before" directory and replaces one function with the # corresponding function from the "bad" file in each step. # # Example usage to identify miscompiled files: # 1. Create a link_test script, make it executable. Simple Example: # clang "$@" -o /tmp/test && /tmp/test || echo "PROBLEM" # 2. Run the script to figure out which files are miscompiled: # > ./abtest.py # somefile.s: ok # someotherfile.s: skipped: same content # anotherfile.s: failed: './link_test' exitcode != 0 # ... # Example usage to identify miscompiled functions inside a file: # 3. First you have to mark begin and end of the functions. # The script comes with some examples called mark_xxx.py. # Unfortunately this is very specific to your environment and it is likely # that you have to write a custom version for your environment. # > for i in before/*.s after/*.s; do mark_xxx.py $i; done # 4. Run the tests on a single file (assuming before/file.s and # after/file.s exist) # > ./abtest.py file.s # funcname1 [0/XX]: ok # funcname2 [1/XX]: ok # funcname3 [2/XX]: skipped: same content # funcname4 [3/XX]: failed: './link_test' exitcode != 0 # ... from fnmatch import filter from sys import stderr import argparse import filecmp import os import subprocess import sys LINKTEST="./link_test" ESCAPE="\033[%sm" BOLD=ESCAPE % "1" RED=ESCAPE % "31" NORMAL=ESCAPE % "0" FAILED=RED+"failed"+NORMAL def find(dir, file_filter=None): files = [walkdir[0]+"/"+file for walkdir in os.walk(dir) for file in walkdir[2]] if file_filter != None: files = filter(files, file_filter) return files def error(message): stderr.write("Error: %s\n" % (message,)) def warn(message): stderr.write("Warning: %s\n" % (message,)) def extract_functions(file): functions = [] in_function = None for line in open(file): if line.startswith("# -- Begin "): if in_function != None: warn("Missing end of function %s" % (in_function,)) funcname = line[12:-1] in_function = funcname text = line elif line.startswith("# -- End "): function_name = line[10:-1] if in_function != function_name: warn("End %s does not match begin %s" % (function_name, in_function)) else: text += line functions.append( (in_function, text) ) in_function = None elif in_function != None: text += line return functions def replace_function(file, function, replacement, dest): out = open(dest, "w") skip = False found = False in_function = None for line in open(file): if line.startswith("# -- Begin "): if in_function != None: warn("Missing end of function %s" % (in_function,)) funcname = line[12:-1] in_function = funcname if in_function == function: out.write(replacement) skip = True elif line.startswith("# -- End "): function_name = line[10:-1] if in_function != function_name: warn("End %s does not match begin %s" % (function_name, in_function)) in_function = None if skip: skip = False continue if not skip: out.write(line) def announce_test(name): stderr.write("%s%s%s: " % (BOLD, name, NORMAL)) stderr.flush() def announce_result(result, info): stderr.write(result) if info != "": stderr.write(": %s" % info) stderr.write("\n") stderr.flush() def testrun(files): linkline="%s %s" % (LINKTEST, " ".join(files),) res = subprocess.call(linkline, shell=True) if res != 0: announce_result(FAILED, "'%s' exitcode != 0" % LINKTEST) return False else: announce_result("ok", "") return True def check_files(): """Check files mode""" for i in range(0, len(NO_PREFIX)): f = NO_PREFIX[i] b=baddir+"/"+f if b not in BAD_FILES: warn("There is no corresponding file to '%s' in %s" \ % (gooddir+"/"+f, baddir)) continue announce_test(f + " [%s/%s]" % (i+1, len(NO_PREFIX))) # combine files (everything from good except f) testfiles=[] skip=False for c in NO_PREFIX: badfile = baddir+"/"+c goodfile = gooddir+"/"+c if c == f: testfiles.append(badfile) if filecmp.cmp(goodfile, badfile): announce_result("skipped", "same content") skip = True break else: testfiles.append(goodfile) if skip: continue testrun(testfiles) def check_functions_in_file(base, goodfile, badfile): functions = extract_functions(goodfile) if len(functions) == 0: warn("Couldn't find any function in %s, missing annotations?" % (goodfile,)) return badfunctions = dict(extract_functions(badfile)) if len(functions) == 0: warn("Couldn't find any function in %s, missing annotations?" % (badfile,)) return COMBINED="/tmp/combined.s" i = 0 for (func,func_text) in functions: announce_test(func + " [%s/%s]" % (i+1, len(functions))) i+=1 if func not in badfunctions: warn("Function '%s' missing from bad file" % func) continue if badfunctions[func] == func_text: announce_result("skipped", "same content") continue replace_function(goodfile, func, badfunctions[func], COMBINED) testfiles=[] for c in NO_PREFIX: if c == base: testfiles.append(COMBINED) continue testfiles.append(gooddir + "/" + c) testrun(testfiles) parser = argparse.ArgumentParser() parser.add_argument('--a', dest='dir_a', default='before') parser.add_argument('--b', dest='dir_b', default='after') parser.add_argument('--insane', help='Skip sanity check', action='store_true') parser.add_argument('file', metavar='file', nargs='?') config = parser.parse_args() gooddir=config.dir_a baddir=config.dir_b BAD_FILES=find(baddir, "*") GOOD_FILES=find(gooddir, "*") NO_PREFIX=sorted([x[len(gooddir)+1:] for x in GOOD_FILES]) # "Checking whether build environment is sane ..." if not config.insane: announce_test("sanity check") if not os.access(LINKTEST, os.X_OK): error("Expect '%s' to be present and executable" % (LINKTEST,)) exit(1) res = testrun(GOOD_FILES) if not res: # "build environment is grinning and holding a spatula. Guess not." linkline="%s %s" % (LINKTEST, " ".join(GOOD_FILES),) stderr.write("\n%s\n\n" % linkline) stderr.write("Returned with exitcode != 0\n") sys.exit(1) if config.file is not None: # File exchange mode goodfile = gooddir+"/"+config.file badfile = baddir+"/"+config.file check_functions_in_file(config.file, goodfile, badfile) else: # Function exchange mode check_files()
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 9138, 282, 4136, 6954, 6555, 31530, 3224, 3201, 2014, 83, 14, 199, 3, 15100, 83, 2877, 6602, 4310, 298, 5182, 2, 436, 298, 4399, 2, 1924, 3035, 282, 663, 402, 199, 3, 24869, 503, 909, 1584, 2382, 314, 298, 4399, 2, 1015, 365, 10826, 370, 506, 10529, 14, 199, 3, 2047, 2597, 1172, 370, 5647, 282, 2884, 2797, 298, 1073, 63, 396, 1674, 2779, 365, 2797, 543, 282, 769, 199, 3, 402, 1584, 1314, 1077, 506, 10632, 10451, 436, 754, 12470, 14, 298, 1073, 63, 396, 2, 1077, 199, 3, 2529, 543, 4458, 600, 378, 340, 314, 25833, 436, 5343, 19268, 14, 199, 3, 199, 3, 2236, 396, 14, 647, 1758, 2335, 701, 16466, 1006, 1584, 687, 314, 298, 5182, 2, 2082, 436, 199, 3, 315, 1924, 3650, 15810, 1373, 402, 3062, 543, 282, 570, 687, 314, 298, 4087, 2, 2082, 14, 199, 3, 199, 3, 25448, 1265, 883, 5147, 314, 2011, 7124, 543, 282, 2849, 1275, 83, 570, 14, 1010, 642, 199, 3, 818, 3423, 787, 15836, 701, 5426, 1553, 25754, 6801, 985, 2, 436, 199, 3, 5426, 1553, 9599, 6801, 985, 2, 14327, 14, 710, 2236, 396, 14, 647, 2066, 6181, 1006, 3423, 687, 199, 3, 314, 570, 315, 314, 298, 5182, 2, 2082, 436, 19058, 1373, 805, 543, 314, 199, 3, 5226, 805, 687, 314, 298, 4087, 2, 570, 315, 1924, 3650, 14, 199, 3, 199, 3, 5679, 4503, 370, 10405, 3201, 8427, 1584, 26, 199, 3, 259, 413, 14, 2790, 282, 2142, 63, 396, 2884, 12, 1852, 652, 7286, 14, 5870, 5679, 26, 199, 3, 3515, 25444, 7880, 32, 2, 446, 79, 1182, 2791, 15, 396, 10883, 1182, 2791, 15, 396, 12208, 11343, 298, 30533, 25847, 2, 199, 3, 259, 499, 14, 3378, 314, 2884, 370, 9658, 734, 1314, 1584, 787, 3201, 8427, 26, 199, 3, 755, 690, 16605, 371, 396, 14, 647, 221, 199, 3, 755, 2005, 493, 14, 83, 26, 4112, 199, 3, 755, 2005, 1848, 493, 14, 83, 26, 9645, 26, 2011, 1564, 199, 3, 755, 4573, 493, 14, 83, 26, 3405, 26, 21526, 1073, 63, 396, 7, 4458, 600, 1137, 378, 199, 3, 755, 2263, 199, 3, 5679, 4503, 370, 10405, 3201, 8427, 3423, 6272, 282, 570, 26, 199, 3, 259, 650, 14, 7758, 1265, 1172, 370, 2216, 5386, 436, 1284, 402, 314, 3423, 14, 199, 3, 755, 710, 2884, 12477, 543, 2005, 7251, 2797, 2216, 63, 10013, 14, 647, 14, 199, 3, 755, 31076, 642, 365, 7437, 2488, 370, 2195, 3734, 436, 652, 365, 12060, 199, 3, 755, 626, 1265, 1172, 370, 2218, 282, 3537, 1015, 367, 2195, 3734, 14, 199, 3, 755, 690, 367, 284, 315, 2544, 20362, 83, 2410, 20362, 83, 27, 886, 2216, 63, 10013, 14, 647, 2672, 73, 27, 4224, 199, 3, 259, 841, 14, 3378, 314, 2295, 641, 282, 2849, 570, 334, 405, 12848, 2544, 15, 493, 14, 83, 436, 199, 3, 755, 2410, 15, 493, 14, 83, 2187, 9, 199, 3, 755, 690, 16605, 371, 396, 14, 647, 570, 14, 83, 199, 3, 755, 24092, 17, 359, 16, 15, 2483, 2189, 4112, 199, 3, 755, 24092, 18, 359, 17, 15, 2483, 2189, 4112, 199, 3, 755, 24092, 19, 359, 18, 15, 2483, 2189, 9645, 26, 2011, 1564, 199, 3, 755, 24092, 20, 359, 19, 15, 2483, 2189, 3405, 26, 21526, 1073, 63, 396, 7, 4458, 600, 1137, 378, 199, 3, 755, 2263, 199, 504, 15951, 492, 2457, 199, 504, 984, 492, 4635, 199, 646, 7534, 199, 646, 570, 5730, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 199, 7916, 2864, 628, 13186, 1073, 63, 396, 2, 199, 28879, 21024, 8762, 9722, 3300, 2, 199, 30144, 29, 28879, 450, 298, 17, 2, 199, 7387, 29, 28879, 450, 298, 2192, 2, 199, 10765, 29, 28879, 450, 298, 16, 2, 199, 12299, 29, 7387, 5207, 4892, 7709, 10765, 199, 199, 318, 2342, 8, 694, 12, 570, 63, 1541, 29, 403, 304, 272, 1584, 275, 359, 7757, 694, 59, 16, 2807, 2, 25976, 493, 367, 12778, 694, 315, 747, 14, 7757, 8, 694, 9, 367, 570, 315, 12778, 694, 59, 18, 2677, 272, 340, 570, 63, 1541, 1137, 488, 26, 267, 1584, 275, 2457, 8, 1725, 12, 570, 63, 1541, 9, 272, 372, 1584, 199, 199, 318, 1125, 8, 1188, 304, 272, 4635, 14, 952, 480, 547, 26, 450, 83, 60, 78, 2, 450, 334, 1188, 4641, 199, 199, 318, 7987, 8, 1188, 304, 272, 4635, 14, 952, 480, 3849, 26, 450, 83, 60, 78, 2, 450, 334, 1188, 4641, 199, 199, 318, 5536, 63, 5777, 8, 493, 304, 272, 3423, 275, 942, 272, 315, 63, 1593, 275, 488, 272, 367, 1004, 315, 1551, 8, 493, 304, 267, 340, 1004, 14, 2460, 10064, 1553, 25754, 221, 26699, 288, 340, 315, 63, 1593, 1137, 488, 26, 355, 7987, 480, 7718, 1284, 402, 805, 450, 83, 2, 450, 334, 262, 63, 1593, 4641, 288, 24092, 275, 1004, 59, 713, 6809, 17, 61, 288, 315, 63, 1593, 275, 24092, 288, 1318, 275, 1004, 267, 916, 1004, 14, 2460, 10064, 1553, 9599, 221, 26699, 288, 805, 63, 354, 275, 1004, 59, 709, 6809, 17, 61, 288, 340, 315, 63, 1593, 1137, 805, 63, 354, 26, 355, 7987, 480, 3005, 450, 83, 1630, 440, 1336, 5386, 450, 83, 2, 450, 334, 1593, 63, 354, 12, 315, 63, 1593, 430, 288, 587, 26, 355, 1318, 847, 1004, 355, 3423, 14, 740, 8, 334, 262, 63, 1593, 12, 1318, 9, 776, 288, 315, 63, 1593, 275, 488, 267, 916, 315, 63, 1593, 1137, 488, 26, 288, 1318, 847, 1004, 272, 372, 3423, 199, 199, 318, 3350, 63, 1593, 8, 493, 12, 805, 12, 8343, 12, 2053, 304, 272, 734, 275, 1551, 8, 2614, 12, 298, 87, 531, 272, 3372, 275, 756, 272, 1911, 275, 756, 272, 315, 63, 1593, 275, 488, 272, 367, 1004, 315, 1551, 8, 493, 304, 267, 340, 1004, 14, 2460, 10064, 1553, 25754, 221, 26699, 288, 340, 315, 63, 1593, 1137, 488, 26, 355, 7987, 480, 7718, 1284, 402, 805, 450, 83, 2, 450, 334, 262, 63, 1593, 4641, 288, 24092, 275, 1004, 59, 713, 6809, 17, 61, 288, 315, 63, 1593, 275 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 9138, 282, 4136, 6954, 6555, 31530, 3224, 3201, 2014, 83, 14, 199, 3, 15100, 83, 2877, 6602, 4310, 298, 5182, 2, 436, 298, 4399, 2, 1924, 3035, 282, 663, 402, 199, 3, 24869, 503, 909, 1584, 2382, 314, 298, 4399, 2, 1015, 365, 10826, 370, 506, 10529, 14, 199, 3, 2047, 2597, 1172, 370, 5647, 282, 2884, 2797, 298, 1073, 63, 396, 1674, 2779, 365, 2797, 543, 282, 769, 199, 3, 402, 1584, 1314, 1077, 506, 10632, 10451, 436, 754, 12470, 14, 298, 1073, 63, 396, 2, 1077, 199, 3, 2529, 543, 4458, 600, 378, 340, 314, 25833, 436, 5343, 19268, 14, 199, 3, 199, 3, 2236, 396, 14, 647, 1758, 2335, 701, 16466, 1006, 1584, 687, 314, 298, 5182, 2, 2082, 436, 199, 3, 315, 1924, 3650, 15810, 1373, 402, 3062, 543, 282, 570, 687, 314, 298, 4087, 2, 2082, 14, 199, 3, 199, 3, 25448, 1265, 883, 5147, 314, 2011, 7124, 543, 282, 2849, 1275, 83, 570, 14, 1010, 642, 199, 3, 818, 3423, 787, 15836, 701, 5426, 1553, 25754, 6801, 985, 2, 436, 199, 3, 5426, 1553, 9599, 6801, 985, 2, 14327, 14, 710, 2236, 396, 14, 647, 2066, 6181, 1006, 3423, 687, 199, 3, 314, 570, 315, 314, 298, 5182, 2, 2082, 436, 19058, 1373, 805, 543, 314, 199, 3, 5226, 805, 687, 314, 298, 4087, 2, 570, 315, 1924, 3650, 14, 199, 3, 199, 3, 5679, 4503, 370, 10405, 3201, 8427, 1584, 26, 199, 3, 259, 413, 14, 2790, 282, 2142, 63, 396, 2884, 12, 1852, 652, 7286, 14, 5870, 5679, 26, 199, 3, 3515, 25444, 7880, 32, 2, 446, 79, 1182, 2791, 15, 396, 10883, 1182, 2791, 15, 396, 12208, 11343, 298, 30533, 25847, 2, 199, 3, 259, 499, 14, 3378, 314, 2884, 370, 9658, 734, 1314, 1584, 787, 3201, 8427, 26, 199, 3, 755, 690, 16605, 371, 396, 14, 647, 221, 199, 3, 755, 2005, 493, 14, 83, 26, 4112, 199, 3, 755, 2005, 1848, 493, 14, 83, 26, 9645, 26, 2011, 1564, 199, 3, 755, 4573, 493, 14, 83, 26, 3405, 26, 21526, 1073, 63, 396, 7, 4458, 600, 1137, 378, 199, 3, 755, 2263, 199, 3, 5679, 4503, 370, 10405, 3201, 8427, 3423, 6272, 282, 570, 26, 199, 3, 259, 650, 14, 7758, 1265, 1172, 370, 2216, 5386, 436, 1284, 402, 314, 3423, 14, 199, 3, 755, 710, 2884, 12477, 543, 2005, 7251, 2797, 2216, 63, 10013, 14, 647, 14, 199, 3, 755, 31076, 642, 365, 7437, 2488, 370, 2195, 3734, 436, 652, 365, 12060, 199, 3, 755, 626, 1265, 1172, 370, 2218, 282, 3537, 1015, 367, 2195, 3734, 14, 199, 3, 755, 690, 367, 284, 315, 2544, 20362, 83, 2410, 20362, 83, 27, 886, 2216, 63, 10013, 14, 647, 2672, 73, 27, 4224, 199, 3, 259, 841, 14, 3378, 314, 2295, 641, 282, 2849, 570, 334, 405, 12848, 2544, 15, 493, 14, 83, 436, 199, 3, 755, 2410, 15, 493, 14, 83, 2187, 9, 199, 3, 755, 690, 16605, 371, 396, 14, 647, 570, 14, 83, 199, 3, 755, 24092, 17, 359, 16, 15, 2483, 2189, 4112, 199, 3, 755, 24092, 18, 359, 17, 15, 2483, 2189, 4112, 199, 3, 755, 24092, 19, 359, 18, 15, 2483, 2189, 9645, 26, 2011, 1564, 199, 3, 755, 24092, 20, 359, 19, 15, 2483, 2189, 3405, 26, 21526, 1073, 63, 396, 7, 4458, 600, 1137, 378, 199, 3, 755, 2263, 199, 504, 15951, 492, 2457, 199, 504, 984, 492, 4635, 199, 646, 7534, 199, 646, 570, 5730, 199, 646, 747, 199, 646, 3873, 199, 646, 984, 199, 199, 7916, 2864, 628, 13186, 1073, 63, 396, 2, 199, 28879, 21024, 8762, 9722, 3300, 2, 199, 30144, 29, 28879, 450, 298, 17, 2, 199, 7387, 29, 28879, 450, 298, 2192, 2, 199, 10765, 29, 28879, 450, 298, 16, 2, 199, 12299, 29, 7387, 5207, 4892, 7709, 10765, 199, 199, 318, 2342, 8, 694, 12, 570, 63, 1541, 29, 403, 304, 272, 1584, 275, 359, 7757, 694, 59, 16, 2807, 2, 25976, 493, 367, 12778, 694, 315, 747, 14, 7757, 8, 694, 9, 367, 570, 315, 12778, 694, 59, 18, 2677, 272, 340, 570, 63, 1541, 1137, 488, 26, 267, 1584, 275, 2457, 8, 1725, 12, 570, 63, 1541, 9, 272, 372, 1584, 199, 199, 318, 1125, 8, 1188, 304, 272, 4635, 14, 952, 480, 547, 26, 450, 83, 60, 78, 2, 450, 334, 1188, 4641, 199, 199, 318, 7987, 8, 1188, 304, 272, 4635, 14, 952, 480, 3849, 26, 450, 83, 60, 78, 2, 450, 334, 1188, 4641, 199, 199, 318, 5536, 63, 5777, 8, 493, 304, 272, 3423, 275, 942, 272, 315, 63, 1593, 275, 488, 272, 367, 1004, 315, 1551, 8, 493, 304, 267, 340, 1004, 14, 2460, 10064, 1553, 25754, 221, 26699, 288, 340, 315, 63, 1593, 1137, 488, 26, 355, 7987, 480, 7718, 1284, 402, 805, 450, 83, 2, 450, 334, 262, 63, 1593, 4641, 288, 24092, 275, 1004, 59, 713, 6809, 17, 61, 288, 315, 63, 1593, 275, 24092, 288, 1318, 275, 1004, 267, 916, 1004, 14, 2460, 10064, 1553, 9599, 221, 26699, 288, 805, 63, 354, 275, 1004, 59, 709, 6809, 17, 61, 288, 340, 315, 63, 1593, 1137, 805, 63, 354, 26, 355, 7987, 480, 3005, 450, 83, 1630, 440, 1336, 5386, 450, 83, 2, 450, 334, 1593, 63, 354, 12, 315, 63, 1593, 430, 288, 587, 26, 355, 1318, 847, 1004, 355, 3423, 14, 740, 8, 334, 262, 63, 1593, 12, 1318, 9, 776, 288, 315, 63, 1593, 275, 488, 267, 916, 315, 63, 1593, 1137, 488, 26, 288, 1318, 847, 1004, 272, 372, 3423, 199, 199, 318, 3350, 63, 1593, 8, 493, 12, 805, 12, 8343, 12, 2053, 304, 272, 734, 275, 1551, 8, 2614, 12, 298, 87, 531, 272, 3372, 275, 756, 272, 1911, 275, 756, 272, 315, 63, 1593, 275, 488, 272, 367, 1004, 315, 1551, 8, 493, 304, 267, 340, 1004, 14, 2460, 10064, 1553, 25754, 221, 26699, 288, 340, 315, 63, 1593, 1137, 488, 26, 355, 7987, 480, 7718, 1284, 402, 805, 450, 83, 2, 450, 334, 262, 63, 1593, 4641, 288, 24092, 275, 1004, 59, 713, 6809, 17, 61, 288, 315, 63, 1593, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
encukou/pytest-sourceorder
setup.py
1
1256
#!/usr/bin/python2 # # Copyright (C) 2014 pytest-sourceorder contributors. See COPYING for license # from setuptools import setup import io with io.open('README.rst', 'rt', encoding='utf-8') as f: readme_contents = f.read() setup_args = dict( name = "pytest-sourceorder", version = "0.5.1", description = "Test-ordering plugin for pytest", long_description = readme_contents, url = "https://pagure.io/python-pytest-sourceorder", license = "GPL", author = "Petr Viktorin", author_email = "pviktori@redhat.com", py_modules = ["pytest_sourceorder"], classifiers=[ 'Development Status :: 4 - Beta', 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 'Operating System :: POSIX', 'Framework :: Pytest', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Topic :: Software Development :: Quality Assurance', ], install_requires=['pytest'], entry_points = { 'pytest11': [ 'sourceorder = pytest_sourceorder', ], }, ) if __name__ == '__main__': setup(**setup_args)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 199, 3, 199, 3, 1898, 334, 35, 9, 6927, 4613, 13, 1365, 1648, 8417, 14, 1666, 9685, 367, 4190, 199, 3, 199, 199, 504, 9116, 492, 3272, 199, 646, 5890, 199, 199, 1045, 5890, 14, 1490, 360, 18195, 14, 8332, 297, 283, 2591, 297, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 272, 1586, 278, 63, 4407, 275, 289, 14, 739, 342, 199, 199, 2758, 63, 589, 275, 1211, 8, 272, 536, 275, 298, 4462, 13, 1365, 1648, 401, 272, 1015, 275, 298, 16, 14, 21, 14, 17, 401, 272, 1369, 275, 298, 774, 13, 7128, 3589, 367, 4613, 401, 272, 1846, 63, 1802, 275, 1586, 278, 63, 4407, 12, 272, 1166, 275, 298, 2859, 921, 15351, 608, 14, 2308, 15, 1548, 13, 4462, 13, 1365, 1648, 401, 272, 4190, 275, 298, 12006, 401, 272, 4132, 275, 298, 48, 386, 82, 812, 3258, 8270, 262, 401, 272, 4132, 63, 2123, 275, 298, 80, 433, 5973, 16039, 32, 17164, 14, 957, 401, 272, 1134, 63, 3112, 275, 2097, 4462, 63, 1365, 1648, 2255, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 1664, 1696, 1684, 844, 373, 19, 503, 2945, 334, 28863, 19, 14705, 267, 283, 23699, 6187, 3800, 18169, 297, 267, 283, 16442, 3800, 1611, 396, 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, 20, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 24108, 10829, 300, 554, 297, 272, 2156, 272, 3907, 63, 6537, 2968, 4462, 995, 272, 2397, 63, 3438, 275, 469, 267, 283, 4462, 845, 356, 359, 288, 283, 1365, 1648, 275, 4613, 63, 1365, 1648, 297, 267, 2156, 272, 1660, 199, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 3272, 3682, 2758, 63, 589, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 18, 199, 3, 199, 3, 1898, 334, 35, 9, 6927, 4613, 13, 1365, 1648, 8417, 14, 1666, 9685, 367, 4190, 199, 3, 199, 199, 504, 9116, 492, 3272, 199, 646, 5890, 199, 199, 1045, 5890, 14, 1490, 360, 18195, 14, 8332, 297, 283, 2591, 297, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 272, 1586, 278, 63, 4407, 275, 289, 14, 739, 342, 199, 199, 2758, 63, 589, 275, 1211, 8, 272, 536, 275, 298, 4462, 13, 1365, 1648, 401, 272, 1015, 275, 298, 16, 14, 21, 14, 17, 401, 272, 1369, 275, 298, 774, 13, 7128, 3589, 367, 4613, 401, 272, 1846, 63, 1802, 275, 1586, 278, 63, 4407, 12, 272, 1166, 275, 298, 2859, 921, 15351, 608, 14, 2308, 15, 1548, 13, 4462, 13, 1365, 1648, 401, 272, 4190, 275, 298, 12006, 401, 272, 4132, 275, 298, 48, 386, 82, 812, 3258, 8270, 262, 401, 272, 4132, 63, 2123, 275, 298, 80, 433, 5973, 16039, 32, 17164, 14, 957, 401, 272, 1134, 63, 3112, 275, 2097, 4462, 63, 1365, 1648, 2255, 272, 19137, 1524, 267, 283, 23753, 9795, 3800, 841, 446, 29521, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 1664, 1696, 1684, 844, 373, 19, 503, 2945, 334, 28863, 19, 14705, 267, 283, 23699, 6187, 3800, 18169, 297, 267, 283, 16442, 3800, 1611, 396, 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, 20, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 24108, 10829, 300, 554, 297, 272, 2156, 272, 3907, 63, 6537, 2968, 4462, 995, 272, 2397, 63, 3438, 275, 469, 267, 283, 4462, 845, 356, 359, 288, 283, 1365, 1648, 275, 4613, 63, 1365, 1648, 297, 267, 2156, 272, 1660, 199, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 3272, 3682, 2758, 63, 589, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
UXJera/JeremiahNyman.com
node_modules/gulp-sass/node_modules/node-sass/node_modules/pangyp/gyp/pylib/gyp/MSVSToolFile.py
2736
1804
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Visual Studio project reader/writer.""" import gyp.common import gyp.easy_xml as easy_xml class Writer(object): """Visual Studio XML tool file writer.""" def __init__(self, tool_file_path, name): """Initializes the tool file. Args: tool_file_path: Path to the tool file. name: Name of the tool file. """ self.tool_file_path = tool_file_path self.name = name self.rules_section = ['Rules'] def AddCustomBuildRule(self, name, cmd, description, additional_dependencies, outputs, extensions): """Adds a rule to the tool file. Args: name: Name of the rule. description: Description of the rule. cmd: Command line of the rule. additional_dependencies: other files which may trigger the rule. outputs: outputs of the rule. extensions: extensions handled by the rule. """ rule = ['CustomBuildRule', {'Name': name, 'ExecutionDescription': description, 'CommandLine': cmd, 'Outputs': ';'.join(outputs), 'FileExtensions': ';'.join(extensions), 'AdditionalDependencies': ';'.join(additional_dependencies) }] self.rules_section.append(rule) def WriteIfChanged(self): """Writes the tool file.""" content = ['VisualStudioToolFile', {'Version': '8.00', 'Name': self.name }, self.rules_section ] easy_xml.WriteXmlIfChanged(content, self.tool_file_path, encoding="Windows-1252")
cc0-1.0
[ 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 15039, 13225, 2199, 7002, 15, 5491, 1041, 199, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 13581, 63, 1652, 465, 8837, 63, 1652, 421, 199, 533, 24441, 8, 785, 304, 523, 408, 15039, 13225, 4692, 4744, 570, 7060, 1041, 819, 347, 636, 826, 721, 277, 12, 4744, 63, 493, 63, 515, 12, 536, 304, 272, 408, 23489, 314, 4744, 570, 14, 339, 3033, 26, 489, 4744, 63, 493, 63, 515, 26, 6912, 370, 314, 4744, 570, 14, 489, 536, 26, 2812, 402, 314, 4744, 570, 14, 272, 408, 272, 291, 14, 3557, 63, 493, 63, 515, 275, 4744, 63, 493, 63, 515, 272, 291, 14, 354, 275, 536, 272, 291, 14, 4423, 63, 2792, 275, 788, 12920, 418, 819, 347, 2654, 7223, 3425, 5065, 8, 277, 12, 536, 12, 2088, 12, 1369, 12, 586, 4722, 63, 5714, 12, 586, 4704, 12, 5478, 304, 272, 408, 14995, 282, 2332, 370, 314, 4744, 570, 14, 339, 3033, 26, 489, 536, 26, 2812, 402, 314, 2332, 14, 489, 1369, 26, 11994, 402, 314, 2332, 14, 489, 2088, 26, 5817, 1004, 402, 314, 2332, 14, 489, 4722, 63, 5714, 26, 1163, 1584, 1314, 1443, 6804, 314, 2332, 14, 489, 4704, 26, 4704, 402, 314, 2332, 14, 489, 5478, 26, 5478, 8860, 701, 314, 2332, 14, 272, 408, 272, 2332, 275, 788, 7223, 3425, 5065, 297, 288, 791, 985, 356, 536, 12, 1467, 283, 11310, 5831, 356, 1369, 12, 1467, 283, 16926, 356, 2088, 12, 1467, 283, 18669, 356, 30955, 904, 8, 4467, 395, 1467, 283, 1173, 10597, 356, 30955, 904, 8, 5359, 395, 1467, 283, 31780, 356, 326, 30955, 904, 8, 8460, 63, 5714, 9, 288, 14877, 272, 291, 14, 4423, 63, 2792, 14, 740, 8, 2200, 9, 819, 347, 6990, 3917, 6970, 8, 277, 304, 272, 408, 20908, 314, 4744, 570, 1041, 272, 1564, 275, 788, 15039, 21025, 5157, 1173, 297, 2049, 791, 3353, 356, 283, 24, 14, 383, 297, 355, 283, 985, 356, 291, 14, 354, 2049, 1660, 2049, 291, 14, 4423, 63, 2792, 2049, 1622, 272, 8837, 63, 1652, 14, 3534, 8672, 3917, 6970, 8, 1317, 12, 291, 14, 3557, 63, 493, 63, 515, 12, 3044, 2644, 628, 8647, 13, 19364, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 15039, 13225, 2199, 7002, 15, 5491, 1041, 199, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 13581, 63, 1652, 465, 8837, 63, 1652, 421, 199, 533, 24441, 8, 785, 304, 523, 408, 15039, 13225, 4692, 4744, 570, 7060, 1041, 819, 347, 636, 826, 721, 277, 12, 4744, 63, 493, 63, 515, 12, 536, 304, 272, 408, 23489, 314, 4744, 570, 14, 339, 3033, 26, 489, 4744, 63, 493, 63, 515, 26, 6912, 370, 314, 4744, 570, 14, 489, 536, 26, 2812, 402, 314, 4744, 570, 14, 272, 408, 272, 291, 14, 3557, 63, 493, 63, 515, 275, 4744, 63, 493, 63, 515, 272, 291, 14, 354, 275, 536, 272, 291, 14, 4423, 63, 2792, 275, 788, 12920, 418, 819, 347, 2654, 7223, 3425, 5065, 8, 277, 12, 536, 12, 2088, 12, 1369, 12, 586, 4722, 63, 5714, 12, 586, 4704, 12, 5478, 304, 272, 408, 14995, 282, 2332, 370, 314, 4744, 570, 14, 339, 3033, 26, 489, 536, 26, 2812, 402, 314, 2332, 14, 489, 1369, 26, 11994, 402, 314, 2332, 14, 489, 2088, 26, 5817, 1004, 402, 314, 2332, 14, 489, 4722, 63, 5714, 26, 1163, 1584, 1314, 1443, 6804, 314, 2332, 14, 489, 4704, 26, 4704, 402, 314, 2332, 14, 489, 5478, 26, 5478, 8860, 701, 314, 2332, 14, 272, 408, 272, 2332, 275, 788, 7223, 3425, 5065, 297, 288, 791, 985, 356, 536, 12, 1467, 283, 11310, 5831, 356, 1369, 12, 1467, 283, 16926, 356, 2088, 12, 1467, 283, 18669, 356, 30955, 904, 8, 4467, 395, 1467, 283, 1173, 10597, 356, 30955, 904, 8, 5359, 395, 1467, 283, 31780, 356, 326, 30955, 904, 8, 8460, 63, 5714, 9, 288, 14877, 272, 291, 14, 4423, 63, 2792, 14, 740, 8, 2200, 9, 819, 347, 6990, 3917, 6970, 8, 277, 304, 272, 408, 20908, 314, 4744, 570, 1041, 272, 1564, 275, 788, 15039, 21025, 5157, 1173, 297, 2049, 791, 3353, 356, 283, 24, 14, 383, 297, 355, 283, 985, 356, 291, 14, 354, 2049, 1660, 2049, 291, 14, 4423, 63, 2792, 2049, 1622, 272, 8837, 63, 1652, 14, 3534, 8672, 3917, 6970, 8, 1317, 12, 291, 14, 3557, 63, 493, 63, 515, 12, 3044, 2644, 628, 8647, 13, 19364, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
maelnor/nova
nova/compute/vm_states.py
99
2089
# Copyright 2010 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Possible vm states for instances. Compute instance vm states represent the state of an instance as it pertains to a user or administrator. vm_state describes a VM's current stable (not transition) state. That is, if there is no ongoing compute API calls (running tasks), vm_state should reflect what the customer expect the VM to be. When combined with task states (task_states.py), a better picture can be formed regarding the instance's health and progress. See http://wiki.openstack.org/VMState """ ACTIVE = 'active' # VM is running BUILDING = 'building' # VM only exists in DB PAUSED = 'paused' SUSPENDED = 'suspended' # VM is suspended to disk. STOPPED = 'stopped' # VM is powered off, the disk image is still there. RESCUED = 'rescued' # A rescue image is running with the original VM image # attached. RESIZED = 'resized' # a VM with the new size is active. The user is expected # to manually confirm or revert. SOFT_DELETED = 'soft-delete' # VM is marked as deleted but the disk images are # still available to restore. DELETED = 'deleted' # VM is permanently deleted. ERROR = 'error' SHELVED = 'shelved' # VM is powered off, resources still on hypervisor SHELVED_OFFLOADED = 'shelved_offloaded' # VM and associated resources are # not on hypervisor ALLOW_SOFT_REBOOT = [ACTIVE] # states we can soft reboot from ALLOW_HARD_REBOOT = ALLOW_SOFT_REBOOT + [STOPPED, PAUSED, SUSPENDED, ERROR] # states we allow hard reboot from
apache-2.0
[ 3, 1898, 7129, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 28096, 4169, 6363, 367, 4454, 14, 199, 199, 8564, 1256, 4169, 6363, 2954, 314, 1174, 402, 376, 1256, 465, 652, 1126, 3953, 370, 199, 65, 922, 503, 31056, 14, 199, 199, 2611, 63, 929, 23369, 282, 7525, 1159, 1453, 17830, 334, 1397, 14116, 9, 1174, 14, 10314, 365, 12, 340, 199, 16990, 365, 949, 641, 10947, 4526, 3261, 4882, 334, 5720, 6527, 395, 4169, 63, 929, 1077, 16806, 199, 10058, 314, 15229, 4282, 314, 7525, 370, 506, 14, 3979, 12149, 543, 2120, 6363, 199, 8, 1765, 63, 4981, 14, 647, 395, 282, 8034, 24945, 883, 506, 28917, 12602, 314, 1256, 1159, 199, 9665, 436, 6696, 14, 199, 199, 9295, 1455, 921, 6797, 14, 8512, 14, 1308, 15, 6849, 2223, 199, 624, 199, 199, 10401, 275, 283, 2682, 7, 221, 327, 7525, 365, 3879, 199, 8248, 1206, 275, 283, 17952, 7, 221, 327, 7525, 1454, 3495, 315, 6249, 199, 8470, 8558, 275, 283, 22478, 7, 199, 51, 28011, 25518, 275, 283, 83, 18559, 7, 221, 327, 7525, 365, 308, 18559, 370, 4543, 14, 199, 11632, 19359, 275, 283, 14661, 7, 221, 327, 7525, 365, 13131, 16179, 2331, 12, 314, 4543, 1834, 365, 5139, 2337, 14, 199, 3830, 35, 53, 1149, 275, 283, 32318, 11158, 7, 221, 327, 437, 522, 14932, 1834, 365, 3879, 543, 314, 3379, 7525, 1834, 199, 3, 10102, 14, 199, 3830, 18732, 275, 283, 264, 15308, 7, 221, 327, 282, 7525, 543, 314, 892, 1568, 365, 4702, 14, 710, 922, 365, 1420, 199, 3, 370, 10250, 12679, 503, 23347, 14, 199, 199, 26999, 63, 27408, 275, 283, 4617, 13, 1807, 7, 221, 327, 7525, 365, 11584, 465, 5463, 1325, 314, 4543, 5935, 787, 199, 3, 5139, 2808, 370, 9066, 14, 199, 27408, 275, 283, 6062, 7, 221, 327, 7525, 365, 19860, 590, 5463, 14, 199, 199, 3170, 275, 283, 705, 7, 199, 199, 20255, 44, 14112, 275, 283, 609, 352, 1354, 7, 221, 327, 7525, 365, 13131, 16179, 2331, 12, 5944, 5139, 641, 21724, 199, 20255, 44, 14112, 63, 7517, 1484, 33, 8280, 275, 283, 609, 352, 1354, 63, 1997, 4591, 7, 221, 327, 7525, 436, 4568, 5944, 787, 199, 3, 440, 641, 21724, 199, 199, 12231, 63, 26999, 63, 907, 22679, 275, 359, 10401, 61, 221, 327, 6363, 781, 883, 11620, 19457, 687, 199, 12231, 63, 30322, 63, 907, 22679, 275, 27805, 63, 26999, 63, 907, 22679, 435, 359, 11632, 19359, 12, 510, 33, 8558, 12, 428, 28011, 25518, 12, 12539, 61, 199, 3, 6363, 781, 2040, 7508, 19457, 687, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7129, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 28096, 4169, 6363, 367, 4454, 14, 199, 199, 8564, 1256, 4169, 6363, 2954, 314, 1174, 402, 376, 1256, 465, 652, 1126, 3953, 370, 199, 65, 922, 503, 31056, 14, 199, 199, 2611, 63, 929, 23369, 282, 7525, 1159, 1453, 17830, 334, 1397, 14116, 9, 1174, 14, 10314, 365, 12, 340, 199, 16990, 365, 949, 641, 10947, 4526, 3261, 4882, 334, 5720, 6527, 395, 4169, 63, 929, 1077, 16806, 199, 10058, 314, 15229, 4282, 314, 7525, 370, 506, 14, 3979, 12149, 543, 2120, 6363, 199, 8, 1765, 63, 4981, 14, 647, 395, 282, 8034, 24945, 883, 506, 28917, 12602, 314, 1256, 1159, 199, 9665, 436, 6696, 14, 199, 199, 9295, 1455, 921, 6797, 14, 8512, 14, 1308, 15, 6849, 2223, 199, 624, 199, 199, 10401, 275, 283, 2682, 7, 221, 327, 7525, 365, 3879, 199, 8248, 1206, 275, 283, 17952, 7, 221, 327, 7525, 1454, 3495, 315, 6249, 199, 8470, 8558, 275, 283, 22478, 7, 199, 51, 28011, 25518, 275, 283, 83, 18559, 7, 221, 327, 7525, 365, 308, 18559, 370, 4543, 14, 199, 11632, 19359, 275, 283, 14661, 7, 221, 327, 7525, 365, 13131, 16179, 2331, 12, 314, 4543, 1834, 365, 5139, 2337, 14, 199, 3830, 35, 53, 1149, 275, 283, 32318, 11158, 7, 221, 327, 437, 522, 14932, 1834, 365, 3879, 543, 314, 3379, 7525, 1834, 199, 3, 10102, 14, 199, 3830, 18732, 275, 283, 264, 15308, 7, 221, 327, 282, 7525, 543, 314, 892, 1568, 365, 4702, 14, 710, 922, 365, 1420, 199, 3, 370, 10250, 12679, 503, 23347, 14, 199, 199, 26999, 63, 27408, 275, 283, 4617, 13, 1807, 7, 221, 327, 7525, 365, 11584, 465, 5463, 1325, 314, 4543, 5935, 787, 199, 3, 5139, 2808, 370, 9066, 14, 199, 27408, 275, 283, 6062, 7, 221, 327, 7525, 365, 19860, 590, 5463, 14, 199, 199, 3170, 275, 283, 705, 7, 199, 199, 20255, 44, 14112, 275, 283, 609, 352, 1354, 7, 221, 327, 7525, 365, 13131, 16179, 2331, 12, 5944, 5139, 641, 21724, 199, 20255, 44, 14112, 63, 7517, 1484, 33, 8280, 275, 283, 609, 352, 1354, 63, 1997, 4591, 7, 221, 327, 7525, 436, 4568, 5944, 787, 199, 3, 440, 641, 21724, 199, 199, 12231, 63, 26999, 63, 907, 22679, 275, 359, 10401, 61, 221, 327, 6363, 781, 883, 11620, 19457, 687, 199, 12231, 63, 30322, 63, 907, 22679, 275, 27805, 63, 26999, 63, 907, 22679, 435, 359, 11632, 19359, 12, 510, 33, 8558, 12, 428, 28011, 25518, 12, 12539, 61, 199, 3, 6363, 781, 2040, 7508, 19457, 687, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
purpleKarrot/fluorescence
gumps/spellbook.py
12
4103
import ui from data import Texture, TextureSource, rgba import client def create(args): g = ui.GumpMenu("spellbook", 100, 100) g.setFont("Devinne Swash", 16) g.addPage(0) g.addImage((0, 0), Texture(TextureSource.GUMPART, 2220)) # circle numbers g.addPageButton((58, 175), Texture(TextureSource.GUMPART, 2225), 1) g.addPageButton((92, 175), Texture(TextureSource.GUMPART, 2226), 1) g.addPageButton((129, 175), Texture(TextureSource.GUMPART, 2227), 2) g.addPageButton((164, 175), Texture(TextureSource.GUMPART, 2228), 2) g.addPageButton((227, 175), Texture(TextureSource.GUMPART, 2229), 3) g.addPageButton((260, 175), Texture(TextureSource.GUMPART, 2230), 3) g.addPageButton((297, 175), Texture(TextureSource.GUMPART, 2231), 4) g.addPageButton((332, 175), Texture(TextureSource.GUMPART, 2232), 4) # circles is a list of dictionaries, each dictionary holding a list of spells and infos about the circle: # circle["spells"]: list of spells # ["id"]: numerical id # ["name"]: name # each spell is a tuple # (id, name, wops, descriptionHeader, description, gumpid) # id: numerical id # name: name # wops: words of power # descriptionHeader: header text of the spell description # description: spell description # gumpid: spell icon id circles = args["circles"] page = 0 spellPage = 5 spellCount = 0 # circle overviews for circle in circles: if circle["id"] % 2 == 1: # left page page += 1 g.addPage(page) # flip back if page > 1: g.addPageButton((50, 8), Texture(TextureSource.GUMPART, 2235), page - 1) # flip forward g.addPageButton((321, 8), Texture(TextureSource.GUMPART, 2236), page + 1) addTitleLabel(g, (100, 14, 40, 15), "INDEX") addTitleLabel(g, (55, 34, 150, 15), circle["name"]) spellX = 55 else: # right page addTitleLabel(g, (267, 14, 40, 15), "INDEX") addTitleLabel(g, (223, 34, 150, 15), circle["name"]) spellX = 223 spellY = 50 for spell in circle["spells"]: l = addTextLabel(g, (spellX, spellY, 150, 15), spell[1]) l.page = spellPage # flip gump to this page if clicked spellCount += 1 if spellCount % 2 == 0: spellPage += 1 spellY += 15 spellPage = 5 spellCount = 0 x = 0 for circle in circles: for spell in circle["spells"]: if spellCount % 2 == 0: # add flip forward to previous page if spellCount > 1: g.addPageButton((321, 8), Texture(TextureSource.GUMPART, 2236), spellPage + 1) g.addPage(spellPage) # flip back g.addPageButton((50, 8), Texture(TextureSource.GUMPART, 2235), spellPage - 1) spellPage += 1 x = 0 # circle header for left page addTitleLabel(g, (x + 85, 14, 100, 15), circle["name"]) else: # circle header for right page addTitleLabel(g, (x + 65, 14, 100, 15), circle["name"]) # spell name addTitleLabel(g, (x + 105, 38, 90, 35), spell[1]) # description title addTitleLabel(g, (x + 55, 95, 150, 15), spell[3]) # description addTextLabel(g, (x + 55, 110, 150, 55), spell[4]) # spell icon btCast = g.addPythonButton((x + 55, 40), Texture(TextureSource.GUMPART, spell[5]), castSpell) btCast.store["spellid"] = spell[0] spellCount += 1 x += 168 args["item"].setSpellbookGump(g) def addTitleLabel(g, geom, text): l = g.addLabel(geom, text) l.rgba = rgba("#001052") return l def addTextLabel(g, geom, text): l = g.addLabel(geom, text) l.rgba = rgba("#5a4a31") return l def castSpell(button): client.castSpell(button.store["spellid"])
gpl-3.0
[ 199, 646, 8574, 199, 504, 666, 492, 4516, 608, 12, 4516, 608, 2980, 12, 23136, 2470, 199, 646, 1890, 199, 199, 318, 1218, 8, 589, 304, 272, 486, 275, 8574, 14, 39, 1220, 5977, 480, 32252, 2706, 401, 2948, 12, 2948, 9, 272, 486, 14, 24432, 480, 872, 11908, 685, 16666, 1119, 401, 3193, 9, 339, 486, 14, 525, 3276, 8, 16, 9, 272, 486, 14, 525, 3491, 1332, 16, 12, 378, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11174, 430, 339, 327, 17990, 5579, 272, 486, 14, 525, 3276, 4259, 1332, 2010, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 821, 395, 413, 9, 272, 486, 14, 525, 3276, 4259, 1332, 2942, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11085, 395, 413, 9, 272, 486, 14, 525, 3276, 4259, 1332, 7263, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11385, 395, 499, 9, 272, 486, 14, 525, 3276, 4259, 1332, 8982, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 12048, 395, 499, 9, 272, 486, 14, 525, 3276, 4259, 1332, 11385, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11182, 395, 650, 9, 272, 486, 14, 525, 3276, 4259, 1332, 13085, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1216, 395, 650, 9, 272, 486, 14, 525, 3276, 4259, 1332, 12615, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11921, 395, 841, 9, 272, 486, 14, 525, 3276, 4259, 1332, 9526, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 708, 395, 841, 9, 339, 327, 17990, 83, 365, 282, 769, 402, 11196, 12, 1924, 2600, 17573, 282, 769, 402, 14475, 76, 478, 436, 24485, 3595, 314, 17990, 26, 272, 327, 17990, 905, 12325, 76, 478, 6229, 769, 402, 14475, 76, 478, 272, 327, 2097, 344, 6229, 15470, 1305, 272, 327, 2097, 354, 6229, 536, 339, 327, 1924, 14475, 914, 365, 282, 2008, 272, 327, 334, 344, 12, 536, 12, 336, 1483, 12, 1369, 2567, 12, 1369, 12, 486, 1220, 344, 9, 272, 327, 1305, 26, 15470, 1305, 272, 327, 536, 26, 536, 272, 327, 336, 1483, 26, 5932, 402, 7074, 272, 327, 1369, 2567, 26, 1406, 1318, 402, 314, 14475, 914, 1369, 272, 327, 1369, 26, 14475, 914, 1369, 272, 327, 486, 1220, 344, 26, 14475, 914, 7016, 1305, 272, 17990, 83, 275, 1249, 905, 6092, 2978, 937, 339, 2034, 275, 378, 272, 14475, 914, 3276, 275, 959, 272, 14475, 914, 2353, 275, 378, 272, 327, 17990, 1806, 4196, 272, 367, 17990, 315, 17990, 83, 26, 267, 340, 17990, 905, 344, 937, 450, 499, 508, 413, 26, 288, 327, 3602, 2034, 288, 2034, 847, 413, 288, 486, 14, 525, 3276, 8, 1606, 9, 953, 327, 18761, 1771, 288, 340, 2034, 690, 413, 26, 355, 486, 14, 525, 3276, 4259, 1332, 1400, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1276, 395, 2034, 446, 413, 9, 288, 327, 18761, 7568, 288, 486, 14, 525, 3276, 4259, 1332, 12638, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1344, 395, 2034, 435, 413, 9, 953, 1050, 6888, 4314, 8, 71, 12, 334, 1960, 12, 4329, 12, 6335, 12, 4114, 395, 298, 10215, 531, 288, 1050, 6888, 4314, 8, 71, 12, 334, 1229, 12, 8177, 12, 14711, 12, 4114, 395, 17990, 905, 354, 3135, 953, 14475, 914, 56, 275, 12766, 267, 587, 26, 288, 327, 2451, 2034, 288, 1050, 6888, 4314, 8, 71, 12, 334, 13406, 12, 4329, 12, 6335, 12, 4114, 395, 298, 10215, 531, 288, 1050, 6888, 4314, 8, 71, 12, 334, 11583, 12, 8177, 12, 14711, 12, 4114, 395, 17990, 905, 354, 3135, 953, 14475, 914, 56, 275, 499, 1789, 398, 14475, 914, 57, 275, 5238, 267, 367, 14475, 914, 315, 17990, 905, 12325, 76, 478, 6229, 288, 634, 275, 1050, 1872, 4314, 8, 71, 12, 334, 32252, 56, 12, 14475, 914, 57, 12, 14711, 12, 4114, 395, 14475, 914, 59, 17, 566, 288, 634, 14, 1606, 275, 14475, 914, 3276, 327, 18761, 486, 1220, 370, 642, 2034, 340, 28614, 288, 14475, 914, 2353, 847, 413, 288, 340, 14475, 914, 2353, 450, 499, 508, 378, 26, 355, 14475, 914, 3276, 847, 413, 953, 14475, 914, 57, 847, 4114, 339, 14475, 914, 3276, 275, 959, 272, 14475, 914, 2353, 275, 378, 272, 671, 275, 378, 272, 367, 17990, 315, 17990, 83, 26, 267, 367, 14475, 914, 315, 17990, 905, 12325, 76, 478, 6229, 288, 340, 14475, 914, 2353, 450, 499, 508, 378, 26, 355, 327, 1050, 18761, 7568, 370, 4136, 2034, 355, 340, 14475, 914, 2353, 690, 413, 26, 490, 486, 14, 525, 3276, 4259, 1332, 12638, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1344, 395, 14475, 914, 3276, 435, 413, 9, 355, 486, 14, 525, 3276, 8, 32252, 3276, 9, 355, 327, 18761, 1771, 355, 486, 14, 525, 3276, 4259, 1332, 1400, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1276, 395, 14475, 914, 3276, 446, 413, 9, 355, 14475, 914, 3276, 847, 413, 355, 671, 275, 378, 2234, 327, 17990, 1406, 367, 3602, 2034, 355, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 16412, 12, 4329, 12, 2948, 12, 4114, 395, 17990, 905, 354, 3135, 288, 587, 26, 355, 327, 17990, 1406, 367, 2451, 2034, 355, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 11738, 12, 4329, 12, 2948, 12, 4114, 395, 17990, 905, 354, 3135, 953, 327, 14475, 914, 536, 288, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 20462, 12, 10448, 12, 9137, 12, 8685, 395, 14475, 914, 59, 17, 566, 288, 327, 1369, 2538, 288, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 12766, 12, 16102, 12, 14711, 12, 4114, 395, 14475, 914, 59, 19, 566, 288, 327, 1369, 288, 1050, 1872, 4314, 8, 71, 12, 334, 88, 435, 12766, 12, 16814, 12, 14711, 12, 12766, 395 ]
[ 646, 8574, 199, 504, 666, 492, 4516, 608, 12, 4516, 608, 2980, 12, 23136, 2470, 199, 646, 1890, 199, 199, 318, 1218, 8, 589, 304, 272, 486, 275, 8574, 14, 39, 1220, 5977, 480, 32252, 2706, 401, 2948, 12, 2948, 9, 272, 486, 14, 24432, 480, 872, 11908, 685, 16666, 1119, 401, 3193, 9, 339, 486, 14, 525, 3276, 8, 16, 9, 272, 486, 14, 525, 3491, 1332, 16, 12, 378, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11174, 430, 339, 327, 17990, 5579, 272, 486, 14, 525, 3276, 4259, 1332, 2010, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 821, 395, 413, 9, 272, 486, 14, 525, 3276, 4259, 1332, 2942, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11085, 395, 413, 9, 272, 486, 14, 525, 3276, 4259, 1332, 7263, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11385, 395, 499, 9, 272, 486, 14, 525, 3276, 4259, 1332, 8982, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 12048, 395, 499, 9, 272, 486, 14, 525, 3276, 4259, 1332, 11385, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11182, 395, 650, 9, 272, 486, 14, 525, 3276, 4259, 1332, 13085, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1216, 395, 650, 9, 272, 486, 14, 525, 3276, 4259, 1332, 12615, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 499, 11921, 395, 841, 9, 272, 486, 14, 525, 3276, 4259, 1332, 9526, 12, 27306, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 708, 395, 841, 9, 339, 327, 17990, 83, 365, 282, 769, 402, 11196, 12, 1924, 2600, 17573, 282, 769, 402, 14475, 76, 478, 436, 24485, 3595, 314, 17990, 26, 272, 327, 17990, 905, 12325, 76, 478, 6229, 769, 402, 14475, 76, 478, 272, 327, 2097, 344, 6229, 15470, 1305, 272, 327, 2097, 354, 6229, 536, 339, 327, 1924, 14475, 914, 365, 282, 2008, 272, 327, 334, 344, 12, 536, 12, 336, 1483, 12, 1369, 2567, 12, 1369, 12, 486, 1220, 344, 9, 272, 327, 1305, 26, 15470, 1305, 272, 327, 536, 26, 536, 272, 327, 336, 1483, 26, 5932, 402, 7074, 272, 327, 1369, 2567, 26, 1406, 1318, 402, 314, 14475, 914, 1369, 272, 327, 1369, 26, 14475, 914, 1369, 272, 327, 486, 1220, 344, 26, 14475, 914, 7016, 1305, 272, 17990, 83, 275, 1249, 905, 6092, 2978, 937, 339, 2034, 275, 378, 272, 14475, 914, 3276, 275, 959, 272, 14475, 914, 2353, 275, 378, 272, 327, 17990, 1806, 4196, 272, 367, 17990, 315, 17990, 83, 26, 267, 340, 17990, 905, 344, 937, 450, 499, 508, 413, 26, 288, 327, 3602, 2034, 288, 2034, 847, 413, 288, 486, 14, 525, 3276, 8, 1606, 9, 953, 327, 18761, 1771, 288, 340, 2034, 690, 413, 26, 355, 486, 14, 525, 3276, 4259, 1332, 1400, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1276, 395, 2034, 446, 413, 9, 288, 327, 18761, 7568, 288, 486, 14, 525, 3276, 4259, 1332, 12638, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1344, 395, 2034, 435, 413, 9, 953, 1050, 6888, 4314, 8, 71, 12, 334, 1960, 12, 4329, 12, 6335, 12, 4114, 395, 298, 10215, 531, 288, 1050, 6888, 4314, 8, 71, 12, 334, 1229, 12, 8177, 12, 14711, 12, 4114, 395, 17990, 905, 354, 3135, 953, 14475, 914, 56, 275, 12766, 267, 587, 26, 288, 327, 2451, 2034, 288, 1050, 6888, 4314, 8, 71, 12, 334, 13406, 12, 4329, 12, 6335, 12, 4114, 395, 298, 10215, 531, 288, 1050, 6888, 4314, 8, 71, 12, 334, 11583, 12, 8177, 12, 14711, 12, 4114, 395, 17990, 905, 354, 3135, 953, 14475, 914, 56, 275, 499, 1789, 398, 14475, 914, 57, 275, 5238, 267, 367, 14475, 914, 315, 17990, 905, 12325, 76, 478, 6229, 288, 634, 275, 1050, 1872, 4314, 8, 71, 12, 334, 32252, 56, 12, 14475, 914, 57, 12, 14711, 12, 4114, 395, 14475, 914, 59, 17, 566, 288, 634, 14, 1606, 275, 14475, 914, 3276, 327, 18761, 486, 1220, 370, 642, 2034, 340, 28614, 288, 14475, 914, 2353, 847, 413, 288, 340, 14475, 914, 2353, 450, 499, 508, 378, 26, 355, 14475, 914, 3276, 847, 413, 953, 14475, 914, 57, 847, 4114, 339, 14475, 914, 3276, 275, 959, 272, 14475, 914, 2353, 275, 378, 272, 671, 275, 378, 272, 367, 17990, 315, 17990, 83, 26, 267, 367, 14475, 914, 315, 17990, 905, 12325, 76, 478, 6229, 288, 340, 14475, 914, 2353, 450, 499, 508, 378, 26, 355, 327, 1050, 18761, 7568, 370, 4136, 2034, 355, 340, 14475, 914, 2353, 690, 413, 26, 490, 486, 14, 525, 3276, 4259, 1332, 12638, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1344, 395, 14475, 914, 3276, 435, 413, 9, 355, 486, 14, 525, 3276, 8, 32252, 3276, 9, 355, 327, 18761, 1771, 355, 486, 14, 525, 3276, 4259, 1332, 1400, 12, 1695, 395, 4516, 608, 8, 17165, 2980, 14, 17188, 1658, 2294, 12, 6928, 1276, 395, 14475, 914, 3276, 446, 413, 9, 355, 14475, 914, 3276, 847, 413, 355, 671, 275, 378, 2234, 327, 17990, 1406, 367, 3602, 2034, 355, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 16412, 12, 4329, 12, 2948, 12, 4114, 395, 17990, 905, 354, 3135, 288, 587, 26, 355, 327, 17990, 1406, 367, 2451, 2034, 355, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 11738, 12, 4329, 12, 2948, 12, 4114, 395, 17990, 905, 354, 3135, 953, 327, 14475, 914, 536, 288, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 20462, 12, 10448, 12, 9137, 12, 8685, 395, 14475, 914, 59, 17, 566, 288, 327, 1369, 2538, 288, 1050, 6888, 4314, 8, 71, 12, 334, 88, 435, 12766, 12, 16102, 12, 14711, 12, 4114, 395, 14475, 914, 59, 19, 566, 288, 327, 1369, 288, 1050, 1872, 4314, 8, 71, 12, 334, 88, 435, 12766, 12, 16814, 12, 14711, 12, 12766, 395, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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/_pydevd_bundle/pydevd_custom_frames.py
2
4396
from _pydevd_bundle.pydevd_constants import get_current_thread_id, Null, ForkSafeLock from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame from _pydev_imps._pydev_saved_modules import thread, threading import sys from _pydev_bundle import pydev_log DEBUG = False class CustomFramesContainer: # Actual Values initialized later on. custom_frames_lock = None # : :type custom_frames_lock: threading.Lock custom_frames = None _next_frame_id = None _py_db_command_thread_event = None def custom_frames_container_init(): # Note: no staticmethod on jython 2.1 (so, use free-function) CustomFramesContainer.custom_frames_lock = ForkSafeLock() # custom_frames can only be accessed if properly locked with custom_frames_lock! # Key is a string identifying the frame (as well as the thread it belongs to). # Value is a CustomFrame. # CustomFramesContainer.custom_frames = {} # Only to be used in this module CustomFramesContainer._next_frame_id = 0 # This is the event we must set to release an internal process events. It's later set by the actual debugger # when we do create the debugger. CustomFramesContainer._py_db_command_thread_event = Null() # Initialize it the first time (it may be reinitialized later on when dealing with a fork). custom_frames_container_init() class CustomFrame: def __init__(self, name, frame, thread_id): # 0 = string with the representation of that frame self.name = name # 1 = the frame to show self.frame = frame # 2 = an integer identifying the last time the frame was changed. self.mod_time = 0 # 3 = the thread id of the given frame self.thread_id = thread_id def add_custom_frame(frame, name, thread_id): ''' It's possible to show paused frames by adding a custom frame through this API (it's intended to be used for coroutines, but could potentially be used for generators too). :param frame: The topmost frame to be shown paused when a thread with thread.ident == thread_id is paused. :param name: The name to be shown for the custom thread in the UI. :param thread_id: The thread id to which this frame is related (must match thread.ident). :return: str Returns the custom thread id which will be used to show the given frame paused. ''' with CustomFramesContainer.custom_frames_lock: curr_thread_id = get_current_thread_id(threading.currentThread()) next_id = CustomFramesContainer._next_frame_id = CustomFramesContainer._next_frame_id + 1 # Note: the frame id kept contains an id and thread information on the thread where the frame was added # so that later on we can check if the frame is from the current thread by doing frame_id.endswith('|'+thread_id). frame_custom_thread_id = '__frame__:%s|%s' % (next_id, curr_thread_id) if DEBUG: sys.stderr.write('add_custom_frame: %s (%s) %s %s\n' % ( frame_custom_thread_id, get_abs_path_real_path_and_base_from_frame(frame)[-1], frame.f_lineno, frame.f_code.co_name)) CustomFramesContainer.custom_frames[frame_custom_thread_id] = CustomFrame(name, frame, thread_id) CustomFramesContainer._py_db_command_thread_event.set() return frame_custom_thread_id def update_custom_frame(frame_custom_thread_id, frame, thread_id, name=None): with CustomFramesContainer.custom_frames_lock: if DEBUG: sys.stderr.write('update_custom_frame: %s\n' % frame_custom_thread_id) try: old = CustomFramesContainer.custom_frames[frame_custom_thread_id] if name is not None: old.name = name old.mod_time += 1 old.thread_id = thread_id except: sys.stderr.write('Unable to get frame to replace: %s\n' % (frame_custom_thread_id,)) pydev_log.exception() CustomFramesContainer._py_db_command_thread_event.set() def remove_custom_frame(frame_custom_thread_id): with CustomFramesContainer.custom_frames_lock: if DEBUG: sys.stderr.write('remove_custom_frame: %s\n' % frame_custom_thread_id) CustomFramesContainer.custom_frames.pop(frame_custom_thread_id, None) CustomFramesContainer._py_db_command_thread_event.set()
epl-1.0
[ 504, 485, 23996, 68, 63, 6469, 14, 23996, 68, 63, 5559, 492, 664, 63, 1818, 63, 2671, 63, 344, 12, 12119, 12, 2104, 75, 11090, 6432, 199, 504, 29240, 68, 63, 493, 63, 1208, 492, 664, 63, 2101, 63, 515, 63, 3093, 63, 515, 63, 460, 63, 1095, 63, 504, 63, 1943, 199, 504, 485, 23996, 63, 3236, 83, 423, 23996, 63, 8420, 63, 3112, 492, 2462, 12, 5796, 199, 646, 984, 199, 504, 485, 23996, 63, 6469, 492, 29240, 63, 793, 199, 199, 5287, 275, 756, 421, 199, 533, 8388, 22024, 4076, 26, 339, 327, 18982, 1061, 13468, 10038, 2945, 641, 14, 272, 3537, 63, 8444, 63, 831, 275, 488, 221, 327, 520, 520, 466, 3537, 63, 8444, 63, 831, 26, 5796, 14, 6432, 339, 3537, 63, 8444, 275, 488, 339, 485, 2184, 63, 1943, 63, 344, 275, 488, 339, 485, 647, 63, 697, 63, 1531, 63, 2671, 63, 1430, 275, 488, 421, 199, 318, 3537, 63, 8444, 63, 3600, 63, 826, 837, 221, 327, 3390, 26, 949, 12822, 641, 1335, 11361, 499, 14, 17, 334, 1152, 12, 675, 2867, 13, 1593, 9, 339, 8388, 22024, 4076, 14, 4229, 63, 8444, 63, 831, 275, 2104, 75, 11090, 6432, 342, 339, 327, 3537, 63, 8444, 883, 1454, 506, 13810, 340, 7684, 14233, 543, 3537, 63, 8444, 63, 831, 1, 272, 327, 2606, 365, 282, 1059, 21119, 314, 2787, 334, 305, 5521, 465, 314, 2462, 652, 15006, 370, 680, 272, 327, 1594, 365, 282, 8388, 3160, 14, 272, 327, 272, 8388, 22024, 4076, 14, 4229, 63, 8444, 275, 1052, 339, 327, 5972, 370, 506, 1202, 315, 642, 859, 272, 8388, 22024, 4076, 423, 2184, 63, 1943, 63, 344, 275, 378, 339, 327, 961, 365, 314, 1566, 781, 1471, 663, 370, 4683, 376, 5007, 2112, 4474, 14, 2779, 1159, 2945, 663, 701, 314, 3503, 14958, 272, 327, 1380, 781, 886, 1218, 314, 14958, 14, 272, 8388, 22024, 4076, 423, 647, 63, 697, 63, 1531, 63, 2671, 63, 1430, 275, 12119, 342, 421, 199, 3, 11578, 652, 314, 1642, 900, 334, 390, 1443, 506, 295, 12486, 2945, 641, 1380, 23654, 543, 282, 14926, 680, 199, 4229, 63, 8444, 63, 3600, 63, 826, 342, 421, 199, 533, 8388, 3160, 26, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2787, 12, 2462, 63, 344, 304, 267, 327, 378, 275, 1059, 543, 314, 6025, 402, 626, 2787, 267, 291, 14, 354, 275, 536, 398, 327, 413, 275, 314, 2787, 370, 2498, 267, 291, 14, 1943, 275, 2787, 398, 327, 499, 275, 376, 3000, 21119, 314, 2061, 900, 314, 2787, 1990, 2896, 14, 267, 291, 14, 1494, 63, 521, 275, 378, 398, 327, 650, 275, 314, 2462, 1305, 402, 314, 1627, 2787, 267, 291, 14, 2671, 63, 344, 275, 2462, 63, 344, 421, 199, 318, 1050, 63, 4229, 63, 1943, 8, 1943, 12, 536, 12, 2462, 63, 344, 304, 272, 1449, 272, 2779, 1159, 3962, 370, 2498, 691, 2972, 11223, 701, 7791, 282, 3537, 2787, 4012, 642, 3261, 334, 390, 1159, 272, 11619, 370, 506, 1202, 367, 1970, 548, 3746, 12, 1325, 4293, 18994, 506, 1202, 367, 16952, 4634, 680, 339, 520, 635, 2787, 26, 267, 710, 2746, 2786, 2787, 370, 506, 9164, 691, 2972, 1380, 282, 2462, 543, 2462, 14, 5425, 508, 2462, 63, 344, 365, 691, 2972, 14, 339, 520, 635, 536, 26, 267, 710, 536, 370, 506, 9164, 367, 314, 3537, 2462, 315, 314, 14041, 14, 339, 520, 635, 2462, 63, 344, 26, 267, 710, 2462, 1305, 370, 1314, 642, 2787, 365, 4048, 334, 7790, 1336, 2462, 14, 5425, 680, 339, 520, 1107, 26, 620, 267, 1803, 314, 3537, 2462, 1305, 1314, 911, 506, 1202, 370, 2498, 314, 1627, 2787, 691, 2972, 14, 272, 1449, 272, 543, 8388, 22024, 4076, 14, 4229, 63, 8444, 63, 831, 26, 267, 8230, 63, 2671, 63, 344, 275, 664, 63, 1818, 63, 2671, 63, 344, 8, 12562, 14, 1818, 4436, 1012, 267, 2163, 63, 344, 275, 8388, 22024, 4076, 423, 2184, 63, 1943, 63, 344, 275, 8388, 22024, 4076, 423, 2184, 63, 1943, 63, 344, 435, 413, 398, 327, 3390, 26, 314, 2787, 1305, 16204, 3509, 376, 1305, 436, 2462, 2556, 641, 314, 2462, 2382, 314, 2787, 1990, 3483, 267, 327, 880, 626, 2945, 641, 781, 883, 1104, 340, 314, 2787, 365, 687, 314, 1453, 2462, 701, 9689, 2787, 63, 344, 14, 4130, 360, 5227, 11, 2671, 63, 344, 680, 267, 2787, 63, 4229, 63, 2671, 63, 344, 275, 2560, 1943, 363, 2689, 83, 15287, 83, 7, 450, 334, 2184, 63, 344, 12, 8230, 63, 2671, 63, 344, 9, 267, 340, 10990, 26, 288, 984, 14, 3083, 14, 952, 360, 525, 63, 4229, 63, 1943, 26, 450, 83, 4366, 83, 9, 450, 83, 450, 83, 60, 78, 7, 450, 334, 355, 2787, 63, 4229, 63, 2671, 63, 344, 12, 664, 63, 2101, 63, 515, 63, 3093, 63, 515, 63, 460, 63, 1095, 63, 504, 63, 1943, 8, 1943, 15786, 17, 467, 2787, 14, 70, 63, 3469, 12, 2787, 14, 70, 63, 600, 14, 331, 63, 354, 430, 398, 8388, 22024, 4076, 14, 4229, 63, 8444, 59, 1943, 63, 4229, 63, 2671, 63, 344, 61, 275, 8388, 3160, 8, 354, 12, 2787, 12, 2462, 63, 344, 9, 267, 8388, 22024, 4076, 423, 647, 63, 697, 63, 1531, 63, 2671, 63, 1430, 14, 409, 342, 267, 372, 2787, 63, 4229, 63, 2671, 63, 344, 421, 199, 318, 1678, 63, 4229, 63, 1943, 8, 1943, 63, 4229, 63, 2671, 63, 344, 12, 2787, 12, 2462, 63, 344, 12, 536, 29, 403, 304, 272, 543, 8388, 22024, 4076, 14, 4229, 63, 8444, 63, 831, 26, 267, 340, 10990, 26, 288, 984, 14, 3083, 14, 952, 360, 873, 63, 4229, 63, 1943, 26, 450, 83, 60, 78, 7, 450, 2787, 63, 4229, 63, 2671, 63, 344, 9, 267, 862, 26, 288, 2269, 275, 8388, 22024, 4076, 14, 4229, 63, 8444, 59, 1943, 63, 4229, 63, 2671, 63, 344, 61, 288, 340, 536, 365, 440, 488, 26, 355, 2269, 14, 354, 275, 536, 288, 2269, 14, 1494, 63, 521, 847, 413, 288, 2269, 14, 2671, 63, 344, 275, 2462, 63, 344, 267, 871, 26, 288, 984, 14, 3083, 14, 952, 360, 6005, 370, 664, 2787, 370, 3350 ]
[ 485, 23996, 68, 63, 6469, 14, 23996, 68, 63, 5559, 492, 664, 63, 1818, 63, 2671, 63, 344, 12, 12119, 12, 2104, 75, 11090, 6432, 199, 504, 29240, 68, 63, 493, 63, 1208, 492, 664, 63, 2101, 63, 515, 63, 3093, 63, 515, 63, 460, 63, 1095, 63, 504, 63, 1943, 199, 504, 485, 23996, 63, 3236, 83, 423, 23996, 63, 8420, 63, 3112, 492, 2462, 12, 5796, 199, 646, 984, 199, 504, 485, 23996, 63, 6469, 492, 29240, 63, 793, 199, 199, 5287, 275, 756, 421, 199, 533, 8388, 22024, 4076, 26, 339, 327, 18982, 1061, 13468, 10038, 2945, 641, 14, 272, 3537, 63, 8444, 63, 831, 275, 488, 221, 327, 520, 520, 466, 3537, 63, 8444, 63, 831, 26, 5796, 14, 6432, 339, 3537, 63, 8444, 275, 488, 339, 485, 2184, 63, 1943, 63, 344, 275, 488, 339, 485, 647, 63, 697, 63, 1531, 63, 2671, 63, 1430, 275, 488, 421, 199, 318, 3537, 63, 8444, 63, 3600, 63, 826, 837, 221, 327, 3390, 26, 949, 12822, 641, 1335, 11361, 499, 14, 17, 334, 1152, 12, 675, 2867, 13, 1593, 9, 339, 8388, 22024, 4076, 14, 4229, 63, 8444, 63, 831, 275, 2104, 75, 11090, 6432, 342, 339, 327, 3537, 63, 8444, 883, 1454, 506, 13810, 340, 7684, 14233, 543, 3537, 63, 8444, 63, 831, 1, 272, 327, 2606, 365, 282, 1059, 21119, 314, 2787, 334, 305, 5521, 465, 314, 2462, 652, 15006, 370, 680, 272, 327, 1594, 365, 282, 8388, 3160, 14, 272, 327, 272, 8388, 22024, 4076, 14, 4229, 63, 8444, 275, 1052, 339, 327, 5972, 370, 506, 1202, 315, 642, 859, 272, 8388, 22024, 4076, 423, 2184, 63, 1943, 63, 344, 275, 378, 339, 327, 961, 365, 314, 1566, 781, 1471, 663, 370, 4683, 376, 5007, 2112, 4474, 14, 2779, 1159, 2945, 663, 701, 314, 3503, 14958, 272, 327, 1380, 781, 886, 1218, 314, 14958, 14, 272, 8388, 22024, 4076, 423, 647, 63, 697, 63, 1531, 63, 2671, 63, 1430, 275, 12119, 342, 421, 199, 3, 11578, 652, 314, 1642, 900, 334, 390, 1443, 506, 295, 12486, 2945, 641, 1380, 23654, 543, 282, 14926, 680, 199, 4229, 63, 8444, 63, 3600, 63, 826, 342, 421, 199, 533, 8388, 3160, 26, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2787, 12, 2462, 63, 344, 304, 267, 327, 378, 275, 1059, 543, 314, 6025, 402, 626, 2787, 267, 291, 14, 354, 275, 536, 398, 327, 413, 275, 314, 2787, 370, 2498, 267, 291, 14, 1943, 275, 2787, 398, 327, 499, 275, 376, 3000, 21119, 314, 2061, 900, 314, 2787, 1990, 2896, 14, 267, 291, 14, 1494, 63, 521, 275, 378, 398, 327, 650, 275, 314, 2462, 1305, 402, 314, 1627, 2787, 267, 291, 14, 2671, 63, 344, 275, 2462, 63, 344, 421, 199, 318, 1050, 63, 4229, 63, 1943, 8, 1943, 12, 536, 12, 2462, 63, 344, 304, 272, 1449, 272, 2779, 1159, 3962, 370, 2498, 691, 2972, 11223, 701, 7791, 282, 3537, 2787, 4012, 642, 3261, 334, 390, 1159, 272, 11619, 370, 506, 1202, 367, 1970, 548, 3746, 12, 1325, 4293, 18994, 506, 1202, 367, 16952, 4634, 680, 339, 520, 635, 2787, 26, 267, 710, 2746, 2786, 2787, 370, 506, 9164, 691, 2972, 1380, 282, 2462, 543, 2462, 14, 5425, 508, 2462, 63, 344, 365, 691, 2972, 14, 339, 520, 635, 536, 26, 267, 710, 536, 370, 506, 9164, 367, 314, 3537, 2462, 315, 314, 14041, 14, 339, 520, 635, 2462, 63, 344, 26, 267, 710, 2462, 1305, 370, 1314, 642, 2787, 365, 4048, 334, 7790, 1336, 2462, 14, 5425, 680, 339, 520, 1107, 26, 620, 267, 1803, 314, 3537, 2462, 1305, 1314, 911, 506, 1202, 370, 2498, 314, 1627, 2787, 691, 2972, 14, 272, 1449, 272, 543, 8388, 22024, 4076, 14, 4229, 63, 8444, 63, 831, 26, 267, 8230, 63, 2671, 63, 344, 275, 664, 63, 1818, 63, 2671, 63, 344, 8, 12562, 14, 1818, 4436, 1012, 267, 2163, 63, 344, 275, 8388, 22024, 4076, 423, 2184, 63, 1943, 63, 344, 275, 8388, 22024, 4076, 423, 2184, 63, 1943, 63, 344, 435, 413, 398, 327, 3390, 26, 314, 2787, 1305, 16204, 3509, 376, 1305, 436, 2462, 2556, 641, 314, 2462, 2382, 314, 2787, 1990, 3483, 267, 327, 880, 626, 2945, 641, 781, 883, 1104, 340, 314, 2787, 365, 687, 314, 1453, 2462, 701, 9689, 2787, 63, 344, 14, 4130, 360, 5227, 11, 2671, 63, 344, 680, 267, 2787, 63, 4229, 63, 2671, 63, 344, 275, 2560, 1943, 363, 2689, 83, 15287, 83, 7, 450, 334, 2184, 63, 344, 12, 8230, 63, 2671, 63, 344, 9, 267, 340, 10990, 26, 288, 984, 14, 3083, 14, 952, 360, 525, 63, 4229, 63, 1943, 26, 450, 83, 4366, 83, 9, 450, 83, 450, 83, 60, 78, 7, 450, 334, 355, 2787, 63, 4229, 63, 2671, 63, 344, 12, 664, 63, 2101, 63, 515, 63, 3093, 63, 515, 63, 460, 63, 1095, 63, 504, 63, 1943, 8, 1943, 15786, 17, 467, 2787, 14, 70, 63, 3469, 12, 2787, 14, 70, 63, 600, 14, 331, 63, 354, 430, 398, 8388, 22024, 4076, 14, 4229, 63, 8444, 59, 1943, 63, 4229, 63, 2671, 63, 344, 61, 275, 8388, 3160, 8, 354, 12, 2787, 12, 2462, 63, 344, 9, 267, 8388, 22024, 4076, 423, 647, 63, 697, 63, 1531, 63, 2671, 63, 1430, 14, 409, 342, 267, 372, 2787, 63, 4229, 63, 2671, 63, 344, 421, 199, 318, 1678, 63, 4229, 63, 1943, 8, 1943, 63, 4229, 63, 2671, 63, 344, 12, 2787, 12, 2462, 63, 344, 12, 536, 29, 403, 304, 272, 543, 8388, 22024, 4076, 14, 4229, 63, 8444, 63, 831, 26, 267, 340, 10990, 26, 288, 984, 14, 3083, 14, 952, 360, 873, 63, 4229, 63, 1943, 26, 450, 83, 60, 78, 7, 450, 2787, 63, 4229, 63, 2671, 63, 344, 9, 267, 862, 26, 288, 2269, 275, 8388, 22024, 4076, 14, 4229, 63, 8444, 59, 1943, 63, 4229, 63, 2671, 63, 344, 61, 288, 340, 536, 365, 440, 488, 26, 355, 2269, 14, 354, 275, 536, 288, 2269, 14, 1494, 63, 521, 847, 413, 288, 2269, 14, 2671, 63, 344, 275, 2462, 63, 344, 267, 871, 26, 288, 984, 14, 3083, 14, 952, 360, 6005, 370, 664, 2787, 370, 3350, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xiaoyexu/xCRM
setup.py
1
19311
# -*- coding: UTF-8 -*- import os, django os.environ['DJANGO_SETTINGS_MODULE'] = 'crm_site.settings' django.setup() from crm.models import * from crm.common import * # Demo initialize # UserRoleType userRoleTypes = [ ['SALES_ROLE', u"销售"], ['DEV_ROLE', u"CRM开发"] ] for userRoleType in userRoleTypes: p = {} p['key'] = userRoleType[0] p['description'] = userRoleType[1] UserRoleType.objects.update_or_create(**p) # ViewType viewTypes = [ ['Search', u"Search View"], ['Result', u"Result View"], ['Detail', u"Detail View"] ] for viewType in viewTypes: p = {} p['key'] = viewType[0] p['description'] = viewType[1] ViewType.objects.update_or_create(**p) # SiteLanguage siteLanguages = [ ['en', u"English"], ['cn', u"中文"] ] for siteLanguage in siteLanguages: p = {} p['key'] = siteLanguage[0] p['description'] = siteLanguage[1] SiteLanguage.objects.update_or_create(**p) # SiteMenuItem siteMenuItems = [ ['SALES_ROLE', None, 'home', 'menu', 'home', 10, True], ['SALES_ROLE', None, 'comSearch', 'menu', 'commonOrder', 20, True] ] for siteMenuItem in siteMenuItems: p = {} p['role'] = UserRoleType.objects.get(pk=siteMenuItem[0]) p['parentMenuId'] = siteMenuItem[1] p['phraseId'] = siteMenuItem[2] p['appId'] = siteMenuItem[3] p['pageApp'] = siteMenuItem[4] p['sortOrder'] = siteMenuItem[5] p['valid'] = siteMenuItem[6] SiteMenuItem.objects.update_or_create(**p) # SiteMenuItem siteAppTypes = [ ['order', u"单据"], ['message', u"消息"], ['menu', u"菜单"], ['g_default', u"全局默认"], ['feedback', u"反馈"], ['calendar', u"日程"], ['bp', u"商业伙伴"] ] for siteAppType in siteAppTypes: p = {} p['appId'] = siteAppType[0] p['description'] = siteAppType[1] SiteAppType.objects.update_or_create(**p) userProfileTypes = [ ['P_SALE_BASIC', 'Sales basic profile'] ] for userProfileType in userProfileTypes: p = {} p['key'] = userProfileType[0] p['description'] = userProfileType[1] UserProfileType.objects.update_or_create(**p) authObjectTypes = [ ['Order_SA01_Access', 'For order type SA01'], ['Order_AC01_Access', 'For order type AC01'], ['BP_OR_Access', 'For organization access'], ['BP_IN_Access', 'For individual account access'], ['BP_CO_Access', 'For corporation accounts access'] ] for authObjectType in authObjectTypes: p = {} p['key'] = authObjectType[0] p['description'] = authObjectType[1] AuthObjectType.objects.update_or_create(**p) orderBaseTypes = [ ['Order', 'Order'], ['Activity', 'Activity'] ] for orderBaseType in orderBaseTypes: p = {} p['key'] = orderBaseType[0] p['description'] = orderBaseType[1] OrderBaseType.objects.update_or_create(**p) orderTypes = [ ['SA01', 'Order', u'销售线索', 'attachment,changelog'], ['AC01', 'Activity', u'日程活动', ''] ] for orderType in orderTypes: p = {} p['key'] = orderType[0] p['baseType'] = OrderBaseType.objects.get(pk=orderType[1]) p['description'] = orderType[2] p['assignmentBlock'] = orderType[3] OrderType.objects.update_or_create(**p) orderBEDefs = [ ['SA01', 'SaleOrderBE'], ['AC01', 'ActivityBE'] ] for orderBEDef in orderBEDefs: p = {} p['orderType'] = OrderType.objects.get(pk=orderBEDef[0]) p['businessEntity'] = orderBEDef[1] OrderBEDef.objects.update_or_create(**p) addressTypes = [ ['ST', u'默认地址'] ] for addressType in addressTypes: p = {} p['key'] = addressType[0] p['description'] = addressType[1] AddressType.objects.update_or_create(**p) bPTypes = [ ['ZZ', None, u'本公司', None], ['OR', None, u'部门组织', None], ['IN', None, u'个人账户', None], ['CO', None, u'公司账户', None] ] for bPType in bPTypes: p = {} p['key'] = bPType[0] p['baseType'] = None p['description'] = bPType[2] p['assignmentBlock'] = None BPType.objects.update_or_create(**p) userLoginStatuses = [ ['LOCK', u'已锁'], ['CLOSED', u'关闭'], ['ACTIVE', u'正常'] ] for userLoginStatus in userLoginStatuses: p = {} p['key'] = userLoginStatus[0] p['description'] = userLoginStatus[1] UserLoginStatus.objects.update_or_create(**p) # tester user firstName = 'tester' lastName = 'tester' bp = BP.objects.filter(firstName=firstName, lastName=lastName) if bp: bp = bp[0] else: bp = BP() bp.type = BPType.objects.get(pk='IN') bp.firstName = firstName bp.lastName = lastName bp.save() userLogin = UserLogin.objects.filter(userbp=bp) if userLogin: userLogin = userLogin[0] else: userLogin = UserLogin() user = User() user.nickName = '%s %s' % (lastName, firstName) user.realName = '%s %s' % (lastName, firstName) user.save() userLogin.user = user userLogin.userbp = bp userLogin.username = "%s.%s" % (firstName, lastName) userLogin.password = '111111' userLogin.passwordEncrypted = False userLogin.status = UserLoginStatus.objects.get(pk='ACTIVE') userLogin.save() userRole = UserRole() userRole.userlogin = userLogin userRole.role = UserRoleType.objects.get(pk='SALES_ROLE') userRole.save() # Phrases phrases = [ ['nickName', 'g_default', 'cn', u'昵称'], ['nickName', 'g_default', 'en', u'Nickname'], ['oldPassword', 'g_default', 'cn', u'旧密码'], ['oldPassword', 'g_default', 'en', u'Old password'], ['enterOldPwd', 'g_default', 'cn', u'输入旧密码'], ['enterOldPwd', 'g_default', 'en', u'Enter old password'], ['newPassword', 'g_default', 'cn', u'新密码'], ['newPassword', 'g_default', 'en', u'New password'], ['enterNewPwd', 'g_default', 'cn', u'输入密码'], ['enterNewPwd', 'g_default', 'en', u'Enter new password'], ['reNewPassword', 'g_default', 'cn', u'确认新密码'], ['reNewPassword', 'g_default', 'en', u'Confirm new password'], ['eNewPwdAgain', 'g_default', 'cn', u'再次输入新密码'], ['eNewPwdAgain', 'g_default', 'en', u'Enter new password again'], ['calEventColor', 'g_default', 'cn', u'日程项目颜色'], ['calEventColor', 'g_default', 'en', u'Calendar item color'], ['public', 'order', 'cn', u'公开'], ['public', 'order', 'en', u'Public'], ['content', 'order', 'cn', u'内容'], ['content', 'order', 'en', u'Detail'], ['title', 'order', 'cn', u'标题'], ['title', 'order', 'en', u'Title'], ['orderChart', 'order', 'cn', u'概览'], ['orderChart', 'order', 'en', u'Overview'], ['orderList', 'order', 'cn', u'列表'], ['orderList', 'order', 'en', u'List'], ['newText', 'bp', 'cn', u'新增备注'], ['newText', 'bp', 'en', u'New Text'], ['allText', 'bp', 'cn', u'全部备注'], ['allText', 'bp', 'en', u'All Text'], ['customerType', 'order', 'cn', u'账户类型'], ['customerType', 'order', 'en', u'Type'], ['settleType', 'order', 'cn', u'结算类型'], ['settleType', 'order', 'en', u'Settlement'], ['orderSaved', 'g_default', 'cn', u'数据已保存'], ['orderSaved', 'g_default', 'en', u'Order saved'], ['field', 'g_default', 'cn', u'字段'], ['field', 'g_default', 'en', u'Field'], ['oldValue', 'g_default', 'cn', u'旧值'], ['oldValue', 'g_default', 'en', u'Old Value'], ['newValue', 'g_default', 'cn', u'新值'], ['newValue', 'g_default', 'en', u'New Value'], ['updatedBy', 'g_default', 'cn', u'更新者'], ['updatedBy', 'g_default', 'en', u'Updated By'], ['updatedAt', 'g_default', 'cn', u'更新时间'], ['updatedAt', 'g_default', 'en', u'Updated At'], ['UATP', 'order', 'cn', u'UATP票'], ['UATP', 'order', 'en', u'UATP Tickets'], ['NONUATP', 'order', 'cn', u'非UATP票'], ['NONUATP', 'order', 'en', u'Non-UATP Tickets'], ['calendar', 'calendar', 'cn', u'日程'], ['calendar', 'calendar', 'en', u'Calendar'], ['detail', 'calendar', 'cn', u'详情'], ['detail', 'calendar', 'en', u'Activity'], ['startDateTime', 'order', 'cn', u'开始时间'], ['startDateTime', 'order', 'en', u'Start At'], ['endDateTime', 'order', 'cn', u'结束时间'], ['endDateTime', 'order', 'en', u'End At'], ['visibility', 'order', 'cn', u'可见性'], ['visibility', 'order', 'en', u'Visible'], ['upload', 'g_default', 'cn', u'上传'], ['upload', 'g_default', 'en', u'Upload'], ['addNewFile', 'g_default', 'cn', u'新增文件'], ['addNewFile', 'g_default', 'en', u'Add new file'], ['caution', 'g_default', 'cn', u'注意'], ['caution', 'g_default', 'en', u'Caution'], ['delFilePrompt', 'order', 'cn', u'确认要删除该文件吗?'], ['delFilePrompt', 'order', 'en', u'Are you sure to delete the file?'], ['thisYear', 'g_default', 'cn', u'本年'], ['thisYear', 'g_default', 'en', u'This year'], ['thisSeason', 'g_default', 'cn', u'本季度'], ['thisSeason', 'g_default', 'en', u'This season'], ['thisMonth', 'g_default', 'cn', u'本月'], ['thisMonth', 'g_default', 'en', u'This month'], ['thisWeek', 'g_default', 'cn', u'本周'], ['thisWeek', 'g_default', 'en', u'This week'], ['cardNumber', 'g_default', 'cn', u'卡号'], ['cardNumber', 'g_default', 'en', u'Card Number'], ['sales', 'g_default', 'cn', u'销售'], ['sales', 'g_default', 'en', u'Salesman'], ['corporate', 'g_default', 'cn', u'企业'], ['corporate', 'g_default', 'en', u'Corporation'], ['detail', 'g_default', 'cn', u'详情'], ['detail', 'g_default', 'en', u'Detail'], ['attachment', 'g_default', 'cn', u'附件'], ['attachment', 'g_default', 'en', u'Attachment'], ['change', 'g_default', 'cn', u'修改历史'], ['change', 'g_default', 'en', u'Change log'], ['custDate', 'g_default', 'cn', u'自定义日期段'], ['custDate', 'g_default', 'en', u'Custimized Date Range'], ['salesAnalysis', 'g_default', 'cn', u'销售业务分析'], ['salesAnalysis', 'g_default', 'en', u'Analysis'], ['all', 'g_default', 'cn', u'全部'], ['all', 'g_default', 'en', u'All'], ['transactionTotal', 'g_default', 'cn', u'交易量'], ['transactionTotal', 'g_default', 'en', u'Total'], ['shanhangTotal', 'g_default', 'cn', u'山航交易量'], ['shanhangTotal', 'g_default', 'en', u'Shanghan Total'], ['err.e01', 'g_default', 'cn', u'用户名或密码错误'], ['err.e01', 'g_default', 'en', u'Wrong username or password'], ['err.e02', 'g_default', 'cn', u'登录失败过多,账户已锁,请联系管理员'], ['err.e02', 'g_default', 'en', u'Too many failures, please contact administrator'], ['copyright', 'g_default', 'cn', u'&copy; 20XX-20XX 版权所有<br>'], ['copyright', 'g_default', 'en', u'&copy; 20XX-20XX'], ['version', 'g_default', 'cn', u'版本'], ['version', 'g_default', 'en', u'Version'], ['customerList', 'g_default', 'cn', u'客户列表'], ['customerList', 'g_default', 'en', u'Customers'], ['customerDetail', 'g_default', 'cn', u'客户详情'], ['customerDetail', 'g_default', 'en', u'Customer Detail'], ['phone', 'g_default', 'cn', u'联系电话'], ['phone', 'g_default', 'en', u'Phone'], ['contactPerson', 'g_default', 'cn', u'联系人'], ['contactPerson', 'g_default', 'en', u'Contact'], ['legalPerson', 'g_default', 'cn', u'法人'], ['legalPerson', 'g_default', 'en', u'Legal Person'], ['actualPerson', 'g_default', 'cn', u'实际控制人'], ['actualPerson', 'g_default', 'en', u'Actual Person'], ['copStructure', 'g_default', 'cn', u'组织结构'], ['copStructure', 'g_default', 'en', u'Structure'], ['corpLiscense', 'g_default', 'cn', u'营业执照'], ['corpLiscense', 'g_default', 'en', u'Liscense'], ['showLiscense', 'g_default', 'cn', u'显示'], ['showLiscense', 'g_default', 'en', u'Show'], ['noLiscense', 'g_default', 'cn', u'未上传'], ['noLiscense', 'g_default', 'en', u'Not available'], ['reUpload', 'g_default', 'cn', u'重新上传'], ['reUpload', 'g_default', 'en', u'Reupload'], ['searchOrder', 'bp', 'cn', u'筛选条件'], ['searchOrder', 'bp', 'en', u'Search'], ['type', 'bp', 'cn', u'类型'], ['type', 'bp', 'en', u'Type'], ['name1', 'bp', 'cn', u'名称 1'], ['name1', 'bp', 'en', u'Name 1'], ['name2', 'bp', 'cn', u'名称 2'], ['name2', 'bp', 'en', u'Name 2'], ['commonBp', 'menu', 'cn', u'商业伙伴'], ['commonBp', 'menu', 'en', u'Business Partner'], ['createBp', 'g_default', 'cn', u'创建商业伙伴'], ['createBp', 'g_default', 'en', u'Create Business Partner'], ['createBpTxt', 'g_default', 'cn', u'选择商业伙伴类型'], ['createBpTxt', 'g_default', 'en', u'Select business partner type'], ['bpSaved', 'g_default', 'cn', u'商业伙伴已保存'], ['bpSaved', 'g_default', 'en', u'Business partner saved'], ['district', 'bp', 'cn', u'地区'], ['district', 'bp', 'en', u'District'], ['phone', 'bp', 'cn', u'联系电话'], ['phone', 'bp', 'en', u'Phone'], ['contact', 'bp', 'cn', u'联系人'], ['contact', 'bp', 'en', u'Contact'], ['legalPerson', 'bp', 'cn', u'法人'], ['legalPerson', 'bp', 'en', u'Legal Person'], ['actualPerson', 'bp', 'cn', u'实际控制人'], ['actualPerson', 'bp', 'en', u'Actual Person'], ['corpStructure', 'bp', 'cn', u'组织结构'], ['corpStructure', 'bp', 'en', u'Corporation type'], ['partnerNo', 'bp', 'cn', u'编号'], ['partnerNo', 'bp', 'en', u'Partner No'], ['id', 'bp', 'cn', u'编号'], ['id', 'bp', 'en', u'ID'], ['corpLiscense', 'bp', 'cn', u'营业执照'], ['corpLiscense', 'bp', 'en', u'Liscense'], ['noImage', 'g_default', 'cn', u'未上传图片'], ['noImage', 'g_default', 'en', u'No image'], ['noFile', 'g_default', 'cn', u'未上传文件'], ['noFile', 'g_default', 'en', u'No file'], ['err.noRole', 'g_default', 'cn', u"""您还未被指派角色,请联系管理员"""], ['err.noRole', 'g_default', 'en', u"""You don't have role assigned yet, please contact administrator"""], ['file1', 'order', 'cn', u'文件1'], ['file1', 'order', 'en', u'File 1'], ['imgFile1', 'order', 'cn', u'图片1'], ['imgFile1', 'order', 'en', u'Image 1'], ['file2', 'order', 'cn', u'文件2'], ['file2', 'order', 'en', u'File 2'], ['imgFile2', 'order', 'cn', u'图片2'], ['imgFile2', 'order', 'en', u'Image 2'], ['file1', 'bp', 'cn', u'文件1'], ['file1', 'bp', 'en', u'File 1'], ['imgFile1', 'bp', 'cn', u'图片1'], ['imgFile1', 'bp', 'en', u'Image 1'], ['file2', 'bp', 'cn', u'文件2'], ['file2', 'bp', 'en', u'File 2'], ['imgFile2', 'bp', 'cn', u'图片2'], ['imgFile2', 'bp', 'en', u'Image 2'], ['feedback', 'g_default', 'cn', u'我有意见'], ['feedback', 'g_default', 'en', u'Feedback'], ['feedback', 'menu', 'cn', u'我有意见'], ['feedback', 'menu', 'en', u'Feedback'], ['message', 'menu', 'cn', u'消息'], ['message', 'menu', 'en', u'Message'], ['sender', 'message', 'cn', u'发送者'], ['sender', 'message', 'en', u'Sender'], ['receiver', 'message', 'cn', u'接收者'], ['receiver', 'message', 'en', u'Receiver'], ['content', 'message', 'cn', u'内容'], ['content', 'message', 'en', u'Content'], ['sentAt', 'message', 'cn', u'时间'], ['sentAt', 'message', 'en', u'Sent At'], ['orderFollowUp', 'g_default', 'cn', u'相关单据'], ['orderFollowUp', 'g_default', 'en', u'Follow ups'], ['createFollowUp', 'g_default', 'cn', u'创建跟进'], ['createFollowUp', 'g_default', 'en', u'Follow up'], ['checkResult', 'order', 'cn', u'审核结果'], ['checkResult', 'order', 'en', u'Result'], ['err.inMaint', 'g_default', 'cn', u"""系统正在维护中,请稍后登录……"""], ['err.inMaint', 'g_default', 'en', u'Maintainence is ongoing, please wait...'], ['err.e03', 'g_default', 'cn', u"""该账号已被禁用"""], ['err.e03', 'g_default', 'en', u"""Account not valid"""], ['ajaxError', 'g_default', 'cn', u"""消息错误,请确保登录状态后重试"""], ['ajaxError', 'g_default', 'en', u"""Response error"""], ['title', 'feedback', 'cn', u"""标题"""], ['title', 'feedback', 'en', u"""Title"""], ['type', 'feedback', 'cn', u"""类型"""], ['type', 'feedback', 'en', u"""Type"""], ['text', 'feedback', 'cn', u"""详细意见"""], ['text', 'feedback', 'en', u"""Text"""], ['bug', 'feedback', 'cn', u"""Bug错误"""], ['bug', 'feedback', 'en', u"""Bug"""], ['suggestion', 'feedback', 'cn', u"""需求建议"""], ['suggestion', 'feedback', 'en', u"""New requirement"""], ['corpStruct', 'menu', 'cn', u"""公司结构"""], ['corpStruct', 'menu', 'en', u"""Sturcture"""], ['corpStruct', 'g_default', 'cn', u"""公司结构"""], ['corpStruct', 'g_default', 'en', u"""Sturcture"""], ['myWork', 'menu', 'cn', u'我的任务'], ['myWork', 'menu', 'en', u'My work'], ['checkOrder', 'order', 'cn', u'审核对象'], ['checkOrder', 'order', 'en', u'Check target'], ['reply', 'g_default', 'cn', u'回复'], ['reply', 'g_default', 'en', u'Reply'], ['text', 'message', 'cn', u'内容'], ['text', 'message', 'en', u'Content'], ['send', 'message', 'cn', u'发送'], ['send', 'message', 'en', u'Send'], ['sendMessage', 'message', 'cn', u'发送消息'], ['sendMessage', 'message', 'en', u'Post'], ['dataTableCommNoPro', 'g_default', 'cn', None, u""" "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-12'i><'col-md-12 center-block'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "每页 _MENU_ 条记录", "oPaginate": { "sFirst": "首页", "sLast": "末页", "sNext": "下一页", "sPrevious": "上一页" }, "sEmptyTable": "无记录", "sInfo": "共 _TOTAL_ 条记录 (_START_ / _END_)", "sInfoEmpty": "无记录", "sSearch": "快速搜索 _INPUT_ ", "sZeroRecords": "无匹配记录", "sInfoFiltered": "从 _MAX_ 条记录中过滤","sProcessing": ""}, """], ['dataTableCommNoPro', 'g_default', 'en', None, u""" "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-12'i><'col-md-12 center-block'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ Per page", "oPaginate": { "sFirst": "First", "sLast": "Last", "sNext": "Next", "sPrevious": "Previous" }, "sEmptyTable": "No record", "sInfo": "Total _TOTAL_ record(s) (_START_ / _END_)", "sInfoEmpty": "No records", "sSearch": "Fast search _INPUT_ ", "sZeroRecords": "No record matches", "sInfoFiltered": "Filter from _MAX_ record(s)","sProcessing": ""}, """ ], ['dev', 'menu', 'cn', u'开发'], ['dev', 'menu', 'en', u'Develop'], ['add', 'g_default', 'cn', u'增加'], ['add', 'g_default', 'en', u'Add'] ] for phrase in phrases: print phrase p = {} p['phraseId'] = phrase[0] p['app'] = SiteAppType.objects.get(appId=phrase[1]) p['phraseLan'] = SiteLanguage.objects.get(key=phrase[2]) if phrase[3]: p['content'] = phrase[3] else: p['content'] = '' p['bigContent'] = phrase[4] SitePhrase.objects.update_or_create(**p)
gpl-3.0
[ 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 646, 747, 12, 1639, 199, 199, 736, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 283, 15213, 63, 2124, 14, 1751, 7, 199, 1176, 14, 2758, 342, 199, 199, 504, 2467, 77, 14, 992, 492, 627, 199, 504, 2467, 77, 14, 2330, 492, 627, 199, 199, 3, 28939, 8265, 199, 3, 2876, 7422, 804, 199, 751, 7422, 4100, 275, 359, 272, 788, 51, 748, 654, 63, 15468, 297, 399, 2, 21076, 223, 162, 243, 107, 2255, 272, 788, 13260, 63, 15468, 297, 399, 2, 2944, 45, 26683, 26835, 937, 199, 61, 199, 199, 509, 922, 7422, 804, 315, 922, 7422, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 922, 7422, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 922, 7422, 804, 59, 17, 61, 272, 2876, 7422, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 10935, 804, 199, 1345, 4100, 275, 359, 272, 788, 5278, 297, 399, 2, 5278, 10935, 2255, 272, 788, 2889, 297, 399, 2, 2889, 10935, 2255, 272, 788, 8064, 297, 399, 2, 8064, 10935, 937, 199, 61, 199, 199, 509, 2455, 804, 315, 2455, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 2455, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 2455, 804, 59, 17, 61, 272, 10935, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 11666, 8493, 199, 2124, 8493, 83, 275, 359, 272, 788, 287, 297, 399, 2, 19410, 2255, 272, 788, 6413, 297, 399, 2, 17088, 20918, 937, 199, 61, 199, 199, 509, 4770, 8493, 315, 4770, 8493, 83, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 4770, 8493, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 4770, 8493, 59, 17, 61, 272, 11666, 8493, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 11666, 20973, 199, 2124, 5977, 7412, 275, 359, 272, 788, 51, 748, 654, 63, 15468, 297, 488, 12, 283, 4219, 297, 283, 4470, 297, 283, 4219, 297, 1616, 12, 715, 467, 272, 788, 51, 748, 654, 63, 15468, 297, 488, 12, 283, 957, 5278, 297, 283, 4470, 297, 283, 2330, 4738, 297, 3388, 12, 715, 61, 199, 61, 199, 199, 509, 4770, 20973, 315, 4770, 5977, 7412, 26, 272, 299, 275, 1052, 272, 299, 459, 3756, 418, 275, 2876, 7422, 804, 14, 1462, 14, 362, 8, 2051, 29, 2124, 20973, 59, 16, 566, 272, 299, 459, 1708, 5977, 1304, 418, 275, 4770, 20973, 59, 17, 61, 272, 299, 459, 10906, 1304, 418, 275, 4770, 20973, 59, 18, 61, 272, 299, 459, 571, 1304, 418, 275, 4770, 20973, 59, 19, 61, 272, 299, 459, 1606, 2640, 418, 275, 4770, 20973, 59, 20, 61, 272, 299, 459, 3191, 4738, 418, 275, 4770, 20973, 59, 21, 61, 272, 299, 459, 1078, 418, 275, 4770, 20973, 59, 22, 61, 272, 11666, 20973, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 11666, 20973, 199, 2124, 2640, 4100, 275, 359, 272, 788, 1648, 297, 399, 2, 15582, 20466, 2255, 272, 788, 1188, 297, 399, 2, 163, 115, 231, 22439, 2255, 272, 788, 4470, 297, 399, 2, 165, 238, 251, 15582, 2255, 272, 788, 71, 63, 885, 297, 399, 2, 8379, 102, 27289, 223, 28931, 247, 14082, 98, 2255, 272, 788, 13485, 297, 399, 2, 6075, 236, 166, 100, 231, 2255, 272, 788, 8183, 297, 399, 2, 17243, 30664, 2255, 272, 788, 10913, 297, 399, 2, 29548, 229, 4344, 249, 17848, 248, 17848, 113, 937, 199, 61, 199, 199, 509, 4770, 2640, 804, 315, 4770, 2640, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 571, 1304, 418, 275, 4770, 2640, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 4770, 2640, 804, 59, 17, 61, 272, 11666, 2640, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 751, 5736, 4100, 275, 359, 272, 788, 48, 63, 51, 28553, 63, 27271, 297, 283, 18220, 5678, 4690, 418, 199, 61, 199, 509, 922, 5736, 804, 315, 922, 5736, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 922, 5736, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 922, 5736, 804, 59, 17, 61, 272, 19037, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 1178, 1692, 4100, 275, 359, 272, 788, 4738, 63, 4251, 614, 63, 3946, 297, 283, 1858, 1865, 730, 13950, 614, 995, 272, 788, 4738, 63, 1348, 614, 63, 3946, 297, 283, 1858, 1865, 730, 6570, 614, 995, 272, 788, 24408, 63, 726, 63, 3946, 297, 283, 1858, 13237, 2879, 995, 272, 788, 24408, 63, 568, 63, 3946, 297, 283, 1858, 8212, 2933, 2879, 995, 272, 788, 24408, 63, 1439, 63, 3946, 297, 283, 1858, 1970, 10633, 12639, 2879, 418, 199, 61, 199, 509, 1790, 1692, 804, 315, 1790, 1692, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 1790, 1692, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 1790, 1692, 804, 59, 17, 61, 272, 3590, 1692, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 1648, 1563, 4100, 275, 359, 272, 788, 4738, 297, 283, 4738, 995, 272, 788, 14350, 297, 283, 14350, 418, 199, 61, 199, 509, 1865, 1563, 804, 315, 1865, 1563, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 1865, 1563, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 1865, 1563, 804, 59, 17, 61, 272, 9240, 1563, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 1648, 4100, 275, 359, 272, 788, 4251, 614, 297, 283, 4738, 297, 399, 7, 21076, 223, 162, 243, 107, 13389, 124, 24626, 96, 297, 283, 8905, 12, 23436, 995, 272, 788, 1348, 614, 297, 283, 14350, 297, 399, 7, 17243, 30664, 163, 113, 8698, 233, 102, 297, 28696, 199, 61, 199, 509, 1865, 804, 315, 1865, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 1865, 804, 59, 16, 61, 272, 299, 459, 1095 ]
[ 1882, 2803, 26, 9094, 13, 24, 1882, 199, 646, 747, 12, 1639, 199, 199, 736, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 283, 15213, 63, 2124, 14, 1751, 7, 199, 1176, 14, 2758, 342, 199, 199, 504, 2467, 77, 14, 992, 492, 627, 199, 504, 2467, 77, 14, 2330, 492, 627, 199, 199, 3, 28939, 8265, 199, 3, 2876, 7422, 804, 199, 751, 7422, 4100, 275, 359, 272, 788, 51, 748, 654, 63, 15468, 297, 399, 2, 21076, 223, 162, 243, 107, 2255, 272, 788, 13260, 63, 15468, 297, 399, 2, 2944, 45, 26683, 26835, 937, 199, 61, 199, 199, 509, 922, 7422, 804, 315, 922, 7422, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 922, 7422, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 922, 7422, 804, 59, 17, 61, 272, 2876, 7422, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 10935, 804, 199, 1345, 4100, 275, 359, 272, 788, 5278, 297, 399, 2, 5278, 10935, 2255, 272, 788, 2889, 297, 399, 2, 2889, 10935, 2255, 272, 788, 8064, 297, 399, 2, 8064, 10935, 937, 199, 61, 199, 199, 509, 2455, 804, 315, 2455, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 2455, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 2455, 804, 59, 17, 61, 272, 10935, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 11666, 8493, 199, 2124, 8493, 83, 275, 359, 272, 788, 287, 297, 399, 2, 19410, 2255, 272, 788, 6413, 297, 399, 2, 17088, 20918, 937, 199, 61, 199, 199, 509, 4770, 8493, 315, 4770, 8493, 83, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 4770, 8493, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 4770, 8493, 59, 17, 61, 272, 11666, 8493, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 11666, 20973, 199, 2124, 5977, 7412, 275, 359, 272, 788, 51, 748, 654, 63, 15468, 297, 488, 12, 283, 4219, 297, 283, 4470, 297, 283, 4219, 297, 1616, 12, 715, 467, 272, 788, 51, 748, 654, 63, 15468, 297, 488, 12, 283, 957, 5278, 297, 283, 4470, 297, 283, 2330, 4738, 297, 3388, 12, 715, 61, 199, 61, 199, 199, 509, 4770, 20973, 315, 4770, 5977, 7412, 26, 272, 299, 275, 1052, 272, 299, 459, 3756, 418, 275, 2876, 7422, 804, 14, 1462, 14, 362, 8, 2051, 29, 2124, 20973, 59, 16, 566, 272, 299, 459, 1708, 5977, 1304, 418, 275, 4770, 20973, 59, 17, 61, 272, 299, 459, 10906, 1304, 418, 275, 4770, 20973, 59, 18, 61, 272, 299, 459, 571, 1304, 418, 275, 4770, 20973, 59, 19, 61, 272, 299, 459, 1606, 2640, 418, 275, 4770, 20973, 59, 20, 61, 272, 299, 459, 3191, 4738, 418, 275, 4770, 20973, 59, 21, 61, 272, 299, 459, 1078, 418, 275, 4770, 20973, 59, 22, 61, 272, 11666, 20973, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 3, 11666, 20973, 199, 2124, 2640, 4100, 275, 359, 272, 788, 1648, 297, 399, 2, 15582, 20466, 2255, 272, 788, 1188, 297, 399, 2, 163, 115, 231, 22439, 2255, 272, 788, 4470, 297, 399, 2, 165, 238, 251, 15582, 2255, 272, 788, 71, 63, 885, 297, 399, 2, 8379, 102, 27289, 223, 28931, 247, 14082, 98, 2255, 272, 788, 13485, 297, 399, 2, 6075, 236, 166, 100, 231, 2255, 272, 788, 8183, 297, 399, 2, 17243, 30664, 2255, 272, 788, 10913, 297, 399, 2, 29548, 229, 4344, 249, 17848, 248, 17848, 113, 937, 199, 61, 199, 199, 509, 4770, 2640, 804, 315, 4770, 2640, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 571, 1304, 418, 275, 4770, 2640, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 4770, 2640, 804, 59, 17, 61, 272, 11666, 2640, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 751, 5736, 4100, 275, 359, 272, 788, 48, 63, 51, 28553, 63, 27271, 297, 283, 18220, 5678, 4690, 418, 199, 61, 199, 509, 922, 5736, 804, 315, 922, 5736, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 922, 5736, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 922, 5736, 804, 59, 17, 61, 272, 19037, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 1178, 1692, 4100, 275, 359, 272, 788, 4738, 63, 4251, 614, 63, 3946, 297, 283, 1858, 1865, 730, 13950, 614, 995, 272, 788, 4738, 63, 1348, 614, 63, 3946, 297, 283, 1858, 1865, 730, 6570, 614, 995, 272, 788, 24408, 63, 726, 63, 3946, 297, 283, 1858, 13237, 2879, 995, 272, 788, 24408, 63, 568, 63, 3946, 297, 283, 1858, 8212, 2933, 2879, 995, 272, 788, 24408, 63, 1439, 63, 3946, 297, 283, 1858, 1970, 10633, 12639, 2879, 418, 199, 61, 199, 509, 1790, 1692, 804, 315, 1790, 1692, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 1790, 1692, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 1790, 1692, 804, 59, 17, 61, 272, 3590, 1692, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 1648, 1563, 4100, 275, 359, 272, 788, 4738, 297, 283, 4738, 995, 272, 788, 14350, 297, 283, 14350, 418, 199, 61, 199, 509, 1865, 1563, 804, 315, 1865, 1563, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 1865, 1563, 804, 59, 16, 61, 272, 299, 459, 1802, 418, 275, 1865, 1563, 804, 59, 17, 61, 272, 9240, 1563, 804, 14, 1462, 14, 873, 63, 269, 63, 981, 3682, 80, 9, 199, 199, 1648, 4100, 275, 359, 272, 788, 4251, 614, 297, 283, 4738, 297, 399, 7, 21076, 223, 162, 243, 107, 13389, 124, 24626, 96, 297, 283, 8905, 12, 23436, 995, 272, 788, 1348, 614, 297, 283, 14350, 297, 399, 7, 17243, 30664, 163, 113, 8698, 233, 102, 297, 28696, 199, 61, 199, 509, 1865, 804, 315, 1865, 4100, 26, 272, 299, 275, 1052, 272, 299, 459, 498, 418, 275, 1865, 804, 59, 16, 61, 272, 299, 459, 1095, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cloudbau/glance
glance/openstack/common/context.py
5
2664
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Simple class that stores security context information in the web request. Projects should subclass this class if they wish to enhance the request context or provide additional information in their specific WSGI pipeline. """ import itertools from glance.openstack.common import uuidutils def generate_request_id(): return 'req-%s' % uuidutils.generate_uuid() class RequestContext(object): """ Stores information about the security context under which the user accesses the system, as well as additional request information. """ def __init__(self, auth_token=None, user=None, tenant=None, is_admin=False, read_only=False, show_deleted=False, request_id=None): self.auth_token = auth_token self.user = user self.tenant = tenant self.is_admin = is_admin self.read_only = read_only self.show_deleted = show_deleted if not request_id: request_id = generate_request_id() self.request_id = request_id def to_dict(self): return {'user': self.user, 'tenant': self.tenant, 'is_admin': self.is_admin, 'read_only': self.read_only, 'show_deleted': self.show_deleted, 'auth_token': self.auth_token, 'request_id': self.request_id} def get_admin_context(show_deleted="no"): context = RequestContext(None, tenant=None, is_admin=True, show_deleted=show_deleted) return context def get_context_from_function_and_args(function, args, kwargs): """Find an arg of type RequestContext and return it. This is useful in a couple of decorators where we don't know much about the function we're wrapping. """ for arg in itertools.chain(kwargs.values(), args): if isinstance(arg, RequestContext): return arg return None
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7760, 14260, 2752, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 3184, 1021, 626, 14086, 6391, 1067, 2556, 315, 314, 3330, 1056, 14, 199, 199, 24286, 1077, 5516, 642, 1021, 340, 2985, 13809, 370, 655, 14666, 314, 1056, 199, 1100, 503, 5647, 4722, 2556, 315, 3932, 2488, 9279, 7679, 14, 199, 624, 199, 199, 646, 7975, 199, 199, 504, 21785, 14, 8512, 14, 2330, 492, 5377, 1208, 421, 199, 318, 3550, 63, 1069, 63, 344, 837, 272, 372, 283, 2103, 3295, 83, 7, 450, 5377, 1208, 14, 4208, 63, 2580, 342, 421, 199, 533, 22538, 8, 785, 304, 339, 408, 272, 31299, 2556, 3595, 314, 6391, 1067, 1334, 1314, 314, 922, 272, 1066, 5804, 314, 2656, 12, 465, 5521, 465, 4722, 1056, 2556, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1790, 63, 1418, 29, 403, 12, 922, 29, 403, 12, 8261, 29, 403, 12, 365, 63, 2113, 29, 797, 12, 326, 1586, 63, 2118, 29, 797, 12, 2498, 63, 6062, 29, 797, 12, 1056, 63, 344, 29, 403, 304, 267, 291, 14, 1178, 63, 1418, 275, 1790, 63, 1418, 267, 291, 14, 751, 275, 922, 267, 291, 14, 4647, 275, 8261, 267, 291, 14, 374, 63, 2113, 275, 365, 63, 2113, 267, 291, 14, 739, 63, 2118, 275, 1586, 63, 2118, 267, 291, 14, 2384, 63, 6062, 275, 2498, 63, 6062, 267, 340, 440, 1056, 63, 344, 26, 288, 1056, 63, 344, 275, 3550, 63, 1069, 63, 344, 342, 267, 291, 14, 1069, 63, 344, 275, 1056, 63, 344, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 791, 751, 356, 291, 14, 751, 12, 355, 283, 4647, 356, 291, 14, 4647, 12, 355, 283, 374, 63, 2113, 356, 291, 14, 374, 63, 2113, 12, 355, 283, 739, 63, 2118, 356, 291, 14, 739, 63, 2118, 12, 355, 283, 2384, 63, 6062, 356, 291, 14, 2384, 63, 6062, 12, 355, 283, 1178, 63, 1418, 356, 291, 14, 1178, 63, 1418, 12, 355, 283, 1069, 63, 344, 356, 291, 14, 1069, 63, 344, 93, 421, 199, 318, 664, 63, 2113, 63, 1100, 8, 2384, 63, 6062, 628, 889, 2349, 272, 1067, 275, 22538, 8, 403, 12, 2490, 8261, 29, 403, 12, 2490, 365, 63, 2113, 29, 549, 12, 2490, 2498, 63, 6062, 29, 2384, 63, 6062, 9, 272, 372, 1067, 421, 199, 318, 664, 63, 1100, 63, 504, 63, 1593, 63, 460, 63, 589, 8, 1593, 12, 1249, 12, 2074, 304, 272, 408, 6591, 376, 1680, 402, 730, 22538, 436, 372, 652, 14, 10817, 961, 365, 2997, 315, 282, 17535, 402, 20419, 2382, 781, 2793, 1133, 2126, 5715, 8298, 3595, 314, 805, 781, 3984, 19696, 14, 272, 408, 339, 367, 1680, 315, 7975, 14, 4429, 8, 958, 14, 1459, 1062, 1249, 304, 267, 340, 1228, 8, 1273, 12, 22538, 304, 288, 372, 1680, 339, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7760, 14260, 2752, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 3184, 1021, 626, 14086, 6391, 1067, 2556, 315, 314, 3330, 1056, 14, 199, 199, 24286, 1077, 5516, 642, 1021, 340, 2985, 13809, 370, 655, 14666, 314, 1056, 199, 1100, 503, 5647, 4722, 2556, 315, 3932, 2488, 9279, 7679, 14, 199, 624, 199, 199, 646, 7975, 199, 199, 504, 21785, 14, 8512, 14, 2330, 492, 5377, 1208, 421, 199, 318, 3550, 63, 1069, 63, 344, 837, 272, 372, 283, 2103, 3295, 83, 7, 450, 5377, 1208, 14, 4208, 63, 2580, 342, 421, 199, 533, 22538, 8, 785, 304, 339, 408, 272, 31299, 2556, 3595, 314, 6391, 1067, 1334, 1314, 314, 922, 272, 1066, 5804, 314, 2656, 12, 465, 5521, 465, 4722, 1056, 2556, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1790, 63, 1418, 29, 403, 12, 922, 29, 403, 12, 8261, 29, 403, 12, 365, 63, 2113, 29, 797, 12, 326, 1586, 63, 2118, 29, 797, 12, 2498, 63, 6062, 29, 797, 12, 1056, 63, 344, 29, 403, 304, 267, 291, 14, 1178, 63, 1418, 275, 1790, 63, 1418, 267, 291, 14, 751, 275, 922, 267, 291, 14, 4647, 275, 8261, 267, 291, 14, 374, 63, 2113, 275, 365, 63, 2113, 267, 291, 14, 739, 63, 2118, 275, 1586, 63, 2118, 267, 291, 14, 2384, 63, 6062, 275, 2498, 63, 6062, 267, 340, 440, 1056, 63, 344, 26, 288, 1056, 63, 344, 275, 3550, 63, 1069, 63, 344, 342, 267, 291, 14, 1069, 63, 344, 275, 1056, 63, 344, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 791, 751, 356, 291, 14, 751, 12, 355, 283, 4647, 356, 291, 14, 4647, 12, 355, 283, 374, 63, 2113, 356, 291, 14, 374, 63, 2113, 12, 355, 283, 739, 63, 2118, 356, 291, 14, 739, 63, 2118, 12, 355, 283, 2384, 63, 6062, 356, 291, 14, 2384, 63, 6062, 12, 355, 283, 1178, 63, 1418, 356, 291, 14, 1178, 63, 1418, 12, 355, 283, 1069, 63, 344, 356, 291, 14, 1069, 63, 344, 93, 421, 199, 318, 664, 63, 2113, 63, 1100, 8, 2384, 63, 6062, 628, 889, 2349, 272, 1067, 275, 22538, 8, 403, 12, 2490, 8261, 29, 403, 12, 2490, 365, 63, 2113, 29, 549, 12, 2490, 2498, 63, 6062, 29, 2384, 63, 6062, 9, 272, 372, 1067, 421, 199, 318, 664, 63, 1100, 63, 504, 63, 1593, 63, 460, 63, 589, 8, 1593, 12, 1249, 12, 2074, 304, 272, 408, 6591, 376, 1680, 402, 730, 22538, 436, 372, 652, 14, 10817, 961, 365, 2997, 315, 282, 17535, 402, 20419, 2382, 781, 2793, 1133, 2126, 5715, 8298, 3595, 314, 805, 781, 3984, 19696, 14, 272, 408, 339, 367, 1680, 315, 7975, 14, 4429, 8, 958, 14, 1459, 1062, 1249, 304, 267, 340, 1228, 8, 1273, 12, 22538, 304, 288, 372, 1680, 339, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chongtianfeiyu/kbengine
kbe/res/scripts/common/Lib/test/test_faulthandler.py
60
21327
from contextlib import contextmanager import datetime import faulthandler import os import re import signal import subprocess import sys from test import support, script_helper from test.script_helper import assert_python_ok import tempfile import unittest from textwrap import dedent try: import threading HAVE_THREADS = True except ImportError: HAVE_THREADS = False TIMEOUT = 0.5 def expected_traceback(lineno1, lineno2, header, min_count=1): regex = header regex += ' File "<string>", line %s in func\n' % lineno1 regex += ' File "<string>", line %s in <module>' % lineno2 if 1 < min_count: return '^' + (regex + '\n') * (min_count - 1) + regex else: return '^' + regex + '$' @contextmanager def temporary_filename(): filename = tempfile.mktemp() try: yield filename finally: support.unlink(filename) class FaultHandlerTests(unittest.TestCase): def get_output(self, code, filename=None): """ Run the specified code in Python (in a new child process) and read the output from the standard error or from a file (if filename is set). Return the output lines as a list. Strip the reference count from the standard error for Python debug build, and replace "Current thread 0x00007f8d8fbd9700" by "Current thread XXX". """ code = dedent(code).strip() with support.SuppressCrashReport(): process = script_helper.spawn_python('-c', code) stdout, stderr = process.communicate() exitcode = process.wait() output = support.strip_python_stderr(stdout) output = output.decode('ascii', 'backslashreplace') if filename: self.assertEqual(output, '') with open(filename, "rb") as fp: output = fp.read() output = output.decode('ascii', 'backslashreplace') output = re.sub('Current thread 0x[0-9a-f]+', 'Current thread XXX', output) return output.splitlines(), exitcode def check_fatal_error(self, code, line_number, name_regex, filename=None, all_threads=True, other_regex=None): """ Check that the fault handler for fatal errors is enabled and check the traceback from the child process output. Raise an error if the output doesn't match the expected format. """ if all_threads: header = 'Current thread XXX (most recent call first)' else: header = 'Stack (most recent call first)' regex = """ ^Fatal Python error: {name} {header}: File "<string>", line {lineno} in <module> """ regex = dedent(regex.format( lineno=line_number, name=name_regex, header=re.escape(header))).strip() if other_regex: regex += '|' + other_regex output, exitcode = self.get_output(code, filename) output = '\n'.join(output) self.assertRegex(output, regex) self.assertNotEqual(exitcode, 0) @unittest.skipIf(sys.platform.startswith('aix'), "the first page of memory is a mapped read-only on AIX") def test_read_null(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._read_null() """, 3, # Issue #12700: Read NULL raises SIGILL on Mac OS X Lion '(?:Segmentation fault|Bus error|Illegal instruction)') def test_sigsegv(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigsegv() """, 3, 'Segmentation fault') def test_sigabrt(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigabrt() """, 3, 'Aborted') @unittest.skipIf(sys.platform == 'win32', "SIGFPE cannot be caught on Windows") def test_sigfpe(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigfpe() """, 3, 'Floating point exception') @unittest.skipIf(not hasattr(faulthandler, '_sigbus'), "need faulthandler._sigbus()") def test_sigbus(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigbus() """, 3, 'Bus error') @unittest.skipIf(not hasattr(faulthandler, '_sigill'), "need faulthandler._sigill()") def test_sigill(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._sigill() """, 3, 'Illegal instruction') def test_fatal_error(self): self.check_fatal_error(""" import faulthandler faulthandler._fatal_error(b'xyz') """, 2, 'xyz') @unittest.skipIf(sys.platform.startswith('openbsd') and HAVE_THREADS, "Issue #12868: sigaltstack() doesn't work on " "OpenBSD if Python is compiled with pthread") @unittest.skipIf(not hasattr(faulthandler, '_stack_overflow'), 'need faulthandler._stack_overflow()') def test_stack_overflow(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._stack_overflow() """, 3, '(?:Segmentation fault|Bus error)', other_regex='unable to raise a stack overflow') def test_gil_released(self): self.check_fatal_error(""" import faulthandler faulthandler.enable() faulthandler._read_null(True) """, 3, '(?:Segmentation fault|Bus error|Illegal instruction)') def test_enable_file(self): with temporary_filename() as filename: self.check_fatal_error(""" import faulthandler output = open({filename}, 'wb') faulthandler.enable(output) faulthandler._sigsegv() """.format(filename=repr(filename)), 4, 'Segmentation fault', filename=filename) def test_enable_single_thread(self): self.check_fatal_error(""" import faulthandler faulthandler.enable(all_threads=False) faulthandler._sigsegv() """, 3, 'Segmentation fault', all_threads=False) def test_disable(self): code = """ import faulthandler faulthandler.enable() faulthandler.disable() faulthandler._sigsegv() """ not_expected = 'Fatal Python error' stderr, exitcode = self.get_output(code) stder = '\n'.join(stderr) self.assertTrue(not_expected not in stderr, "%r is present in %r" % (not_expected, stderr)) self.assertNotEqual(exitcode, 0) def test_is_enabled(self): orig_stderr = sys.stderr try: # regrtest may replace sys.stderr by io.StringIO object, but # faulthandler.enable() requires that sys.stderr has a fileno() # method sys.stderr = sys.__stderr__ was_enabled = faulthandler.is_enabled() try: faulthandler.enable() self.assertTrue(faulthandler.is_enabled()) faulthandler.disable() self.assertFalse(faulthandler.is_enabled()) finally: if was_enabled: faulthandler.enable() else: faulthandler.disable() finally: sys.stderr = orig_stderr def test_disabled_by_default(self): # By default, the module should be disabled code = "import faulthandler; print(faulthandler.is_enabled())" args = (sys.executable, '-E', '-c', code) # don't use assert_python_ok() because it always enable faulthandler output = subprocess.check_output(args) self.assertEqual(output.rstrip(), b"False") def test_sys_xoptions(self): # Test python -X faulthandler code = "import faulthandler; print(faulthandler.is_enabled())" args = (sys.executable, "-E", "-X", "faulthandler", "-c", code) # don't use assert_python_ok() because it always enable faulthandler output = subprocess.check_output(args) self.assertEqual(output.rstrip(), b"True") def test_env_var(self): # empty env var code = "import faulthandler; print(faulthandler.is_enabled())" args = (sys.executable, "-c", code) env = os.environ.copy() env['PYTHONFAULTHANDLER'] = '' # don't use assert_python_ok() because it always enable faulthandler output = subprocess.check_output(args, env=env) self.assertEqual(output.rstrip(), b"False") # non-empty env var env = os.environ.copy() env['PYTHONFAULTHANDLER'] = '1' output = subprocess.check_output(args, env=env) self.assertEqual(output.rstrip(), b"True") def check_dump_traceback(self, filename): """ Explicitly call dump_traceback() function and check its output. Raise an error if the output doesn't match the expected format. """ code = """ import faulthandler def funcB(): if {has_filename}: with open({filename}, "wb") as fp: faulthandler.dump_traceback(fp, all_threads=False) else: faulthandler.dump_traceback(all_threads=False) def funcA(): funcB() funcA() """ code = code.format( filename=repr(filename), has_filename=bool(filename), ) if filename: lineno = 6 else: lineno = 8 expected = [ 'Stack (most recent call first):', ' File "<string>", line %s in funcB' % lineno, ' File "<string>", line 11 in funcA', ' File "<string>", line 13 in <module>' ] trace, exitcode = self.get_output(code, filename) self.assertEqual(trace, expected) self.assertEqual(exitcode, 0) def test_dump_traceback(self): self.check_dump_traceback(None) def test_dump_traceback_file(self): with temporary_filename() as filename: self.check_dump_traceback(filename) def test_truncate(self): maxlen = 500 func_name = 'x' * (maxlen + 50) truncated = 'x' * maxlen + '...' code = """ import faulthandler def {func_name}(): faulthandler.dump_traceback(all_threads=False) {func_name}() """ code = code.format( func_name=func_name, ) expected = [ 'Stack (most recent call first):', ' File "<string>", line 4 in %s' % truncated, ' File "<string>", line 6 in <module>' ] trace, exitcode = self.get_output(code) self.assertEqual(trace, expected) self.assertEqual(exitcode, 0) @unittest.skipIf(not HAVE_THREADS, 'need threads') def check_dump_traceback_threads(self, filename): """ Call explicitly dump_traceback(all_threads=True) and check the output. Raise an error if the output doesn't match the expected format. """ code = """ import faulthandler from threading import Thread, Event import time def dump(): if {filename}: with open({filename}, "wb") as fp: faulthandler.dump_traceback(fp, all_threads=True) else: faulthandler.dump_traceback(all_threads=True) class Waiter(Thread): # avoid blocking if the main thread raises an exception. daemon = True def __init__(self): Thread.__init__(self) self.running = Event() self.stop = Event() def run(self): self.running.set() self.stop.wait() waiter = Waiter() waiter.start() waiter.running.wait() dump() waiter.stop.set() waiter.join() """ code = code.format(filename=repr(filename)) output, exitcode = self.get_output(code, filename) output = '\n'.join(output) if filename: lineno = 8 else: lineno = 10 regex = """ ^Thread 0x[0-9a-f]+ \(most recent call first\): (?: File ".*threading.py", line [0-9]+ in [_a-z]+ ){{1,3}} File "<string>", line 23 in run File ".*threading.py", line [0-9]+ in _bootstrap_inner File ".*threading.py", line [0-9]+ in _bootstrap Current thread XXX \(most recent call first\): File "<string>", line {lineno} in dump File "<string>", line 28 in <module>$ """ regex = dedent(regex.format(lineno=lineno)).strip() self.assertRegex(output, regex) self.assertEqual(exitcode, 0) def test_dump_traceback_threads(self): self.check_dump_traceback_threads(None) def test_dump_traceback_threads_file(self): with temporary_filename() as filename: self.check_dump_traceback_threads(filename) def _check_dump_traceback_later(self, repeat, cancel, filename, loops): """ Check how many times the traceback is written in timeout x 2.5 seconds, or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending on repeat and cancel options. Raise an error if the output doesn't match the expect format. """ timeout_str = str(datetime.timedelta(seconds=TIMEOUT)) code = """ import faulthandler import time def func(timeout, repeat, cancel, file, loops): for loop in range(loops): faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file) if cancel: faulthandler.cancel_dump_traceback_later() time.sleep(timeout * 5) faulthandler.cancel_dump_traceback_later() timeout = {timeout} repeat = {repeat} cancel = {cancel} loops = {loops} if {has_filename}: file = open({filename}, "wb") else: file = None func(timeout, repeat, cancel, file, loops) if file is not None: file.close() """ code = code.format( timeout=TIMEOUT, repeat=repeat, cancel=cancel, loops=loops, has_filename=bool(filename), filename=repr(filename), ) trace, exitcode = self.get_output(code, filename) trace = '\n'.join(trace) if not cancel: count = loops if repeat: count *= 2 header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+ \(most recent call first\):\n' % timeout_str regex = expected_traceback(9, 20, header, min_count=count) self.assertRegex(trace, regex) else: self.assertEqual(trace, '') self.assertEqual(exitcode, 0) @unittest.skipIf(not hasattr(faulthandler, 'dump_traceback_later'), 'need faulthandler.dump_traceback_later()') def check_dump_traceback_later(self, repeat=False, cancel=False, file=False, twice=False): if twice: loops = 2 else: loops = 1 if file: with temporary_filename() as filename: self._check_dump_traceback_later(repeat, cancel, filename, loops) else: self._check_dump_traceback_later(repeat, cancel, None, loops) def test_dump_traceback_later(self): self.check_dump_traceback_later() def test_dump_traceback_later_repeat(self): self.check_dump_traceback_later(repeat=True) def test_dump_traceback_later_cancel(self): self.check_dump_traceback_later(cancel=True) def test_dump_traceback_later_file(self): self.check_dump_traceback_later(file=True) def test_dump_traceback_later_twice(self): self.check_dump_traceback_later(twice=True) @unittest.skipIf(not hasattr(faulthandler, "register"), "need faulthandler.register") def check_register(self, filename=False, all_threads=False, unregister=False, chain=False): """ Register a handler displaying the traceback on a user signal. Raise the signal and check the written traceback. If chain is True, check that the previous signal handler is called. Raise an error if the output doesn't match the expected format. """ signum = signal.SIGUSR1 code = """ import faulthandler import os import signal import sys def func(signum): os.kill(os.getpid(), signum) def handler(signum, frame): handler.called = True handler.called = False exitcode = 0 signum = {signum} unregister = {unregister} chain = {chain} if {has_filename}: file = open({filename}, "wb") else: file = None if chain: signal.signal(signum, handler) faulthandler.register(signum, file=file, all_threads={all_threads}, chain={chain}) if unregister: faulthandler.unregister(signum) func(signum) if chain and not handler.called: if file is not None: output = file else: output = sys.stderr print("Error: signal handler not called!", file=output) exitcode = 1 if file is not None: file.close() sys.exit(exitcode) """ code = code.format( filename=repr(filename), has_filename=bool(filename), all_threads=all_threads, signum=signum, unregister=unregister, chain=chain, ) trace, exitcode = self.get_output(code, filename) trace = '\n'.join(trace) if not unregister: if all_threads: regex = 'Current thread XXX \(most recent call first\):\n' else: regex = 'Stack \(most recent call first\):\n' regex = expected_traceback(7, 28, regex) self.assertRegex(trace, regex) else: self.assertEqual(trace, '') if unregister: self.assertNotEqual(exitcode, 0) else: self.assertEqual(exitcode, 0) def test_register(self): self.check_register() def test_unregister(self): self.check_register(unregister=True) def test_register_file(self): with temporary_filename() as filename: self.check_register(filename=filename) def test_register_threads(self): self.check_register(all_threads=True) def test_register_chain(self): self.check_register(chain=True) @contextmanager def check_stderr_none(self): stderr = sys.stderr try: sys.stderr = None with self.assertRaises(RuntimeError) as cm: yield self.assertEqual(str(cm.exception), "sys.stderr is None") finally: sys.stderr = stderr def test_stderr_None(self): # Issue #21497: provide an helpful error if sys.stderr is None, # instead of just an attribute error: "None has no attribute fileno". with self.check_stderr_none(): faulthandler.enable() with self.check_stderr_none(): faulthandler.dump_traceback() if hasattr(faulthandler, 'dump_traceback_later'): with self.check_stderr_none(): faulthandler.dump_traceback_later(1e-3) if hasattr(faulthandler, "register"): with self.check_stderr_none(): faulthandler.register(signal.SIGUSR1) if __name__ == "__main__": unittest.main()
lgpl-3.0
[ 504, 15502, 492, 27608, 199, 646, 2197, 199, 646, 1433, 348, 273, 1221, 199, 646, 747, 199, 646, 295, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 504, 511, 492, 2291, 12, 2884, 63, 3676, 199, 504, 511, 14, 1579, 63, 3676, 492, 702, 63, 1548, 63, 745, 199, 646, 5549, 199, 646, 2882, 199, 504, 13390, 492, 22622, 199, 199, 893, 26, 272, 492, 5796, 272, 25227, 63, 16103, 51, 275, 715, 199, 2590, 3545, 26, 272, 25227, 63, 16103, 51, 275, 756, 199, 199, 8899, 275, 378, 14, 21, 199, 199, 318, 1420, 63, 6894, 8, 3469, 17, 12, 5874, 18, 12, 1406, 12, 1748, 63, 835, 29, 17, 304, 272, 5163, 275, 1406, 272, 5163, 847, 283, 221, 3814, 3886, 875, 7166, 1004, 450, 83, 315, 2562, 60, 78, 7, 450, 5874, 17, 272, 5163, 847, 283, 221, 3814, 3886, 875, 7166, 1004, 450, 83, 315, 665, 578, 3524, 450, 5874, 18, 272, 340, 413, 665, 1748, 63, 835, 26, 267, 372, 14452, 7, 435, 334, 3821, 435, 1557, 78, 358, 627, 334, 827, 63, 835, 446, 413, 9, 435, 5163, 272, 587, 26, 267, 372, 14452, 7, 435, 5163, 435, 25271, 199, 199, 32, 14237, 199, 318, 7937, 63, 1501, 837, 272, 1788, 275, 5549, 14, 22136, 342, 272, 862, 26, 267, 1995, 1788, 272, 3753, 26, 267, 2291, 14, 7162, 8, 1501, 9, 199, 199, 533, 31422, 2461, 2925, 8, 2796, 14, 1746, 304, 272, 347, 664, 63, 1199, 8, 277, 12, 1233, 12, 1788, 29, 403, 304, 267, 408, 267, 3378, 314, 2013, 1233, 315, 2018, 334, 262, 282, 892, 1982, 2112, 9, 436, 1586, 314, 267, 1072, 687, 314, 4465, 1125, 503, 687, 282, 570, 334, 692, 1788, 365, 663, 680, 267, 1432, 314, 1072, 2385, 465, 282, 769, 14, 398, 19828, 314, 3659, 2338, 687, 314, 4465, 1125, 367, 2018, 3105, 267, 1900, 12, 436, 3350, 298, 5639, 2462, 378, 88, 993, 23, 70, 24, 68, 24, 17108, 2576, 383, 2, 701, 298, 5639, 267, 2462, 5787, 1674, 267, 408, 267, 1233, 275, 22622, 8, 600, 680, 1913, 342, 267, 543, 2291, 14, 18334, 17345, 1119, 7457, 837, 288, 2112, 275, 2884, 63, 3676, 14, 10212, 63, 1548, 3654, 67, 297, 1233, 9, 267, 3839, 12, 4635, 275, 2112, 14, 10664, 342, 267, 4458, 600, 275, 2112, 14, 2573, 342, 267, 1072, 275, 2291, 14, 1913, 63, 1548, 63, 3083, 8, 2703, 9, 267, 1072, 275, 1072, 14, 2708, 360, 4371, 297, 283, 21509, 1814, 358, 267, 340, 1788, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 288, 543, 1551, 8, 1501, 12, 298, 4848, 531, 465, 4090, 26, 355, 1072, 275, 4090, 14, 739, 342, 288, 1072, 275, 1072, 14, 2708, 360, 4371, 297, 283, 21509, 1814, 358, 267, 1072, 275, 295, 14, 954, 360, 5639, 2462, 378, 88, 59, 16, 13, 25, 65, 13, 70, 11529, 717, 283, 5639, 2462, 5787, 297, 717, 1072, 9, 267, 372, 1072, 14, 7644, 1062, 4458, 600, 339, 347, 1104, 63, 16208, 63, 705, 8, 277, 12, 1233, 12, 1004, 63, 1955, 12, 536, 63, 3821, 12, 2079, 1788, 29, 403, 12, 1006, 63, 6962, 29, 549, 12, 1163, 63, 3821, 29, 403, 304, 267, 408, 267, 2670, 626, 314, 16898, 3016, 367, 14294, 2552, 365, 5223, 436, 1104, 314, 267, 5190, 687, 314, 1982, 2112, 1072, 14, 398, 14771, 376, 1125, 340, 314, 1072, 3181, 1133, 1336, 314, 1420, 1475, 14, 267, 408, 267, 340, 1006, 63, 6962, 26, 288, 1406, 275, 283, 5639, 2462, 5787, 334, 2786, 8058, 1240, 1642, 3171, 267, 587, 26, 288, 1406, 275, 283, 4851, 334, 2786, 8058, 1240, 1642, 3171, 267, 5163, 275, 408, 288, 7167, 19507, 2018, 1125, 26, 469, 354, 93, 953, 469, 1291, 9160, 1598, 3814, 3886, 875, 7166, 1004, 469, 3469, 93, 315, 665, 578, 30, 288, 408, 267, 5163, 275, 22622, 8, 3821, 14, 908, 8, 288, 5874, 29, 604, 63, 1955, 12, 288, 536, 29, 354, 63, 3821, 12, 288, 1406, 29, 264, 14, 3765, 8, 1291, 23261, 1913, 342, 267, 340, 1163, 63, 3821, 26, 288, 5163, 847, 24628, 435, 1163, 63, 3821, 267, 1072, 12, 4458, 600, 275, 291, 14, 362, 63, 1199, 8, 600, 12, 1788, 9, 267, 1072, 275, 1557, 78, 1370, 904, 8, 1199, 9, 267, 291, 14, 31132, 8, 1199, 12, 5163, 9, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 768, 2796, 14, 15118, 8, 1274, 14, 3246, 14, 2460, 360, 65, 1148, 659, 2151, 298, 1589, 1642, 2034, 402, 4402, 365, 282, 9994, 1586, 13, 2118, 641, 437, 3867, 531, 272, 347, 511, 63, 739, 63, 2307, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 739, 63, 2307, 342, 288, 10327, 288, 650, 12, 288, 327, 13383, 327, 4195, 383, 26, 5574, 5962, 6534, 15522, 14961, 641, 10444, 4403, 1323, 491, 1636, 288, 283, 5169, 19689, 3117, 16898, 92, 12106, 1125, 92, 25501, 16329, 5942, 339, 347, 511, 63, 4093, 8359, 86, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 4093, 8359, 86, 342, 288, 10327, 288, 650, 12, 288, 283, 19689, 3117, 16898, 358, 339, 347, 511, 63, 4093, 371, 2591, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 4093, 371, 2591, 342, 288, 10327, 288, 650, 12, 288, 283, 5583, 1376, 358, 339, 768, 2796, 14, 15118, 8, 1274, 14, 3246, 508, 283, 2676, 708, 297, 2151, 298, 7864, 38, 1510, 3913, 506, 15604, 641, 5417, 531, 272, 347, 511, 63, 4093, 70, 321, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 4093, 70, 321, 342, 288, 10327, 288, 650, 12, 288, 283 ]
[ 15502, 492, 27608, 199, 646, 2197, 199, 646, 1433, 348, 273, 1221, 199, 646, 747, 199, 646, 295, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 504, 511, 492, 2291, 12, 2884, 63, 3676, 199, 504, 511, 14, 1579, 63, 3676, 492, 702, 63, 1548, 63, 745, 199, 646, 5549, 199, 646, 2882, 199, 504, 13390, 492, 22622, 199, 199, 893, 26, 272, 492, 5796, 272, 25227, 63, 16103, 51, 275, 715, 199, 2590, 3545, 26, 272, 25227, 63, 16103, 51, 275, 756, 199, 199, 8899, 275, 378, 14, 21, 199, 199, 318, 1420, 63, 6894, 8, 3469, 17, 12, 5874, 18, 12, 1406, 12, 1748, 63, 835, 29, 17, 304, 272, 5163, 275, 1406, 272, 5163, 847, 283, 221, 3814, 3886, 875, 7166, 1004, 450, 83, 315, 2562, 60, 78, 7, 450, 5874, 17, 272, 5163, 847, 283, 221, 3814, 3886, 875, 7166, 1004, 450, 83, 315, 665, 578, 3524, 450, 5874, 18, 272, 340, 413, 665, 1748, 63, 835, 26, 267, 372, 14452, 7, 435, 334, 3821, 435, 1557, 78, 358, 627, 334, 827, 63, 835, 446, 413, 9, 435, 5163, 272, 587, 26, 267, 372, 14452, 7, 435, 5163, 435, 25271, 199, 199, 32, 14237, 199, 318, 7937, 63, 1501, 837, 272, 1788, 275, 5549, 14, 22136, 342, 272, 862, 26, 267, 1995, 1788, 272, 3753, 26, 267, 2291, 14, 7162, 8, 1501, 9, 199, 199, 533, 31422, 2461, 2925, 8, 2796, 14, 1746, 304, 272, 347, 664, 63, 1199, 8, 277, 12, 1233, 12, 1788, 29, 403, 304, 267, 408, 267, 3378, 314, 2013, 1233, 315, 2018, 334, 262, 282, 892, 1982, 2112, 9, 436, 1586, 314, 267, 1072, 687, 314, 4465, 1125, 503, 687, 282, 570, 334, 692, 1788, 365, 663, 680, 267, 1432, 314, 1072, 2385, 465, 282, 769, 14, 398, 19828, 314, 3659, 2338, 687, 314, 4465, 1125, 367, 2018, 3105, 267, 1900, 12, 436, 3350, 298, 5639, 2462, 378, 88, 993, 23, 70, 24, 68, 24, 17108, 2576, 383, 2, 701, 298, 5639, 267, 2462, 5787, 1674, 267, 408, 267, 1233, 275, 22622, 8, 600, 680, 1913, 342, 267, 543, 2291, 14, 18334, 17345, 1119, 7457, 837, 288, 2112, 275, 2884, 63, 3676, 14, 10212, 63, 1548, 3654, 67, 297, 1233, 9, 267, 3839, 12, 4635, 275, 2112, 14, 10664, 342, 267, 4458, 600, 275, 2112, 14, 2573, 342, 267, 1072, 275, 2291, 14, 1913, 63, 1548, 63, 3083, 8, 2703, 9, 267, 1072, 275, 1072, 14, 2708, 360, 4371, 297, 283, 21509, 1814, 358, 267, 340, 1788, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 288, 543, 1551, 8, 1501, 12, 298, 4848, 531, 465, 4090, 26, 355, 1072, 275, 4090, 14, 739, 342, 288, 1072, 275, 1072, 14, 2708, 360, 4371, 297, 283, 21509, 1814, 358, 267, 1072, 275, 295, 14, 954, 360, 5639, 2462, 378, 88, 59, 16, 13, 25, 65, 13, 70, 11529, 717, 283, 5639, 2462, 5787, 297, 717, 1072, 9, 267, 372, 1072, 14, 7644, 1062, 4458, 600, 339, 347, 1104, 63, 16208, 63, 705, 8, 277, 12, 1233, 12, 1004, 63, 1955, 12, 536, 63, 3821, 12, 2079, 1788, 29, 403, 12, 1006, 63, 6962, 29, 549, 12, 1163, 63, 3821, 29, 403, 304, 267, 408, 267, 2670, 626, 314, 16898, 3016, 367, 14294, 2552, 365, 5223, 436, 1104, 314, 267, 5190, 687, 314, 1982, 2112, 1072, 14, 398, 14771, 376, 1125, 340, 314, 1072, 3181, 1133, 1336, 314, 1420, 1475, 14, 267, 408, 267, 340, 1006, 63, 6962, 26, 288, 1406, 275, 283, 5639, 2462, 5787, 334, 2786, 8058, 1240, 1642, 3171, 267, 587, 26, 288, 1406, 275, 283, 4851, 334, 2786, 8058, 1240, 1642, 3171, 267, 5163, 275, 408, 288, 7167, 19507, 2018, 1125, 26, 469, 354, 93, 953, 469, 1291, 9160, 1598, 3814, 3886, 875, 7166, 1004, 469, 3469, 93, 315, 665, 578, 30, 288, 408, 267, 5163, 275, 22622, 8, 3821, 14, 908, 8, 288, 5874, 29, 604, 63, 1955, 12, 288, 536, 29, 354, 63, 3821, 12, 288, 1406, 29, 264, 14, 3765, 8, 1291, 23261, 1913, 342, 267, 340, 1163, 63, 3821, 26, 288, 5163, 847, 24628, 435, 1163, 63, 3821, 267, 1072, 12, 4458, 600, 275, 291, 14, 362, 63, 1199, 8, 600, 12, 1788, 9, 267, 1072, 275, 1557, 78, 1370, 904, 8, 1199, 9, 267, 291, 14, 31132, 8, 1199, 12, 5163, 9, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 768, 2796, 14, 15118, 8, 1274, 14, 3246, 14, 2460, 360, 65, 1148, 659, 2151, 298, 1589, 1642, 2034, 402, 4402, 365, 282, 9994, 1586, 13, 2118, 641, 437, 3867, 531, 272, 347, 511, 63, 739, 63, 2307, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 739, 63, 2307, 342, 288, 10327, 288, 650, 12, 288, 327, 13383, 327, 4195, 383, 26, 5574, 5962, 6534, 15522, 14961, 641, 10444, 4403, 1323, 491, 1636, 288, 283, 5169, 19689, 3117, 16898, 92, 12106, 1125, 92, 25501, 16329, 5942, 339, 347, 511, 63, 4093, 8359, 86, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 4093, 8359, 86, 342, 288, 10327, 288, 650, 12, 288, 283, 19689, 3117, 16898, 358, 339, 347, 511, 63, 4093, 371, 2591, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 4093, 371, 2591, 342, 288, 10327, 288, 650, 12, 288, 283, 5583, 1376, 358, 339, 768, 2796, 14, 15118, 8, 1274, 14, 3246, 508, 283, 2676, 708, 297, 2151, 298, 7864, 38, 1510, 3913, 506, 15604, 641, 5417, 531, 272, 347, 511, 63, 4093, 70, 321, 8, 277, 304, 267, 291, 14, 1074, 63, 16208, 63, 705, 4852, 288, 492, 1433, 348, 273, 1221, 288, 1433, 348, 273, 1221, 14, 4296, 342, 288, 1433, 348, 273, 1221, 423, 4093, 70, 321, 342, 288, 10327, 288, 650, 12, 288, 283, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
carnotweat/cpupimp
libs/rsa/pem.py
216
3372
# -*- coding: utf-8 -*- # # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu> # # 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. '''Functions that load and write PEM-encoded files.''' import base64 from rsa._compat import b, is_bytes def _markers(pem_marker): ''' Returns the start and end PEM markers ''' if is_bytes(pem_marker): pem_marker = pem_marker.decode('utf-8') return (b('-----BEGIN %s-----' % pem_marker), b('-----END %s-----' % pem_marker)) def load_pem(contents, pem_marker): '''Loads a PEM file. @param contents: the contents of the file to interpret @param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY' when your file has '-----BEGIN RSA PRIVATE KEY-----' and '-----END RSA PRIVATE KEY-----' markers. @return the base64-decoded content between the start and end markers. @raise ValueError: when the content is invalid, for example when the start marker cannot be found. ''' (pem_start, pem_end) = _markers(pem_marker) pem_lines = [] in_pem_part = False for line in contents.splitlines(): line = line.strip() # Skip empty lines if not line: continue # Handle start marker if line == pem_start: if in_pem_part: raise ValueError('Seen start marker "%s" twice' % pem_start) in_pem_part = True continue # Skip stuff before first marker if not in_pem_part: continue # Handle end marker if in_pem_part and line == pem_end: in_pem_part = False break # Load fields if b(':') in line: continue pem_lines.append(line) # Do some sanity checks if not pem_lines: raise ValueError('No PEM start marker "%s" found' % pem_start) if in_pem_part: raise ValueError('No PEM end marker "%s" found' % pem_end) # Base64-decode the contents pem = b('').join(pem_lines) return base64.decodestring(pem) def save_pem(contents, pem_marker): '''Saves a PEM file. @param contents: the contents to encode in PEM format @param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY' when your file has '-----BEGIN RSA PRIVATE KEY-----' and '-----END RSA PRIVATE KEY-----' markers. @return the base64-encoded content between the start and end markers. ''' (pem_start, pem_end) = _markers(pem_marker) b64 = base64.encodestring(contents).replace(b('\n'), b('')) pem_lines = [pem_start] for block_start in range(0, len(b64), 64): block = b64[block_start:block_start + 64] pem_lines.append(block) pem_lines.append(pem_end) pem_lines.append(b('')) return b('\n').join(pem_lines)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 1898, 7760, 5515, 66, 828, 437, 14, 1933, 17709, 1090, 665, 1786, 66, 828, 32, 270, 85, 1090, 14, 16913, 30, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 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, 420, 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, 199, 2344, 13967, 626, 2248, 436, 2218, 25957, 13, 8167, 1584, 10595, 199, 199, 646, 1300, 772, 199, 504, 23609, 423, 5819, 492, 330, 12, 365, 63, 2394, 199, 199, 318, 485, 16835, 8, 13102, 63, 4211, 304, 272, 1449, 272, 1803, 314, 1343, 436, 1284, 25957, 14327, 272, 1449, 339, 340, 365, 63, 2394, 8, 13102, 63, 4211, 304, 267, 4837, 77, 63, 4211, 275, 4837, 77, 63, 4211, 14, 2708, 360, 1624, 13, 24, 358, 339, 372, 334, 66, 360, 9858, 15947, 450, 83, 9858, 7, 450, 4837, 77, 63, 4211, 395, 288, 330, 360, 9858, 3902, 450, 83, 9858, 7, 450, 4837, 77, 63, 4211, 430, 199, 199, 318, 2248, 63, 13102, 8, 4407, 12, 4837, 77, 63, 4211, 304, 272, 1449, 30777, 282, 25957, 570, 14, 339, 768, 635, 4072, 26, 314, 4072, 402, 314, 570, 370, 15579, 272, 768, 635, 4837, 77, 63, 4211, 26, 314, 3608, 402, 314, 25957, 1564, 12, 4066, 465, 283, 12115, 28644, 1951, 9301, 7, 267, 1380, 2195, 570, 965, 283, 9858, 15947, 18471, 28644, 1951, 9301, 9858, 7, 436, 267, 283, 9858, 3902, 18471, 28644, 1951, 9301, 9858, 7, 14327, 14, 339, 768, 1107, 314, 1300, 772, 13, 16167, 1564, 3382, 314, 1343, 436, 1284, 14327, 14, 339, 768, 3730, 1722, 26, 1380, 314, 1564, 365, 3866, 12, 367, 2893, 1380, 314, 1343, 267, 3608, 3913, 506, 1911, 14, 339, 1449, 339, 334, 13102, 63, 928, 12, 4837, 77, 63, 500, 9, 275, 485, 16835, 8, 13102, 63, 4211, 9, 339, 4837, 77, 63, 1278, 275, 942, 272, 315, 63, 13102, 63, 2064, 275, 756, 339, 367, 1004, 315, 4072, 14, 7644, 837, 267, 1004, 275, 1004, 14, 1913, 342, 398, 327, 8232, 2701, 2385, 267, 340, 440, 1004, 26, 288, 1980, 398, 327, 8690, 1343, 3608, 267, 340, 1004, 508, 4837, 77, 63, 928, 26, 288, 340, 315, 63, 13102, 63, 2064, 26, 355, 746, 1722, 360, 1513, 287, 1343, 3608, 2071, 83, 2, 13373, 7, 450, 4837, 77, 63, 928, 9, 953, 315, 63, 13102, 63, 2064, 275, 715, 288, 1980, 398, 327, 8232, 8292, 2544, 1642, 3608, 267, 340, 440, 315, 63, 13102, 63, 2064, 26, 288, 1980, 398, 327, 8690, 1284, 3608, 267, 340, 315, 63, 13102, 63, 2064, 436, 1004, 508, 4837, 77, 63, 500, 26, 288, 315, 63, 13102, 63, 2064, 275, 756, 288, 2059, 398, 327, 7190, 1504, 267, 340, 330, 11633, 315, 1004, 26, 288, 1980, 398, 4837, 77, 63, 1278, 14, 740, 8, 604, 9, 339, 327, 4226, 2005, 16740, 5920, 272, 340, 440, 4837, 77, 63, 1278, 26, 267, 746, 1722, 360, 1944, 25957, 1343, 3608, 2071, 83, 2, 1911, 7, 450, 4837, 77, 63, 928, 9, 339, 340, 315, 63, 13102, 63, 2064, 26, 267, 746, 1722, 360, 1944, 25957, 1284, 3608, 2071, 83, 2, 1911, 7, 450, 4837, 77, 63, 500, 9, 339, 327, 3523, 772, 13, 2708, 314, 4072, 272, 4837, 77, 275, 330, 360, 1959, 904, 8, 13102, 63, 1278, 9, 272, 372, 1300, 772, 14, 2708, 875, 8, 13102, 9, 421, 199, 318, 3354, 63, 13102, 8, 4407, 12, 4837, 77, 63, 4211, 304, 272, 1449, 51, 7047, 282, 25957, 570, 14, 339, 768, 635, 4072, 26, 314, 4072, 370, 3752, 315, 25957, 1475, 272, 768, 635, 4837, 77, 63, 4211, 26, 314, 3608, 402, 314, 25957, 1564, 12, 4066, 465, 283, 12115, 28644, 1951, 9301, 7, 267, 1380, 2195, 570, 965, 283, 9858, 15947, 18471, 28644, 1951, 9301, 9858, 7, 436, 267, 283, 9858, 3902, 18471, 28644, 1951, 9301, 9858, 7, 14327, 14, 339, 768, 1107, 314, 1300, 772, 13, 8167, 1564, 3382, 314, 1343, 436, 1284, 14327, 14, 339, 1449, 339, 334, 13102, 63, 928, 12, 4837, 77, 63, 500, 9, 275, 485, 16835, 8, 13102, 63, 4211, 9, 339, 330, 772, 275, 1300, 772, 14, 2143, 875, 8, 4407, 680, 1814, 8, 66, 2258, 78, 659, 330, 30991, 272, 4837, 77, 63, 1278, 275, 359, 13102, 63, 928, 61, 2286, 367, 1853, 63, 928, 315, 1425, 8, 16, 12, 822, 8, 66, 772, 395, 5049, 304, 267, 1853, 275, 330, 772, 59, 1457, 63, 928, 26, 1457, 63, 928, 435, 5049, 61, 267, 4837, 77, 63, 1278, 14, 740, 8, 1457, 9, 339, 4837, 77, 63, 1278, 14, 740, 8, 13102, 63, 500, 9, 272, 4837, 77, 63, 1278, 14, 740, 8, 66, 30991, 339, 372, 330, 2258, 78, 1959, 904, 8, 13102, 63, 1278, 9, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 1898, 7760, 5515, 66, 828, 437, 14, 1933, 17709, 1090, 665, 1786, 66, 828, 32, 270, 85, 1090, 14, 16913, 30, 199, 3, 199, 3, 221, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 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, 420, 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, 199, 2344, 13967, 626, 2248, 436, 2218, 25957, 13, 8167, 1584, 10595, 199, 199, 646, 1300, 772, 199, 504, 23609, 423, 5819, 492, 330, 12, 365, 63, 2394, 199, 199, 318, 485, 16835, 8, 13102, 63, 4211, 304, 272, 1449, 272, 1803, 314, 1343, 436, 1284, 25957, 14327, 272, 1449, 339, 340, 365, 63, 2394, 8, 13102, 63, 4211, 304, 267, 4837, 77, 63, 4211, 275, 4837, 77, 63, 4211, 14, 2708, 360, 1624, 13, 24, 358, 339, 372, 334, 66, 360, 9858, 15947, 450, 83, 9858, 7, 450, 4837, 77, 63, 4211, 395, 288, 330, 360, 9858, 3902, 450, 83, 9858, 7, 450, 4837, 77, 63, 4211, 430, 199, 199, 318, 2248, 63, 13102, 8, 4407, 12, 4837, 77, 63, 4211, 304, 272, 1449, 30777, 282, 25957, 570, 14, 339, 768, 635, 4072, 26, 314, 4072, 402, 314, 570, 370, 15579, 272, 768, 635, 4837, 77, 63, 4211, 26, 314, 3608, 402, 314, 25957, 1564, 12, 4066, 465, 283, 12115, 28644, 1951, 9301, 7, 267, 1380, 2195, 570, 965, 283, 9858, 15947, 18471, 28644, 1951, 9301, 9858, 7, 436, 267, 283, 9858, 3902, 18471, 28644, 1951, 9301, 9858, 7, 14327, 14, 339, 768, 1107, 314, 1300, 772, 13, 16167, 1564, 3382, 314, 1343, 436, 1284, 14327, 14, 339, 768, 3730, 1722, 26, 1380, 314, 1564, 365, 3866, 12, 367, 2893, 1380, 314, 1343, 267, 3608, 3913, 506, 1911, 14, 339, 1449, 339, 334, 13102, 63, 928, 12, 4837, 77, 63, 500, 9, 275, 485, 16835, 8, 13102, 63, 4211, 9, 339, 4837, 77, 63, 1278, 275, 942, 272, 315, 63, 13102, 63, 2064, 275, 756, 339, 367, 1004, 315, 4072, 14, 7644, 837, 267, 1004, 275, 1004, 14, 1913, 342, 398, 327, 8232, 2701, 2385, 267, 340, 440, 1004, 26, 288, 1980, 398, 327, 8690, 1343, 3608, 267, 340, 1004, 508, 4837, 77, 63, 928, 26, 288, 340, 315, 63, 13102, 63, 2064, 26, 355, 746, 1722, 360, 1513, 287, 1343, 3608, 2071, 83, 2, 13373, 7, 450, 4837, 77, 63, 928, 9, 953, 315, 63, 13102, 63, 2064, 275, 715, 288, 1980, 398, 327, 8232, 8292, 2544, 1642, 3608, 267, 340, 440, 315, 63, 13102, 63, 2064, 26, 288, 1980, 398, 327, 8690, 1284, 3608, 267, 340, 315, 63, 13102, 63, 2064, 436, 1004, 508, 4837, 77, 63, 500, 26, 288, 315, 63, 13102, 63, 2064, 275, 756, 288, 2059, 398, 327, 7190, 1504, 267, 340, 330, 11633, 315, 1004, 26, 288, 1980, 398, 4837, 77, 63, 1278, 14, 740, 8, 604, 9, 339, 327, 4226, 2005, 16740, 5920, 272, 340, 440, 4837, 77, 63, 1278, 26, 267, 746, 1722, 360, 1944, 25957, 1343, 3608, 2071, 83, 2, 1911, 7, 450, 4837, 77, 63, 928, 9, 339, 340, 315, 63, 13102, 63, 2064, 26, 267, 746, 1722, 360, 1944, 25957, 1284, 3608, 2071, 83, 2, 1911, 7, 450, 4837, 77, 63, 500, 9, 339, 327, 3523, 772, 13, 2708, 314, 4072, 272, 4837, 77, 275, 330, 360, 1959, 904, 8, 13102, 63, 1278, 9, 272, 372, 1300, 772, 14, 2708, 875, 8, 13102, 9, 421, 199, 318, 3354, 63, 13102, 8, 4407, 12, 4837, 77, 63, 4211, 304, 272, 1449, 51, 7047, 282, 25957, 570, 14, 339, 768, 635, 4072, 26, 314, 4072, 370, 3752, 315, 25957, 1475, 272, 768, 635, 4837, 77, 63, 4211, 26, 314, 3608, 402, 314, 25957, 1564, 12, 4066, 465, 283, 12115, 28644, 1951, 9301, 7, 267, 1380, 2195, 570, 965, 283, 9858, 15947, 18471, 28644, 1951, 9301, 9858, 7, 436, 267, 283, 9858, 3902, 18471, 28644, 1951, 9301, 9858, 7, 14327, 14, 339, 768, 1107, 314, 1300, 772, 13, 8167, 1564, 3382, 314, 1343, 436, 1284, 14327, 14, 339, 1449, 339, 334, 13102, 63, 928, 12, 4837, 77, 63, 500, 9, 275, 485, 16835, 8, 13102, 63, 4211, 9, 339, 330, 772, 275, 1300, 772, 14, 2143, 875, 8, 4407, 680, 1814, 8, 66, 2258, 78, 659, 330, 30991, 272, 4837, 77, 63, 1278, 275, 359, 13102, 63, 928, 61, 2286, 367, 1853, 63, 928, 315, 1425, 8, 16, 12, 822, 8, 66, 772, 395, 5049, 304, 267, 1853, 275, 330, 772, 59, 1457, 63, 928, 26, 1457, 63, 928, 435, 5049, 61, 267, 4837, 77, 63, 1278, 14, 740, 8, 1457, 9, 339, 4837, 77, 63, 1278, 14, 740, 8, 13102, 63, 500, 9, 272, 4837, 77, 63, 1278, 14, 740, 8, 66, 30991, 339, 372, 330, 2258, 78, 1959, 904, 8, 13102, 63, 1278, 9, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
alaski/nova
nova/api/openstack/compute/server_password.py
7
2555
# Copyright (c) 2012 Nebula, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """The server password extension.""" from nova.api.metadata import password from nova.api.openstack import common from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova import compute from nova.policies import server_password as sp_policies ALIAS = 'os-server-password' class ServerPasswordController(wsgi.Controller): """The Server Password API controller for the OpenStack API.""" def __init__(self): self.compute_api = compute.API() @extensions.expected_errors(404) def index(self, req, server_id): context = req.environ['nova.context'] context.can(sp_policies.BASE_POLICY_NAME) instance = common.get_instance(self.compute_api, context, server_id) passw = password.extract_password(instance) return {'password': passw or ''} @extensions.expected_errors(404) @wsgi.response(204) def clear(self, req, server_id): """Removes the encrypted server password from the metadata server Note that this does not actually change the instance server password. """ context = req.environ['nova.context'] context.can(sp_policies.BASE_POLICY_NAME) instance = common.get_instance(self.compute_api, context, server_id) meta = password.convert_password(context, None) instance.system_metadata.update(meta) instance.save() class ServerPassword(extensions.V21APIExtensionBase): """Server password support.""" name = "ServerPassword" alias = ALIAS version = 1 def get_resources(self): resources = [ extensions.ResourceExtension( ALIAS, ServerPasswordController(), collection_actions={'clear': 'DELETE'}, parent=dict(member_name='server', collection_name='servers'))] return resources def get_controller_extensions(self): return []
apache-2.0
[ 3, 1898, 334, 67, 9, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 1918, 1654, 2505, 3329, 1041, 199, 199, 504, 5913, 14, 1246, 14, 2343, 492, 2505, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 492, 4526, 199, 504, 5913, 14, 11767, 492, 1654, 63, 2060, 465, 2249, 63, 11767, 421, 199, 12644, 275, 283, 736, 13, 1000, 13, 2060, 7, 421, 199, 533, 7146, 6139, 7506, 8, 6508, 14, 7506, 304, 272, 408, 1918, 7146, 13635, 3261, 7614, 367, 314, 14260, 3261, 1041, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3357, 63, 1246, 275, 4526, 14, 3735, 342, 339, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 347, 1478, 8, 277, 12, 2648, 12, 1654, 63, 344, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1067, 14, 2425, 8, 681, 63, 11767, 14, 5825, 63, 15976, 63, 2339, 9, 267, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1654, 63, 344, 9, 398, 986, 87, 275, 2505, 14, 5005, 63, 2060, 8, 842, 9, 267, 372, 791, 2060, 356, 986, 87, 503, 28174, 339, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 768, 6508, 14, 1310, 8, 6686, 9, 272, 347, 5436, 8, 277, 12, 2648, 12, 1654, 63, 344, 304, 267, 408, 22948, 314, 14862, 1654, 2505, 687, 314, 3341, 1654, 398, 3390, 626, 642, 1630, 440, 5965, 1570, 314, 1256, 1654, 267, 2505, 14, 267, 408, 398, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1067, 14, 2425, 8, 681, 63, 11767, 14, 5825, 63, 15976, 63, 2339, 9, 267, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1654, 63, 344, 9, 267, 3404, 275, 2505, 14, 3916, 63, 2060, 8, 1100, 12, 488, 9, 267, 1256, 14, 2253, 63, 2343, 14, 873, 8, 2024, 9, 267, 1256, 14, 2117, 342, 421, 199, 533, 7146, 6139, 8, 5359, 14, 54, 2025, 3735, 6382, 1563, 304, 272, 408, 3120, 2505, 2291, 1041, 339, 536, 275, 298, 3120, 6139, 2, 272, 5162, 275, 437, 2673, 1179, 272, 1015, 275, 413, 339, 347, 664, 63, 4435, 8, 277, 304, 267, 5944, 275, 359, 288, 5478, 14, 4031, 6382, 8, 355, 437, 2673, 1179, 12, 7146, 6139, 7506, 1062, 355, 3245, 63, 3723, 3713, 3584, 356, 283, 7014, 2267, 355, 1676, 29, 807, 8, 1114, 63, 354, 534, 1000, 297, 3245, 63, 354, 534, 5871, 27738, 267, 372, 5944, 339, 347, 664, 63, 5538, 63, 5359, 8, 277, 304, 267, 372, 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 ]
[ 1898, 334, 67, 9, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 1918, 1654, 2505, 3329, 1041, 199, 199, 504, 5913, 14, 1246, 14, 2343, 492, 2505, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 492, 4526, 199, 504, 5913, 14, 11767, 492, 1654, 63, 2060, 465, 2249, 63, 11767, 421, 199, 12644, 275, 283, 736, 13, 1000, 13, 2060, 7, 421, 199, 533, 7146, 6139, 7506, 8, 6508, 14, 7506, 304, 272, 408, 1918, 7146, 13635, 3261, 7614, 367, 314, 14260, 3261, 1041, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3357, 63, 1246, 275, 4526, 14, 3735, 342, 339, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 347, 1478, 8, 277, 12, 2648, 12, 1654, 63, 344, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1067, 14, 2425, 8, 681, 63, 11767, 14, 5825, 63, 15976, 63, 2339, 9, 267, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1654, 63, 344, 9, 398, 986, 87, 275, 2505, 14, 5005, 63, 2060, 8, 842, 9, 267, 372, 791, 2060, 356, 986, 87, 503, 28174, 339, 768, 5359, 14, 2062, 63, 2550, 8, 5188, 9, 272, 768, 6508, 14, 1310, 8, 6686, 9, 272, 347, 5436, 8, 277, 12, 2648, 12, 1654, 63, 344, 304, 267, 408, 22948, 314, 14862, 1654, 2505, 687, 314, 3341, 1654, 398, 3390, 626, 642, 1630, 440, 5965, 1570, 314, 1256, 1654, 267, 2505, 14, 267, 408, 398, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1067, 14, 2425, 8, 681, 63, 11767, 14, 5825, 63, 15976, 63, 2339, 9, 267, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1654, 63, 344, 9, 267, 3404, 275, 2505, 14, 3916, 63, 2060, 8, 1100, 12, 488, 9, 267, 1256, 14, 2253, 63, 2343, 14, 873, 8, 2024, 9, 267, 1256, 14, 2117, 342, 421, 199, 533, 7146, 6139, 8, 5359, 14, 54, 2025, 3735, 6382, 1563, 304, 272, 408, 3120, 2505, 2291, 1041, 339, 536, 275, 298, 3120, 6139, 2, 272, 5162, 275, 437, 2673, 1179, 272, 1015, 275, 413, 339, 347, 664, 63, 4435, 8, 277, 304, 267, 5944, 275, 359, 288, 5478, 14, 4031, 6382, 8, 355, 437, 2673, 1179, 12, 7146, 6139, 7506, 1062, 355, 3245, 63, 3723, 3713, 3584, 356, 283, 7014, 2267, 355, 1676, 29, 807, 8, 1114, 63, 354, 534, 1000, 297, 3245, 63, 354, 534, 5871, 27738, 267, 372, 5944, 339, 347, 664, 63, 5538, 63, 5359, 8, 277, 304, 267, 372, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
naparuba/kunai
opsbro/misc/internalyaml/ruamel/_test/test_version.py
2
2164
# coding: utf-8 import pytest # NOQA import ruamel.yaml from roundtrip import dedent def load(s, version=None): return ruamel.yaml.round_trip_load(dedent(s), version) class TestVersions: def test_explicit_1_2(self): l = load("""\ %YAML 1.2 --- - 12:34:56 - 012 - 012345678 - 0o12 - on - off - yes - no - true """) assert l[0] == '12:34:56' assert l[1] == 12 assert l[2] == '012345678' assert l[3] == 10 assert l[4] == 'on' assert l[5] == 'off' assert l[6] == 'yes' assert l[7] == 'no' assert l[8] is True def test_explicit_1_1(self): l = load("""\ %YAML 1.1 --- - 12:34:56 - 012 - 012345678 - 0o12 - on - off - yes - no - true """) assert l[0] == 45296 assert l[1] == 10 assert l[2] == '012345678' assert l[3] == 10 assert l[4] is True assert l[5] is False assert l[6] is True assert l[7] is False assert l[8] is True def test_implicit_1_2(self): l = load("""\ - 12:34:56 - 012 - 012345678 - 0o12 - on - off - yes - no - true """) assert l[0] == '12:34:56' assert l[1] == 12 assert l[2] == '012345678' assert l[3] == 10 assert l[4] == 'on' assert l[5] == 'off' assert l[6] == 'yes' assert l[7] == 'no' assert l[8] is True def test_load_version_1_1(self): l = load("""\ - 12:34:56 - 012 - 012345678 - 0o12 - on - off - yes - no - true """, version="1.1") assert l[0] == 45296 assert l[1] == 10 assert l[2] == '012345678' assert l[3] == 10 assert l[4] is True assert l[5] is False assert l[6] is True assert l[7] is False assert l[8] is True
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 199, 646, 4613, 12788, 327, 20432, 199, 199, 646, 519, 85, 14868, 14, 5963, 199, 504, 6168, 7254, 492, 22622, 421, 199, 318, 2248, 8, 83, 12, 1015, 29, 403, 304, 272, 372, 519, 85, 14868, 14, 5963, 14, 2363, 63, 7254, 63, 912, 8, 14674, 8, 83, 395, 1015, 9, 421, 199, 533, 1379, 21167, 26, 272, 347, 511, 63, 10306, 63, 17, 63, 18, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 450, 23103, 413, 14, 18, 267, 10894, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 7857, 267, 702, 634, 59, 16, 61, 508, 283, 713, 26, 1082, 26, 1367, 7, 267, 702, 634, 59, 17, 61, 508, 3144, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 508, 283, 265, 7, 267, 702, 634, 59, 21, 61, 508, 283, 1997, 7, 267, 702, 634, 59, 22, 61, 508, 283, 5066, 7, 267, 702, 634, 59, 23, 61, 508, 283, 889, 7, 267, 702, 634, 59, 24, 61, 365, 715, 339, 347, 511, 63, 10306, 63, 17, 63, 17, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 450, 23103, 413, 14, 17, 267, 10894, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 7857, 267, 702, 634, 59, 16, 61, 508, 10416, 11700, 267, 702, 634, 59, 17, 61, 508, 1616, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 365, 715, 267, 702, 634, 59, 21, 61, 365, 756, 267, 702, 634, 59, 22, 61, 365, 715, 267, 702, 634, 59, 23, 61, 365, 756, 267, 702, 634, 59, 24, 61, 365, 715, 339, 347, 511, 63, 11886, 63, 17, 63, 18, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 7857, 267, 702, 634, 59, 16, 61, 508, 283, 713, 26, 1082, 26, 1367, 7, 267, 702, 634, 59, 17, 61, 508, 3144, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 508, 283, 265, 7, 267, 702, 634, 59, 21, 61, 508, 283, 1997, 7, 267, 702, 634, 59, 22, 61, 508, 283, 5066, 7, 267, 702, 634, 59, 23, 61, 508, 283, 889, 7, 267, 702, 634, 59, 24, 61, 365, 715, 339, 347, 511, 63, 912, 63, 1023, 63, 17, 63, 17, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 10327, 1015, 628, 17, 14, 17, 531, 267, 702, 634, 59, 16, 61, 508, 10416, 11700, 267, 702, 634, 59, 17, 61, 508, 1616, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 365, 715, 267, 702, 634, 59, 21, 61, 365, 756, 267, 702, 634, 59, 22, 61, 365, 715, 267, 702, 634, 59, 23, 61, 365, 756, 267, 702, 634, 59, 24, 61, 365, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 26, 2774, 13, 24, 199, 199, 646, 4613, 12788, 327, 20432, 199, 199, 646, 519, 85, 14868, 14, 5963, 199, 504, 6168, 7254, 492, 22622, 421, 199, 318, 2248, 8, 83, 12, 1015, 29, 403, 304, 272, 372, 519, 85, 14868, 14, 5963, 14, 2363, 63, 7254, 63, 912, 8, 14674, 8, 83, 395, 1015, 9, 421, 199, 533, 1379, 21167, 26, 272, 347, 511, 63, 10306, 63, 17, 63, 18, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 450, 23103, 413, 14, 18, 267, 10894, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 7857, 267, 702, 634, 59, 16, 61, 508, 283, 713, 26, 1082, 26, 1367, 7, 267, 702, 634, 59, 17, 61, 508, 3144, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 508, 283, 265, 7, 267, 702, 634, 59, 21, 61, 508, 283, 1997, 7, 267, 702, 634, 59, 22, 61, 508, 283, 5066, 7, 267, 702, 634, 59, 23, 61, 508, 283, 889, 7, 267, 702, 634, 59, 24, 61, 365, 715, 339, 347, 511, 63, 10306, 63, 17, 63, 17, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 450, 23103, 413, 14, 17, 267, 10894, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 7857, 267, 702, 634, 59, 16, 61, 508, 10416, 11700, 267, 702, 634, 59, 17, 61, 508, 1616, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 365, 715, 267, 702, 634, 59, 21, 61, 365, 756, 267, 702, 634, 59, 22, 61, 365, 715, 267, 702, 634, 59, 23, 61, 365, 756, 267, 702, 634, 59, 24, 61, 365, 715, 339, 347, 511, 63, 11886, 63, 17, 63, 18, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 7857, 267, 702, 634, 59, 16, 61, 508, 283, 713, 26, 1082, 26, 1367, 7, 267, 702, 634, 59, 17, 61, 508, 3144, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 508, 283, 265, 7, 267, 702, 634, 59, 21, 61, 508, 283, 1997, 7, 267, 702, 634, 59, 22, 61, 508, 283, 5066, 7, 267, 702, 634, 59, 23, 61, 508, 283, 889, 7, 267, 702, 634, 59, 24, 61, 365, 715, 339, 347, 511, 63, 912, 63, 1023, 63, 17, 63, 17, 8, 277, 304, 267, 634, 275, 2248, 21723, 267, 446, 3144, 26, 1082, 26, 1367, 267, 446, 378, 713, 267, 446, 378, 19542, 267, 446, 378, 79, 713, 267, 446, 641, 267, 446, 2331, 267, 446, 9456, 267, 446, 949, 267, 446, 2549, 267, 10327, 1015, 628, 17, 14, 17, 531, 267, 702, 634, 59, 16, 61, 508, 10416, 11700, 267, 702, 634, 59, 17, 61, 508, 1616, 267, 702, 634, 59, 18, 61, 508, 283, 9461, 12970, 7, 267, 702, 634, 59, 19, 61, 508, 1616, 267, 702, 634, 59, 20, 61, 365, 715, 267, 702, 634, 59, 21, 61, 365, 756, 267, 702, 634, 59, 22, 61, 365, 715, 267, 702, 634, 59, 23, 61, 365, 756, 267, 702, 634, 59, 24, 61, 365, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
csdl/makahiki
makahiki/apps/widgets/notifications/tests.py
2
5060
"""Notification testing.""" from django.test import TransactionTestCase from django.core.urlresolvers import reverse from django.contrib.auth.models import User from apps.managers.challenge_mgr import challenge_mgr from apps.utils import test_utils from apps.widgets.notifications import get_unread_notifications from apps.widgets.notifications.models import UserNotification class NotificationUnitTests(TransactionTestCase): """Notification Test.""" def testGetUnread(self): """Test that we can get the user's unread notifications.""" user = User.objects.create_user("test", "test@test.com") for i in range(0, 3): notification = UserNotification(recipient=user, contents="Test notification %i" % i) notification.save() notifications = get_unread_notifications(user) self.assertEqual(notifications["alerts"].count(), 0, "There should not be any alert notifications.") unread = notifications["unread"] self.assertEqual(unread.count(), 3, "There should be three unread notifications.") alert = UserNotification(recipient=user, contents="Alert notification", display_alert=True) alert.save() notifications = get_unread_notifications(user) self.assertEqual(notifications["alerts"][0], alert, "Alert notification should have been returned.") unread = notifications["unread"] self.assertEqual(unread.count(), 4, "There should be four unread notifications.") class NotificationFunctionalTests(TransactionTestCase): """View Test.""" def setUp(self): self.user = test_utils.setup_user(username="user", password="test") self.team = self.user.profile.team challenge_mgr.register_page_widget("help", "help.faq") challenge_mgr.register_page_widget("home", "home") from apps.managers.cache_mgr import cache_mgr cache_mgr.clear() self.client.login(username="user", password="test") def testShowNotifications(self): """ Test that we can show notifications to the user. """ for i in range(0, 3): notification = UserNotification(recipient=self.user, contents="Test notification %i" % i) notification.save() response = self.client.get(reverse("home_index")) self.assertNotContains(response, "The following item(s) need your attention", msg_prefix="Alert should not be shown" ) for i in range(0, 3): self.assertContains(response, "Test notification %i" % i, msg_prefix="Notification %i is not shown" % i ) def testAlertNotifications(self): """Test alert.""" alert = UserNotification(recipient=self.user, contents="Alert notification", display_alert=True) alert.save() response = self.client.get(reverse("home_index")) self.assertContains(response, "notification-dialog", msg_prefix="Alert should be shown") response = self.client.get(reverse("help_index")) self.assertNotContains(response, "notification-dialog", msg_prefix="Dialog should not be displayed") def testAjaxReadNotifications(self): """Test that notifications can be marked as read via AJAX.""" notification = UserNotification(recipient=self.user, contents="Test notification") notification.save() response = self.client.post(reverse("notifications_read", args=(notification.pk,)), {}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.failUnlessEqual(response.status_code, 200) response = self.client.get(reverse("home_index")) self.assertNotContains(response, "Test notification", msg_prefix="Notification should be read") def testReadNotifications(self): """Test that notifications can be marked as read without AJAX.""" notification = UserNotification(recipient=self.user, contents="Test notification") notification.save() response = self.client.post(reverse("notifications_read", args=(notification.pk,)), {}) self.assertRedirects(response, reverse("home_index"), msg_prefix="Marking as read should redirect.") response = self.client.get(reverse("home_index")) self.assertNotContains(response, "Test notification", msg_prefix="Notification should be read") # Test with a referring page. notification = UserNotification(recipient=self.user, contents="Test notification 2") notification.save() response = self.client.post(reverse("notifications_read", args=(notification.pk,)), {}, HTTP_REFERER=reverse("help_index")) self.assertRedirects(response, reverse("help_index"), msg_prefix="Marking as read should redirect.") response = self.client.get(reverse("home_index")) self.assertNotContains(response, "Test notification 2", msg_prefix="Notification should be read")
mit
[ 624, 11598, 5343, 1041, 199, 199, 504, 1639, 14, 396, 492, 18244, 1746, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 8686, 14, 16259, 14, 13911, 63, 7755, 492, 14929, 63, 7755, 199, 504, 8686, 14, 1208, 492, 511, 63, 1208, 199, 199, 504, 8686, 14, 8583, 14, 12782, 492, 664, 63, 28677, 63, 12782, 199, 504, 8686, 14, 8583, 14, 12782, 14, 992, 492, 2876, 11598, 421, 199, 533, 23362, 5072, 2925, 8, 10161, 1746, 304, 272, 408, 11598, 1379, 1041, 272, 347, 19970, 1358, 739, 8, 277, 304, 267, 408, 774, 626, 781, 883, 664, 314, 922, 1159, 625, 739, 13116, 1041, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 480, 396, 401, 298, 396, 32, 396, 14, 957, 531, 267, 367, 284, 315, 1425, 8, 16, 12, 650, 304, 288, 6955, 275, 2876, 11598, 8, 10043, 29, 751, 12, 4072, 628, 774, 6955, 450, 73, 2, 450, 284, 9, 288, 6955, 14, 2117, 342, 398, 13116, 275, 664, 63, 28677, 63, 12782, 8, 751, 9, 267, 291, 14, 629, 8, 12782, 905, 24501, 4140, 835, 1062, 378, 12, 288, 298, 10924, 1077, 440, 506, 1263, 10459, 13116, 2685, 267, 625, 739, 275, 13116, 905, 28677, 937, 267, 291, 14, 629, 8, 28677, 14, 835, 1062, 650, 12, 298, 10924, 1077, 506, 7795, 625, 739, 13116, 2685, 267, 10459, 275, 2876, 11598, 8, 10043, 29, 751, 12, 4072, 628, 18758, 6955, 401, 2929, 63, 9241, 29, 549, 9, 267, 10459, 14, 2117, 342, 398, 13116, 275, 664, 63, 28677, 63, 12782, 8, 751, 9, 267, 291, 14, 629, 8, 12782, 905, 24501, 9210, 16, 467, 10459, 12, 288, 298, 18758, 6955, 1077, 1172, 2757, 2138, 2685, 267, 625, 739, 275, 13116, 905, 28677, 937, 267, 291, 14, 629, 8, 28677, 14, 835, 1062, 841, 12, 298, 10924, 1077, 506, 11648, 625, 739, 13116, 2685, 421, 199, 533, 23362, 3481, 279, 2925, 8, 10161, 1746, 304, 272, 408, 2768, 1379, 1041, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 751, 275, 511, 63, 1208, 14, 2758, 63, 751, 8, 2473, 628, 751, 401, 2505, 628, 396, 531, 267, 291, 14, 5969, 275, 291, 14, 751, 14, 2913, 14, 5969, 398, 14929, 63, 7755, 14, 2683, 63, 1606, 63, 3440, 480, 3437, 401, 298, 3437, 14, 667, 81, 531, 267, 14929, 63, 7755, 14, 2683, 63, 1606, 63, 3440, 480, 4219, 401, 298, 4219, 531, 398, 687, 8686, 14, 16259, 14, 1637, 63, 7755, 492, 2581, 63, 7755, 267, 2581, 63, 7755, 14, 3584, 342, 398, 291, 14, 1258, 14, 2886, 8, 2473, 628, 751, 401, 2505, 628, 396, 531, 339, 347, 511, 6824, 30620, 8, 277, 304, 267, 408, 267, 1379, 626, 781, 883, 2498, 13116, 370, 314, 922, 14, 267, 408, 267, 367, 284, 315, 1425, 8, 16, 12, 650, 304, 288, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 355, 4072, 628, 774, 6955, 450, 73, 2, 450, 284, 9, 288, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 1918, 2569, 1242, 8, 83, 9, 1929, 2195, 22814, 401, 288, 1499, 63, 1861, 628, 18758, 1077, 440, 506, 9164, 2, 267, 776, 267, 367, 284, 315, 1425, 8, 16, 12, 650, 304, 288, 291, 14, 9535, 8, 1310, 12, 298, 774, 6955, 450, 73, 2, 450, 284, 12, 355, 1499, 63, 1861, 628, 11598, 450, 73, 365, 440, 9164, 2, 450, 284, 288, 776, 339, 347, 511, 18758, 30620, 8, 277, 304, 267, 408, 774, 10459, 1041, 267, 10459, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 18758, 6955, 401, 288, 2929, 63, 9241, 29, 549, 9, 267, 10459, 14, 2117, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 9535, 8, 1310, 12, 298, 6761, 13, 7196, 401, 1499, 63, 1861, 628, 18758, 1077, 506, 9164, 531, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 3437, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 6761, 13, 7196, 401, 288, 1499, 63, 1861, 628, 5619, 1077, 440, 506, 9080, 531, 339, 347, 511, 33, 15863, 3284, 30620, 8, 277, 304, 267, 408, 774, 626, 13116, 883, 506, 11584, 465, 1586, 4799, 437, 42, 9839, 1041, 267, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 774, 6955, 531, 267, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 480, 12782, 63, 739, 401, 1249, 2687, 6761, 14, 2051, 16965, 5479, 288, 3101, 63, 56, 63, 6780, 1149, 63, 9139, 534, 4317, 10441, 358, 267, 291, 14, 14247, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 774, 6955, 401, 288, 1499, 63, 1861, 628, 11598, 1077, 506, 1586, 531, 339, 347, 511, 3284, 30620, 8, 277, 304, 267, 408, 774, 626, 13116, 883, 506, 11584, 465, 1586, 1928, 437, 42, 9839, 1041, 267, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 774, 6955, 531, 267, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 480, 12782, 63, 739, 401, 1249, 2687, 6761, 14, 2051, 16965, 5009, 267, 291, 14, 17466, 8, 1310, 12, 3837, 480, 4219, 63, 1080, 1288, 288, 1499, 63, 1861, 628, 6470, 316, 465, 1586, 1077, 4660, 2685, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 774, 6955, 401, 288, 1499, 63, 1861, 628, 11598, 1077, 506, 1586, 531, 398, 327, 1379, 543, 282, 21864, 2034, 14, 267, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 774, 6955, 499, 531, 267, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 480, 12782, 63, 739, 401, 1249, 2687, 6761, 14, 2051, 16965, 5479 ]
[ 11598, 5343, 1041, 199, 199, 504, 1639, 14, 396, 492, 18244, 1746, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 8686, 14, 16259, 14, 13911, 63, 7755, 492, 14929, 63, 7755, 199, 504, 8686, 14, 1208, 492, 511, 63, 1208, 199, 199, 504, 8686, 14, 8583, 14, 12782, 492, 664, 63, 28677, 63, 12782, 199, 504, 8686, 14, 8583, 14, 12782, 14, 992, 492, 2876, 11598, 421, 199, 533, 23362, 5072, 2925, 8, 10161, 1746, 304, 272, 408, 11598, 1379, 1041, 272, 347, 19970, 1358, 739, 8, 277, 304, 267, 408, 774, 626, 781, 883, 664, 314, 922, 1159, 625, 739, 13116, 1041, 267, 922, 275, 2876, 14, 1462, 14, 981, 63, 751, 480, 396, 401, 298, 396, 32, 396, 14, 957, 531, 267, 367, 284, 315, 1425, 8, 16, 12, 650, 304, 288, 6955, 275, 2876, 11598, 8, 10043, 29, 751, 12, 4072, 628, 774, 6955, 450, 73, 2, 450, 284, 9, 288, 6955, 14, 2117, 342, 398, 13116, 275, 664, 63, 28677, 63, 12782, 8, 751, 9, 267, 291, 14, 629, 8, 12782, 905, 24501, 4140, 835, 1062, 378, 12, 288, 298, 10924, 1077, 440, 506, 1263, 10459, 13116, 2685, 267, 625, 739, 275, 13116, 905, 28677, 937, 267, 291, 14, 629, 8, 28677, 14, 835, 1062, 650, 12, 298, 10924, 1077, 506, 7795, 625, 739, 13116, 2685, 267, 10459, 275, 2876, 11598, 8, 10043, 29, 751, 12, 4072, 628, 18758, 6955, 401, 2929, 63, 9241, 29, 549, 9, 267, 10459, 14, 2117, 342, 398, 13116, 275, 664, 63, 28677, 63, 12782, 8, 751, 9, 267, 291, 14, 629, 8, 12782, 905, 24501, 9210, 16, 467, 10459, 12, 288, 298, 18758, 6955, 1077, 1172, 2757, 2138, 2685, 267, 625, 739, 275, 13116, 905, 28677, 937, 267, 291, 14, 629, 8, 28677, 14, 835, 1062, 841, 12, 298, 10924, 1077, 506, 11648, 625, 739, 13116, 2685, 421, 199, 533, 23362, 3481, 279, 2925, 8, 10161, 1746, 304, 272, 408, 2768, 1379, 1041, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 751, 275, 511, 63, 1208, 14, 2758, 63, 751, 8, 2473, 628, 751, 401, 2505, 628, 396, 531, 267, 291, 14, 5969, 275, 291, 14, 751, 14, 2913, 14, 5969, 398, 14929, 63, 7755, 14, 2683, 63, 1606, 63, 3440, 480, 3437, 401, 298, 3437, 14, 667, 81, 531, 267, 14929, 63, 7755, 14, 2683, 63, 1606, 63, 3440, 480, 4219, 401, 298, 4219, 531, 398, 687, 8686, 14, 16259, 14, 1637, 63, 7755, 492, 2581, 63, 7755, 267, 2581, 63, 7755, 14, 3584, 342, 398, 291, 14, 1258, 14, 2886, 8, 2473, 628, 751, 401, 2505, 628, 396, 531, 339, 347, 511, 6824, 30620, 8, 277, 304, 267, 408, 267, 1379, 626, 781, 883, 2498, 13116, 370, 314, 922, 14, 267, 408, 267, 367, 284, 315, 1425, 8, 16, 12, 650, 304, 288, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 355, 4072, 628, 774, 6955, 450, 73, 2, 450, 284, 9, 288, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 1918, 2569, 1242, 8, 83, 9, 1929, 2195, 22814, 401, 288, 1499, 63, 1861, 628, 18758, 1077, 440, 506, 9164, 2, 267, 776, 267, 367, 284, 315, 1425, 8, 16, 12, 650, 304, 288, 291, 14, 9535, 8, 1310, 12, 298, 774, 6955, 450, 73, 2, 450, 284, 12, 355, 1499, 63, 1861, 628, 11598, 450, 73, 365, 440, 9164, 2, 450, 284, 288, 776, 339, 347, 511, 18758, 30620, 8, 277, 304, 267, 408, 774, 10459, 1041, 267, 10459, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 18758, 6955, 401, 288, 2929, 63, 9241, 29, 549, 9, 267, 10459, 14, 2117, 342, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 9535, 8, 1310, 12, 298, 6761, 13, 7196, 401, 1499, 63, 1861, 628, 18758, 1077, 506, 9164, 531, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 3437, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 6761, 13, 7196, 401, 288, 1499, 63, 1861, 628, 5619, 1077, 440, 506, 9080, 531, 339, 347, 511, 33, 15863, 3284, 30620, 8, 277, 304, 267, 408, 774, 626, 13116, 883, 506, 11584, 465, 1586, 4799, 437, 42, 9839, 1041, 267, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 774, 6955, 531, 267, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 480, 12782, 63, 739, 401, 1249, 2687, 6761, 14, 2051, 16965, 5479, 288, 3101, 63, 56, 63, 6780, 1149, 63, 9139, 534, 4317, 10441, 358, 267, 291, 14, 14247, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 774, 6955, 401, 288, 1499, 63, 1861, 628, 11598, 1077, 506, 1586, 531, 339, 347, 511, 3284, 30620, 8, 277, 304, 267, 408, 774, 626, 13116, 883, 506, 11584, 465, 1586, 1928, 437, 42, 9839, 1041, 267, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 774, 6955, 531, 267, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 480, 12782, 63, 739, 401, 1249, 2687, 6761, 14, 2051, 16965, 5009, 267, 291, 14, 17466, 8, 1310, 12, 3837, 480, 4219, 63, 1080, 1288, 288, 1499, 63, 1861, 628, 6470, 316, 465, 1586, 1077, 4660, 2685, 398, 1177, 275, 291, 14, 1258, 14, 362, 8, 4471, 480, 4219, 63, 1080, 2237, 267, 291, 14, 23218, 8, 1310, 12, 298, 774, 6955, 401, 288, 1499, 63, 1861, 628, 11598, 1077, 506, 1586, 531, 398, 327, 1379, 543, 282, 21864, 2034, 14, 267, 6955, 275, 2876, 11598, 8, 10043, 29, 277, 14, 751, 12, 4072, 628, 774, 6955, 499, 531, 267, 6955, 14, 2117, 342, 398, 1177, 275, 291, 14, 1258, 14, 1932, 8, 4471, 480, 12782, 63, 739, 401, 1249, 2687, 6761, 14, 2051, 16965, 5479, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
andrew-aladev/samba-talloc-debug
auth/credentials/tests/bind.py
11
5515
#!/usr/bin/env python # -*- coding: utf-8 -*- # This is unit with tests for LDAP access checks import optparse import sys import base64 import re import os import copy import time sys.path.insert(0, "bin/python") import samba samba.ensure_external_module("testtools", "testtools") samba.ensure_external_module("subunit", "subunit/python") import samba.getopt as options from ldb import ( SCOPE_BASE, SCOPE_SUBTREE, LdbError, ERR_NO_SUCH_OBJECT) from samba.dcerpc import security from samba.auth import system_session from samba import gensec from samba.samdb import SamDB from samba.credentials import Credentials import samba.tests, unittest from samba.tests import delete_force from subunit.run import SubunitTestRunner from samba.tests import TestCase, TestSkipped parser = optparse.OptionParser("ldap [options] <host>") sambaopts = options.SambaOptions(parser) parser.add_option_group(sambaopts) # use command line creds if available credopts = options.CredentialsOptions(parser) parser.add_option_group(credopts) opts, args = parser.parse_args() if len(args) < 1: parser.print_usage() sys.exit(1) host = args[0] lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp) creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL) creds_machine = copy.deepcopy(creds) creds_user1 = copy.deepcopy(creds) creds_user2 = copy.deepcopy(creds) creds_user3 = copy.deepcopy(creds) class BindTests(samba.tests.TestCase): info_dc = None def setUp(self): super(BindTests, self).setUp() # fetch rootDSEs if self.info_dc is None: res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) self.assertEquals(len(res), 1) BindTests.info_dc = res[0] # cache some of RootDSE props self.schema_dn = self.info_dc["schemaNamingContext"][0] self.domain_dn = self.info_dc["defaultNamingContext"][0] self.config_dn = self.info_dc["configurationNamingContext"][0] self.computer_dn = "CN=centos53,CN=Computers,%s" % self.domain_dn self.password = "P@ssw0rd" self.username = "BindTestUser_" + time.strftime("%s", time.gmtime()) def tearDown(self): super(BindTests, self).tearDown() def test_computer_account_bind(self): # create a computer acocount for the test delete_force(ldb, self.computer_dn) ldb.add_ldif(""" dn: """ + self.computer_dn + """ cn: CENTOS53 displayName: CENTOS53$ name: CENTOS53 sAMAccountName: CENTOS53$ countryCode: 0 objectClass: computer objectClass: organizationalPerson objectClass: person objectClass: top objectClass: user codePage: 0 userAccountControl: 4096 dNSHostName: centos53.alabala.test operatingSystemVersion: 5.2 (3790) operatingSystem: Windows Server 2003 """) ldb.modify_ldif(""" dn: """ + self.computer_dn + """ changetype: modify replace: unicodePwd unicodePwd:: """ + base64.b64encode("\"P@ssw0rd\"".encode('utf-16-le')) + """ """) # do a simple bind and search with the machine account creds_machine.set_bind_dn(self.computer_dn) creds_machine.set_password(self.password) print "BindTest with: " + creds_machine.get_bind_dn() ldb_machine = samba.tests.connect_samdb(host, credentials=creds_machine, lp=lp, ldap_only=True) res = ldb_machine.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) def test_user_account_bind(self): # create user ldb.newuser(username=self.username, password=self.password) ldb_res = ldb.search(base=self.domain_dn, scope=SCOPE_SUBTREE, expression="(samAccountName=%s)" % self.username) self.assertEquals(len(ldb_res), 1) user_dn = ldb_res[0]["dn"] # do a simple bind and search with the user account in format user@realm creds_user1.set_bind_dn(self.username + "@" + creds.get_realm()) creds_user1.set_password(self.password) print "BindTest with: " + creds_user1.get_bind_dn() ldb_user1 = samba.tests.connect_samdb(host, credentials=creds_user1, lp=lp, ldap_only=True) res = ldb_user1.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) # do a simple bind and search with the user account in format domain\user creds_user2.set_bind_dn(creds.get_domain() + "\\" + self.username) creds_user2.set_password(self.password) print "BindTest with: " + creds_user2.get_bind_dn() ldb_user2 = samba.tests.connect_samdb(host, credentials=creds_user2, lp=lp, ldap_only=True) res = ldb_user2.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) # do a simple bind and search with the user account DN creds_user3.set_bind_dn(str(user_dn)) creds_user3.set_password(self.password) print "BindTest with: " + creds_user3.get_bind_dn() ldb_user3 = samba.tests.connect_samdb(host, credentials=creds_user3, lp=lp, ldap_only=True) res = ldb_user3.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) ldb = samba.tests.connect_samdb(host, credentials=creds, lp=lp, ldap_only=True) runner = SubunitTestRunner() rc = 0 if not runner.run(unittest.makeSuite(BindTests)).wasSuccessful(): rc = 1 sys.exit(rc)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 365, 4137, 543, 2295, 367, 20717, 2879, 5920, 199, 199, 646, 8691, 199, 646, 984, 199, 646, 1300, 772, 199, 646, 295, 199, 646, 747, 199, 646, 1331, 199, 646, 900, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 298, 1393, 15, 1548, 531, 199, 646, 31710, 199, 21693, 14, 7505, 63, 5159, 63, 578, 480, 396, 2537, 401, 298, 396, 2537, 531, 199, 21693, 14, 7505, 63, 5159, 63, 578, 480, 954, 3248, 401, 298, 954, 3248, 15, 1548, 531, 199, 199, 646, 31710, 14, 18907, 465, 1511, 199, 199, 504, 634, 697, 492, 334, 272, 428, 1439, 1510, 63, 5825, 12, 428, 1439, 1510, 63, 6348, 22841, 12, 491, 697, 547, 12, 21569, 63, 2826, 63, 6195, 1244, 63, 9868, 9, 199, 504, 31710, 14, 68, 2247, 2352, 492, 6391, 199, 199, 504, 31710, 14, 1178, 492, 2656, 63, 1730, 199, 504, 31710, 492, 486, 677, 67, 199, 504, 31710, 14, 21660, 697, 492, 428, 455, 2846, 199, 504, 31710, 14, 6942, 492, 23934, 199, 646, 31710, 14, 2219, 12, 2882, 199, 504, 31710, 14, 2219, 492, 3145, 63, 3990, 199, 504, 1007, 3248, 14, 1065, 492, 4804, 3248, 13649, 199, 504, 31710, 14, 2219, 492, 7640, 12, 1379, 30472, 199, 199, 2087, 275, 8691, 14, 14553, 480, 9642, 359, 1419, 61, 665, 1102, 9579, 199, 21693, 3291, 275, 1511, 14, 51, 14310, 4558, 8, 2087, 9, 199, 2087, 14, 525, 63, 1422, 63, 923, 8, 21693, 3291, 9, 199, 199, 3, 675, 1414, 1004, 20023, 340, 2808, 199, 18639, 3291, 275, 1511, 14, 13428, 4558, 8, 2087, 9, 199, 2087, 14, 525, 63, 1422, 63, 923, 8, 18639, 3291, 9, 199, 3291, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 822, 8, 589, 9, 665, 413, 26, 272, 1798, 14, 1361, 63, 3807, 342, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1102, 275, 1249, 59, 16, 61, 199, 10343, 275, 31710, 3291, 14, 362, 63, 912, 22176, 342, 199, 15226, 275, 22314, 3291, 14, 362, 63, 6942, 8, 10343, 9, 199, 15226, 14, 409, 63, 71, 677, 67, 63, 3179, 8, 15226, 14, 362, 63, 71, 677, 67, 63, 3179, 342, 1204, 486, 677, 67, 14, 22884, 63, 899, 748, 9, 199, 15226, 63, 6744, 275, 1331, 14, 8293, 8, 15226, 9, 199, 15226, 63, 751, 17, 275, 1331, 14, 8293, 8, 15226, 9, 199, 15226, 63, 751, 18, 275, 1331, 14, 8293, 8, 15226, 9, 199, 15226, 63, 751, 19, 275, 1331, 14, 8293, 8, 15226, 9, 199, 199, 533, 22630, 2925, 8, 21693, 14, 2219, 14, 1746, 304, 339, 2256, 63, 3833, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 8198, 2925, 12, 291, 680, 5996, 342, 267, 327, 5267, 1738, 36, 899, 83, 267, 340, 291, 14, 815, 63, 3833, 365, 488, 26, 288, 522, 275, 634, 697, 14, 1733, 8, 1095, 8772, 3965, 8772, 4194, 29, 17998, 63, 5825, 12, 3290, 6270, 10, 3135, 288, 291, 14, 2947, 8, 552, 8, 470, 395, 413, 9, 288, 22630, 2925, 14, 815, 63, 3833, 275, 522, 59, 16, 61, 267, 327, 2581, 2005, 402, 12826, 36, 899, 10792, 267, 291, 14, 3629, 63, 4272, 275, 291, 14, 815, 63, 3833, 905, 3629, 46, 9568, 2998, 9210, 16, 61, 267, 291, 14, 2261, 63, 4272, 275, 291, 14, 815, 63, 3833, 905, 885, 46, 9568, 2998, 9210, 16, 61, 267, 291, 14, 888, 63, 4272, 275, 291, 14, 815, 63, 3833, 905, 4758, 46, 9568, 2998, 9210, 16, 61, 267, 291, 14, 23805, 63, 4272, 275, 298, 12874, 29, 2497, 14543, 2481, 12, 12874, 29, 2404, 19717, 8719, 83, 2, 450, 291, 14, 2261, 63, 4272, 267, 291, 14, 2060, 275, 298, 48, 32, 385, 87, 16, 6883, 2, 267, 291, 14, 2473, 275, 298, 8198, 774, 1899, 12172, 435, 900, 14, 6205, 3647, 83, 401, 900, 14, 22227, 1012, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 8198, 2925, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 23805, 63, 2048, 63, 3409, 8, 277, 304, 267, 327, 1218, 282, 24189, 282, 331, 835, 367, 314, 511, 267, 3145, 63, 3990, 8, 15793, 12, 291, 14, 23805, 63, 4272, 9, 267, 634, 697, 14, 525, 63, 76, 7330, 4852, 199, 4272, 26, 408, 435, 291, 14, 23805, 63, 4272, 435, 408, 199, 6413, 26, 445, 1309, 3100, 2481, 199, 2918, 985, 26, 445, 1309, 3100, 2481, 4, 199, 354, 26, 445, 1309, 3100, 2481, 199, 83, 1156, 6009, 985, 26, 445, 1309, 3100, 2481, 4, 199, 6063, 3034, 26, 378, 199, 785, 2543, 26, 24189, 199, 785, 2543, 26, 13237, 279, 7344, 199, 785, 2543, 26, 4954, 199, 785, 2543, 26, 2746, 199, 785, 2543, 26, 922, 199, 600, 3276, 26, 378, 199, 751, 6009, 3717, 26, 17125, 199, 68, 2709, 4965, 985, 26, 9679, 14543, 2481, 14, 279, 371, 14774, 14, 396, 199, 2262, 1958, 3989, 3353, 26, 959, 14, 18, 334, 1401, 2710, 9, 199, 2262, 1958, 3989, 26, 5417, 7146, 13004, 199, 6141, 267, 634, 697, 14, 8951, 63, 76, 7330, 4852, 199, 4272, 26, 408, 435, 291, 14, 23805, 63, 4272, 435, 408, 199, 11984, 362, 514, 26, 2811, 199, 1814, 26, 2649, 32701, 199, 2975, 32701, 447, 408, 435, 1300, 772, 14, 66, 772, 2143, 480, 4451, 48, 32, 385, 87, 16, 6883, 18781, 14, 2143, 360, 1624, 13, 975, 13, 274, 1333, 435, 408, 199, 6141, 398, 327, 886, 282, 3486, 5398, 436, 2754, 543, 314, 6844, 2933, 267, 20023, 63, 6744, 14, 409, 63, 3409, 63, 4272, 8, 277, 14, 23805, 63, 4272, 9, 267, 20023, 63, 6744, 14, 409, 63, 2060, 8, 277, 14, 2060, 9, 267, 870, 298, 8198, 774, 543, 26, 298, 435, 20023, 63, 6744, 14, 362, 63, 3409, 63, 4272, 342, 267, 634, 697, 63, 6744, 275, 31710, 14, 2219, 14, 2242, 63, 21660, 697, 8, 1102, 12, 6235, 29, 15226, 63, 6744, 12, 6059, 13204, 29, 10343, 12, 13727, 63, 2118, 29, 549, 9, 267, 522, 275, 634, 697, 63, 6744, 14, 1733, 8, 1095 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 365, 4137, 543, 2295, 367, 20717, 2879, 5920, 199, 199, 646, 8691, 199, 646, 984, 199, 646, 1300, 772, 199, 646, 295, 199, 646, 747, 199, 646, 1331, 199, 646, 900, 199, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 298, 1393, 15, 1548, 531, 199, 646, 31710, 199, 21693, 14, 7505, 63, 5159, 63, 578, 480, 396, 2537, 401, 298, 396, 2537, 531, 199, 21693, 14, 7505, 63, 5159, 63, 578, 480, 954, 3248, 401, 298, 954, 3248, 15, 1548, 531, 199, 199, 646, 31710, 14, 18907, 465, 1511, 199, 199, 504, 634, 697, 492, 334, 272, 428, 1439, 1510, 63, 5825, 12, 428, 1439, 1510, 63, 6348, 22841, 12, 491, 697, 547, 12, 21569, 63, 2826, 63, 6195, 1244, 63, 9868, 9, 199, 504, 31710, 14, 68, 2247, 2352, 492, 6391, 199, 199, 504, 31710, 14, 1178, 492, 2656, 63, 1730, 199, 504, 31710, 492, 486, 677, 67, 199, 504, 31710, 14, 21660, 697, 492, 428, 455, 2846, 199, 504, 31710, 14, 6942, 492, 23934, 199, 646, 31710, 14, 2219, 12, 2882, 199, 504, 31710, 14, 2219, 492, 3145, 63, 3990, 199, 504, 1007, 3248, 14, 1065, 492, 4804, 3248, 13649, 199, 504, 31710, 14, 2219, 492, 7640, 12, 1379, 30472, 199, 199, 2087, 275, 8691, 14, 14553, 480, 9642, 359, 1419, 61, 665, 1102, 9579, 199, 21693, 3291, 275, 1511, 14, 51, 14310, 4558, 8, 2087, 9, 199, 2087, 14, 525, 63, 1422, 63, 923, 8, 21693, 3291, 9, 199, 199, 3, 675, 1414, 1004, 20023, 340, 2808, 199, 18639, 3291, 275, 1511, 14, 13428, 4558, 8, 2087, 9, 199, 2087, 14, 525, 63, 1422, 63, 923, 8, 18639, 3291, 9, 199, 3291, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 692, 822, 8, 589, 9, 665, 413, 26, 272, 1798, 14, 1361, 63, 3807, 342, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1102, 275, 1249, 59, 16, 61, 199, 10343, 275, 31710, 3291, 14, 362, 63, 912, 22176, 342, 199, 15226, 275, 22314, 3291, 14, 362, 63, 6942, 8, 10343, 9, 199, 15226, 14, 409, 63, 71, 677, 67, 63, 3179, 8, 15226, 14, 362, 63, 71, 677, 67, 63, 3179, 342, 1204, 486, 677, 67, 14, 22884, 63, 899, 748, 9, 199, 15226, 63, 6744, 275, 1331, 14, 8293, 8, 15226, 9, 199, 15226, 63, 751, 17, 275, 1331, 14, 8293, 8, 15226, 9, 199, 15226, 63, 751, 18, 275, 1331, 14, 8293, 8, 15226, 9, 199, 15226, 63, 751, 19, 275, 1331, 14, 8293, 8, 15226, 9, 199, 199, 533, 22630, 2925, 8, 21693, 14, 2219, 14, 1746, 304, 339, 2256, 63, 3833, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 8198, 2925, 12, 291, 680, 5996, 342, 267, 327, 5267, 1738, 36, 899, 83, 267, 340, 291, 14, 815, 63, 3833, 365, 488, 26, 288, 522, 275, 634, 697, 14, 1733, 8, 1095, 8772, 3965, 8772, 4194, 29, 17998, 63, 5825, 12, 3290, 6270, 10, 3135, 288, 291, 14, 2947, 8, 552, 8, 470, 395, 413, 9, 288, 22630, 2925, 14, 815, 63, 3833, 275, 522, 59, 16, 61, 267, 327, 2581, 2005, 402, 12826, 36, 899, 10792, 267, 291, 14, 3629, 63, 4272, 275, 291, 14, 815, 63, 3833, 905, 3629, 46, 9568, 2998, 9210, 16, 61, 267, 291, 14, 2261, 63, 4272, 275, 291, 14, 815, 63, 3833, 905, 885, 46, 9568, 2998, 9210, 16, 61, 267, 291, 14, 888, 63, 4272, 275, 291, 14, 815, 63, 3833, 905, 4758, 46, 9568, 2998, 9210, 16, 61, 267, 291, 14, 23805, 63, 4272, 275, 298, 12874, 29, 2497, 14543, 2481, 12, 12874, 29, 2404, 19717, 8719, 83, 2, 450, 291, 14, 2261, 63, 4272, 267, 291, 14, 2060, 275, 298, 48, 32, 385, 87, 16, 6883, 2, 267, 291, 14, 2473, 275, 298, 8198, 774, 1899, 12172, 435, 900, 14, 6205, 3647, 83, 401, 900, 14, 22227, 1012, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 8198, 2925, 12, 291, 680, 12336, 342, 339, 347, 511, 63, 23805, 63, 2048, 63, 3409, 8, 277, 304, 267, 327, 1218, 282, 24189, 282, 331, 835, 367, 314, 511, 267, 3145, 63, 3990, 8, 15793, 12, 291, 14, 23805, 63, 4272, 9, 267, 634, 697, 14, 525, 63, 76, 7330, 4852, 199, 4272, 26, 408, 435, 291, 14, 23805, 63, 4272, 435, 408, 199, 6413, 26, 445, 1309, 3100, 2481, 199, 2918, 985, 26, 445, 1309, 3100, 2481, 4, 199, 354, 26, 445, 1309, 3100, 2481, 199, 83, 1156, 6009, 985, 26, 445, 1309, 3100, 2481, 4, 199, 6063, 3034, 26, 378, 199, 785, 2543, 26, 24189, 199, 785, 2543, 26, 13237, 279, 7344, 199, 785, 2543, 26, 4954, 199, 785, 2543, 26, 2746, 199, 785, 2543, 26, 922, 199, 600, 3276, 26, 378, 199, 751, 6009, 3717, 26, 17125, 199, 68, 2709, 4965, 985, 26, 9679, 14543, 2481, 14, 279, 371, 14774, 14, 396, 199, 2262, 1958, 3989, 3353, 26, 959, 14, 18, 334, 1401, 2710, 9, 199, 2262, 1958, 3989, 26, 5417, 7146, 13004, 199, 6141, 267, 634, 697, 14, 8951, 63, 76, 7330, 4852, 199, 4272, 26, 408, 435, 291, 14, 23805, 63, 4272, 435, 408, 199, 11984, 362, 514, 26, 2811, 199, 1814, 26, 2649, 32701, 199, 2975, 32701, 447, 408, 435, 1300, 772, 14, 66, 772, 2143, 480, 4451, 48, 32, 385, 87, 16, 6883, 18781, 14, 2143, 360, 1624, 13, 975, 13, 274, 1333, 435, 408, 199, 6141, 398, 327, 886, 282, 3486, 5398, 436, 2754, 543, 314, 6844, 2933, 267, 20023, 63, 6744, 14, 409, 63, 3409, 63, 4272, 8, 277, 14, 23805, 63, 4272, 9, 267, 20023, 63, 6744, 14, 409, 63, 2060, 8, 277, 14, 2060, 9, 267, 870, 298, 8198, 774, 543, 26, 298, 435, 20023, 63, 6744, 14, 362, 63, 3409, 63, 4272, 342, 267, 634, 697, 63, 6744, 275, 31710, 14, 2219, 14, 2242, 63, 21660, 697, 8, 1102, 12, 6235, 29, 15226, 63, 6744, 12, 6059, 13204, 29, 10343, 12, 13727, 63, 2118, 29, 549, 9, 267, 522, 275, 634, 697, 63, 6744, 14, 1733, 8, 1095, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Ouranosinc/Magpie
magpie/alembic/versions/2018-06-04_a395ef9d3fe6_reference_root_service.py
1
2200
""" reference root service. Revision ID: a395ef9d3fe6 Revises: ae1a3c8c7860 Create Date: 2018-06-04 11:38:31.296950 """ import sqlalchemy as sa from alembic import op from alembic.context import get_context # noqa: F401 from sqlalchemy.dialects.postgresql.base import PGDialect from sqlalchemy.orm.session import sessionmaker # revision identifiers, used by Alembic. revision = "a395ef9d3fe6" down_revision = "ae1a3c8c7860" branch_labels = None depends_on = None Session = sessionmaker() resources = sa.table( "resources", sa.column("root_service_id", sa.Integer), sa.column("resource_id", sa.Integer), sa.column("parent_id", sa.Integer) ) def upgrade(): context = get_context() session = Session(bind=op.get_bind()) # two following lines avoids double "DELETE" erroneous call when deleting group due to incorrect checks # https://stackoverflow.com/questions/28824401 context.connection.engine.dialect.supports_sane_rowcount = False context.connection.engine.dialect.supports_sane_multi_rowcount = False if isinstance(context.connection.engine.dialect, PGDialect): op.add_column("resources", sa.Column("root_service_id", sa.Integer(), nullable=True)) # add existing resource references to their root service, loop through reference tree chain query = session.execute(sa.select([resources.c.resource_id, resources.c.parent_id])) for resource_id, parent_id in query: root_resource_id = resource_id while parent_id is not None: parent_resource = session.execute( sa.select([resources.c.resource_id, resources.c.parent_id]) .where(resources.c.resource_id == parent_id) ).fetchone() root_resource_id, parent_id = parent_resource session.execute( resources.update().where(resources.c.resource_id == resource_id). values(root_service_id=root_resource_id) ) session.commit() def downgrade(): context = get_context() if isinstance(context.connection.engine.dialect, PGDialect): op.drop_column("resources", "root_service_id")
apache-2.0
[ 624, 199, 4443, 1738, 2435, 14, 199, 199, 12714, 2870, 26, 282, 14099, 2829, 25, 68, 19, 771, 22, 199, 497, 433, 874, 26, 16951, 17, 65, 19, 67, 24, 67, 23, 14832, 199, 2499, 6148, 26, 14894, 13, 1690, 13, 966, 4119, 26, 1703, 26, 2192, 14, 1398, 1876, 1400, 199, 624, 199, 199, 646, 8335, 465, 2937, 199, 504, 30960, 20596, 492, 1687, 199, 504, 30960, 20596, 14, 1100, 492, 664, 63, 1100, 221, 327, 8151, 26, 481, 8854, 199, 504, 8335, 14, 11072, 83, 14, 15437, 14, 1095, 492, 26595, 22080, 199, 504, 8335, 14, 1025, 14, 1730, 492, 2351, 14367, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 298, 65, 14099, 2829, 25, 68, 19, 771, 22, 2, 199, 2110, 63, 5792, 275, 298, 3624, 17, 65, 19, 67, 24, 67, 23, 14832, 2, 199, 4694, 63, 3512, 275, 488, 199, 8912, 63, 265, 275, 488, 199, 199, 4434, 275, 2351, 14367, 342, 199, 199, 4435, 275, 2937, 14, 1224, 8, 272, 298, 4435, 401, 272, 2937, 14, 2301, 480, 1231, 63, 1364, 63, 344, 401, 2937, 14, 2674, 395, 272, 2937, 14, 2301, 480, 1927, 63, 344, 401, 2937, 14, 2674, 395, 272, 2937, 14, 2301, 480, 1708, 63, 344, 401, 2937, 14, 2674, 9, 199, 9, 421, 199, 318, 10754, 837, 272, 1067, 275, 664, 63, 1100, 342, 272, 2351, 275, 8596, 8, 3409, 29, 411, 14, 362, 63, 3409, 1012, 339, 327, 2877, 2569, 2385, 23674, 4270, 298, 7014, 2, 2329, 368, 1785, 1240, 1380, 13794, 1572, 7037, 370, 8927, 5920, 272, 327, 4178, 921, 23153, 14, 957, 15, 16069, 15, 10740, 1194, 8854, 272, 1067, 14, 2105, 14, 3908, 14, 11072, 14, 9823, 63, 83, 5865, 63, 24007, 275, 756, 272, 1067, 14, 2105, 14, 3908, 14, 11072, 14, 9823, 63, 83, 5865, 63, 3029, 63, 24007, 275, 756, 339, 340, 1228, 8, 1100, 14, 2105, 14, 3908, 14, 11072, 12, 26595, 22080, 304, 267, 1687, 14, 525, 63, 2301, 480, 4435, 401, 2937, 14, 4547, 480, 1231, 63, 1364, 63, 344, 401, 2937, 14, 2674, 1062, 7854, 29, 549, 430, 398, 327, 1050, 3411, 2073, 6941, 370, 3932, 1738, 2435, 12, 4438, 4012, 3659, 3123, 6036, 267, 1827, 275, 2351, 14, 2526, 8, 2231, 14, 2416, 779, 4435, 14, 67, 14, 1927, 63, 344, 12, 5944, 14, 67, 14, 1708, 63, 344, 2459, 398, 367, 2073, 63, 344, 12, 1676, 63, 344, 315, 1827, 26, 288, 1738, 63, 1927, 63, 344, 275, 2073, 63, 344, 288, 1830, 1676, 63, 344, 365, 440, 488, 26, 355, 1676, 63, 1927, 275, 2351, 14, 2526, 8, 490, 2937, 14, 2416, 779, 4435, 14, 67, 14, 1927, 63, 344, 12, 5944, 14, 67, 14, 1708, 63, 344, 566, 490, 1275, 4509, 8, 4435, 14, 67, 14, 1927, 63, 344, 508, 1676, 63, 344, 9, 355, 7092, 11591, 342, 355, 1738, 63, 1927, 63, 344, 12, 1676, 63, 344, 275, 1676, 63, 1927, 953, 2351, 14, 2526, 8, 355, 5944, 14, 873, 1252, 4509, 8, 4435, 14, 67, 14, 1927, 63, 344, 508, 2073, 63, 344, 680, 355, 1338, 8, 1231, 63, 1364, 63, 344, 29, 1231, 63, 1927, 63, 344, 9, 288, 776, 398, 2351, 14, 3543, 342, 421, 199, 318, 32498, 837, 272, 1067, 275, 664, 63, 1100, 342, 272, 340, 1228, 8, 1100, 14, 2105, 14, 3908, 14, 11072, 12, 26595, 22080, 304, 267, 1687, 14, 4824, 63, 2301, 480, 4435, 401, 298, 1231, 63, 1364, 63, 344, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 4443, 1738, 2435, 14, 199, 199, 12714, 2870, 26, 282, 14099, 2829, 25, 68, 19, 771, 22, 199, 497, 433, 874, 26, 16951, 17, 65, 19, 67, 24, 67, 23, 14832, 199, 2499, 6148, 26, 14894, 13, 1690, 13, 966, 4119, 26, 1703, 26, 2192, 14, 1398, 1876, 1400, 199, 624, 199, 199, 646, 8335, 465, 2937, 199, 504, 30960, 20596, 492, 1687, 199, 504, 30960, 20596, 14, 1100, 492, 664, 63, 1100, 221, 327, 8151, 26, 481, 8854, 199, 504, 8335, 14, 11072, 83, 14, 15437, 14, 1095, 492, 26595, 22080, 199, 504, 8335, 14, 1025, 14, 1730, 492, 2351, 14367, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 298, 65, 14099, 2829, 25, 68, 19, 771, 22, 2, 199, 2110, 63, 5792, 275, 298, 3624, 17, 65, 19, 67, 24, 67, 23, 14832, 2, 199, 4694, 63, 3512, 275, 488, 199, 8912, 63, 265, 275, 488, 199, 199, 4434, 275, 2351, 14367, 342, 199, 199, 4435, 275, 2937, 14, 1224, 8, 272, 298, 4435, 401, 272, 2937, 14, 2301, 480, 1231, 63, 1364, 63, 344, 401, 2937, 14, 2674, 395, 272, 2937, 14, 2301, 480, 1927, 63, 344, 401, 2937, 14, 2674, 395, 272, 2937, 14, 2301, 480, 1708, 63, 344, 401, 2937, 14, 2674, 9, 199, 9, 421, 199, 318, 10754, 837, 272, 1067, 275, 664, 63, 1100, 342, 272, 2351, 275, 8596, 8, 3409, 29, 411, 14, 362, 63, 3409, 1012, 339, 327, 2877, 2569, 2385, 23674, 4270, 298, 7014, 2, 2329, 368, 1785, 1240, 1380, 13794, 1572, 7037, 370, 8927, 5920, 272, 327, 4178, 921, 23153, 14, 957, 15, 16069, 15, 10740, 1194, 8854, 272, 1067, 14, 2105, 14, 3908, 14, 11072, 14, 9823, 63, 83, 5865, 63, 24007, 275, 756, 272, 1067, 14, 2105, 14, 3908, 14, 11072, 14, 9823, 63, 83, 5865, 63, 3029, 63, 24007, 275, 756, 339, 340, 1228, 8, 1100, 14, 2105, 14, 3908, 14, 11072, 12, 26595, 22080, 304, 267, 1687, 14, 525, 63, 2301, 480, 4435, 401, 2937, 14, 4547, 480, 1231, 63, 1364, 63, 344, 401, 2937, 14, 2674, 1062, 7854, 29, 549, 430, 398, 327, 1050, 3411, 2073, 6941, 370, 3932, 1738, 2435, 12, 4438, 4012, 3659, 3123, 6036, 267, 1827, 275, 2351, 14, 2526, 8, 2231, 14, 2416, 779, 4435, 14, 67, 14, 1927, 63, 344, 12, 5944, 14, 67, 14, 1708, 63, 344, 2459, 398, 367, 2073, 63, 344, 12, 1676, 63, 344, 315, 1827, 26, 288, 1738, 63, 1927, 63, 344, 275, 2073, 63, 344, 288, 1830, 1676, 63, 344, 365, 440, 488, 26, 355, 1676, 63, 1927, 275, 2351, 14, 2526, 8, 490, 2937, 14, 2416, 779, 4435, 14, 67, 14, 1927, 63, 344, 12, 5944, 14, 67, 14, 1708, 63, 344, 566, 490, 1275, 4509, 8, 4435, 14, 67, 14, 1927, 63, 344, 508, 1676, 63, 344, 9, 355, 7092, 11591, 342, 355, 1738, 63, 1927, 63, 344, 12, 1676, 63, 344, 275, 1676, 63, 1927, 953, 2351, 14, 2526, 8, 355, 5944, 14, 873, 1252, 4509, 8, 4435, 14, 67, 14, 1927, 63, 344, 508, 2073, 63, 344, 680, 355, 1338, 8, 1231, 63, 1364, 63, 344, 29, 1231, 63, 1927, 63, 344, 9, 288, 776, 398, 2351, 14, 3543, 342, 421, 199, 318, 32498, 837, 272, 1067, 275, 664, 63, 1100, 342, 272, 340, 1228, 8, 1100, 14, 2105, 14, 3908, 14, 11072, 12, 26595, 22080, 304, 267, 1687, 14, 4824, 63, 2301, 480, 4435, 401, 298, 1231, 63, 1364, 63, 344, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
geniusgogo/rt-thread
bsp/nrf5x/nrf51822/rtconfig.py
5
2499
import os # toolchains options ARCH='arm' CPU='cortex-m0' CROSS_TOOL='keil' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') # cross_tool provides the cross compiler # EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR if CROSS_TOOL == 'gcc': PLATFORM = 'gcc' EXEC_PATH = 'D:/SourceryGCC/bin' elif CROSS_TOOL == 'keil': PLATFORM = 'armcc' EXEC_PATH = 'C:/Keil_v5' elif CROSS_TOOL == 'iar': print('================ERROR============================') print('Not support iar yet!') print('=================================================') exit(0) if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') BUILD = 'debug' if PLATFORM == 'gcc': # toolchains PREFIX = 'arm-none-eabi-' CC = PREFIX + 'gcc' AS = PREFIX + 'gcc' AR = PREFIX + 'ar' LINK = PREFIX + 'gcc' TARGET_EXT = 'elf' SIZE = PREFIX + 'size' OBJDUMP = PREFIX + 'objdump' OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu='+CPU + ' -mthumb -ffunction-sections -fdata-sections' CFLAGS = DEVICE AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' CPATH = '' LPATH = '' if BUILD == 'debug': CFLAGS += ' -O0 -gdwarf-2' AFLAGS += ' -gdwarf-2' else: CFLAGS += ' -O2' POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' elif PLATFORM == 'armcc': # toolchains CC = 'armcc' AS = 'armasm' AR = 'armar' LINK = 'armlink' TARGET_EXT = 'axf' DEVICE = ' --device DARMSTM' CFLAGS = DEVICE + ' --apcs=interwork' AFLAGS = DEVICE LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread.map --scatter "board\linker_scripts\link.sct"' CFLAGS += ' --c99' CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC' LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB' EXEC_PATH += '/arm/bin40/' if BUILD == 'debug': CFLAGS += ' -g -O0' AFLAGS += ' -g' else: CFLAGS += ' -O2' POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' def dist_handle(BSP_ROOT, dist_dir): import sys cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools')) from sdk_dist import dist_do_building dist_do_building(BSP_ROOT, dist_dir)
apache-2.0
[ 646, 747, 199, 199, 3, 4744, 17419, 1511, 199, 7762, 534, 5362, 7, 199, 11011, 534, 989, 3858, 13, 77, 16, 7, 199, 28368, 63, 9731, 534, 415, 382, 7, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 2571, 735, 272, 445, 23264, 63, 9731, 275, 747, 14, 12959, 360, 50, 1481, 63, 2571, 358, 199, 199, 3, 8059, 63, 3557, 6571, 314, 8059, 6365, 199, 3, 3651, 4220, 63, 3243, 365, 314, 6365, 5341, 931, 12, 367, 2893, 12, 5495, 51, 567, 67, 994, 12, 25645, 382, 603, 10892, 12, 473, 689, 199, 199, 692, 221, 445, 23264, 63, 9731, 508, 283, 13112, 356, 272, 21966, 259, 275, 283, 13112, 7, 272, 3651, 4220, 63, 3243, 257, 275, 283, 36, 11254, 51, 567, 67, 994, 10566, 15, 1393, 7, 199, 4164, 445, 23264, 63, 9731, 508, 283, 415, 382, 356, 272, 21966, 259, 275, 283, 5362, 2055, 7, 272, 3651, 4220, 63, 3243, 257, 275, 283, 35, 11254, 1136, 382, 63, 86, 21, 7, 199, 4164, 445, 23264, 63, 9731, 508, 283, 73, 285, 356, 272, 870, 360, 1280, 3170, 1280, 5769, 358, 272, 870, 360, 1763, 2291, 284, 285, 5966, 10916, 272, 870, 360, 12813, 14619, 272, 4458, 8, 16, 9, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 735, 272, 3651, 4220, 63, 3243, 275, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 358, 199, 199, 8248, 275, 283, 1757, 7, 199, 199, 692, 21966, 508, 283, 13112, 356, 272, 327, 4744, 17419, 272, 27884, 275, 283, 5362, 13, 3592, 13, 69, 14677, 15668, 272, 17586, 275, 27884, 435, 283, 13112, 7, 272, 4319, 275, 27884, 435, 283, 13112, 7, 272, 4160, 275, 27884, 435, 283, 285, 7, 272, 19774, 275, 27884, 435, 283, 13112, 7, 272, 26134, 63, 2472, 275, 283, 25371, 7, 272, 32289, 275, 27884, 435, 283, 890, 7, 272, 593, 16262, 26406, 275, 27884, 435, 283, 1113, 2724, 7, 272, 593, 16262, 2890, 57, 275, 27884, 435, 283, 1113, 1574, 7, 339, 11643, 275, 283, 446, 77, 3541, 22078, 11011, 435, 283, 446, 77, 16534, 446, 556, 648, 13, 7786, 446, 70, 576, 13, 7786, 7, 272, 25149, 275, 11643, 272, 437, 4831, 275, 283, 446, 67, 7, 435, 11643, 435, 283, 446, 88, 22931, 82, 13, 1045, 13, 5910, 7, 272, 491, 4831, 275, 11643, 435, 283, 446, 16239, 28925, 9493, 13, 7786, 3057, 2956, 29, 2591, 2671, 14, 1130, 3057, 67, 1121, 3057, 85, 12, 9637, 63, 2461, 446, 52, 13811, 15, 20311, 63, 6429, 15, 1073, 14, 76, 795, 7, 339, 445, 3243, 275, 2125, 272, 491, 3243, 275, 2125, 339, 340, 22974, 508, 283, 1757, 356, 267, 25149, 847, 283, 446, 47, 16, 446, 7136, 3281, 70, 13, 18, 7, 267, 437, 4831, 847, 283, 446, 7136, 3281, 70, 13, 18, 7, 272, 587, 26, 267, 25149, 847, 283, 446, 47, 18, 7, 339, 8761, 63, 10052, 275, 593, 16262, 2890, 57, 435, 283, 446, 47, 3366, 2672, 9268, 14059, 2671, 14, 1393, 60, 78, 7, 435, 32289, 435, 283, 2672, 9268, 971, 78, 7, 199, 199, 4164, 21966, 508, 283, 5362, 2055, 356, 272, 327, 4744, 17419, 272, 17586, 275, 283, 5362, 2055, 7, 272, 4319, 275, 283, 5362, 11374, 7, 272, 4160, 275, 283, 285, 4584, 7, 272, 19774, 275, 283, 5362, 1073, 7, 272, 26134, 63, 2472, 275, 283, 1219, 70, 7, 339, 11643, 275, 283, 1553, 1782, 577, 12482, 16644, 7, 272, 25149, 275, 11643, 435, 283, 1553, 439, 1259, 29, 1058, 800, 7, 272, 437, 4831, 275, 11643, 272, 491, 4831, 275, 11643, 435, 283, 1553, 815, 10627, 1553, 815, 23576, 1553, 815, 9563, 1553, 815, 373, 6349, 1192, 1553, 513, 14059, 2671, 14, 1130, 1553, 13512, 298, 3576, 60, 20311, 63, 6429, 60, 1073, 14, 83, 319, 4507, 339, 25149, 847, 283, 1553, 67, 1020, 7, 272, 25149, 847, 283, 446, 41, 7, 435, 3651, 4220, 63, 3243, 435, 1994, 12482, 15, 28841, 2192, 15, 25205, 7, 272, 491, 4831, 847, 283, 1553, 773, 515, 283, 435, 3651, 4220, 63, 3243, 435, 1994, 12482, 15, 28841, 2192, 15, 5617, 7, 339, 3651, 4220, 63, 3243, 847, 1994, 5362, 15, 1393, 2167, 4805, 339, 340, 22974, 508, 283, 1757, 356, 267, 25149, 847, 283, 446, 71, 446, 47, 16, 7, 267, 437, 4831, 847, 283, 446, 71, 7, 272, 587, 26, 267, 25149, 847, 283, 446, 47, 18, 7, 339, 8761, 63, 10052, 275, 283, 70, 5864, 276, 1553, 1393, 2672, 9268, 1553, 1199, 14059, 2671, 14, 1393, 971, 9914, 5864, 276, 446, 90, 2672, 9268, 7, 421, 199, 318, 2917, 63, 2479, 8, 34, 5763, 63, 5441, 12, 2917, 63, 694, 304, 272, 492, 984, 272, 8288, 63, 515, 275, 747, 14, 9458, 342, 272, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 34, 5763, 63, 5441, 395, 283, 2537, 1333, 272, 687, 13628, 63, 2686, 492, 2917, 63, 1117, 63, 17952, 272, 2917, 63, 1117, 63, 17952, 8, 34, 5763, 63, 5441, 12, 2917, 63, 694, 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 ]
[ 747, 199, 199, 3, 4744, 17419, 1511, 199, 7762, 534, 5362, 7, 199, 11011, 534, 989, 3858, 13, 77, 16, 7, 199, 28368, 63, 9731, 534, 415, 382, 7, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 2571, 735, 272, 445, 23264, 63, 9731, 275, 747, 14, 12959, 360, 50, 1481, 63, 2571, 358, 199, 199, 3, 8059, 63, 3557, 6571, 314, 8059, 6365, 199, 3, 3651, 4220, 63, 3243, 365, 314, 6365, 5341, 931, 12, 367, 2893, 12, 5495, 51, 567, 67, 994, 12, 25645, 382, 603, 10892, 12, 473, 689, 199, 199, 692, 221, 445, 23264, 63, 9731, 508, 283, 13112, 356, 272, 21966, 259, 275, 283, 13112, 7, 272, 3651, 4220, 63, 3243, 257, 275, 283, 36, 11254, 51, 567, 67, 994, 10566, 15, 1393, 7, 199, 4164, 445, 23264, 63, 9731, 508, 283, 415, 382, 356, 272, 21966, 259, 275, 283, 5362, 2055, 7, 272, 3651, 4220, 63, 3243, 257, 275, 283, 35, 11254, 1136, 382, 63, 86, 21, 7, 199, 4164, 445, 23264, 63, 9731, 508, 283, 73, 285, 356, 272, 870, 360, 1280, 3170, 1280, 5769, 358, 272, 870, 360, 1763, 2291, 284, 285, 5966, 10916, 272, 870, 360, 12813, 14619, 272, 4458, 8, 16, 9, 199, 199, 692, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 735, 272, 3651, 4220, 63, 3243, 275, 747, 14, 12959, 360, 50, 1481, 63, 10276, 63, 3243, 358, 199, 199, 8248, 275, 283, 1757, 7, 199, 199, 692, 21966, 508, 283, 13112, 356, 272, 327, 4744, 17419, 272, 27884, 275, 283, 5362, 13, 3592, 13, 69, 14677, 15668, 272, 17586, 275, 27884, 435, 283, 13112, 7, 272, 4319, 275, 27884, 435, 283, 13112, 7, 272, 4160, 275, 27884, 435, 283, 285, 7, 272, 19774, 275, 27884, 435, 283, 13112, 7, 272, 26134, 63, 2472, 275, 283, 25371, 7, 272, 32289, 275, 27884, 435, 283, 890, 7, 272, 593, 16262, 26406, 275, 27884, 435, 283, 1113, 2724, 7, 272, 593, 16262, 2890, 57, 275, 27884, 435, 283, 1113, 1574, 7, 339, 11643, 275, 283, 446, 77, 3541, 22078, 11011, 435, 283, 446, 77, 16534, 446, 556, 648, 13, 7786, 446, 70, 576, 13, 7786, 7, 272, 25149, 275, 11643, 272, 437, 4831, 275, 283, 446, 67, 7, 435, 11643, 435, 283, 446, 88, 22931, 82, 13, 1045, 13, 5910, 7, 272, 491, 4831, 275, 11643, 435, 283, 446, 16239, 28925, 9493, 13, 7786, 3057, 2956, 29, 2591, 2671, 14, 1130, 3057, 67, 1121, 3057, 85, 12, 9637, 63, 2461, 446, 52, 13811, 15, 20311, 63, 6429, 15, 1073, 14, 76, 795, 7, 339, 445, 3243, 275, 2125, 272, 491, 3243, 275, 2125, 339, 340, 22974, 508, 283, 1757, 356, 267, 25149, 847, 283, 446, 47, 16, 446, 7136, 3281, 70, 13, 18, 7, 267, 437, 4831, 847, 283, 446, 7136, 3281, 70, 13, 18, 7, 272, 587, 26, 267, 25149, 847, 283, 446, 47, 18, 7, 339, 8761, 63, 10052, 275, 593, 16262, 2890, 57, 435, 283, 446, 47, 3366, 2672, 9268, 14059, 2671, 14, 1393, 60, 78, 7, 435, 32289, 435, 283, 2672, 9268, 971, 78, 7, 199, 199, 4164, 21966, 508, 283, 5362, 2055, 356, 272, 327, 4744, 17419, 272, 17586, 275, 283, 5362, 2055, 7, 272, 4319, 275, 283, 5362, 11374, 7, 272, 4160, 275, 283, 285, 4584, 7, 272, 19774, 275, 283, 5362, 1073, 7, 272, 26134, 63, 2472, 275, 283, 1219, 70, 7, 339, 11643, 275, 283, 1553, 1782, 577, 12482, 16644, 7, 272, 25149, 275, 11643, 435, 283, 1553, 439, 1259, 29, 1058, 800, 7, 272, 437, 4831, 275, 11643, 272, 491, 4831, 275, 11643, 435, 283, 1553, 815, 10627, 1553, 815, 23576, 1553, 815, 9563, 1553, 815, 373, 6349, 1192, 1553, 513, 14059, 2671, 14, 1130, 1553, 13512, 298, 3576, 60, 20311, 63, 6429, 60, 1073, 14, 83, 319, 4507, 339, 25149, 847, 283, 1553, 67, 1020, 7, 272, 25149, 847, 283, 446, 41, 7, 435, 3651, 4220, 63, 3243, 435, 1994, 12482, 15, 28841, 2192, 15, 25205, 7, 272, 491, 4831, 847, 283, 1553, 773, 515, 283, 435, 3651, 4220, 63, 3243, 435, 1994, 12482, 15, 28841, 2192, 15, 5617, 7, 339, 3651, 4220, 63, 3243, 847, 1994, 5362, 15, 1393, 2167, 4805, 339, 340, 22974, 508, 283, 1757, 356, 267, 25149, 847, 283, 446, 71, 446, 47, 16, 7, 267, 437, 4831, 847, 283, 446, 71, 7, 272, 587, 26, 267, 25149, 847, 283, 446, 47, 18, 7, 339, 8761, 63, 10052, 275, 283, 70, 5864, 276, 1553, 1393, 2672, 9268, 1553, 1199, 14059, 2671, 14, 1393, 971, 9914, 5864, 276, 446, 90, 2672, 9268, 7, 421, 199, 318, 2917, 63, 2479, 8, 34, 5763, 63, 5441, 12, 2917, 63, 694, 304, 272, 492, 984, 272, 8288, 63, 515, 275, 747, 14, 9458, 342, 272, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 34, 5763, 63, 5441, 395, 283, 2537, 1333, 272, 687, 13628, 63, 2686, 492, 2917, 63, 1117, 63, 17952, 272, 2917, 63, 1117, 63, 17952, 8, 34, 5763, 63, 5441, 12, 2917, 63, 694, 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, 0 ]
[ 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
arokem/PyEMMA
pyemma/_ext/sklearn/base.py
2
17484
""" -------------------------------------------------------------------------------------------- Extracted from skikit-learn to ensure basic compatibility without creating an explicit dependency. For the original code see http://scikit-learn.org/ and https://github.com/scikit-learn -------------------------------------------------------------------------------------------- Base classes for all estimators. """ # Author: Gael Varoquaux <gael.varoquaux@normalesup.org> # License: BSD 3 clause import copy import inspect import warnings import numpy as np from scipy import sparse from pyemma._ext import six ############################################################################### def clone(estimator, safe=True): """Constructs a new estimator with the same parameters. Clone does a deep copy of the model in an estimator without actually copying attached data. It yields a new estimator with the same parameters that has not been fit on any data. Parameters ---------- estimator: estimator object, or list, tuple or set of objects The estimator or group of estimators to be cloned safe: boolean, optional If safe is false, clone will fall back to a deepcopy on objects that are not estimators. """ estimator_type = type(estimator) # XXX: not handling dictionaries if estimator_type in (list, tuple, set, frozenset): return estimator_type([clone(e, safe=safe) for e in estimator]) elif not hasattr(estimator, 'get_params'): if not safe: return copy.deepcopy(estimator) else: raise TypeError("Cannot clone object '%s' (type %s): " "it does not seem to be a scikit-learn estimator " "as it does not implement a 'get_params' methods." % (repr(estimator), type(estimator))) klass = estimator.__class__ new_object_params = estimator.get_params(deep=False) for name, param in six.iteritems(new_object_params): new_object_params[name] = clone(param, safe=False) new_object = klass(**new_object_params) params_set = new_object.get_params(deep=False) # quick sanity check of the parameters of the clone for name in new_object_params: param1 = new_object_params[name] param2 = params_set[name] if isinstance(param1, np.ndarray): # For most ndarrays, we do not test for complete equality if not isinstance(param2, type(param1)): equality_test = False elif (param1.ndim > 0 and param1.shape[0] > 0 and isinstance(param2, np.ndarray) and param2.ndim > 0 and param2.shape[0] > 0): equality_test = ( param1.shape == param2.shape and param1.dtype == param2.dtype # We have to use '.flat' for 2D arrays and param1.flat[0] == param2.flat[0] and param1.flat[-1] == param2.flat[-1] ) else: equality_test = np.all(param1 == param2) elif sparse.issparse(param1): # For sparse matrices equality doesn't work if not sparse.issparse(param2): equality_test = False elif param1.size == 0 or param2.size == 0: equality_test = ( param1.__class__ == param2.__class__ and param1.size == 0 and param2.size == 0 ) else: equality_test = ( param1.__class__ == param2.__class__ and param1.data[0] == param2.data[0] and param1.data[-1] == param2.data[-1] and param1.nnz == param2.nnz and param1.shape == param2.shape ) else: new_obj_val = new_object_params[name] params_set_val = params_set[name] # The following construct is required to check equality on special # singletons such as np.nan that are not equal to them-selves: equality_test = (new_obj_val == params_set_val or new_obj_val is params_set_val) if not equality_test: raise RuntimeError('Cannot clone object %s, as the constructor ' 'does not seem to set parameter %s' % (estimator, name)) return new_object ############################################################################### def _pprint(params, offset=0, printer=repr): """Pretty print the dictionary 'params' Parameters ---------- params: dict The dictionary to pretty print offset: int The offset in characters to add at the begin of each line. printer: The function to convert entries to strings, typically the builtin str or repr """ # Do a multi-line justified repr: options = np.get_printoptions() np.set_printoptions(precision=5, threshold=64, edgeitems=2) params_list = list() this_line_length = offset line_sep = ',\n' + (1 + offset // 2) * ' ' for i, (k, v) in enumerate(sorted(six.iteritems(params))): if type(v) is float: # use str for representing floating point numbers # this way we get consistent representation across # architectures and versions. this_repr = '%s=%s' % (k, str(v)) else: # use repr of the rest this_repr = '%s=%s' % (k, printer(v)) if len(this_repr) > 500: this_repr = this_repr[:300] + '...' + this_repr[-100:] if i > 0: if (this_line_length + len(this_repr) >= 75 or '\n' in this_repr): params_list.append(line_sep) this_line_length = len(line_sep) else: params_list.append(', ') this_line_length += 2 params_list.append(this_repr) this_line_length += len(this_repr) np.set_printoptions(**options) lines = ''.join(params_list) # Strip trailing space to avoid nightmare in doctests lines = '\n'.join(l.rstrip(' ') for l in lines.split('\n')) return lines ############################################################################### # NOTE: I have renamed this from BaseEstimator to Parametric in order to also use it for Models class BaseEstimator(object): """Base class for all estimators in scikit-learn Notes ----- All estimators should specify all the parameters that can be set at the class level in their ``__init__`` as explicit keyword arguments (no ``*args`` or ``**kwargs``). """ @classmethod def _get_param_names(cls): """Get parameter names for the estimator""" # fetch the constructor or the original constructor before # deprecation wrapping if any init = getattr(cls.__init__, 'deprecated_original', cls.__init__) if init is object.__init__: # No explicit constructor to introspect return [] # introspect the constructor arguments to find the model parameters # to represent args, varargs, kw, default = inspect.getargspec(init) if varargs is not None: raise RuntimeError("scikit-learn estimators should always " "specify their parameters in the signature" " of their __init__ (no varargs)." " %s doesn't follow this convention." % (cls, )) # Remove 'self' # XXX: This is going to fail if the init is a staticmethod, but # who would do this? args.pop(0) args.sort() return args def get_params(self, deep=True): """Get parameters for this estimator. Parameters ---------- deep: boolean, optional If True, will return the parameters for this estimator and contained subobjects that are estimators. Returns ------- params : mapping of string to any Parameter names mapped to their values. """ out = dict() for key in self._get_param_names(): # We need deprecation warnings to always be on in order to # catch deprecated param values. # This is set in utils/__init__.py but it gets overwritten # when running under python3 somehow. warnings.simplefilter("always", DeprecationWarning) try: with warnings.catch_warnings(record=True) as w: value = getattr(self, key, None) if len(w) and w[0].category == DeprecationWarning: # if the parameter is deprecated, don't show it continue finally: warnings.filters.pop(0) # XXX: should we rather test if instance of estimator? if deep and hasattr(value, 'get_params'): deep_items = value.get_params().items() out.update((key + '__' + k, val) for k, val in deep_items) out[key] = value return out def set_params(self, **params): """Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of a nested object. Returns ------- self """ if not params: # Simple optimisation to gain speed (inspect is slow) return self valid_params = self.get_params(deep=True) for key, value in six.iteritems(params): split = key.split('__', 1) if len(split) > 1: # nested objects case name, sub_name = split if name not in valid_params: raise ValueError('Invalid parameter %s for estimator %s' % (name, self)) sub_object = valid_params[name] sub_object.set_params(**{sub_name: value}) else: # simple objects case if key not in valid_params: raise ValueError('Invalid parameter %s ' 'for estimator %s' % (key, self.__class__.__name__)) setattr(self, key, value) return self def __repr__(self): class_name = self.__class__.__name__ return '%s(%s)' % (class_name, _pprint(self.get_params(deep=False), offset=len(class_name),),) # Currently unused # ############################################################################### # class ClassifierMixin(object): # """Mixin class for all classifiers in scikit-learn.""" # _estimator_type = "classifier" # # def score(self, X, y, sample_weight=None): # """Returns the mean accuracy on the given test data and labels. # In multi-label classification, this is the subset accuracy # which is a harsh metric since you require for each sample that # each label set be correctly predicted. # Parameters # ---------- # X : array-like, shape = (n_samples, n_features) # Test samples. # y : array-like, shape = (n_samples) or (n_samples, n_outputs) # True labels for X. # sample_weight : array-like, shape = [n_samples], optional # Sample weights. # Returns # ------- # score : float # Mean accuracy of self.predict(X) wrt. y. # """ # from .metrics import accuracy_score # return accuracy_score(y, self.predict(X), sample_weight=sample_weight) # Currently unused # ############################################################################### # class RegressorMixin(object): # """Mixin class for all regression estimators in scikit-learn.""" # _estimator_type = "regressor" # # def score(self, X, y, sample_weight=None): # """Returns the coefficient of determination R^2 of the prediction. # The coefficient R^2 is defined as (1 - u/v), where u is the regression # sum of squares ((y_true - y_pred) ** 2).sum() and v is the residual # sum of squares ((y_true - y_true.mean()) ** 2).sum(). # Best possible score is 1.0, lower values are worse. # Parameters # ---------- # X : array-like, shape = (n_samples, n_features) # Test samples. # y : array-like, shape = (n_samples) or (n_samples, n_outputs) # True values for X. # sample_weight : array-like, shape = [n_samples], optional # Sample weights. # Returns # ------- # score : float # R^2 of self.predict(X) wrt. y. # """ # # from .metrics import r2_score # return r2_score(y, self.predict(X), sample_weight=sample_weight) ############################################################################### class ClusterMixin(object): """Mixin class for all cluster estimators in scikit-learn.""" _estimator_type = "clusterer" def fit_predict(self, X, y=None): """Performs clustering on X and returns cluster labels. Parameters ---------- X : ndarray, shape (n_samples, n_features) Input data. Returns ------- y : ndarray, shape (n_samples,) cluster labels """ # non-optimized default implementation; override when a better # method is possible for a given clustering algorithm self.fit(X) return self.labels_ # class BiclusterMixin(object): # """Mixin class for all bicluster estimators in scikit-learn""" # # @property # def biclusters_(self): # """Convenient way to get row and column indicators together. # Returns the ``rows_`` and ``columns_`` members. # """ # return self.rows_, self.columns_ # # def get_indices(self, i): # """Row and column indices of the i'th bicluster. # Only works if ``rows_`` and ``columns_`` attributes exist. # Returns # ------- # row_ind : np.array, dtype=np.intp # Indices of rows in the dataset that belong to the bicluster. # col_ind : np.array, dtype=np.intp # Indices of columns in the dataset that belong to the bicluster. # """ # rows = self.rows_[i] # columns = self.columns_[i] # return np.nonzero(rows)[0], np.nonzero(columns)[0] # # def get_shape(self, i): # """Shape of the i'th bicluster. # Returns # ------- # shape : (int, int) # Number of rows and columns (resp.) in the bicluster. # """ # indices = self.get_indices(i) # return tuple(len(i) for i in indices) # # def get_submatrix(self, i, data): # """Returns the submatrix corresponding to bicluster `i`. # Works with sparse matrices. Only works if ``rows_`` and # ``columns_`` attributes exist. # """ # from .utils.validation import check_array # data = check_array(data, accept_sparse='csr') # row_ind, col_ind = self.get_indices(i) # return data[row_ind[:, np.newaxis], col_ind] ############################################################################### class TransformerMixin(object): """Mixin class for all transformers in scikit-learn.""" def fit_transform(self, X, y=None, **fit_params): """Fit to data, then transform it. Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X. Parameters ---------- X : numpy array of shape [n_samples, n_features] Training set. y : numpy array of shape [n_samples] Target values. Returns ------- X_new : numpy array of shape [n_samples, n_features_new] Transformed array. """ # non-optimized default implementation; override when a better # method is possible for a given clustering algorithm if y is None: # fit method of arity 1 (unsupervised transformation) return self.fit(X, **fit_params).transform(X) else: # fit method of arity 2 (supervised transformation) return self.fit(X, y, **fit_params).transform(X) ############################################################################### class MetaEstimatorMixin(object): """Mixin class for all meta estimators in scikit-learn.""" # this is just a tag for the moment ############################################################################### def is_classifier(estimator): """Returns True if the given estimator is (probably) a classifier.""" return getattr(estimator, "_estimator_type", None) == "classifier" def is_regressor(estimator): """Returns True if the given estimator is (probably) a regressor.""" return getattr(estimator, "_estimator_type", None) == "regressor"
bsd-2-clause
[ 624, 199, 3606, 777, 4559, 199, 7426, 1522, 687, 2386, 3258, 390, 13, 4643, 370, 4868, 5678, 7163, 199, 7395, 6425, 376, 5027, 5936, 14, 199, 199, 1858, 314, 3379, 1233, 1937, 272, 1455, 921, 551, 3258, 390, 13, 4643, 14, 1308, 15, 199, 460, 272, 4178, 921, 5031, 14, 957, 15, 551, 3258, 390, 13, 4643, 199, 3606, 777, 4559, 199, 199, 1563, 3992, 367, 1006, 23155, 14, 199, 624, 199, 3, 6529, 26, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 14, 1391, 79, 392, 10962, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 1331, 199, 646, 6485, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5178, 199, 504, 1134, 5633, 391, 423, 832, 492, 3816, 421, 199, 11490, 199, 318, 7289, 8, 8627, 12, 5048, 29, 549, 304, 272, 408, 27943, 282, 892, 8943, 543, 314, 2011, 2633, 14, 272, 8465, 368, 1630, 282, 13217, 1331, 402, 314, 1402, 315, 376, 8943, 272, 1928, 5965, 16743, 10102, 666, 14, 2779, 14801, 282, 892, 8943, 272, 543, 314, 2011, 2633, 626, 965, 440, 2757, 5542, 641, 1263, 666, 14, 272, 3897, 272, 4143, 272, 8943, 26, 8943, 909, 12, 503, 769, 12, 2008, 503, 663, 402, 2251, 267, 710, 8943, 503, 1572, 402, 23155, 370, 506, 26210, 272, 5048, 26, 5046, 12, 2716, 267, 982, 5048, 365, 3055, 12, 7289, 911, 11264, 1771, 370, 282, 14800, 641, 2251, 267, 626, 787, 440, 23155, 14, 272, 408, 272, 8943, 63, 466, 275, 730, 8, 8627, 9, 272, 327, 5787, 26, 440, 7252, 11196, 272, 340, 8943, 63, 466, 315, 334, 513, 12, 2008, 12, 663, 12, 9522, 304, 267, 372, 8943, 63, 466, 779, 6311, 8, 69, 12, 5048, 29, 3489, 9, 367, 325, 315, 8943, 566, 272, 916, 440, 2688, 8, 8627, 12, 283, 362, 63, 1162, 735, 267, 340, 440, 5048, 26, 288, 372, 1331, 14, 8293, 8, 8627, 9, 267, 587, 26, 288, 746, 3146, 480, 6612, 7289, 909, 1543, 83, 7, 334, 466, 450, 83, 304, 298, 1169, 298, 390, 1630, 440, 17021, 370, 506, 282, 6276, 6065, 13, 4643, 8943, 298, 1169, 298, 305, 652, 1630, 440, 5669, 282, 283, 362, 63, 1162, 7, 3102, 2122, 1169, 450, 334, 2722, 8, 8627, 395, 730, 8, 8627, 1724, 272, 8531, 275, 8943, 855, 533, 363, 272, 892, 63, 785, 63, 1162, 275, 8943, 14, 362, 63, 1162, 8, 16131, 29, 797, 9, 272, 367, 536, 12, 1215, 315, 3816, 14, 4611, 8, 1222, 63, 785, 63, 1162, 304, 267, 892, 63, 785, 63, 1162, 59, 354, 61, 275, 7289, 8, 635, 12, 5048, 29, 797, 9, 272, 892, 63, 785, 275, 8531, 3682, 1222, 63, 785, 63, 1162, 9, 272, 1862, 63, 409, 275, 892, 63, 785, 14, 362, 63, 1162, 8, 16131, 29, 797, 9, 339, 327, 12530, 16740, 1104, 402, 314, 2633, 402, 314, 7289, 272, 367, 536, 315, 892, 63, 785, 63, 1162, 26, 267, 1215, 17, 275, 892, 63, 785, 63, 1162, 59, 354, 61, 267, 1215, 18, 275, 1862, 63, 409, 59, 354, 61, 267, 340, 1228, 8, 635, 17, 12, 980, 14, 8237, 304, 288, 327, 2104, 4750, 302, 4460, 4814, 12, 781, 886, 440, 511, 367, 4890, 16612, 288, 340, 440, 1228, 8, 635, 18, 12, 730, 8, 635, 17, 2298, 355, 16612, 63, 396, 275, 756, 288, 916, 334, 635, 17, 14, 8322, 690, 378, 490, 436, 1215, 17, 14, 1392, 59, 16, 61, 690, 378, 490, 436, 1228, 8, 635, 18, 12, 980, 14, 8237, 9, 490, 436, 1215, 18, 14, 8322, 690, 378, 490, 436, 1215, 18, 14, 1392, 59, 16, 61, 690, 378, 304, 355, 16612, 63, 396, 275, 334, 490, 1215, 17, 14, 1392, 508, 1215, 18, 14, 1392, 490, 436, 1215, 17, 14, 2271, 508, 1215, 18, 14, 2271, 490, 327, 2136, 1172, 370, 675, 1987, 7088, 7, 367, 499, 36, 6572, 490, 436, 1215, 17, 14, 7088, 59, 16, 61, 508, 1215, 18, 14, 7088, 59, 16, 61, 490, 436, 1215, 17, 14, 7088, 1988, 17, 61, 508, 1215, 18, 14, 7088, 1988, 17, 61, 355, 776, 288, 587, 26, 355, 16612, 63, 396, 275, 980, 14, 452, 8, 635, 17, 508, 1215, 18, 9, 267, 916, 5178, 14, 30962, 8, 635, 17, 304, 288, 327, 2104, 5178, 12627, 16612, 3181, 1133, 1736, 288, 340, 440, 5178, 14, 30962, 8, 635, 18, 304, 355, 16612, 63, 396, 275, 756, 288, 916, 1215, 17, 14, 890, 508, 378, 503, 1215, 18, 14, 890, 508, 378, 26, 355, 16612, 63, 396, 275, 334, 490, 1215, 17, 855, 533, 363, 508, 1215, 18, 855, 533, 363, 490, 436, 1215, 17, 14, 890, 508, 378, 490, 436, 1215, 18, 14, 890, 508, 378, 355, 776, 288, 587, 26, 355, 16612, 63, 396, 275, 334, 490, 1215, 17, 855, 533, 363, 508, 1215, 18, 855, 533, 363, 490, 436, 1215, 17, 14, 576, 59, 16, 61, 508, 1215, 18, 14, 576, 59, 16, 61, 490, 436, 1215, 17, 14, 576, 1988, 17, 61, 508, 1215, 18, 14, 576, 1988, 17, 61, 490, 436, 1215, 17, 14, 28339, 508, 1215, 18, 14, 28339, 490, 436, 1215, 17, 14, 1392, 508, 1215, 18, 14, 1392, 355, 776, 267, 587, 26, 288, 892, 63, 1113, 63, 637, 275, 892, 63, 785, 63, 1162, 59, 354, 61, 288, 1862, 63, 409, 63, 637, 275, 1862, 63, 409, 59, 354, 61, 288, 327, 710, 2569, 6982, 365, 1415, 370, 1104, 16612, 641, 4539, 288, 327, 19768, 83, 4066, 465, 980, 14, 4304, 626, 787, 440, 4472, 370, 3062, 13, 16887, 26, 288, 16612, 63, 396, 275, 334, 1222, 63, 1113, 63, 637, 508, 1862, 63, 409, 63, 637, 503, 2490, 892, 63, 1113, 63, 637, 365, 1862, 63, 409, 63, 637, 9, 267, 340, 440, 16612, 63, 396, 26, 288, 746, 6064, 360, 6612, 7289, 909, 450, 83, 12, 465, 314, 3787, 283, 3044, 283, 9105, 440, 17021, 370, 663, 2725, 450, 83, 7, 450, 3044, 334, 8627, 12, 536, 430, 339, 372, 892, 63, 785, 421, 199, 11490, 199, 318, 485, 15380, 8, 1162, 12, 3268, 29, 16, 12 ]
[ 199, 3606, 777, 4559, 199, 7426, 1522, 687, 2386, 3258, 390, 13, 4643, 370, 4868, 5678, 7163, 199, 7395, 6425, 376, 5027, 5936, 14, 199, 199, 1858, 314, 3379, 1233, 1937, 272, 1455, 921, 551, 3258, 390, 13, 4643, 14, 1308, 15, 199, 460, 272, 4178, 921, 5031, 14, 957, 15, 551, 3258, 390, 13, 4643, 199, 3606, 777, 4559, 199, 199, 1563, 3992, 367, 1006, 23155, 14, 199, 624, 199, 3, 6529, 26, 9647, 352, 21084, 79, 392, 10962, 665, 5294, 352, 14, 1391, 79, 392, 10962, 32, 6505, 17667, 1961, 14, 1308, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 1331, 199, 646, 6485, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 504, 7026, 492, 5178, 199, 504, 1134, 5633, 391, 423, 832, 492, 3816, 421, 199, 11490, 199, 318, 7289, 8, 8627, 12, 5048, 29, 549, 304, 272, 408, 27943, 282, 892, 8943, 543, 314, 2011, 2633, 14, 272, 8465, 368, 1630, 282, 13217, 1331, 402, 314, 1402, 315, 376, 8943, 272, 1928, 5965, 16743, 10102, 666, 14, 2779, 14801, 282, 892, 8943, 272, 543, 314, 2011, 2633, 626, 965, 440, 2757, 5542, 641, 1263, 666, 14, 272, 3897, 272, 4143, 272, 8943, 26, 8943, 909, 12, 503, 769, 12, 2008, 503, 663, 402, 2251, 267, 710, 8943, 503, 1572, 402, 23155, 370, 506, 26210, 272, 5048, 26, 5046, 12, 2716, 267, 982, 5048, 365, 3055, 12, 7289, 911, 11264, 1771, 370, 282, 14800, 641, 2251, 267, 626, 787, 440, 23155, 14, 272, 408, 272, 8943, 63, 466, 275, 730, 8, 8627, 9, 272, 327, 5787, 26, 440, 7252, 11196, 272, 340, 8943, 63, 466, 315, 334, 513, 12, 2008, 12, 663, 12, 9522, 304, 267, 372, 8943, 63, 466, 779, 6311, 8, 69, 12, 5048, 29, 3489, 9, 367, 325, 315, 8943, 566, 272, 916, 440, 2688, 8, 8627, 12, 283, 362, 63, 1162, 735, 267, 340, 440, 5048, 26, 288, 372, 1331, 14, 8293, 8, 8627, 9, 267, 587, 26, 288, 746, 3146, 480, 6612, 7289, 909, 1543, 83, 7, 334, 466, 450, 83, 304, 298, 1169, 298, 390, 1630, 440, 17021, 370, 506, 282, 6276, 6065, 13, 4643, 8943, 298, 1169, 298, 305, 652, 1630, 440, 5669, 282, 283, 362, 63, 1162, 7, 3102, 2122, 1169, 450, 334, 2722, 8, 8627, 395, 730, 8, 8627, 1724, 272, 8531, 275, 8943, 855, 533, 363, 272, 892, 63, 785, 63, 1162, 275, 8943, 14, 362, 63, 1162, 8, 16131, 29, 797, 9, 272, 367, 536, 12, 1215, 315, 3816, 14, 4611, 8, 1222, 63, 785, 63, 1162, 304, 267, 892, 63, 785, 63, 1162, 59, 354, 61, 275, 7289, 8, 635, 12, 5048, 29, 797, 9, 272, 892, 63, 785, 275, 8531, 3682, 1222, 63, 785, 63, 1162, 9, 272, 1862, 63, 409, 275, 892, 63, 785, 14, 362, 63, 1162, 8, 16131, 29, 797, 9, 339, 327, 12530, 16740, 1104, 402, 314, 2633, 402, 314, 7289, 272, 367, 536, 315, 892, 63, 785, 63, 1162, 26, 267, 1215, 17, 275, 892, 63, 785, 63, 1162, 59, 354, 61, 267, 1215, 18, 275, 1862, 63, 409, 59, 354, 61, 267, 340, 1228, 8, 635, 17, 12, 980, 14, 8237, 304, 288, 327, 2104, 4750, 302, 4460, 4814, 12, 781, 886, 440, 511, 367, 4890, 16612, 288, 340, 440, 1228, 8, 635, 18, 12, 730, 8, 635, 17, 2298, 355, 16612, 63, 396, 275, 756, 288, 916, 334, 635, 17, 14, 8322, 690, 378, 490, 436, 1215, 17, 14, 1392, 59, 16, 61, 690, 378, 490, 436, 1228, 8, 635, 18, 12, 980, 14, 8237, 9, 490, 436, 1215, 18, 14, 8322, 690, 378, 490, 436, 1215, 18, 14, 1392, 59, 16, 61, 690, 378, 304, 355, 16612, 63, 396, 275, 334, 490, 1215, 17, 14, 1392, 508, 1215, 18, 14, 1392, 490, 436, 1215, 17, 14, 2271, 508, 1215, 18, 14, 2271, 490, 327, 2136, 1172, 370, 675, 1987, 7088, 7, 367, 499, 36, 6572, 490, 436, 1215, 17, 14, 7088, 59, 16, 61, 508, 1215, 18, 14, 7088, 59, 16, 61, 490, 436, 1215, 17, 14, 7088, 1988, 17, 61, 508, 1215, 18, 14, 7088, 1988, 17, 61, 355, 776, 288, 587, 26, 355, 16612, 63, 396, 275, 980, 14, 452, 8, 635, 17, 508, 1215, 18, 9, 267, 916, 5178, 14, 30962, 8, 635, 17, 304, 288, 327, 2104, 5178, 12627, 16612, 3181, 1133, 1736, 288, 340, 440, 5178, 14, 30962, 8, 635, 18, 304, 355, 16612, 63, 396, 275, 756, 288, 916, 1215, 17, 14, 890, 508, 378, 503, 1215, 18, 14, 890, 508, 378, 26, 355, 16612, 63, 396, 275, 334, 490, 1215, 17, 855, 533, 363, 508, 1215, 18, 855, 533, 363, 490, 436, 1215, 17, 14, 890, 508, 378, 490, 436, 1215, 18, 14, 890, 508, 378, 355, 776, 288, 587, 26, 355, 16612, 63, 396, 275, 334, 490, 1215, 17, 855, 533, 363, 508, 1215, 18, 855, 533, 363, 490, 436, 1215, 17, 14, 576, 59, 16, 61, 508, 1215, 18, 14, 576, 59, 16, 61, 490, 436, 1215, 17, 14, 576, 1988, 17, 61, 508, 1215, 18, 14, 576, 1988, 17, 61, 490, 436, 1215, 17, 14, 28339, 508, 1215, 18, 14, 28339, 490, 436, 1215, 17, 14, 1392, 508, 1215, 18, 14, 1392, 355, 776, 267, 587, 26, 288, 892, 63, 1113, 63, 637, 275, 892, 63, 785, 63, 1162, 59, 354, 61, 288, 1862, 63, 409, 63, 637, 275, 1862, 63, 409, 59, 354, 61, 288, 327, 710, 2569, 6982, 365, 1415, 370, 1104, 16612, 641, 4539, 288, 327, 19768, 83, 4066, 465, 980, 14, 4304, 626, 787, 440, 4472, 370, 3062, 13, 16887, 26, 288, 16612, 63, 396, 275, 334, 1222, 63, 1113, 63, 637, 508, 1862, 63, 409, 63, 637, 503, 2490, 892, 63, 1113, 63, 637, 365, 1862, 63, 409, 63, 637, 9, 267, 340, 440, 16612, 63, 396, 26, 288, 746, 6064, 360, 6612, 7289, 909, 450, 83, 12, 465, 314, 3787, 283, 3044, 283, 9105, 440, 17021, 370, 663, 2725, 450, 83, 7, 450, 3044, 334, 8627, 12, 536, 430, 339, 372, 892, 63, 785, 421, 199, 11490, 199, 318, 485, 15380, 8, 1162, 12, 3268, 29, 16, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
OiNutter/microbit-scripts
runner/runner.py
1
4487
from microbit import * import random from math import ceil MAX_COLS = 5 PAUSE = 500 def init(): global blocks, wait, player, old_player, jump_counter, start, counter, lives, jump_held, jump_amount, jump_maxed, PAUSE blocks = [] wait = 0 player = [1, 4] old_player = None jump_counter = 0 start = counter = running_time() lives = 3 jump_held = False jump_amount = 0 jump_maxed = False PAUSE = 500 def handle_obstacles(): global blocks, wait # Make sure there's been enough times between blocks if wait == 0: # Do we want to create block? if random.choice([True, False]): new_block = [MAX_COLS, random.choice([4, 4, 4, 3])] blocks.append(new_block) wait = 2 # Are we making this a double? if new_block[1] != 3 and random.choice([True, False]): blocks.append([MAX_COLS+1, new_block[1]]) wait += 2 else: wait -= 1 # Draw the blocks for i in range(0, len(blocks)): if blocks[i][0] < MAX_COLS: # Hide the previous block position if blocks[i] != player: display.set_pixel(blocks[i][0], blocks[i][1], 0) # Move the block blocks[i][0] -= 1 if blocks[i][0] >= 0 and blocks[i][0] < MAX_COLS: display.set_pixel(blocks[i][0], blocks[i][1], 3) print(blocks) # Clear any blocks that have gone off screen while len(blocks) > 0 and blocks[0][0] == -1: blocks.pop(0) def draw_player (): global old_player, player # If the player has moved turn off the old position if old_player is not None: display.set_pixel(old_player[0], old_player[1], 0) old_player = None # display the player display.set_pixel(player[0], player[1], 9) def jump(): global player, jump_counter, old_player # Create a ref to the old position old_player = player[:] # Change the y position by the current jump amount player[1] = 4 - (jump_amount) jump_counter += 1 def check_collision(): global lives # Is the player in the position of a block? print (player) print (blocks) print (tuple(player) in [tuple(block) for block in blocks]) if tuple(player) in [tuple(block) for block in blocks]: # If so remove a life display.set_pixel(4-lives+1, 0, 0) lives -= 1 def display_lives(): if lives > 0: for i in range(4, 4 - lives, -1): display.set_pixel(i, 0, 5) display.scroll("RUNNER") display.scroll('Press any button to play', wait=False, loop=True) while True: if button_a.is_pressed() or button_b.is_pressed(): display.clear() while button_a.is_pressed() or button_b.is_pressed(): sleep(0.1) break init() while True: while True: if button_a.is_pressed(): # Check the button has been released and they're not at the max jump height if jump_held == False and jump_maxed == False: jump_amount = min(2, jump_amount + 1) jump_maxed = jump_amount == 2 jump_held = True jump() else: jump_held = False # Update everything every 500ms (this speeds up as the game goes on) if running_time() - counter >= PAUSE: if jump_counter == 0: # If they've just finished jumping bring them back to the ground if jump_amount > 0: jump_amount = max(0, jump_amount - 1) old_player = player[:] player[1] = 4 - jump_amount if player[1] == 4: jump_maxed = False else: jump_counter -= 1 draw_player() handle_obstacles() check_collision() display_lives() counter = running_time() running = running_time() - start if running > 0 and (running / 1000) % 30 == 0: PAUSE -= 50 if lives == 0: break else: sleep(0.1) display.scroll("SCORE: %ds" % (round(running_time() - start)/1000), wait=False, loop=True) sleep(100) while True: if button_a.is_pressed() or button_b.is_pressed(): while button_a.is_pressed(): continue init() display.clear() break
mit
[ 504, 9967, 2075, 492, 627, 199, 646, 2196, 199, 504, 3473, 492, 30449, 199, 199, 4283, 63, 3978, 51, 275, 959, 199, 8470, 4701, 275, 6891, 199, 199, 318, 4205, 837, 272, 2288, 5664, 12, 3618, 12, 7748, 12, 2269, 63, 6147, 12, 14882, 63, 5337, 12, 1343, 12, 7055, 12, 27576, 12, 14882, 63, 31415, 12, 14882, 63, 4606, 12, 14882, 63, 988, 379, 12, 510, 33, 4701, 339, 5664, 275, 942, 272, 3618, 275, 378, 272, 7748, 275, 359, 17, 12, 841, 61, 272, 2269, 63, 6147, 275, 488, 272, 14882, 63, 5337, 275, 378, 272, 1343, 275, 7055, 275, 3879, 63, 521, 342, 272, 27576, 275, 650, 272, 14882, 63, 31415, 275, 756, 272, 14882, 63, 4606, 275, 378, 272, 14882, 63, 988, 379, 275, 756, 272, 510, 33, 4701, 275, 6891, 199, 199, 318, 2429, 63, 2873, 270, 645, 2978, 837, 272, 2288, 5664, 12, 3618, 339, 327, 4155, 3238, 2337, 1159, 2757, 8321, 5431, 3382, 5664, 272, 340, 3618, 508, 378, 26, 267, 327, 4226, 781, 2934, 370, 1218, 1853, 31, 267, 340, 2196, 14, 5095, 779, 549, 12, 756, 4682, 288, 892, 63, 1457, 275, 359, 4283, 63, 3978, 51, 12, 2196, 14, 5095, 779, 20, 12, 841, 12, 841, 12, 650, 12457, 288, 5664, 14, 740, 8, 1222, 63, 1457, 9, 288, 3618, 275, 499, 953, 327, 23889, 781, 10663, 642, 282, 4270, 31, 288, 340, 892, 63, 1457, 59, 17, 61, 1137, 650, 436, 2196, 14, 5095, 779, 549, 12, 756, 4682, 355, 5664, 14, 740, 779, 4283, 63, 3978, 51, 11, 17, 12, 892, 63, 1457, 59, 17, 3934, 355, 3618, 847, 499, 339, 587, 26, 267, 3618, 4862, 413, 339, 327, 17813, 314, 5664, 272, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 4166, 2298, 267, 340, 5664, 59, 73, 1527, 16, 61, 665, 9141, 63, 3978, 51, 26, 288, 327, 869, 2655, 314, 4136, 1853, 3421, 288, 340, 5664, 59, 73, 61, 1137, 7748, 26, 355, 2929, 14, 409, 63, 8435, 8, 4166, 59, 73, 1527, 16, 467, 5664, 59, 73, 1527, 17, 467, 378, 9, 398, 327, 14171, 314, 1853, 267, 5664, 59, 73, 1527, 16, 61, 4862, 413, 267, 340, 5664, 59, 73, 1527, 16, 61, 2356, 378, 436, 5664, 59, 73, 1527, 16, 61, 665, 9141, 63, 3978, 51, 26, 288, 2929, 14, 409, 63, 8435, 8, 4166, 59, 73, 1527, 16, 467, 5664, 59, 73, 1527, 17, 467, 650, 9, 339, 870, 8, 4166, 9, 272, 327, 14836, 1263, 5664, 626, 1172, 21737, 2331, 6426, 272, 1830, 822, 8, 4166, 9, 690, 378, 436, 5664, 59, 16, 1527, 16, 61, 508, 446, 17, 26, 267, 5664, 14, 1935, 8, 16, 9, 199, 199, 318, 5954, 63, 6147, 23390, 272, 2288, 2269, 63, 6147, 12, 7748, 339, 327, 982, 314, 7748, 965, 12155, 7485, 2331, 314, 2269, 3421, 272, 340, 2269, 63, 6147, 365, 440, 488, 26, 267, 2929, 14, 409, 63, 8435, 8, 1753, 63, 6147, 59, 16, 467, 2269, 63, 6147, 59, 17, 467, 378, 9, 267, 2269, 63, 6147, 275, 488, 339, 327, 2929, 314, 7748, 272, 2929, 14, 409, 63, 8435, 8, 6147, 59, 16, 467, 7748, 59, 17, 467, 1749, 9, 421, 199, 318, 14882, 837, 272, 2288, 7748, 12, 14882, 63, 5337, 12, 2269, 63, 6147, 339, 327, 2790, 282, 2984, 370, 314, 2269, 3421, 272, 2269, 63, 6147, 275, 7748, 5873, 339, 327, 7743, 314, 612, 3421, 701, 314, 1453, 14882, 5982, 272, 7748, 59, 17, 61, 275, 841, 446, 334, 11126, 63, 4606, 9, 272, 14882, 63, 5337, 847, 413, 199, 199, 318, 1104, 63, 761, 23656, 837, 272, 2288, 27576, 339, 327, 6596, 314, 7748, 315, 314, 3421, 402, 282, 1853, 31, 272, 870, 334, 6147, 9, 272, 870, 334, 4166, 9, 272, 870, 334, 2960, 8, 6147, 9, 315, 359, 2960, 8, 1457, 9, 367, 1853, 315, 5664, 566, 272, 340, 2008, 8, 6147, 9, 315, 359, 2960, 8, 1457, 9, 367, 1853, 315, 5664, 2189, 267, 327, 982, 880, 2813, 282, 15451, 267, 2929, 14, 409, 63, 8435, 8, 20, 13, 317, 2310, 11, 17, 12, 378, 12, 378, 9, 267, 27576, 4862, 413, 199, 199, 318, 2929, 63, 317, 2310, 837, 339, 340, 27576, 690, 378, 26, 267, 367, 284, 315, 1425, 8, 20, 12, 841, 446, 27576, 12, 446, 17, 304, 288, 2929, 14, 409, 63, 8435, 8, 73, 12, 378, 12, 959, 9, 199, 199, 2918, 14, 6755, 480, 9390, 15215, 531, 199, 199, 2918, 14, 6755, 360, 14414, 1263, 5528, 370, 5232, 297, 3618, 29, 797, 12, 4438, 29, 549, 9, 199, 6710, 715, 26, 272, 340, 5528, 63, 65, 14, 374, 63, 30455, 342, 503, 5528, 63, 66, 14, 374, 63, 30455, 837, 267, 2929, 14, 3584, 342, 267, 1830, 5528, 63, 65, 14, 374, 63, 30455, 342, 503, 5528, 63, 66, 14, 374, 63, 30455, 837, 288, 9435, 8, 16, 14, 17, 9, 267, 2059, 199, 199, 826, 342, 199, 6710, 715, 26, 339, 1830, 715, 26, 267, 340, 5528, 63, 65, 14, 374, 63, 30455, 837, 953, 327, 2670, 314, 5528, 965, 2757, 14286, 436, 2985, 3984, 440, 737, 314, 1390, 14882, 4569, 288, 340, 14882, 63, 31415, 508, 756, 436, 14882, 63, 988, 379, 508, 756, 26, 355, 14882, 63, 4606, 275, 1748, 8, 18, 12, 14882, 63, 4606, 435, 413, 9, 355, 14882, 63, 988, 379, 275, 14882, 63, 4606, 508, 499, 355, 14882, 63, 31415, 275, 715, 355, 14882, 342, 267, 587, 26, 288, 14882, 63, 31415, 275, 756, 398, 327, 6162, 8137, 4036, 6891, 706, 334, 3749, 8112, 83, 1536, 465, 314, 9219, 13538, 641, 9, 267, 340, 3879, 63, 521, 342, 446, 7055, 2356, 510, 33, 4701, 26, 22919, 340, 14882, 63, 5337, 508, 378, 26, 355, 327, 982, 2985, 9064, 2951, 9158, 14882, 316, 330, 5985, 3062, 1771, 370, 314, 19252, 355, 340, 14882, 63, 4606, 690, 378, 26, 490, 14882, 63, 4606, 275, 1390, 8, 16, 12, 14882, 63, 4606, 446, 413, 9, 4951, 2269, 63, 6147, 275, 7748, 5873, 490, 7748, 59, 17, 61, 275, 841, 446, 14882, 63, 4606, 490, 340, 7748, 59, 17, 61, 508, 841, 26, 717, 14882, 63, 988 ]
[ 9967, 2075, 492, 627, 199, 646, 2196, 199, 504, 3473, 492, 30449, 199, 199, 4283, 63, 3978, 51, 275, 959, 199, 8470, 4701, 275, 6891, 199, 199, 318, 4205, 837, 272, 2288, 5664, 12, 3618, 12, 7748, 12, 2269, 63, 6147, 12, 14882, 63, 5337, 12, 1343, 12, 7055, 12, 27576, 12, 14882, 63, 31415, 12, 14882, 63, 4606, 12, 14882, 63, 988, 379, 12, 510, 33, 4701, 339, 5664, 275, 942, 272, 3618, 275, 378, 272, 7748, 275, 359, 17, 12, 841, 61, 272, 2269, 63, 6147, 275, 488, 272, 14882, 63, 5337, 275, 378, 272, 1343, 275, 7055, 275, 3879, 63, 521, 342, 272, 27576, 275, 650, 272, 14882, 63, 31415, 275, 756, 272, 14882, 63, 4606, 275, 378, 272, 14882, 63, 988, 379, 275, 756, 272, 510, 33, 4701, 275, 6891, 199, 199, 318, 2429, 63, 2873, 270, 645, 2978, 837, 272, 2288, 5664, 12, 3618, 339, 327, 4155, 3238, 2337, 1159, 2757, 8321, 5431, 3382, 5664, 272, 340, 3618, 508, 378, 26, 267, 327, 4226, 781, 2934, 370, 1218, 1853, 31, 267, 340, 2196, 14, 5095, 779, 549, 12, 756, 4682, 288, 892, 63, 1457, 275, 359, 4283, 63, 3978, 51, 12, 2196, 14, 5095, 779, 20, 12, 841, 12, 841, 12, 650, 12457, 288, 5664, 14, 740, 8, 1222, 63, 1457, 9, 288, 3618, 275, 499, 953, 327, 23889, 781, 10663, 642, 282, 4270, 31, 288, 340, 892, 63, 1457, 59, 17, 61, 1137, 650, 436, 2196, 14, 5095, 779, 549, 12, 756, 4682, 355, 5664, 14, 740, 779, 4283, 63, 3978, 51, 11, 17, 12, 892, 63, 1457, 59, 17, 3934, 355, 3618, 847, 499, 339, 587, 26, 267, 3618, 4862, 413, 339, 327, 17813, 314, 5664, 272, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 4166, 2298, 267, 340, 5664, 59, 73, 1527, 16, 61, 665, 9141, 63, 3978, 51, 26, 288, 327, 869, 2655, 314, 4136, 1853, 3421, 288, 340, 5664, 59, 73, 61, 1137, 7748, 26, 355, 2929, 14, 409, 63, 8435, 8, 4166, 59, 73, 1527, 16, 467, 5664, 59, 73, 1527, 17, 467, 378, 9, 398, 327, 14171, 314, 1853, 267, 5664, 59, 73, 1527, 16, 61, 4862, 413, 267, 340, 5664, 59, 73, 1527, 16, 61, 2356, 378, 436, 5664, 59, 73, 1527, 16, 61, 665, 9141, 63, 3978, 51, 26, 288, 2929, 14, 409, 63, 8435, 8, 4166, 59, 73, 1527, 16, 467, 5664, 59, 73, 1527, 17, 467, 650, 9, 339, 870, 8, 4166, 9, 272, 327, 14836, 1263, 5664, 626, 1172, 21737, 2331, 6426, 272, 1830, 822, 8, 4166, 9, 690, 378, 436, 5664, 59, 16, 1527, 16, 61, 508, 446, 17, 26, 267, 5664, 14, 1935, 8, 16, 9, 199, 199, 318, 5954, 63, 6147, 23390, 272, 2288, 2269, 63, 6147, 12, 7748, 339, 327, 982, 314, 7748, 965, 12155, 7485, 2331, 314, 2269, 3421, 272, 340, 2269, 63, 6147, 365, 440, 488, 26, 267, 2929, 14, 409, 63, 8435, 8, 1753, 63, 6147, 59, 16, 467, 2269, 63, 6147, 59, 17, 467, 378, 9, 267, 2269, 63, 6147, 275, 488, 339, 327, 2929, 314, 7748, 272, 2929, 14, 409, 63, 8435, 8, 6147, 59, 16, 467, 7748, 59, 17, 467, 1749, 9, 421, 199, 318, 14882, 837, 272, 2288, 7748, 12, 14882, 63, 5337, 12, 2269, 63, 6147, 339, 327, 2790, 282, 2984, 370, 314, 2269, 3421, 272, 2269, 63, 6147, 275, 7748, 5873, 339, 327, 7743, 314, 612, 3421, 701, 314, 1453, 14882, 5982, 272, 7748, 59, 17, 61, 275, 841, 446, 334, 11126, 63, 4606, 9, 272, 14882, 63, 5337, 847, 413, 199, 199, 318, 1104, 63, 761, 23656, 837, 272, 2288, 27576, 339, 327, 6596, 314, 7748, 315, 314, 3421, 402, 282, 1853, 31, 272, 870, 334, 6147, 9, 272, 870, 334, 4166, 9, 272, 870, 334, 2960, 8, 6147, 9, 315, 359, 2960, 8, 1457, 9, 367, 1853, 315, 5664, 566, 272, 340, 2008, 8, 6147, 9, 315, 359, 2960, 8, 1457, 9, 367, 1853, 315, 5664, 2189, 267, 327, 982, 880, 2813, 282, 15451, 267, 2929, 14, 409, 63, 8435, 8, 20, 13, 317, 2310, 11, 17, 12, 378, 12, 378, 9, 267, 27576, 4862, 413, 199, 199, 318, 2929, 63, 317, 2310, 837, 339, 340, 27576, 690, 378, 26, 267, 367, 284, 315, 1425, 8, 20, 12, 841, 446, 27576, 12, 446, 17, 304, 288, 2929, 14, 409, 63, 8435, 8, 73, 12, 378, 12, 959, 9, 199, 199, 2918, 14, 6755, 480, 9390, 15215, 531, 199, 199, 2918, 14, 6755, 360, 14414, 1263, 5528, 370, 5232, 297, 3618, 29, 797, 12, 4438, 29, 549, 9, 199, 6710, 715, 26, 272, 340, 5528, 63, 65, 14, 374, 63, 30455, 342, 503, 5528, 63, 66, 14, 374, 63, 30455, 837, 267, 2929, 14, 3584, 342, 267, 1830, 5528, 63, 65, 14, 374, 63, 30455, 342, 503, 5528, 63, 66, 14, 374, 63, 30455, 837, 288, 9435, 8, 16, 14, 17, 9, 267, 2059, 199, 199, 826, 342, 199, 6710, 715, 26, 339, 1830, 715, 26, 267, 340, 5528, 63, 65, 14, 374, 63, 30455, 837, 953, 327, 2670, 314, 5528, 965, 2757, 14286, 436, 2985, 3984, 440, 737, 314, 1390, 14882, 4569, 288, 340, 14882, 63, 31415, 508, 756, 436, 14882, 63, 988, 379, 508, 756, 26, 355, 14882, 63, 4606, 275, 1748, 8, 18, 12, 14882, 63, 4606, 435, 413, 9, 355, 14882, 63, 988, 379, 275, 14882, 63, 4606, 508, 499, 355, 14882, 63, 31415, 275, 715, 355, 14882, 342, 267, 587, 26, 288, 14882, 63, 31415, 275, 756, 398, 327, 6162, 8137, 4036, 6891, 706, 334, 3749, 8112, 83, 1536, 465, 314, 9219, 13538, 641, 9, 267, 340, 3879, 63, 521, 342, 446, 7055, 2356, 510, 33, 4701, 26, 22919, 340, 14882, 63, 5337, 508, 378, 26, 355, 327, 982, 2985, 9064, 2951, 9158, 14882, 316, 330, 5985, 3062, 1771, 370, 314, 19252, 355, 340, 14882, 63, 4606, 690, 378, 26, 490, 14882, 63, 4606, 275, 1390, 8, 16, 12, 14882, 63, 4606, 446, 413, 9, 4951, 2269, 63, 6147, 275, 7748, 5873, 490, 7748, 59, 17, 61, 275, 841, 446, 14882, 63, 4606, 490, 340, 7748, 59, 17, 61, 508, 841, 26, 717, 14882, 63, 988, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ajyoon/brown
tests/test_interface/test_font_interface.py
1
1421
import unittest import pytest from PyQt5 import QtGui from brown.core import brown from brown.interface.font_interface import FontInterface from brown.utils.units import Unit class MockUnit(Unit): CONVERSION_RATE = 0.5 class TestFontInterface(unittest.TestCase): def setUp(self): brown.setup() brown._app_interface._remove_all_loaded_fonts() def test_init(self): test_font = FontInterface(None, 'Bravura', MockUnit(12), 1, False) assert(test_font.family_name == 'Bravura') assert(test_font.size == MockUnit(12)) assert(test_font.weight == 1) assert(test_font.italic is False) def test_init_qt_attribute_transfer(self): test_font = FontInterface(None, 'Bravura', MockUnit(12), 1, False) assert(isinstance(test_font.qt_object, QtGui.QFont)) assert(test_font.qt_object.bold() is False) assert(test_font.qt_object.italic() is False) assert(test_font.qt_object.pointSize() == 6) assert(test_font.qt_object.weight() == 1) @pytest.mark.skip # Skip this test - seems to vary by OS or display settings? # May not actually be a problem. Proper testing to see if this # is an issue will likely require visual checks on different OS's. def test_em_size(self): test_font = FontInterface(None, 'Bravura', MockUnit(2000), 1, False) assert(int(test_font.em_size) == 366)
gpl-3.0
[ 646, 2882, 199, 199, 646, 4613, 199, 504, 14084, 21, 492, 5928, 199, 199, 504, 330, 18406, 14, 1018, 492, 330, 18406, 199, 504, 330, 18406, 14, 3266, 14, 4246, 63, 3266, 492, 26159, 4267, 199, 504, 330, 18406, 14, 1208, 14, 5260, 492, 12008, 421, 199, 533, 4420, 5072, 8, 5072, 304, 272, 1868, 4612, 63, 16553, 275, 378, 14, 21, 421, 199, 533, 1379, 6986, 4267, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 330, 18406, 14, 2758, 342, 267, 330, 18406, 423, 571, 63, 3266, 423, 2168, 63, 452, 63, 4591, 63, 19864, 342, 339, 347, 511, 63, 826, 8, 277, 304, 267, 511, 63, 4246, 275, 26159, 4267, 8, 403, 12, 283, 17171, 86, 12417, 297, 4420, 5072, 8, 713, 395, 413, 12, 756, 9, 267, 702, 8, 396, 63, 4246, 14, 6606, 63, 354, 508, 283, 17171, 86, 12417, 358, 267, 702, 8, 396, 63, 4246, 14, 890, 508, 4420, 5072, 8, 713, 430, 267, 702, 8, 396, 63, 4246, 14, 3463, 508, 413, 9, 267, 702, 8, 396, 63, 4246, 14, 21843, 365, 756, 9, 339, 347, 511, 63, 826, 63, 8440, 63, 3215, 63, 9609, 8, 277, 304, 267, 511, 63, 4246, 275, 26159, 4267, 8, 403, 12, 283, 17171, 86, 12417, 297, 4420, 5072, 8, 713, 395, 413, 12, 756, 9, 267, 702, 8, 6074, 8, 396, 63, 4246, 14, 8440, 63, 785, 12, 5928, 14, 49, 6986, 430, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 9771, 342, 365, 756, 9, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 21843, 342, 365, 756, 9, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 1403, 2320, 342, 508, 1227, 9, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 3463, 342, 508, 413, 9, 339, 768, 4462, 14, 1657, 14, 2759, 272, 327, 8232, 642, 511, 446, 12237, 370, 17083, 701, 4403, 503, 2929, 2202, 31, 272, 327, 10162, 440, 5965, 506, 282, 5160, 14, 2165, 529, 5343, 370, 1937, 340, 642, 272, 327, 365, 376, 4976, 911, 12060, 4409, 13104, 5920, 641, 3365, 4403, 1159, 14, 272, 347, 511, 63, 5633, 63, 890, 8, 277, 304, 267, 511, 63, 4246, 275, 26159, 4267, 8, 403, 12, 283, 17171, 86, 12417, 297, 4420, 5072, 8, 8269, 395, 413, 12, 756, 9, 267, 702, 8, 442, 8, 396, 63, 4246, 14, 5633, 63, 890, 9, 508, 650, 1272, 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 ]
[ 2882, 199, 199, 646, 4613, 199, 504, 14084, 21, 492, 5928, 199, 199, 504, 330, 18406, 14, 1018, 492, 330, 18406, 199, 504, 330, 18406, 14, 3266, 14, 4246, 63, 3266, 492, 26159, 4267, 199, 504, 330, 18406, 14, 1208, 14, 5260, 492, 12008, 421, 199, 533, 4420, 5072, 8, 5072, 304, 272, 1868, 4612, 63, 16553, 275, 378, 14, 21, 421, 199, 533, 1379, 6986, 4267, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 330, 18406, 14, 2758, 342, 267, 330, 18406, 423, 571, 63, 3266, 423, 2168, 63, 452, 63, 4591, 63, 19864, 342, 339, 347, 511, 63, 826, 8, 277, 304, 267, 511, 63, 4246, 275, 26159, 4267, 8, 403, 12, 283, 17171, 86, 12417, 297, 4420, 5072, 8, 713, 395, 413, 12, 756, 9, 267, 702, 8, 396, 63, 4246, 14, 6606, 63, 354, 508, 283, 17171, 86, 12417, 358, 267, 702, 8, 396, 63, 4246, 14, 890, 508, 4420, 5072, 8, 713, 430, 267, 702, 8, 396, 63, 4246, 14, 3463, 508, 413, 9, 267, 702, 8, 396, 63, 4246, 14, 21843, 365, 756, 9, 339, 347, 511, 63, 826, 63, 8440, 63, 3215, 63, 9609, 8, 277, 304, 267, 511, 63, 4246, 275, 26159, 4267, 8, 403, 12, 283, 17171, 86, 12417, 297, 4420, 5072, 8, 713, 395, 413, 12, 756, 9, 267, 702, 8, 6074, 8, 396, 63, 4246, 14, 8440, 63, 785, 12, 5928, 14, 49, 6986, 430, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 9771, 342, 365, 756, 9, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 21843, 342, 365, 756, 9, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 1403, 2320, 342, 508, 1227, 9, 267, 702, 8, 396, 63, 4246, 14, 8440, 63, 785, 14, 3463, 342, 508, 413, 9, 339, 768, 4462, 14, 1657, 14, 2759, 272, 327, 8232, 642, 511, 446, 12237, 370, 17083, 701, 4403, 503, 2929, 2202, 31, 272, 327, 10162, 440, 5965, 506, 282, 5160, 14, 2165, 529, 5343, 370, 1937, 340, 642, 272, 327, 365, 376, 4976, 911, 12060, 4409, 13104, 5920, 641, 3365, 4403, 1159, 14, 272, 347, 511, 63, 5633, 63, 890, 8, 277, 304, 267, 511, 63, 4246, 275, 26159, 4267, 8, 403, 12, 283, 17171, 86, 12417, 297, 4420, 5072, 8, 8269, 395, 413, 12, 756, 9, 267, 702, 8, 442, 8, 396, 63, 4246, 14, 5633, 63, 890, 9, 508, 650, 1272, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
marcoantoniooliveira/labweb
tests/integration/partner/strategy_tests.py
51
4245
from django.test import TestCase from decimal import Decimal as D from oscar.apps.partner import strategy from oscar.apps.catalogue import models from oscar.test import factories from oscar.apps.basket.models import Line class TestDefaultStrategy(TestCase): def setUp(self): self.strategy = strategy.Default() def test_no_stockrecords(self): product = factories.create_product() info = self.strategy.fetch_for_product(product) self.assertFalse(info.availability.is_available_to_buy) self.assertIsNone(info.price.incl_tax) def test_one_stockrecord(self): product = factories.create_product(price=D('1.99'), num_in_stock=4) info = self.strategy.fetch_for_product(product) self.assertTrue(info.availability.is_available_to_buy) self.assertEqual(D('1.99'), info.price.excl_tax) self.assertEqual(D('1.99'), info.price.incl_tax) def test_product_which_doesnt_track_stock(self): product_class = models.ProductClass.objects.create( name="Digital", track_stock=False) product = factories.create_product( product_class=product_class, price=D('1.99'), num_in_stock=None) info = self.strategy.fetch_for_product(product) self.assertTrue(info.availability.is_available_to_buy) def test_line_method_is_same_as_product_one(self): product = factories.create_product() line = Line(product=product) info = self.strategy.fetch_for_line(line) self.assertFalse(info.availability.is_available_to_buy) self.assertIsNone(info.price.incl_tax) def test_free_product_is_available_to_buy(self): product = factories.create_product(price=D('0'), num_in_stock=1) info = self.strategy.fetch_for_product(product) self.assertTrue(info.availability.is_available_to_buy) self.assertTrue(info.price.exists) class TestDefaultStrategyForParentProductWhoseVariantsHaveNoStockRecords(TestCase): def setUp(self): self.strategy = strategy.Default() parent = factories.create_product(structure='parent') for x in range(3): factories.create_product(parent=parent) self.info = self.strategy.fetch_for_parent(parent) def test_specifies_product_is_unavailable(self): self.assertFalse(self.info.availability.is_available_to_buy) def test_specifies_correct_availability_code(self): self.assertEqual('unavailable', self.info.availability.code) def test_specifies_product_has_no_price(self): self.assertFalse(self.info.price.exists) class TestDefaultStrategyForParentProductWithInStockVariant(TestCase): def setUp(self): self.strategy = strategy.Default() parent = factories.create_product(structure='parent') factories.create_product(parent=parent, price=D('10.00'), num_in_stock=3) for x in range(2): factories.create_product(parent=parent) self.info = self.strategy.fetch_for_parent(parent) def test_specifies_product_is_available(self): self.assertTrue(self.info.availability.is_available_to_buy) def test_specifies_correct_availability_code(self): self.assertEqual('available', self.info.availability.code) def test_specifies_product_has_correct_price(self): self.assertEqual(D('10.00'), self.info.price.incl_tax) class TestDefaultStrategyForParentProductWithOutOfStockVariant(TestCase): def setUp(self): self.strategy = strategy.Default() parent = factories.create_product(structure='parent') factories.create_product( parent=parent, price=D('10.00'), num_in_stock=0) for x in range(2): factories.create_product(parent=parent) self.info = self.strategy.fetch_for_parent(parent) def test_specifies_product_is_unavailable(self): self.assertFalse(self.info.availability.is_available_to_buy) def test_specifies_correct_availability_code(self): self.assertEqual('unavailable', self.info.availability.code) def test_specifies_product_has_correct_price(self): self.assertEqual(D('10.00'), self.info.price.incl_tax)
bsd-3-clause
[ 504, 1639, 14, 396, 492, 7640, 199, 504, 6107, 492, 6345, 465, 577, 199, 199, 504, 312, 22707, 14, 5181, 14, 3899, 492, 10054, 199, 504, 312, 22707, 14, 5181, 14, 22330, 492, 1709, 199, 504, 312, 22707, 14, 396, 492, 22115, 199, 504, 312, 22707, 14, 5181, 14, 18136, 14, 992, 492, 7030, 421, 199, 533, 1379, 2698, 16199, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 339, 347, 511, 63, 889, 63, 6088, 6502, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 342, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 3334, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 7702, 8, 815, 14, 4777, 14, 31941, 63, 5530, 9, 339, 347, 511, 63, 368, 63, 6088, 3059, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 8, 4777, 29, 36, 360, 17, 14, 1020, 659, 1967, 63, 262, 63, 6088, 29, 20, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 1815, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 629, 8, 36, 360, 17, 14, 1020, 659, 2256, 14, 4777, 14, 476, 429, 63, 5530, 9, 267, 291, 14, 629, 8, 36, 360, 17, 14, 1020, 659, 2256, 14, 4777, 14, 31941, 63, 5530, 9, 339, 347, 511, 63, 2558, 63, 6777, 63, 26664, 63, 3885, 63, 6088, 8, 277, 304, 267, 3336, 63, 533, 275, 1709, 14, 5884, 2543, 14, 1462, 14, 981, 8, 288, 536, 628, 32660, 401, 4426, 63, 6088, 29, 797, 9, 267, 3336, 275, 22115, 14, 981, 63, 2558, 8, 288, 3336, 63, 533, 29, 2558, 63, 533, 12, 288, 8033, 29, 36, 360, 17, 14, 1020, 659, 1967, 63, 262, 63, 6088, 29, 403, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 1815, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 339, 347, 511, 63, 604, 63, 765, 63, 374, 63, 7191, 63, 305, 63, 2558, 63, 368, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 342, 267, 1004, 275, 7030, 8, 2558, 29, 2558, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 604, 8, 604, 9, 267, 291, 14, 3334, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 7702, 8, 815, 14, 4777, 14, 31941, 63, 5530, 9, 339, 347, 511, 63, 4624, 63, 2558, 63, 374, 63, 4561, 63, 475, 63, 31240, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 8, 4777, 29, 36, 360, 16, 659, 1967, 63, 262, 63, 6088, 29, 17, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 1815, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 1815, 8, 815, 14, 4777, 14, 2444, 9, 421, 199, 533, 1379, 2698, 16199, 1858, 6652, 5884, 55, 526, 261, 9958, 2285, 40, 811, 1944, 17103, 14941, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 267, 1676, 275, 22115, 14, 981, 63, 2558, 8, 6976, 534, 1708, 358, 267, 367, 671, 315, 1425, 8, 19, 304, 288, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 9, 267, 291, 14, 815, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 1708, 8, 1708, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 374, 63, 28119, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 339, 347, 511, 63, 3017, 5604, 63, 4525, 63, 11856, 63, 600, 8, 277, 304, 267, 291, 14, 629, 360, 28119, 297, 291, 14, 815, 14, 11856, 14, 600, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 1989, 63, 889, 63, 4777, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 815, 14, 4777, 14, 2444, 9, 421, 199, 533, 1379, 2698, 16199, 1858, 6652, 5884, 3007, 607, 17103, 12935, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 267, 1676, 275, 22115, 14, 981, 63, 2558, 8, 6976, 534, 1708, 358, 267, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 12, 8033, 29, 36, 360, 709, 14, 383, 659, 639, 1967, 63, 262, 63, 6088, 29, 19, 9, 267, 367, 671, 315, 1425, 8, 18, 304, 288, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 9, 267, 291, 14, 815, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 1708, 8, 1708, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 374, 63, 4561, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 339, 347, 511, 63, 3017, 5604, 63, 4525, 63, 11856, 63, 600, 8, 277, 304, 267, 291, 14, 629, 360, 4561, 297, 291, 14, 815, 14, 11856, 14, 600, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 1989, 63, 4525, 63, 4777, 8, 277, 304, 267, 291, 14, 629, 8, 36, 360, 709, 14, 383, 659, 291, 14, 815, 14, 4777, 14, 31941, 63, 5530, 9, 421, 199, 533, 1379, 2698, 16199, 1858, 6652, 5884, 3007, 21383, 17103, 12935, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 267, 1676, 275, 22115, 14, 981, 63, 2558, 8, 6976, 534, 1708, 358, 267, 22115, 14, 981, 63, 2558, 8, 288, 1676, 29, 1708, 12, 8033, 29, 36, 360, 709, 14, 383, 659, 1967, 63, 262, 63, 6088, 29, 16, 9, 267, 367, 671, 315, 1425, 8, 18, 304, 288, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 9, 267, 291, 14, 815, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 1708, 8, 1708, 9, 339 ]
[ 1639, 14, 396, 492, 7640, 199, 504, 6107, 492, 6345, 465, 577, 199, 199, 504, 312, 22707, 14, 5181, 14, 3899, 492, 10054, 199, 504, 312, 22707, 14, 5181, 14, 22330, 492, 1709, 199, 504, 312, 22707, 14, 396, 492, 22115, 199, 504, 312, 22707, 14, 5181, 14, 18136, 14, 992, 492, 7030, 421, 199, 533, 1379, 2698, 16199, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 339, 347, 511, 63, 889, 63, 6088, 6502, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 342, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 3334, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 7702, 8, 815, 14, 4777, 14, 31941, 63, 5530, 9, 339, 347, 511, 63, 368, 63, 6088, 3059, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 8, 4777, 29, 36, 360, 17, 14, 1020, 659, 1967, 63, 262, 63, 6088, 29, 20, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 1815, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 629, 8, 36, 360, 17, 14, 1020, 659, 2256, 14, 4777, 14, 476, 429, 63, 5530, 9, 267, 291, 14, 629, 8, 36, 360, 17, 14, 1020, 659, 2256, 14, 4777, 14, 31941, 63, 5530, 9, 339, 347, 511, 63, 2558, 63, 6777, 63, 26664, 63, 3885, 63, 6088, 8, 277, 304, 267, 3336, 63, 533, 275, 1709, 14, 5884, 2543, 14, 1462, 14, 981, 8, 288, 536, 628, 32660, 401, 4426, 63, 6088, 29, 797, 9, 267, 3336, 275, 22115, 14, 981, 63, 2558, 8, 288, 3336, 63, 533, 29, 2558, 63, 533, 12, 288, 8033, 29, 36, 360, 17, 14, 1020, 659, 1967, 63, 262, 63, 6088, 29, 403, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 1815, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 339, 347, 511, 63, 604, 63, 765, 63, 374, 63, 7191, 63, 305, 63, 2558, 63, 368, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 342, 267, 1004, 275, 7030, 8, 2558, 29, 2558, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 604, 8, 604, 9, 267, 291, 14, 3334, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 7702, 8, 815, 14, 4777, 14, 31941, 63, 5530, 9, 339, 347, 511, 63, 4624, 63, 2558, 63, 374, 63, 4561, 63, 475, 63, 31240, 8, 277, 304, 267, 3336, 275, 22115, 14, 981, 63, 2558, 8, 4777, 29, 36, 360, 16, 659, 1967, 63, 262, 63, 6088, 29, 17, 9, 267, 2256, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 2558, 8, 2558, 9, 267, 291, 14, 1815, 8, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 267, 291, 14, 1815, 8, 815, 14, 4777, 14, 2444, 9, 421, 199, 533, 1379, 2698, 16199, 1858, 6652, 5884, 55, 526, 261, 9958, 2285, 40, 811, 1944, 17103, 14941, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 267, 1676, 275, 22115, 14, 981, 63, 2558, 8, 6976, 534, 1708, 358, 267, 367, 671, 315, 1425, 8, 19, 304, 288, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 9, 267, 291, 14, 815, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 1708, 8, 1708, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 374, 63, 28119, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 339, 347, 511, 63, 3017, 5604, 63, 4525, 63, 11856, 63, 600, 8, 277, 304, 267, 291, 14, 629, 360, 28119, 297, 291, 14, 815, 14, 11856, 14, 600, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 1989, 63, 889, 63, 4777, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 815, 14, 4777, 14, 2444, 9, 421, 199, 533, 1379, 2698, 16199, 1858, 6652, 5884, 3007, 607, 17103, 12935, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 267, 1676, 275, 22115, 14, 981, 63, 2558, 8, 6976, 534, 1708, 358, 267, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 12, 8033, 29, 36, 360, 709, 14, 383, 659, 639, 1967, 63, 262, 63, 6088, 29, 19, 9, 267, 367, 671, 315, 1425, 8, 18, 304, 288, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 9, 267, 291, 14, 815, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 1708, 8, 1708, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 374, 63, 4561, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 815, 14, 11856, 14, 374, 63, 4561, 63, 475, 63, 31240, 9, 339, 347, 511, 63, 3017, 5604, 63, 4525, 63, 11856, 63, 600, 8, 277, 304, 267, 291, 14, 629, 360, 4561, 297, 291, 14, 815, 14, 11856, 14, 600, 9, 339, 347, 511, 63, 3017, 5604, 63, 2558, 63, 1989, 63, 4525, 63, 4777, 8, 277, 304, 267, 291, 14, 629, 8, 36, 360, 709, 14, 383, 659, 291, 14, 815, 14, 4777, 14, 31941, 63, 5530, 9, 421, 199, 533, 1379, 2698, 16199, 1858, 6652, 5884, 3007, 21383, 17103, 12935, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 8590, 275, 10054, 14, 2698, 342, 267, 1676, 275, 22115, 14, 981, 63, 2558, 8, 6976, 534, 1708, 358, 267, 22115, 14, 981, 63, 2558, 8, 288, 1676, 29, 1708, 12, 8033, 29, 36, 360, 709, 14, 383, 659, 1967, 63, 262, 63, 6088, 29, 16, 9, 267, 367, 671, 315, 1425, 8, 18, 304, 288, 22115, 14, 981, 63, 2558, 8, 1708, 29, 1708, 9, 267, 291, 14, 815, 275, 291, 14, 8590, 14, 3535, 63, 509, 63, 1708, 8, 1708, 9, 339, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
biothings/biothings_explorer
biothings_explorer/utils/networkx.py
1
4018
# -*- coding: utf-8 -*- """A collection of util functions related to networkx .. moduleauthor:: Jiwen Xin <kevinxin@scripps.edu> """ from collections import defaultdict def load_res_to_networkx(_res, G, labels, id_mapping, output_id_types): """Load restructured API response into a networkx MultiDiGraph. Parameters * G: networkx MultiDiGraph * _res: restructured API response * labels: list of schema properties to extract from API response * id_mapping: dict containing mapping between equivalent ids and original ids * output_id_types: list of output identifiers """ # check if API response is empty if not _res: return G # m represent input id, n represent parsed API output for input_id, parsed_api_output in _res.items(): if not parsed_api_output: continue # a represent schema property, b represent value for prop, prop_vals in parsed_api_output.items(): if prop not in labels: continue for _val in prop_vals: if not isinstance(_val, dict): G.add_node( str(_val), identifier=prop, type=parsed_api_output["@type"], level=2, ) G.add_edge(id_mapping[input_id], str(_val), info=None, label=prop) else: for i, j in _val.items(): if i in output_id_types and j: output_type = _val.get("@type") source = _val.get("$source") if not isinstance(j, list): j = [j] j = [str(jj) for jj in j] G.add_nodes_from(j, identifier=i, type=output_type, level=2) for _j in j: G.add_edge( id_mapping[input_id], _j, info=_val, label=prop, source=source, ) return G def add_equivalent_ids_to_nodes(G, IDResolver): """Add equivalent ids to each node. Parameters * G: Networkx Graph * IDConverter: Python Class in BTE to convert IDs TODO: This is weird, shouldn't include IDConverter in this. """ # check if G is empty if not G: return (G, {}) # get all nodes which are level 2 (output nodes) output_ids = [x for x, y in G.nodes(data=True) if y and y["level"] == 2] # check if there is no output nodes if not output_ids: return (G, {}) # group output ids based on identifier and type idc_inputs = [] output_ids_dict = defaultdict(list) for _id in output_ids: type_identifier = G.nodes[_id]["type"] + "," + G.nodes[_id]["identifier"] output_ids_dict[type_identifier].append(_id) # construct inputs for IDConverter for k, v in output_ids_dict.items(): input_cls, input_id = k.split(",") idc_inputs.append((v, input_id, input_cls)) # find equivalent ids equivalent_ids = IDResolver.resolve_ids(idc_inputs) # populate nodes with equivalent ids for m, n in equivalent_ids.items(): G.nodes[m.split(":", 1)[-1]]["equivalent_ids"] = n return (G, equivalent_ids) def merge_two_networkx_graphs(G1, G2): """Merge two networkx MultiDiGraphs. :param: G1: networkx graph as the source graph :param: G2: networkx graph added to G1 TODO: line G1.add_edges_from(G2.edges(data=True)) will introduce duplicate edges """ nodes_to_add = [] for k, v in G2.nodes(data=True): if k not in G1: nodes_to_add.append((k, v)) G1.add_nodes_from(nodes_to_add) G1.add_edges_from(G2.edges(data=True)) return G1
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 33, 3245, 402, 4884, 3423, 4048, 370, 24313, 199, 199, 703, 28966, 447, 1603, 73, 87, 287, 1323, 262, 665, 415, 86, 5092, 262, 32, 729, 802, 83, 14, 8654, 30, 421, 199, 624, 199, 199, 504, 5055, 492, 10018, 421, 199, 318, 2248, 63, 470, 63, 475, 63, 1200, 88, 1547, 470, 12, 598, 12, 3628, 12, 1305, 63, 4745, 12, 1072, 63, 344, 63, 1313, 304, 272, 408, 6200, 295, 15774, 3261, 1177, 1901, 282, 24313, 6879, 23208, 14, 339, 3897, 267, 627, 598, 26, 24313, 6879, 23208, 267, 627, 485, 470, 26, 295, 15774, 3261, 1177, 267, 627, 3628, 26, 769, 402, 4177, 4382, 370, 5536, 687, 3261, 1177, 267, 627, 1305, 63, 4745, 26, 1211, 3035, 4412, 3382, 7353, 2762, 436, 3379, 2762, 267, 627, 1072, 63, 344, 63, 1313, 26, 769, 402, 1072, 14154, 272, 408, 272, 327, 1104, 340, 3261, 1177, 365, 2701, 272, 340, 440, 485, 470, 26, 267, 372, 598, 272, 327, 333, 2954, 1324, 1305, 12, 302, 2954, 4565, 3261, 1072, 272, 367, 1324, 63, 344, 12, 4565, 63, 1246, 63, 1199, 315, 485, 470, 14, 1744, 837, 267, 340, 440, 4565, 63, 1246, 63, 1199, 26, 288, 1980, 267, 327, 282, 2954, 4177, 3324, 12, 330, 2954, 574, 267, 367, 5931, 12, 5931, 63, 3643, 315, 4565, 63, 1246, 63, 1199, 14, 1744, 837, 288, 340, 5931, 440, 315, 3628, 26, 355, 1980, 288, 367, 485, 637, 315, 5931, 63, 3643, 26, 355, 340, 440, 1228, 1547, 637, 12, 1211, 304, 490, 598, 14, 525, 63, 932, 8, 717, 620, 1547, 637, 395, 717, 5148, 29, 4469, 12, 717, 730, 29, 6751, 63, 1246, 63, 1199, 905, 32, 466, 2255, 717, 2166, 29, 18, 12, 490, 776, 490, 598, 14, 525, 63, 5173, 8, 344, 63, 4745, 59, 1210, 63, 344, 467, 620, 1547, 637, 395, 2256, 29, 403, 12, 1768, 29, 4469, 9, 355, 587, 26, 490, 367, 284, 12, 1335, 315, 485, 637, 14, 1744, 837, 717, 340, 284, 315, 1072, 63, 344, 63, 1313, 436, 1335, 26, 1169, 1072, 63, 466, 275, 485, 637, 14, 362, 25915, 466, 531, 1169, 1350, 275, 485, 637, 14, 362, 21506, 1365, 531, 1169, 340, 440, 1228, 8, 74, 12, 769, 304, 1816, 1335, 275, 359, 74, 61, 1169, 1335, 275, 359, 495, 8, 12098, 9, 367, 1335, 74, 315, 1335, 61, 1169, 598, 14, 525, 63, 2415, 63, 504, 8, 74, 12, 5148, 29, 73, 12, 730, 29, 1199, 63, 466, 12, 2166, 29, 18, 9, 1169, 367, 485, 74, 315, 1335, 26, 1816, 598, 14, 525, 63, 5173, 8, 2511, 1305, 63, 4745, 59, 1210, 63, 344, 467, 2511, 485, 74, 12, 2511, 2256, 3699, 637, 12, 2511, 1768, 29, 4469, 12, 2511, 1350, 29, 1365, 12, 1816, 776, 272, 372, 598, 421, 199, 318, 1050, 63, 24179, 63, 1580, 63, 475, 63, 2415, 8, 39, 12, 2870, 12407, 304, 272, 408, 1123, 7353, 2762, 370, 1924, 1031, 14, 339, 3897, 267, 627, 598, 26, 7220, 88, 11513, 267, 627, 2870, 11907, 26, 2018, 8089, 315, 699, 3727, 370, 3957, 11449, 339, 3254, 26, 961, 365, 22965, 12, 9296, 1133, 2387, 2870, 11907, 315, 642, 14, 272, 408, 272, 327, 1104, 340, 598, 365, 2701, 272, 340, 440, 598, 26, 267, 372, 334, 39, 12, 5009, 272, 327, 664, 1006, 3380, 1314, 787, 2166, 499, 334, 1199, 3380, 9, 272, 1072, 63, 1580, 275, 359, 88, 367, 671, 12, 612, 315, 598, 14, 2415, 8, 576, 29, 549, 9, 340, 612, 436, 612, 905, 1896, 937, 508, 499, 61, 272, 327, 1104, 340, 2337, 365, 949, 1072, 3380, 272, 340, 440, 1072, 63, 1580, 26, 267, 372, 334, 39, 12, 5009, 272, 327, 1572, 1072, 2762, 4079, 641, 5148, 436, 730, 272, 1305, 67, 63, 3711, 275, 942, 272, 1072, 63, 1580, 63, 807, 275, 10018, 8, 513, 9, 272, 367, 485, 344, 315, 1072, 63, 1580, 26, 267, 730, 63, 5364, 275, 598, 14, 2415, 13040, 344, 7541, 466, 937, 435, 21147, 435, 598, 14, 2415, 13040, 344, 7541, 5364, 937, 267, 1072, 63, 1580, 63, 807, 59, 466, 63, 5364, 1055, 740, 1547, 344, 9, 272, 327, 6982, 4153, 367, 2870, 11907, 272, 367, 1022, 12, 373, 315, 1072, 63, 1580, 63, 807, 14, 1744, 837, 267, 1324, 63, 1886, 12, 1324, 63, 344, 275, 1022, 14, 1294, 20324, 267, 1305, 67, 63, 3711, 14, 740, 1332, 86, 12, 1324, 63, 344, 12, 1324, 63, 1886, 430, 272, 327, 2342, 7353, 2762, 272, 7353, 63, 1580, 275, 2870, 12407, 14, 6983, 63, 1580, 8, 344, 67, 63, 3711, 9, 272, 327, 13904, 3380, 543, 7353, 2762, 272, 367, 333, 12, 302, 315, 7353, 63, 1580, 14, 1744, 837, 267, 598, 14, 2415, 59, 77, 14, 1294, 480, 6783, 413, 15786, 17, 2677, 905, 24179, 63, 1580, 937, 275, 302, 272, 372, 334, 39, 12, 7353, 63, 1580, 9, 421, 199, 318, 5389, 63, 5601, 63, 1200, 88, 63, 16670, 8, 39, 17, 12, 598, 18, 304, 272, 408, 11359, 2877, 24313, 6879, 23208, 83, 14, 339, 520, 635, 26, 598, 17, 26, 24313, 3343, 465, 314, 1350, 3343, 272, 520, 635, 26, 598, 18, 26, 24313, 3343, 3483, 370, 598, 17, 339, 3254, 26, 1004, 598, 17, 14, 525, 63, 6929, 63, 504, 8, 39, 18, 14, 6929, 8, 576, 29, 549, 430, 911, 13318, 3402, 9250, 8207, 272, 408, 272, 3380, 63, 475, 63, 525, 275, 942, 272, 367, 1022, 12, 373, 315, 598, 18, 14, 2415, 8, 576, 29, 549, 304, 267, 340, 1022, 440, 315, 598, 17, 26, 288, 3380, 63, 475, 63, 525, 14, 740, 1332, 75, 12, 373, 430, 272, 598, 17, 14, 525, 63, 2415, 63, 504, 8, 2415, 63, 475, 63, 525, 9, 272, 598, 17, 14, 525, 63, 6929, 63, 504, 8, 39, 18, 14, 6929, 8, 576, 29, 549, 430, 272, 372, 598, 17, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 33, 3245, 402, 4884, 3423, 4048, 370, 24313, 199, 199, 703, 28966, 447, 1603, 73, 87, 287, 1323, 262, 665, 415, 86, 5092, 262, 32, 729, 802, 83, 14, 8654, 30, 421, 199, 624, 199, 199, 504, 5055, 492, 10018, 421, 199, 318, 2248, 63, 470, 63, 475, 63, 1200, 88, 1547, 470, 12, 598, 12, 3628, 12, 1305, 63, 4745, 12, 1072, 63, 344, 63, 1313, 304, 272, 408, 6200, 295, 15774, 3261, 1177, 1901, 282, 24313, 6879, 23208, 14, 339, 3897, 267, 627, 598, 26, 24313, 6879, 23208, 267, 627, 485, 470, 26, 295, 15774, 3261, 1177, 267, 627, 3628, 26, 769, 402, 4177, 4382, 370, 5536, 687, 3261, 1177, 267, 627, 1305, 63, 4745, 26, 1211, 3035, 4412, 3382, 7353, 2762, 436, 3379, 2762, 267, 627, 1072, 63, 344, 63, 1313, 26, 769, 402, 1072, 14154, 272, 408, 272, 327, 1104, 340, 3261, 1177, 365, 2701, 272, 340, 440, 485, 470, 26, 267, 372, 598, 272, 327, 333, 2954, 1324, 1305, 12, 302, 2954, 4565, 3261, 1072, 272, 367, 1324, 63, 344, 12, 4565, 63, 1246, 63, 1199, 315, 485, 470, 14, 1744, 837, 267, 340, 440, 4565, 63, 1246, 63, 1199, 26, 288, 1980, 267, 327, 282, 2954, 4177, 3324, 12, 330, 2954, 574, 267, 367, 5931, 12, 5931, 63, 3643, 315, 4565, 63, 1246, 63, 1199, 14, 1744, 837, 288, 340, 5931, 440, 315, 3628, 26, 355, 1980, 288, 367, 485, 637, 315, 5931, 63, 3643, 26, 355, 340, 440, 1228, 1547, 637, 12, 1211, 304, 490, 598, 14, 525, 63, 932, 8, 717, 620, 1547, 637, 395, 717, 5148, 29, 4469, 12, 717, 730, 29, 6751, 63, 1246, 63, 1199, 905, 32, 466, 2255, 717, 2166, 29, 18, 12, 490, 776, 490, 598, 14, 525, 63, 5173, 8, 344, 63, 4745, 59, 1210, 63, 344, 467, 620, 1547, 637, 395, 2256, 29, 403, 12, 1768, 29, 4469, 9, 355, 587, 26, 490, 367, 284, 12, 1335, 315, 485, 637, 14, 1744, 837, 717, 340, 284, 315, 1072, 63, 344, 63, 1313, 436, 1335, 26, 1169, 1072, 63, 466, 275, 485, 637, 14, 362, 25915, 466, 531, 1169, 1350, 275, 485, 637, 14, 362, 21506, 1365, 531, 1169, 340, 440, 1228, 8, 74, 12, 769, 304, 1816, 1335, 275, 359, 74, 61, 1169, 1335, 275, 359, 495, 8, 12098, 9, 367, 1335, 74, 315, 1335, 61, 1169, 598, 14, 525, 63, 2415, 63, 504, 8, 74, 12, 5148, 29, 73, 12, 730, 29, 1199, 63, 466, 12, 2166, 29, 18, 9, 1169, 367, 485, 74, 315, 1335, 26, 1816, 598, 14, 525, 63, 5173, 8, 2511, 1305, 63, 4745, 59, 1210, 63, 344, 467, 2511, 485, 74, 12, 2511, 2256, 3699, 637, 12, 2511, 1768, 29, 4469, 12, 2511, 1350, 29, 1365, 12, 1816, 776, 272, 372, 598, 421, 199, 318, 1050, 63, 24179, 63, 1580, 63, 475, 63, 2415, 8, 39, 12, 2870, 12407, 304, 272, 408, 1123, 7353, 2762, 370, 1924, 1031, 14, 339, 3897, 267, 627, 598, 26, 7220, 88, 11513, 267, 627, 2870, 11907, 26, 2018, 8089, 315, 699, 3727, 370, 3957, 11449, 339, 3254, 26, 961, 365, 22965, 12, 9296, 1133, 2387, 2870, 11907, 315, 642, 14, 272, 408, 272, 327, 1104, 340, 598, 365, 2701, 272, 340, 440, 598, 26, 267, 372, 334, 39, 12, 5009, 272, 327, 664, 1006, 3380, 1314, 787, 2166, 499, 334, 1199, 3380, 9, 272, 1072, 63, 1580, 275, 359, 88, 367, 671, 12, 612, 315, 598, 14, 2415, 8, 576, 29, 549, 9, 340, 612, 436, 612, 905, 1896, 937, 508, 499, 61, 272, 327, 1104, 340, 2337, 365, 949, 1072, 3380, 272, 340, 440, 1072, 63, 1580, 26, 267, 372, 334, 39, 12, 5009, 272, 327, 1572, 1072, 2762, 4079, 641, 5148, 436, 730, 272, 1305, 67, 63, 3711, 275, 942, 272, 1072, 63, 1580, 63, 807, 275, 10018, 8, 513, 9, 272, 367, 485, 344, 315, 1072, 63, 1580, 26, 267, 730, 63, 5364, 275, 598, 14, 2415, 13040, 344, 7541, 466, 937, 435, 21147, 435, 598, 14, 2415, 13040, 344, 7541, 5364, 937, 267, 1072, 63, 1580, 63, 807, 59, 466, 63, 5364, 1055, 740, 1547, 344, 9, 272, 327, 6982, 4153, 367, 2870, 11907, 272, 367, 1022, 12, 373, 315, 1072, 63, 1580, 63, 807, 14, 1744, 837, 267, 1324, 63, 1886, 12, 1324, 63, 344, 275, 1022, 14, 1294, 20324, 267, 1305, 67, 63, 3711, 14, 740, 1332, 86, 12, 1324, 63, 344, 12, 1324, 63, 1886, 430, 272, 327, 2342, 7353, 2762, 272, 7353, 63, 1580, 275, 2870, 12407, 14, 6983, 63, 1580, 8, 344, 67, 63, 3711, 9, 272, 327, 13904, 3380, 543, 7353, 2762, 272, 367, 333, 12, 302, 315, 7353, 63, 1580, 14, 1744, 837, 267, 598, 14, 2415, 59, 77, 14, 1294, 480, 6783, 413, 15786, 17, 2677, 905, 24179, 63, 1580, 937, 275, 302, 272, 372, 334, 39, 12, 7353, 63, 1580, 9, 421, 199, 318, 5389, 63, 5601, 63, 1200, 88, 63, 16670, 8, 39, 17, 12, 598, 18, 304, 272, 408, 11359, 2877, 24313, 6879, 23208, 83, 14, 339, 520, 635, 26, 598, 17, 26, 24313, 3343, 465, 314, 1350, 3343, 272, 520, 635, 26, 598, 18, 26, 24313, 3343, 3483, 370, 598, 17, 339, 3254, 26, 1004, 598, 17, 14, 525, 63, 6929, 63, 504, 8, 39, 18, 14, 6929, 8, 576, 29, 549, 430, 911, 13318, 3402, 9250, 8207, 272, 408, 272, 3380, 63, 475, 63, 525, 275, 942, 272, 367, 1022, 12, 373, 315, 598, 18, 14, 2415, 8, 576, 29, 549, 304, 267, 340, 1022, 440, 315, 598, 17, 26, 288, 3380, 63, 475, 63, 525, 14, 740, 1332, 75, 12, 373, 430, 272, 598, 17, 14, 525, 63, 2415, 63, 504, 8, 2415, 63, 475, 63, 525, 9, 272, 598, 17, 14, 525, 63, 6929, 63, 504, 8, 39, 18, 14, 6929, 8, 576, 29, 549, 430, 272, 372, 598, 17, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gdgellatly/server-tools
auth_admin_passkey/model/res_config.py
61
3206
# -*- encoding: utf-8 -*- ############################################################################## # # Admin Passkey module for OpenERP # Copyright (C) 2013-2014 GRAP (http://www.grap.coop) # @author Sylvain LE GAL (https://twitter.com/legalsylvain) # # 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 from openerp.osv.orm import TransientModel from openerp.tools.safe_eval import safe_eval class base_config_settings(TransientModel): _inherit = 'base.config.settings' # Getter / Setter Section def get_default_auth_admin_passkey_send_to_admin( self, cr, uid, ids, context=None): icp = self.pool['ir.config_parameter'] return { 'auth_admin_passkey_send_to_admin': safe_eval(icp.get_param( cr, uid, 'auth_admin_passkey.send_to_admin', 'True')), } def set_auth_admin_passkey_send_to_admin(self, cr, uid, ids, context=None): config = self.browse(cr, uid, ids[0], context=context) icp = self.pool['ir.config_parameter'] icp.set_param( cr, uid, 'auth_admin_passkey.send_to_admin', repr(config.auth_admin_passkey_send_to_admin)) def get_default_auth_admin_passkey_send_to_user( self, cr, uid, ids, context=None): icp = self.pool['ir.config_parameter'] return { 'auth_admin_passkey_send_to_user': safe_eval(icp.get_param( cr, uid, 'auth_admin_passkey.send_to_user', 'True')), } def set_auth_admin_passkey_send_to_user(self, cr, uid, ids, context=None): config = self.browse(cr, uid, ids[0], context=context) icp = self.pool['ir.config_parameter'] icp.set_param( cr, uid, 'auth_admin_passkey.send_to_user', repr(config.auth_admin_passkey_send_to_user)) # Columns Section _columns = { 'auth_admin_passkey_send_to_admin': fields.boolean( 'Send email to admin user.', help="""When the administrator use his password to login in """ """with a different account, OpenERP will send an email """ """to the admin user.""", ), 'auth_admin_passkey_send_to_user': fields.boolean( string='Send email to user.', help="""When the administrator use his password to login in """ """with a different account, OpenERP will send an email """ """to the account user.""", ), }
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 9516, 8325, 498, 859, 367, 7653, 199, 3, 259, 1898, 334, 35, 9, 6171, 13, 7280, 21772, 1282, 334, 1014, 921, 1544, 14, 926, 80, 14, 331, 411, 9, 199, 3, 259, 768, 2502, 5515, 6371, 1581, 6124, 598, 748, 334, 2859, 921, 13746, 14, 957, 15, 9666, 1786, 6371, 1581, 9, 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, 1504, 199, 504, 5166, 14, 4795, 14, 1025, 492, 19894, 14928, 1685, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 421, 199, 533, 1300, 63, 888, 63, 1751, 8, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 1095, 14, 888, 14, 1751, 7, 339, 327, 2372, 351, 1182, 2494, 351, 15247, 272, 347, 664, 63, 885, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 8, 288, 291, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 372, 469, 288, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 356, 5048, 63, 2579, 8, 530, 80, 14, 362, 63, 635, 8, 355, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 2113, 297, 283, 549, 3855, 267, 789, 339, 347, 663, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 9, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 284, 1850, 14, 409, 63, 635, 8, 288, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 2113, 297, 288, 4700, 8, 888, 14, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 430, 339, 347, 664, 63, 885, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 8, 288, 291, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 372, 469, 288, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 356, 5048, 63, 2579, 8, 530, 80, 14, 362, 63, 635, 8, 355, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 751, 297, 283, 549, 3855, 267, 789, 339, 347, 663, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 9, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 284, 1850, 14, 409, 63, 635, 8, 288, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 751, 297, 288, 4700, 8, 888, 14, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 430, 339, 327, 3626, 2346, 15247, 272, 485, 3406, 275, 469, 267, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 356, 1504, 14, 4871, 8, 288, 283, 6795, 3031, 370, 4628, 922, 3130, 288, 1720, 11916, 11423, 314, 31056, 675, 17049, 2505, 370, 4676, 315, 408, 288, 408, 1045, 282, 3365, 2933, 12, 7653, 911, 3222, 376, 3031, 408, 288, 408, 475, 314, 4628, 922, 17129, 267, 2318, 267, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 356, 1504, 14, 4871, 8, 288, 1059, 534, 6795, 3031, 370, 922, 3130, 288, 1720, 11916, 11423, 314, 31056, 675, 17049, 2505, 370, 4676, 315, 408, 288, 408, 1045, 282, 3365, 2933, 12, 7653, 911, 3222, 376, 3031, 408, 288, 408, 475, 314, 2933, 922, 17129, 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 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 9516, 8325, 498, 859, 367, 7653, 199, 3, 259, 1898, 334, 35, 9, 6171, 13, 7280, 21772, 1282, 334, 1014, 921, 1544, 14, 926, 80, 14, 331, 411, 9, 199, 3, 259, 768, 2502, 5515, 6371, 1581, 6124, 598, 748, 334, 2859, 921, 13746, 14, 957, 15, 9666, 1786, 6371, 1581, 9, 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, 1504, 199, 504, 5166, 14, 4795, 14, 1025, 492, 19894, 14928, 1685, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 421, 199, 533, 1300, 63, 888, 63, 1751, 8, 14612, 14928, 1685, 304, 272, 485, 6486, 275, 283, 1095, 14, 888, 14, 1751, 7, 339, 327, 2372, 351, 1182, 2494, 351, 15247, 272, 347, 664, 63, 885, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 8, 288, 291, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 372, 469, 288, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 356, 5048, 63, 2579, 8, 530, 80, 14, 362, 63, 635, 8, 355, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 2113, 297, 283, 549, 3855, 267, 789, 339, 347, 663, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 9, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 284, 1850, 14, 409, 63, 635, 8, 288, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 2113, 297, 288, 4700, 8, 888, 14, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 430, 339, 347, 664, 63, 885, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 8, 288, 291, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 372, 469, 288, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 356, 5048, 63, 2579, 8, 530, 80, 14, 362, 63, 635, 8, 355, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 751, 297, 283, 549, 3855, 267, 789, 339, 347, 663, 63, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 9, 267, 284, 1850, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 284, 1850, 14, 409, 63, 635, 8, 288, 2467, 12, 1747, 12, 283, 1178, 63, 2113, 63, 1529, 498, 14, 2254, 63, 475, 63, 751, 297, 288, 4700, 8, 888, 14, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 430, 339, 327, 3626, 2346, 15247, 272, 485, 3406, 275, 469, 267, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 2113, 356, 1504, 14, 4871, 8, 288, 283, 6795, 3031, 370, 4628, 922, 3130, 288, 1720, 11916, 11423, 314, 31056, 675, 17049, 2505, 370, 4676, 315, 408, 288, 408, 1045, 282, 3365, 2933, 12, 7653, 911, 3222, 376, 3031, 408, 288, 408, 475, 314, 4628, 922, 17129, 267, 2318, 267, 283, 1178, 63, 2113, 63, 1529, 498, 63, 2254, 63, 475, 63, 751, 356, 1504, 14, 4871, 8, 288, 1059, 534, 6795, 3031, 370, 922, 3130, 288, 1720, 11916, 11423, 314, 31056, 675, 17049, 2505, 370, 4676, 315, 408, 288, 408, 1045, 282, 3365, 2933, 12, 7653, 911, 3222, 376, 3031, 408, 288, 408, 475, 314, 2933, 922, 17129, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
blaggacao/OpenUpgrade
addons/board/__init__.py
439
1144
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2010-2012 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/>. # ############################################################################## import board import controllers # 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, 259, 1898, 334, 35, 9, 7129, 13, 7409, 7653, 308, 14, 65, 14, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 13811, 199, 646, 27325, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 259, 1898, 334, 35, 9, 7129, 13, 7409, 7653, 308, 14, 65, 14, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 13811, 199, 646, 27325, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gwparikh/cvgui
grouping_calibration.py
2
9402
#!/usr/bin/env python import os, sys, subprocess import argparse import subprocess import threading import timeit from multiprocessing import Queue, Lock from configobj import ConfigObj from numpy import loadtxt from numpy.linalg import inv import matplotlib.pyplot as plt import moving from cvguipy import trajstorage, cvgenetic, cvconfig """ Grouping Calibration By Genetic Algorithm. This script uses genetic algorithm to search for the best configuration. It does not monitor RAM usage, therefore, CPU thrashing might be happened when number of parents (selection size) is too large. """ # class for genetic algorithm class GeneticCompare(object): def __init__(self, motalist, motplist, IDlist, cfg_list, lock): self.motalist = motalist self.motplist = motplist self.IDlist = IDlist self.cfg_list = cfg_list self.lock = lock # This is used for calculte fitness of individual in genetic algorithn. # It is modified to create sqlite and cfg file before tuning computeClearMOT. # NOTE errors show up when loading two same ID def computeMOT(self, i): # create sqlite and cfg file with id i cfg_name = config_files +str(i)+'.cfg' sql_name = sqlite_files +str(i)+'.sqlite' open(cfg_name,'w').close() config = ConfigObj(cfg_name) cfg_list.write_config(i ,config) command = ['cp', 'tracking_only.sqlite', sql_name] process = subprocess.Popen(command) process.wait() command = ['trajextract.py', args.inputVideo, '-o', args.homography, '-t', cfg_name, '-d', sql_name, '--gf'] # suppress output of grouping extraction devnull = open(os.devnull, 'wb') process = subprocess.Popen(command, stdout = devnull) process.wait() obj = trajstorage.CVsqlite(sql_name) print "loading", i obj.loadObjects() motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(cdb.annotations, obj.objects, args.matchDistance, firstFrame, lastFrame) if motp is None: motp = 0 self.lock.acquire() self.IDlist.put(i) self.motplist.put(motp) self.motalist.put(mota) obj.close() if args.PrintMOTA: print("ID: mota:{} motp:{}".format(mota, motp)) self.lock.release() return mota if __name__ == '__main__' : parser = argparse.ArgumentParser(description="compare all sqlites that are created by cfg_combination.py to the Annotated version to find the ID of the best configuration") parser.add_argument('inputVideo', help= "input video filename") parser.add_argument('-r', '--configuration-file', dest='range_cfg', help= "the configuration-file contain the range of configuration") parser.add_argument('-t', '--traffintel-config', dest='traffintelConfig', help= "the TrafficIntelligence file to use for running the first extraction.") parser.add_argument('-m', '--mask-File', dest='maskFilename', help="Name of the mask-File for trajextract") parser.add_argument('-d', '--database-file', dest ='databaseFile', help ="Name of the databaseFile.") parser.add_argument('-o', '--homography-file', dest ='homography', help = "Name of the homography file.", required = True) parser.add_argument('-md', '--matching-distance', dest='matchDistance', help = "matchDistance", default = 10, type = float) parser.add_argument('-a', '--accuracy', dest = 'accuracy', help = "accuracy parameter for genetic algorithm", type = int) parser.add_argument('-p', '--population', dest = 'population', help = "population parameter for genetic algorithm", required = True, type = int) parser.add_argument('-np', '--num-of-parents', dest = 'num_of_parents', help = "Number of parents that are selected each generation", type = int) parser.add_argument('-mota', '--print-MOTA', dest='PrintMOTA', action = 'store_true', help = "Print MOTA for each ID.") args = parser.parse_args() os.mkdir('cfg_files') os.mkdir('sql_files') sqlite_files = "sql_files/Sqlite_ID_" config_files = "cfg_files/Cfg_ID_" # ------------------initialize annotated version if not existed ---------- # # inputVideo check if not os.path.exists(args.inputVideo): print("Input video {} does not exist! Exiting...".format(args.inputVideo)) sys.exit(1) # configuration file check if args.range_cfg is None: config = ConfigObj('range.cfg') else: config = ConfigObj(args.range_cfg) # get configuration and put them to a List cfg_list = cvconfig.CVConfigList() thread_cfgtolist = threading.Thread(target = cvconfig.config_to_list, args = (cfg_list, config)) thread_cfgtolist.start(); # check if dbfile name is entered if args.databaseFile is None: print("Database-file is not entered, running trajextract and cvplayer.") if not os.path.exists(args.homography): print("Homography file does not exist! Exiting...") sys.exit(1) else: videofile=args.inputVideo if 'avi' in videofile: if args.maskFilename is not None: command = ['trajextract.py',args.inputVideo,'-m', args.maskFilename,'-o', args.homography] else: command = ['trajextract.py',args.inputVideo,'-o', args.homography] process = subprocess.Popen(command) process.wait() databaseFile = videofile.replace('avi','sqlite') command = ['cvplayer.py',args.inputVideo,'-d',databaseFile,'-o',args.homography] process = subprocess.Popen(command) process.wait() else: print("Input video {} is not 'avi' type. Exiting...".format(args.inputVideo)) sys.exit(1) else: databaseFile = args.databaseFile thread_cfgtolist.join() # ------------------Done initialization for annotation-------------------- # # create first tracking only database template. print("creating the first tracking only database template.") if args.maskFilename is not None: command = map(str, ['trajextract.py',args.inputVideo, '-d', 'tracking_only.sqlite', '-t', args.traffintelConfig, '-o', args.homography, '-m', args.maskFilename, '--tf']) else: command = map(str, ['trajextract.py',args.inputVideo, '-d', sql_name, '-t', args.traffintelConfig, '-o', args.homography, '--tf']) process = subprocess.Popen(command) process.wait() # ----start using genetic algorithm to search for best configuration-------# start = timeit.default_timer() dbfile = databaseFile; homography = loadtxt(args.homography) cdb = trajstorage.CVsqlite(dbfile) cdb.open() cdb.getLatestAnnotation() cdb.createBoundingBoxTable(cdb.latestannotations, inv(homography)) cdb.loadAnnotaion() for a in cdb.annotations: a.computeCentroidTrajectory(homography) print "Latest Annotaions in "+dbfile+": ", cdb.latestannotations cdb.frameNumbers = cdb.getFrameList() firstFrame = cdb.frameNumbers[0] lastFrame = cdb.frameNumbers[-1] foundmota = Queue() foundmotp = Queue() IDs = Queue() lock = Lock() Comp = GeneticCompare(foundmota, foundmotp, IDs, cfg_list, lock) if args.accuracy != None: GeneticCal = cvgenetic.CVGenetic(args.population, cfg_list, Comp.computeMOT, args.accuracy) else: GeneticCal = cvgenetic.CVGenetic(args.population, cfg_list, Comp.computeMOT) if args.num_of_parents != None: GeneticCal.run_thread(args.num_of_parents) else: GeneticCal.run_thread() # tranform queues to lists foundmota = cvgenetic.Queue_to_list(foundmota) foundmotp = cvgenetic.Queue_to_list(foundmotp) IDs = cvgenetic.Queue_to_list(IDs) for i in range(len(foundmotp)): foundmotp[i] /= args.matchDistance Best_mota = max(foundmota) Best_ID = IDs[foundmota.index(Best_mota)] print "Best multiple object tracking accuracy (MOTA)", Best_mota print "ID:", Best_ID stop = timeit.default_timer() print str(stop-start) + "s" total = [] for i in range(len(foundmota)): total.append(foundmota[i]- 0.1 * foundmotp[i]) Best_total = max(total) Best_total_ID = IDs[total.index(Best_total)] # ------------------------------Done searching----------------------------# # use matplot to plot a graph of all calculated IDs along with thier mota plt.figure(1) plt.plot(foundmota ,IDs ,'bo') plt.plot(foundmotp ,IDs ,'yo') plt.plot(Best_mota, Best_ID, 'ro') plt.axis([-1, 1, -1, cfg_list.get_total_combination()]) plt.xlabel('mota') plt.ylabel('ID') plt.title(b'Best MOTA: '+str(Best_mota) +'\nwith ID: '+str(Best_ID)) plotFile = os.path.splitext(dbfile)[0] + '_CalibrationResult_mota.png' plt.savefig(plotFile) plt.figure(2) plt.plot(total, IDs, 'bo') plt.plot(Best_total, Best_total_ID, 'ro') plt.xlabel('mota + motp') plt.ylabel('ID') plt.title(b'Best total: '+str(Best_total) +'\nwith ID: '+str(Best_total_ID)) # save the plot plotFile = os.path.splitext(dbfile)[0] + '_CalibrationResult_motp.png' plt.savefig(plotFile) plt.show() cdb.close()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 12, 984, 12, 3873, 199, 646, 7534, 199, 646, 3873, 199, 646, 5796, 199, 646, 900, 390, 199, 504, 12866, 492, 10703, 12, 15536, 199, 504, 1101, 1113, 492, 4094, 5665, 199, 504, 2680, 492, 2248, 2424, 199, 504, 2680, 14, 10096, 492, 4572, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 12876, 199, 504, 6277, 5885, 647, 492, 1468, 74, 3494, 12, 6277, 10654, 764, 12, 6277, 888, 199, 199, 624, 221, 199, 2448, 316, 8256, 1892, 1754, 4885, 598, 6349, 764, 23823, 14, 199, 2765, 2884, 4440, 15599, 764, 5563, 370, 2754, 367, 314, 5526, 2897, 14, 199, 199, 7940, 1630, 440, 8372, 30207, 4503, 12, 16119, 12, 11952, 294, 82, 1119, 316, 5594, 506, 21056, 1380, 1329, 402, 8623, 334, 5592, 1568, 9, 365, 4634, 7031, 14, 221, 199, 624, 199, 3, 1021, 367, 15599, 764, 5563, 199, 533, 598, 6349, 764, 16051, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 333, 1735, 631, 12, 333, 357, 10265, 12, 2870, 513, 12, 4810, 63, 513, 12, 4650, 304, 267, 291, 14, 77, 1735, 631, 275, 333, 1735, 631, 267, 291, 14, 30034, 10265, 275, 333, 357, 10265, 267, 291, 14, 998, 513, 275, 2870, 513, 267, 291, 14, 4128, 63, 513, 275, 4810, 63, 513, 267, 291, 14, 831, 275, 4650, 2286, 327, 961, 365, 1202, 367, 6966, 266, 5542, 4171, 402, 8212, 315, 15599, 764, 741, 3497, 78, 14, 272, 327, 2779, 365, 6042, 370, 1218, 11723, 436, 4810, 570, 2544, 15486, 316, 4526, 9721, 27235, 14, 272, 327, 6944, 2552, 2498, 1536, 1380, 8697, 2877, 2011, 2870, 272, 347, 4526, 27235, 8, 277, 12, 284, 304, 2728, 327, 1218, 11723, 436, 4810, 570, 543, 1305, 284, 267, 4810, 63, 354, 275, 1101, 63, 1725, 435, 495, 8, 73, 6393, 1370, 4128, 7, 267, 3875, 63, 354, 275, 11723, 63, 1725, 435, 495, 8, 73, 6393, 1370, 10659, 7, 267, 1551, 8, 4128, 63, 354, 2584, 87, 1959, 1600, 342, 267, 1101, 275, 4094, 5665, 8, 4128, 63, 354, 9, 267, 4810, 63, 513, 14, 952, 63, 888, 8, 73, 2360, 888, 9, 267, 1414, 275, 788, 1850, 297, 283, 14428, 63, 2118, 14, 10659, 297, 3875, 63, 354, 61, 267, 2112, 275, 3873, 14, 7942, 8, 1531, 9, 267, 2112, 14, 2573, 342, 267, 1414, 275, 788, 22788, 5005, 14, 647, 297, 1249, 14, 1210, 9166, 12, 2475, 79, 297, 1249, 14, 526, 573, 9773, 12, 2475, 84, 297, 4810, 63, 354, 12, 2475, 68, 297, 3875, 63, 354, 12, 2850, 7102, 418, 267, 327, 15678, 1072, 402, 17786, 19967, 267, 4866, 2307, 275, 1551, 8, 736, 14, 19778, 12, 283, 6603, 358, 267, 2112, 275, 3873, 14, 7942, 8, 1531, 12, 3839, 275, 4866, 2307, 9, 267, 2112, 14, 2573, 342, 2728, 1559, 275, 1468, 74, 3494, 14, 12847, 10659, 8, 3009, 63, 354, 9, 267, 870, 298, 8786, 401, 284, 267, 1559, 14, 912, 11188, 342, 267, 333, 357, 80, 12, 333, 12041, 12, 19592, 12, 333, 278, 12, 289, 541, 12, 16484, 275, 12876, 14, 3357, 9721, 27235, 8, 24035, 14, 11270, 12, 1559, 14, 1462, 12, 1249, 14, 1431, 10076, 12, 1642, 3160, 12, 2061, 3160, 9, 267, 340, 333, 357, 80, 365, 488, 26, 288, 333, 357, 80, 275, 378, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 14, 998, 513, 14, 524, 8, 73, 9, 267, 291, 14, 30034, 10265, 14, 524, 8, 30034, 80, 9, 267, 291, 14, 77, 1735, 631, 14, 524, 8, 77, 12041, 9, 267, 1559, 14, 1600, 342, 267, 340, 1249, 14, 5375, 27235, 33, 26, 288, 870, 480, 998, 26, 333, 12041, 29930, 333, 357, 80, 26, 13536, 908, 8, 77, 12041, 12, 333, 357, 80, 430, 267, 291, 14, 831, 14, 3221, 342, 10631, 372, 333, 12041, 268, 199, 692, 636, 354, 363, 508, 2560, 973, 12217, 520, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 5785, 1006, 5295, 317, 744, 626, 787, 2737, 701, 4810, 63, 6560, 3155, 14, 647, 370, 314, 1626, 1397, 972, 1015, 370, 2342, 314, 2870, 402, 314, 5526, 2897, 531, 272, 1798, 14, 525, 63, 2094, 360, 1210, 9166, 297, 1720, 29, 298, 1210, 3991, 1788, 531, 272, 1798, 14, 525, 63, 2094, 3654, 82, 297, 2850, 4758, 13, 493, 297, 2053, 534, 1842, 63, 4128, 297, 1720, 29, 298, 1589, 2897, 13, 493, 1395, 314, 1425, 402, 2897, 531, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1239, 556, 22264, 13, 888, 297, 2053, 534, 1239, 556, 22264, 2028, 297, 1720, 29, 298, 1589, 12643, 8376, 8309, 31566, 570, 370, 675, 367, 3879, 314, 1642, 19967, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 77, 297, 2850, 2629, 13, 1173, 297, 2053, 534, 2629, 8117, 297, 1720, 628, 985, 402, 314, 3656, 13, 1173, 367, 1468, 74, 5005, 531, 272, 1798, 14, 525, 63, 2094, 3654, 68, 297, 2850, 4659, 13, 493, 297, 2053, 275, 7, 4659, 1173, 297, 1720, 29049, 985, 402, 314, 3050, 1173, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 79, 297, 2850, 526, 573, 9773, 13, 493, 297, 2053, 275, 7, 526, 573, 9773, 297, 1720, 275, 298, 985, 402, 314, 2636, 573, 9773, 570, 4765, 1415, 275, 715, 9, 272, 1798, 14, 525, 63, 2094, 3654, 1064, 297, 2850, 9467, 13, 5590, 297, 2053, 534, 1431, 10076, 297, 1720, 275, 298, 1431, 10076, 401, 849, 275, 1616, 12, 730, 275, 2069, 9, 272, 1798, 14, 525, 63, 2094, 3654, 65, 297, 2850, 13374, 297, 2053, 275, 283, 13374, 297, 1720, 275, 298, 13374, 2725, 367, 15599, 764, 5563, 401, 730, 275, 1109, 9, 272, 1798, 14, 525, 63, 2094, 3654, 80, 297, 2850, 16003, 297, 2053, 275, 283, 16003, 297, 1720, 275, 298, 16003, 2725, 367, 15599, 764, 5563, 401, 1415, 275, 715, 12, 730, 275, 1109, 9, 272, 1798, 14, 525, 63, 2094, 3654, 1590, 297, 2850, 1507, 13, 1618, 13, 8859, 297, 2053, 275, 283, 1507, 63, 1618, 63, 8859, 297, 1720, 275, 298, 3259, 402, 8623, 626, 787, 4895, 1924, 10152, 401, 730, 275, 1109, 9, 272, 1798, 14, 525, 63, 2094 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 12, 984, 12, 3873, 199, 646, 7534, 199, 646, 3873, 199, 646, 5796, 199, 646, 900, 390, 199, 504, 12866, 492, 10703, 12, 15536, 199, 504, 1101, 1113, 492, 4094, 5665, 199, 504, 2680, 492, 2248, 2424, 199, 504, 2680, 14, 10096, 492, 4572, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 12876, 199, 504, 6277, 5885, 647, 492, 1468, 74, 3494, 12, 6277, 10654, 764, 12, 6277, 888, 199, 199, 624, 221, 199, 2448, 316, 8256, 1892, 1754, 4885, 598, 6349, 764, 23823, 14, 199, 2765, 2884, 4440, 15599, 764, 5563, 370, 2754, 367, 314, 5526, 2897, 14, 199, 199, 7940, 1630, 440, 8372, 30207, 4503, 12, 16119, 12, 11952, 294, 82, 1119, 316, 5594, 506, 21056, 1380, 1329, 402, 8623, 334, 5592, 1568, 9, 365, 4634, 7031, 14, 221, 199, 624, 199, 3, 1021, 367, 15599, 764, 5563, 199, 533, 598, 6349, 764, 16051, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 333, 1735, 631, 12, 333, 357, 10265, 12, 2870, 513, 12, 4810, 63, 513, 12, 4650, 304, 267, 291, 14, 77, 1735, 631, 275, 333, 1735, 631, 267, 291, 14, 30034, 10265, 275, 333, 357, 10265, 267, 291, 14, 998, 513, 275, 2870, 513, 267, 291, 14, 4128, 63, 513, 275, 4810, 63, 513, 267, 291, 14, 831, 275, 4650, 2286, 327, 961, 365, 1202, 367, 6966, 266, 5542, 4171, 402, 8212, 315, 15599, 764, 741, 3497, 78, 14, 272, 327, 2779, 365, 6042, 370, 1218, 11723, 436, 4810, 570, 2544, 15486, 316, 4526, 9721, 27235, 14, 272, 327, 6944, 2552, 2498, 1536, 1380, 8697, 2877, 2011, 2870, 272, 347, 4526, 27235, 8, 277, 12, 284, 304, 2728, 327, 1218, 11723, 436, 4810, 570, 543, 1305, 284, 267, 4810, 63, 354, 275, 1101, 63, 1725, 435, 495, 8, 73, 6393, 1370, 4128, 7, 267, 3875, 63, 354, 275, 11723, 63, 1725, 435, 495, 8, 73, 6393, 1370, 10659, 7, 267, 1551, 8, 4128, 63, 354, 2584, 87, 1959, 1600, 342, 267, 1101, 275, 4094, 5665, 8, 4128, 63, 354, 9, 267, 4810, 63, 513, 14, 952, 63, 888, 8, 73, 2360, 888, 9, 267, 1414, 275, 788, 1850, 297, 283, 14428, 63, 2118, 14, 10659, 297, 3875, 63, 354, 61, 267, 2112, 275, 3873, 14, 7942, 8, 1531, 9, 267, 2112, 14, 2573, 342, 267, 1414, 275, 788, 22788, 5005, 14, 647, 297, 1249, 14, 1210, 9166, 12, 2475, 79, 297, 1249, 14, 526, 573, 9773, 12, 2475, 84, 297, 4810, 63, 354, 12, 2475, 68, 297, 3875, 63, 354, 12, 2850, 7102, 418, 267, 327, 15678, 1072, 402, 17786, 19967, 267, 4866, 2307, 275, 1551, 8, 736, 14, 19778, 12, 283, 6603, 358, 267, 2112, 275, 3873, 14, 7942, 8, 1531, 12, 3839, 275, 4866, 2307, 9, 267, 2112, 14, 2573, 342, 2728, 1559, 275, 1468, 74, 3494, 14, 12847, 10659, 8, 3009, 63, 354, 9, 267, 870, 298, 8786, 401, 284, 267, 1559, 14, 912, 11188, 342, 267, 333, 357, 80, 12, 333, 12041, 12, 19592, 12, 333, 278, 12, 289, 541, 12, 16484, 275, 12876, 14, 3357, 9721, 27235, 8, 24035, 14, 11270, 12, 1559, 14, 1462, 12, 1249, 14, 1431, 10076, 12, 1642, 3160, 12, 2061, 3160, 9, 267, 340, 333, 357, 80, 365, 488, 26, 288, 333, 357, 80, 275, 378, 267, 291, 14, 831, 14, 8174, 342, 267, 291, 14, 998, 513, 14, 524, 8, 73, 9, 267, 291, 14, 30034, 10265, 14, 524, 8, 30034, 80, 9, 267, 291, 14, 77, 1735, 631, 14, 524, 8, 77, 12041, 9, 267, 1559, 14, 1600, 342, 267, 340, 1249, 14, 5375, 27235, 33, 26, 288, 870, 480, 998, 26, 333, 12041, 29930, 333, 357, 80, 26, 13536, 908, 8, 77, 12041, 12, 333, 357, 80, 430, 267, 291, 14, 831, 14, 3221, 342, 10631, 372, 333, 12041, 268, 199, 692, 636, 354, 363, 508, 2560, 973, 12217, 520, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 5785, 1006, 5295, 317, 744, 626, 787, 2737, 701, 4810, 63, 6560, 3155, 14, 647, 370, 314, 1626, 1397, 972, 1015, 370, 2342, 314, 2870, 402, 314, 5526, 2897, 531, 272, 1798, 14, 525, 63, 2094, 360, 1210, 9166, 297, 1720, 29, 298, 1210, 3991, 1788, 531, 272, 1798, 14, 525, 63, 2094, 3654, 82, 297, 2850, 4758, 13, 493, 297, 2053, 534, 1842, 63, 4128, 297, 1720, 29, 298, 1589, 2897, 13, 493, 1395, 314, 1425, 402, 2897, 531, 272, 1798, 14, 525, 63, 2094, 3654, 84, 297, 2850, 1239, 556, 22264, 13, 888, 297, 2053, 534, 1239, 556, 22264, 2028, 297, 1720, 29, 298, 1589, 12643, 8376, 8309, 31566, 570, 370, 675, 367, 3879, 314, 1642, 19967, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 77, 297, 2850, 2629, 13, 1173, 297, 2053, 534, 2629, 8117, 297, 1720, 628, 985, 402, 314, 3656, 13, 1173, 367, 1468, 74, 5005, 531, 272, 1798, 14, 525, 63, 2094, 3654, 68, 297, 2850, 4659, 13, 493, 297, 2053, 275, 7, 4659, 1173, 297, 1720, 29049, 985, 402, 314, 3050, 1173, 2685, 272, 1798, 14, 525, 63, 2094, 3654, 79, 297, 2850, 526, 573, 9773, 13, 493, 297, 2053, 275, 7, 526, 573, 9773, 297, 1720, 275, 298, 985, 402, 314, 2636, 573, 9773, 570, 4765, 1415, 275, 715, 9, 272, 1798, 14, 525, 63, 2094, 3654, 1064, 297, 2850, 9467, 13, 5590, 297, 2053, 534, 1431, 10076, 297, 1720, 275, 298, 1431, 10076, 401, 849, 275, 1616, 12, 730, 275, 2069, 9, 272, 1798, 14, 525, 63, 2094, 3654, 65, 297, 2850, 13374, 297, 2053, 275, 283, 13374, 297, 1720, 275, 298, 13374, 2725, 367, 15599, 764, 5563, 401, 730, 275, 1109, 9, 272, 1798, 14, 525, 63, 2094, 3654, 80, 297, 2850, 16003, 297, 2053, 275, 283, 16003, 297, 1720, 275, 298, 16003, 2725, 367, 15599, 764, 5563, 401, 1415, 275, 715, 12, 730, 275, 1109, 9, 272, 1798, 14, 525, 63, 2094, 3654, 1590, 297, 2850, 1507, 13, 1618, 13, 8859, 297, 2053, 275, 283, 1507, 63, 1618, 63, 8859, 297, 1720, 275, 298, 3259, 402, 8623, 626, 787, 4895, 1924, 10152, 401, 730, 275, 1109, 9, 272, 1798, 14, 525, 63, 2094, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
davidvon/pipa-pay-server
site-packages/jinja2/bccache.py
256
12289
# -*- coding: utf-8 -*- """ jinja2.bccache ~~~~~~~~~~~~~~ This module implements the bytecode cache system Jinja is optionally using. This is useful if you have very complex template situations and the compiliation of all those templates slow down your application too much. Situations where this is useful are often forking web applications that are initialized on the first request. :copyright: (c) 2010 by the Jinja Team. :license: BSD. """ from os import path, listdir import os import stat import sys import errno import marshal import tempfile import fnmatch from hashlib import sha1 from jinja2.utils import open_if_exists from jinja2._compat import BytesIO, pickle, PY2, text_type # marshal works better on 3.x, one hack less required if not PY2: marshal_dump = marshal.dump marshal_load = marshal.load else: def marshal_dump(code, f): if isinstance(f, file): marshal.dump(code, f) else: f.write(marshal.dumps(code)) def marshal_load(f): if isinstance(f, file): return marshal.load(f) return marshal.loads(f.read()) bc_version = 2 # magic version used to only change with new jinja versions. With 2.6 # we change this to also take Python version changes into account. The # reason for this is that Python tends to segfault if fed earlier bytecode # versions because someone thought it would be a good idea to reuse opcodes # or make Python incompatible with earlier versions. bc_magic = 'j2'.encode('ascii') + \ pickle.dumps(bc_version, 2) + \ pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1]) class Bucket(object): """Buckets are used to store the bytecode for one template. It's created and initialized by the bytecode cache and passed to the loading functions. The buckets get an internal checksum from the cache assigned and use this to automatically reject outdated cache material. Individual bytecode cache subclasses don't have to care about cache invalidation. """ def __init__(self, environment, key, checksum): self.environment = environment self.key = key self.checksum = checksum self.reset() def reset(self): """Resets the bucket (unloads the bytecode).""" self.code = None def load_bytecode(self, f): """Loads bytecode from a file or file like object.""" # make sure the magic header is correct magic = f.read(len(bc_magic)) if magic != bc_magic: self.reset() return # the source code of the file changed, we need to reload checksum = pickle.load(f) if self.checksum != checksum: self.reset() return self.code = marshal_load(f) def write_bytecode(self, f): """Dump the bytecode into the file or file like object passed.""" if self.code is None: raise TypeError('can\'t write empty bucket') f.write(bc_magic) pickle.dump(self.checksum, f, 2) marshal_dump(self.code, f) def bytecode_from_string(self, string): """Load bytecode from a string.""" self.load_bytecode(BytesIO(string)) def bytecode_to_string(self): """Return the bytecode as string.""" out = BytesIO() self.write_bytecode(out) return out.getvalue() class BytecodeCache(object): """To implement your own bytecode cache you have to subclass this class and override :meth:`load_bytecode` and :meth:`dump_bytecode`. Both of these methods are passed a :class:`~jinja2.bccache.Bucket`. A very basic bytecode cache that saves the bytecode on the file system:: from os import path class MyCache(BytecodeCache): def __init__(self, directory): self.directory = directory def load_bytecode(self, bucket): filename = path.join(self.directory, bucket.key) if path.exists(filename): with open(filename, 'rb') as f: bucket.load_bytecode(f) def dump_bytecode(self, bucket): filename = path.join(self.directory, bucket.key) with open(filename, 'wb') as f: bucket.write_bytecode(f) A more advanced version of a filesystem based bytecode cache is part of Jinja2. """ def load_bytecode(self, bucket): """Subclasses have to override this method to load bytecode into a bucket. If they are not able to find code in the cache for the bucket, it must not do anything. """ raise NotImplementedError() def dump_bytecode(self, bucket): """Subclasses have to override this method to write the bytecode from a bucket back to the cache. If it unable to do so it must not fail silently but raise an exception. """ raise NotImplementedError() def clear(self): """Clears the cache. This method is not used by Jinja2 but should be implemented to allow applications to clear the bytecode cache used by a particular environment. """ def get_cache_key(self, name, filename=None): """Returns the unique hash key for this template name.""" hash = sha1(name.encode('utf-8')) if filename is not None: filename = '|' + filename if isinstance(filename, text_type): filename = filename.encode('utf-8') hash.update(filename) return hash.hexdigest() def get_source_checksum(self, source): """Returns a checksum for the source.""" return sha1(source.encode('utf-8')).hexdigest() def get_bucket(self, environment, name, filename, source): """Return a cache bucket for the given template. All arguments are mandatory but filename may be `None`. """ key = self.get_cache_key(name, filename) checksum = self.get_source_checksum(source) bucket = Bucket(environment, key, checksum) self.load_bytecode(bucket) return bucket def set_bucket(self, bucket): """Put the bucket into the cache.""" self.dump_bytecode(bucket) class FileSystemBytecodeCache(BytecodeCache): """A bytecode cache that stores bytecode on the filesystem. It accepts two arguments: The directory where the cache items are stored and a pattern string that is used to build the filename. If no directory is specified a default cache directory is selected. On Windows the user's temp directory is used, on UNIX systems a directory is created for the user in the system temp directory. The pattern can be used to have multiple separate caches operate on the same directory. The default pattern is ``'__jinja2_%s.cache'``. ``%s`` is replaced with the cache key. >>> bcc = FileSystemBytecodeCache('/tmp/jinja_cache', '%s.cache') This bytecode cache supports clearing of the cache using the clear method. """ def __init__(self, directory=None, pattern='__jinja2_%s.cache'): if directory is None: directory = self._get_default_cache_dir() self.directory = directory self.pattern = pattern def _get_default_cache_dir(self): tmpdir = tempfile.gettempdir() # On windows the temporary directory is used specific unless # explicitly forced otherwise. We can just use that. if os.name == 'nt': return tmpdir if not hasattr(os, 'getuid'): raise RuntimeError('Cannot determine safe temp directory. You ' 'need to explicitly provide one.') dirname = '_jinja2-cache-%d' % os.getuid() actual_dir = os.path.join(tmpdir, dirname) try: os.mkdir(actual_dir, stat.S_IRWXU) # 0o700 except OSError as e: if e.errno != errno.EEXIST: raise actual_dir_stat = os.lstat(actual_dir) if actual_dir_stat.st_uid != os.getuid() \ or not stat.S_ISDIR(actual_dir_stat.st_mode) \ or stat.S_IMODE(actual_dir_stat.st_mode) != stat.S_IRWXU: raise RuntimeError('Temporary directory \'%s\' has an incorrect ' 'owner, permissions, or type.' % actual_dir) return actual_dir def _get_cache_filename(self, bucket): return path.join(self.directory, self.pattern % bucket.key) def load_bytecode(self, bucket): f = open_if_exists(self._get_cache_filename(bucket), 'rb') if f is not None: try: bucket.load_bytecode(f) finally: f.close() def dump_bytecode(self, bucket): f = open(self._get_cache_filename(bucket), 'wb') try: bucket.write_bytecode(f) finally: f.close() def clear(self): # imported lazily here because google app-engine doesn't support # write access on the file system and the function does not exist # normally. from os import remove files = fnmatch.filter(listdir(self.directory), self.pattern % '*') for filename in files: try: remove(path.join(self.directory, filename)) except OSError: pass class MemcachedBytecodeCache(BytecodeCache): """This class implements a bytecode cache that uses a memcache cache for storing the information. It does not enforce a specific memcache library (tummy's memcache or cmemcache) but will accept any class that provides the minimal interface required. Libraries compatible with this class: - `werkzeug <http://werkzeug.pocoo.org/>`_.contrib.cache - `python-memcached <http://www.tummy.com/Community/software/python-memcached/>`_ - `cmemcache <http://gijsbert.org/cmemcache/>`_ (Unfortunately the django cache interface is not compatible because it does not support storing binary data, only unicode. You can however pass the underlying cache client to the bytecode cache which is available as `django.core.cache.cache._client`.) The minimal interface for the client passed to the constructor is this: .. class:: MinimalClientInterface .. method:: set(key, value[, timeout]) Stores the bytecode in the cache. `value` is a string and `timeout` the timeout of the key. If timeout is not provided a default timeout or no timeout should be assumed, if it's provided it's an integer with the number of seconds the cache item should exist. .. method:: get(key) Returns the value for the cache key. If the item does not exist in the cache the return value must be `None`. The other arguments to the constructor are the prefix for all keys that is added before the actual cache key and the timeout for the bytecode in the cache system. We recommend a high (or no) timeout. This bytecode cache does not support clearing of used items in the cache. The clear method is a no-operation function. .. versionadded:: 2.7 Added support for ignoring memcache errors through the `ignore_memcache_errors` parameter. """ def __init__(self, client, prefix='jinja2/bytecode/', timeout=None, ignore_memcache_errors=True): self.client = client self.prefix = prefix self.timeout = timeout self.ignore_memcache_errors = ignore_memcache_errors def load_bytecode(self, bucket): try: code = self.client.get(self.prefix + bucket.key) except Exception: if not self.ignore_memcache_errors: raise code = None if code is not None: bucket.bytecode_from_string(code) def dump_bytecode(self, bucket): args = (self.prefix + bucket.key, bucket.bytecode_to_string()) if self.timeout is not None: args += (self.timeout,) try: self.client.set(*args) except Exception: if not self.ignore_memcache_errors: raise
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 3776, 1637, 272, 32202, 1714, 339, 961, 859, 9031, 314, 16855, 2581, 2656, 17300, 365, 14190, 272, 1808, 14, 221, 961, 365, 2997, 340, 1265, 1172, 7437, 6114, 1978, 24325, 436, 272, 314, 1013, 1638, 425, 402, 1006, 5204, 7009, 11999, 3224, 2195, 4223, 4634, 272, 8298, 14, 339, 428, 390, 18012, 2382, 642, 365, 2997, 787, 14115, 14926, 316, 3330, 13103, 626, 272, 787, 10038, 641, 314, 1642, 1056, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 747, 492, 931, 12, 27483, 199, 646, 747, 199, 646, 5672, 199, 646, 984, 199, 646, 7554, 199, 646, 21985, 199, 646, 5549, 199, 646, 15951, 199, 504, 8337, 492, 7793, 17, 199, 504, 10321, 18, 14, 1208, 492, 1551, 63, 692, 63, 2444, 199, 504, 10321, 18, 423, 5819, 492, 11808, 12, 5927, 12, 7843, 18, 12, 1318, 63, 466, 421, 199, 3, 21985, 5419, 8034, 641, 650, 14, 88, 12, 1373, 11176, 6656, 1415, 199, 692, 440, 7843, 18, 26, 272, 21985, 63, 2724, 275, 21985, 14, 2724, 272, 21985, 63, 912, 275, 21985, 14, 912, 199, 2836, 26, 339, 347, 21985, 63, 2724, 8, 600, 12, 289, 304, 267, 340, 1228, 8, 70, 12, 570, 304, 288, 21985, 14, 2724, 8, 600, 12, 289, 9, 267, 587, 26, 288, 289, 14, 952, 8, 18376, 14, 4180, 8, 600, 430, 339, 347, 21985, 63, 912, 8, 70, 304, 267, 340, 1228, 8, 70, 12, 570, 304, 288, 372, 21985, 14, 912, 8, 70, 9, 267, 372, 21985, 14, 3640, 8, 70, 14, 739, 1012, 421, 199, 3776, 63, 1023, 275, 499, 199, 199, 3, 10628, 1015, 1202, 370, 1454, 1570, 543, 892, 10321, 5459, 14, 221, 8777, 499, 14, 22, 199, 3, 781, 1570, 642, 370, 2597, 5452, 2018, 1015, 4493, 1901, 2933, 14, 221, 710, 199, 3, 4499, 367, 642, 365, 626, 2018, 16685, 795, 370, 8812, 1879, 340, 23036, 14119, 16855, 199, 3, 5459, 2952, 17122, 32463, 652, 3955, 506, 282, 6954, 16819, 370, 12598, 27388, 199, 3, 503, 1852, 2018, 18457, 543, 14119, 5459, 14, 199, 3776, 63, 11523, 275, 283, 74, 18, 1370, 2143, 360, 4371, 358, 435, 971, 272, 5927, 14, 4180, 8, 3776, 63, 1023, 12, 499, 9, 435, 971, 272, 5927, 14, 4180, 1332, 1274, 14, 1023, 63, 815, 59, 16, 61, 5213, 5504, 9, 1204, 984, 14, 1023, 63, 815, 59, 17, 566, 421, 199, 533, 31479, 8, 785, 304, 272, 408, 12311, 83, 787, 1202, 370, 3877, 314, 16855, 367, 1373, 1978, 14, 221, 2779, 1159, 2737, 272, 436, 10038, 701, 314, 16855, 2581, 436, 3032, 370, 314, 8697, 3423, 14, 339, 710, 18655, 664, 376, 5007, 9040, 687, 314, 2581, 7943, 436, 675, 642, 272, 370, 5847, 17100, 734, 19074, 2581, 6285, 14, 221, 1010, 15067, 16855, 272, 2581, 9180, 2793, 1133, 1172, 370, 10296, 3595, 2581, 3866, 425, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3734, 12, 790, 12, 9040, 304, 267, 291, 14, 5418, 275, 3734, 267, 291, 14, 498, 275, 790, 267, 291, 14, 8928, 275, 9040, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 408, 497, 2193, 314, 5315, 334, 324, 3640, 314, 16855, 10477, 267, 291, 14, 600, 275, 488, 339, 347, 2248, 63, 19812, 8, 277, 12, 289, 304, 267, 408, 30777, 16855, 687, 282, 570, 503, 570, 2839, 909, 1041, 267, 327, 1852, 3238, 314, 10628, 1406, 365, 3211, 267, 10628, 275, 289, 14, 739, 8, 552, 8, 3776, 63, 11523, 430, 267, 340, 10628, 1137, 16604, 63, 11523, 26, 288, 291, 14, 3958, 342, 288, 372, 267, 327, 314, 1350, 1233, 402, 314, 570, 2896, 12, 781, 1929, 370, 13101, 267, 9040, 275, 5927, 14, 912, 8, 70, 9, 267, 340, 291, 14, 8928, 1137, 9040, 26, 288, 291, 14, 3958, 342, 288, 372, 267, 291, 14, 600, 275, 21985, 63, 912, 8, 70, 9, 339, 347, 2218, 63, 19812, 8, 277, 12, 289, 304, 267, 408, 11772, 314, 16855, 1901, 314, 570, 503, 570, 2839, 909, 3032, 1041, 267, 340, 291, 14, 600, 365, 488, 26, 288, 746, 3146, 360, 2425, 3985, 84, 2218, 2701, 5315, 358, 267, 289, 14, 952, 8, 3776, 63, 11523, 9, 267, 5927, 14, 2724, 8, 277, 14, 8928, 12, 289, 12, 499, 9, 267, 21985, 63, 2724, 8, 277, 14, 600, 12, 289, 9, 339, 347, 16855, 63, 504, 63, 875, 8, 277, 12, 1059, 304, 267, 408, 6200, 16855, 687, 282, 1059, 1041, 267, 291, 14, 912, 63, 19812, 8, 15466, 8, 875, 430, 339, 347, 16855, 63, 475, 63, 875, 8, 277, 304, 267, 408, 1767, 314, 16855, 465, 1059, 1041, 267, 734, 275, 11808, 342, 267, 291, 14, 952, 63, 19812, 8, 548, 9, 267, 372, 734, 14, 7150, 342, 421, 199, 533, 20301, 600, 4437, 8, 785, 304, 272, 408, 1378, 5669, 2195, 5705, 16855, 2581, 1265, 1172, 370, 5516, 642, 1021, 272, 436, 4278, 520, 5247, 1705, 912, 63, 19812, 64, 436, 520, 5247, 1705, 2724, 63, 19812, 2313, 221, 17650, 402, 272, 3520, 3102, 787, 3032, 282, 520, 533, 6054, 12264, 18, 14, 3776, 1637, 14, 12311, 2313, 339, 437, 7437, 5678, 16855, 2581, 626, 23050, 314, 16855, 641, 314, 570, 2656, 447, 398, 687, 747, 492, 931, 398, 1021, 4932, 4437, 8, 4861, 600, 4437, 304, 953, 347, 636, 826, 721, 277, 12, 2082, 304, 355, 291, 14, 3619, 275, 2082, 953, 347, 2248, 63, 19812, 8, 277, 12, 5315, 304, 355, 1788, 275, 931, 14, 904, 8, 277, 14, 3619, 12, 5315, 14, 498, 9, 355, 340, 931, 14, 2444, 8, 1501, 304, 490, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 717, 5315, 14, 912, 63, 19812, 8, 70, 9, 953, 347, 5461, 63, 19812, 8, 277, 12, 5315, 304, 355, 1788, 275, 931, 14, 904, 8, 277, 14, 3619, 12, 5315, 14, 498, 9, 355, 543, 1551, 8, 1501, 12, 283, 6603, 358, 465, 289, 26, 490, 5315, 14, 952, 63, 19812, 8, 70, 9, 339, 437, 1655, 19472 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 3776, 1637, 272, 32202, 1714, 339, 961, 859, 9031, 314, 16855, 2581, 2656, 17300, 365, 14190, 272, 1808, 14, 221, 961, 365, 2997, 340, 1265, 1172, 7437, 6114, 1978, 24325, 436, 272, 314, 1013, 1638, 425, 402, 1006, 5204, 7009, 11999, 3224, 2195, 4223, 4634, 272, 8298, 14, 339, 428, 390, 18012, 2382, 642, 365, 2997, 787, 14115, 14926, 316, 3330, 13103, 626, 272, 787, 10038, 641, 314, 1642, 1056, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 14, 199, 624, 199, 504, 747, 492, 931, 12, 27483, 199, 646, 747, 199, 646, 5672, 199, 646, 984, 199, 646, 7554, 199, 646, 21985, 199, 646, 5549, 199, 646, 15951, 199, 504, 8337, 492, 7793, 17, 199, 504, 10321, 18, 14, 1208, 492, 1551, 63, 692, 63, 2444, 199, 504, 10321, 18, 423, 5819, 492, 11808, 12, 5927, 12, 7843, 18, 12, 1318, 63, 466, 421, 199, 3, 21985, 5419, 8034, 641, 650, 14, 88, 12, 1373, 11176, 6656, 1415, 199, 692, 440, 7843, 18, 26, 272, 21985, 63, 2724, 275, 21985, 14, 2724, 272, 21985, 63, 912, 275, 21985, 14, 912, 199, 2836, 26, 339, 347, 21985, 63, 2724, 8, 600, 12, 289, 304, 267, 340, 1228, 8, 70, 12, 570, 304, 288, 21985, 14, 2724, 8, 600, 12, 289, 9, 267, 587, 26, 288, 289, 14, 952, 8, 18376, 14, 4180, 8, 600, 430, 339, 347, 21985, 63, 912, 8, 70, 304, 267, 340, 1228, 8, 70, 12, 570, 304, 288, 372, 21985, 14, 912, 8, 70, 9, 267, 372, 21985, 14, 3640, 8, 70, 14, 739, 1012, 421, 199, 3776, 63, 1023, 275, 499, 199, 199, 3, 10628, 1015, 1202, 370, 1454, 1570, 543, 892, 10321, 5459, 14, 221, 8777, 499, 14, 22, 199, 3, 781, 1570, 642, 370, 2597, 5452, 2018, 1015, 4493, 1901, 2933, 14, 221, 710, 199, 3, 4499, 367, 642, 365, 626, 2018, 16685, 795, 370, 8812, 1879, 340, 23036, 14119, 16855, 199, 3, 5459, 2952, 17122, 32463, 652, 3955, 506, 282, 6954, 16819, 370, 12598, 27388, 199, 3, 503, 1852, 2018, 18457, 543, 14119, 5459, 14, 199, 3776, 63, 11523, 275, 283, 74, 18, 1370, 2143, 360, 4371, 358, 435, 971, 272, 5927, 14, 4180, 8, 3776, 63, 1023, 12, 499, 9, 435, 971, 272, 5927, 14, 4180, 1332, 1274, 14, 1023, 63, 815, 59, 16, 61, 5213, 5504, 9, 1204, 984, 14, 1023, 63, 815, 59, 17, 566, 421, 199, 533, 31479, 8, 785, 304, 272, 408, 12311, 83, 787, 1202, 370, 3877, 314, 16855, 367, 1373, 1978, 14, 221, 2779, 1159, 2737, 272, 436, 10038, 701, 314, 16855, 2581, 436, 3032, 370, 314, 8697, 3423, 14, 339, 710, 18655, 664, 376, 5007, 9040, 687, 314, 2581, 7943, 436, 675, 642, 272, 370, 5847, 17100, 734, 19074, 2581, 6285, 14, 221, 1010, 15067, 16855, 272, 2581, 9180, 2793, 1133, 1172, 370, 10296, 3595, 2581, 3866, 425, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3734, 12, 790, 12, 9040, 304, 267, 291, 14, 5418, 275, 3734, 267, 291, 14, 498, 275, 790, 267, 291, 14, 8928, 275, 9040, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 408, 497, 2193, 314, 5315, 334, 324, 3640, 314, 16855, 10477, 267, 291, 14, 600, 275, 488, 339, 347, 2248, 63, 19812, 8, 277, 12, 289, 304, 267, 408, 30777, 16855, 687, 282, 570, 503, 570, 2839, 909, 1041, 267, 327, 1852, 3238, 314, 10628, 1406, 365, 3211, 267, 10628, 275, 289, 14, 739, 8, 552, 8, 3776, 63, 11523, 430, 267, 340, 10628, 1137, 16604, 63, 11523, 26, 288, 291, 14, 3958, 342, 288, 372, 267, 327, 314, 1350, 1233, 402, 314, 570, 2896, 12, 781, 1929, 370, 13101, 267, 9040, 275, 5927, 14, 912, 8, 70, 9, 267, 340, 291, 14, 8928, 1137, 9040, 26, 288, 291, 14, 3958, 342, 288, 372, 267, 291, 14, 600, 275, 21985, 63, 912, 8, 70, 9, 339, 347, 2218, 63, 19812, 8, 277, 12, 289, 304, 267, 408, 11772, 314, 16855, 1901, 314, 570, 503, 570, 2839, 909, 3032, 1041, 267, 340, 291, 14, 600, 365, 488, 26, 288, 746, 3146, 360, 2425, 3985, 84, 2218, 2701, 5315, 358, 267, 289, 14, 952, 8, 3776, 63, 11523, 9, 267, 5927, 14, 2724, 8, 277, 14, 8928, 12, 289, 12, 499, 9, 267, 21985, 63, 2724, 8, 277, 14, 600, 12, 289, 9, 339, 347, 16855, 63, 504, 63, 875, 8, 277, 12, 1059, 304, 267, 408, 6200, 16855, 687, 282, 1059, 1041, 267, 291, 14, 912, 63, 19812, 8, 15466, 8, 875, 430, 339, 347, 16855, 63, 475, 63, 875, 8, 277, 304, 267, 408, 1767, 314, 16855, 465, 1059, 1041, 267, 734, 275, 11808, 342, 267, 291, 14, 952, 63, 19812, 8, 548, 9, 267, 372, 734, 14, 7150, 342, 421, 199, 533, 20301, 600, 4437, 8, 785, 304, 272, 408, 1378, 5669, 2195, 5705, 16855, 2581, 1265, 1172, 370, 5516, 642, 1021, 272, 436, 4278, 520, 5247, 1705, 912, 63, 19812, 64, 436, 520, 5247, 1705, 2724, 63, 19812, 2313, 221, 17650, 402, 272, 3520, 3102, 787, 3032, 282, 520, 533, 6054, 12264, 18, 14, 3776, 1637, 14, 12311, 2313, 339, 437, 7437, 5678, 16855, 2581, 626, 23050, 314, 16855, 641, 314, 570, 2656, 447, 398, 687, 747, 492, 931, 398, 1021, 4932, 4437, 8, 4861, 600, 4437, 304, 953, 347, 636, 826, 721, 277, 12, 2082, 304, 355, 291, 14, 3619, 275, 2082, 953, 347, 2248, 63, 19812, 8, 277, 12, 5315, 304, 355, 1788, 275, 931, 14, 904, 8, 277, 14, 3619, 12, 5315, 14, 498, 9, 355, 340, 931, 14, 2444, 8, 1501, 304, 490, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 717, 5315, 14, 912, 63, 19812, 8, 70, 9, 953, 347, 5461, 63, 19812, 8, 277, 12, 5315, 304, 355, 1788, 275, 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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 ]
julianwang/cinder
cinder/openstack/common/fileutils.py
78
4135
# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import contextlib import errno import logging import os import stat import tempfile from oslo_utils import excutils LOG = logging.getLogger(__name__) _FILE_CACHE = {} DEFAULT_MODE = stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO def ensure_tree(path, mode=DEFAULT_MODE): """Create a directory (and any ancestor directories required) :param path: Directory to create :param mode: Directory creation permissions """ try: os.makedirs(path, mode) except OSError as exc: if exc.errno == errno.EEXIST: if not os.path.isdir(path): raise else: raise def read_cached_file(filename, force_reload=False): """Read from a file if it has been modified. :param force_reload: Whether to reload the file. :returns: A tuple with a boolean specifying if the data is fresh or not. """ global _FILE_CACHE if force_reload: delete_cached_file(filename) reloaded = False mtime = os.path.getmtime(filename) cache_info = _FILE_CACHE.setdefault(filename, {}) if not cache_info or mtime > cache_info.get('mtime', 0): LOG.debug("Reloading cached file %s" % filename) with open(filename) as fap: cache_info['data'] = fap.read() cache_info['mtime'] = mtime reloaded = True return (reloaded, cache_info['data']) def delete_cached_file(filename): """Delete cached file if present. :param filename: filename to delete """ global _FILE_CACHE if filename in _FILE_CACHE: del _FILE_CACHE[filename] def delete_if_exists(path, remove=os.unlink): """Delete a file, but ignore file not found error. :param path: File to delete :param remove: Optional function to remove passed path """ try: remove(path) except OSError as e: if e.errno != errno.ENOENT: raise @contextlib.contextmanager def remove_path_on_error(path, remove=delete_if_exists): """Protect code that wants to operate on PATH atomically. Any exception will cause PATH to be removed. :param path: File to work with :param remove: Optional function to remove passed path """ try: yield except Exception: with excutils.save_and_reraise_exception(): remove(path) def file_open(*args, **kwargs): """Open file see built-in open() documentation for more details Note: The reason this is kept in a separate module is to easily be able to provide a stub module that doesn't alter system state at all (for unit tests) """ return open(*args, **kwargs) def write_to_tempfile(content, path=None, suffix='', prefix='tmp'): """Create temporary file or use existing file. This util is needed for creating temporary file with specified content, suffix and prefix. If path is not None, it will be used for writing content. If the path doesn't exist it'll be created. :param content: content for temporary file. :param path: same as parameter 'dir' for mkstemp :param suffix: same as parameter 'suffix' for mkstemp :param prefix: same as parameter 'prefix' for mkstemp For example: it can be used in database tests for creating configuration files. """ if path: ensure_tree(path) (fd, path) = tempfile.mkstemp(suffix=suffix, dir=path, prefix=prefix) try: os.write(fd, content) finally: os.close(fd) return path
apache-2.0
[ 3, 1898, 7760, 14260, 2752, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 15502, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 199, 646, 5672, 199, 646, 5549, 199, 199, 504, 11258, 63, 1208, 492, 32763, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 3817, 63, 8677, 275, 1052, 199, 3472, 63, 6963, 275, 5672, 14, 51, 63, 3927, 16783, 53, 1204, 5672, 14, 51, 63, 3927, 16783, 39, 1204, 5672, 14, 51, 63, 3927, 16783, 47, 421, 199, 318, 4868, 63, 2350, 8, 515, 12, 818, 29, 3472, 63, 6963, 304, 272, 408, 2499, 282, 2082, 334, 460, 1263, 18432, 6602, 1415, 9, 339, 520, 635, 931, 26, 15191, 370, 1218, 272, 520, 635, 818, 26, 15191, 7143, 3443, 272, 408, 272, 862, 26, 267, 747, 14, 8347, 8, 515, 12, 818, 9, 272, 871, 6440, 465, 3178, 26, 267, 340, 3178, 14, 7931, 508, 7554, 14, 28596, 26, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 515, 304, 355, 746, 267, 587, 26, 288, 746, 421, 199, 318, 1586, 63, 5245, 63, 493, 8, 1501, 12, 3542, 63, 9233, 29, 797, 304, 272, 408, 3284, 687, 282, 570, 340, 652, 965, 2757, 6042, 14, 339, 520, 635, 3542, 63, 9233, 26, 7480, 370, 13101, 314, 570, 14, 272, 520, 5808, 26, 437, 2008, 543, 282, 5046, 9176, 340, 314, 666, 365, 17480, 1598, 503, 440, 14, 272, 408, 272, 2288, 485, 3817, 63, 8677, 339, 340, 3542, 63, 9233, 26, 267, 3145, 63, 5245, 63, 493, 8, 1501, 9, 339, 31848, 275, 756, 272, 15005, 275, 747, 14, 515, 14, 26628, 8, 1501, 9, 272, 2581, 63, 815, 275, 485, 3817, 63, 8677, 14, 5486, 8, 1501, 12, 5009, 339, 340, 440, 2581, 63, 815, 503, 15005, 690, 2581, 63, 815, 14, 362, 360, 8180, 297, 378, 304, 267, 5051, 14, 1757, 480, 497, 8786, 6328, 570, 450, 83, 2, 450, 1788, 9, 267, 543, 1551, 8, 1501, 9, 465, 289, 439, 26, 288, 2581, 63, 815, 459, 576, 418, 275, 289, 439, 14, 739, 342, 267, 2581, 63, 815, 459, 8180, 418, 275, 15005, 267, 31848, 275, 715, 272, 372, 334, 264, 4591, 12, 2581, 63, 815, 459, 576, 1105, 421, 199, 318, 3145, 63, 5245, 63, 493, 8, 1501, 304, 272, 408, 5392, 6328, 570, 340, 3451, 14, 339, 520, 635, 1788, 26, 1788, 370, 3145, 272, 408, 272, 2288, 485, 3817, 63, 8677, 339, 340, 1788, 315, 485, 3817, 63, 8677, 26, 267, 2150, 485, 3817, 63, 8677, 59, 1501, 61, 421, 199, 318, 3145, 63, 692, 63, 2444, 8, 515, 12, 2813, 29, 736, 14, 7162, 304, 272, 408, 5392, 282, 570, 12, 1325, 3686, 570, 440, 1911, 1125, 14, 339, 520, 635, 931, 26, 3814, 370, 3145, 272, 520, 635, 2813, 26, 4879, 805, 370, 2813, 3032, 931, 272, 408, 339, 862, 26, 267, 2813, 8, 515, 9, 272, 871, 6440, 465, 325, 26, 267, 340, 325, 14, 7931, 1137, 7554, 14, 20465, 26, 288, 746, 421, 199, 32, 23464, 14, 14237, 199, 318, 2813, 63, 515, 63, 265, 63, 705, 8, 515, 12, 2813, 29, 1807, 63, 692, 63, 2444, 304, 272, 408, 919, 5302, 1233, 626, 15061, 370, 19218, 641, 15097, 6222, 7288, 14, 272, 6184, 1919, 911, 7675, 15097, 370, 506, 4829, 14, 339, 520, 635, 931, 26, 3814, 370, 1736, 543, 272, 520, 635, 2813, 26, 4879, 805, 370, 2813, 3032, 931, 272, 408, 339, 862, 26, 267, 1995, 272, 871, 2186, 26, 267, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 837, 288, 2813, 8, 515, 9, 421, 199, 318, 570, 63, 1490, 2031, 589, 12, 1011, 958, 304, 272, 408, 4299, 570, 339, 1937, 6137, 13, 262, 1551, 342, 3794, 367, 1655, 2436, 339, 3390, 26, 710, 4499, 642, 365, 16204, 315, 282, 7396, 859, 365, 370, 16174, 272, 506, 7688, 370, 5647, 282, 10098, 859, 626, 3181, 1133, 17355, 2656, 272, 1174, 737, 1006, 334, 509, 4137, 2295, 9, 272, 408, 272, 372, 1551, 2031, 589, 12, 1011, 958, 9, 421, 199, 318, 2218, 63, 475, 63, 17336, 8, 1317, 12, 931, 29, 403, 12, 4739, 4581, 2403, 534, 2791, 735, 272, 408, 2499, 7937, 570, 503, 675, 3411, 570, 14, 339, 961, 4884, 365, 4346, 367, 6425, 7937, 570, 543, 272, 2013, 1564, 12, 4739, 436, 2403, 14, 982, 931, 365, 440, 488, 12, 272, 652, 911, 506, 1202, 367, 3575, 1564, 14, 982, 314, 931, 3181, 1133, 272, 2187, 652, 7171, 506, 2737, 14, 339, 520, 635, 1564, 26, 1564, 367, 7937, 570, 14, 272, 520, 635, 931, 26, 2011, 465, 2725, 283, 694, 7, 367, 333, 6080, 808, 272, 520, 635, 4739, 26, 2011, 465, 2725, 283, 4511, 7, 367, 333, 6080, 808, 272, 520, 635, 2403, 26, 2011, 465, 2725, 283, 1861, 7, 367, 333, 6080, 808, 339, 2104, 2893, 26, 652, 883, 506, 1202, 315, 3050, 2295, 367, 6425, 272, 2897, 1584, 14, 272, 408, 272, 340, 931, 26, 267, 4868, 63, 2350, 8, 515, 9, 339, 334, 2592, 12, 931, 9, 275, 5549, 14, 17721, 8, 4511, 29, 4511, 12, 2935, 29, 515, 12, 2403, 29, 1861, 9, 272, 862, 26, 267, 747, 14, 952, 8, 2592, 12, 1564, 9, 272, 3753, 26, 267, 747, 14, 1600, 8, 2592, 9, 272, 372, 931, 199 ]
[ 1898, 7760, 14260, 2752, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 15502, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 199, 646, 5672, 199, 646, 5549, 199, 199, 504, 11258, 63, 1208, 492, 32763, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 3817, 63, 8677, 275, 1052, 199, 3472, 63, 6963, 275, 5672, 14, 51, 63, 3927, 16783, 53, 1204, 5672, 14, 51, 63, 3927, 16783, 39, 1204, 5672, 14, 51, 63, 3927, 16783, 47, 421, 199, 318, 4868, 63, 2350, 8, 515, 12, 818, 29, 3472, 63, 6963, 304, 272, 408, 2499, 282, 2082, 334, 460, 1263, 18432, 6602, 1415, 9, 339, 520, 635, 931, 26, 15191, 370, 1218, 272, 520, 635, 818, 26, 15191, 7143, 3443, 272, 408, 272, 862, 26, 267, 747, 14, 8347, 8, 515, 12, 818, 9, 272, 871, 6440, 465, 3178, 26, 267, 340, 3178, 14, 7931, 508, 7554, 14, 28596, 26, 288, 340, 440, 747, 14, 515, 14, 6027, 8, 515, 304, 355, 746, 267, 587, 26, 288, 746, 421, 199, 318, 1586, 63, 5245, 63, 493, 8, 1501, 12, 3542, 63, 9233, 29, 797, 304, 272, 408, 3284, 687, 282, 570, 340, 652, 965, 2757, 6042, 14, 339, 520, 635, 3542, 63, 9233, 26, 7480, 370, 13101, 314, 570, 14, 272, 520, 5808, 26, 437, 2008, 543, 282, 5046, 9176, 340, 314, 666, 365, 17480, 1598, 503, 440, 14, 272, 408, 272, 2288, 485, 3817, 63, 8677, 339, 340, 3542, 63, 9233, 26, 267, 3145, 63, 5245, 63, 493, 8, 1501, 9, 339, 31848, 275, 756, 272, 15005, 275, 747, 14, 515, 14, 26628, 8, 1501, 9, 272, 2581, 63, 815, 275, 485, 3817, 63, 8677, 14, 5486, 8, 1501, 12, 5009, 339, 340, 440, 2581, 63, 815, 503, 15005, 690, 2581, 63, 815, 14, 362, 360, 8180, 297, 378, 304, 267, 5051, 14, 1757, 480, 497, 8786, 6328, 570, 450, 83, 2, 450, 1788, 9, 267, 543, 1551, 8, 1501, 9, 465, 289, 439, 26, 288, 2581, 63, 815, 459, 576, 418, 275, 289, 439, 14, 739, 342, 267, 2581, 63, 815, 459, 8180, 418, 275, 15005, 267, 31848, 275, 715, 272, 372, 334, 264, 4591, 12, 2581, 63, 815, 459, 576, 1105, 421, 199, 318, 3145, 63, 5245, 63, 493, 8, 1501, 304, 272, 408, 5392, 6328, 570, 340, 3451, 14, 339, 520, 635, 1788, 26, 1788, 370, 3145, 272, 408, 272, 2288, 485, 3817, 63, 8677, 339, 340, 1788, 315, 485, 3817, 63, 8677, 26, 267, 2150, 485, 3817, 63, 8677, 59, 1501, 61, 421, 199, 318, 3145, 63, 692, 63, 2444, 8, 515, 12, 2813, 29, 736, 14, 7162, 304, 272, 408, 5392, 282, 570, 12, 1325, 3686, 570, 440, 1911, 1125, 14, 339, 520, 635, 931, 26, 3814, 370, 3145, 272, 520, 635, 2813, 26, 4879, 805, 370, 2813, 3032, 931, 272, 408, 339, 862, 26, 267, 2813, 8, 515, 9, 272, 871, 6440, 465, 325, 26, 267, 340, 325, 14, 7931, 1137, 7554, 14, 20465, 26, 288, 746, 421, 199, 32, 23464, 14, 14237, 199, 318, 2813, 63, 515, 63, 265, 63, 705, 8, 515, 12, 2813, 29, 1807, 63, 692, 63, 2444, 304, 272, 408, 919, 5302, 1233, 626, 15061, 370, 19218, 641, 15097, 6222, 7288, 14, 272, 6184, 1919, 911, 7675, 15097, 370, 506, 4829, 14, 339, 520, 635, 931, 26, 3814, 370, 1736, 543, 272, 520, 635, 2813, 26, 4879, 805, 370, 2813, 3032, 931, 272, 408, 339, 862, 26, 267, 1995, 272, 871, 2186, 26, 267, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 837, 288, 2813, 8, 515, 9, 421, 199, 318, 570, 63, 1490, 2031, 589, 12, 1011, 958, 304, 272, 408, 4299, 570, 339, 1937, 6137, 13, 262, 1551, 342, 3794, 367, 1655, 2436, 339, 3390, 26, 710, 4499, 642, 365, 16204, 315, 282, 7396, 859, 365, 370, 16174, 272, 506, 7688, 370, 5647, 282, 10098, 859, 626, 3181, 1133, 17355, 2656, 272, 1174, 737, 1006, 334, 509, 4137, 2295, 9, 272, 408, 272, 372, 1551, 2031, 589, 12, 1011, 958, 9, 421, 199, 318, 2218, 63, 475, 63, 17336, 8, 1317, 12, 931, 29, 403, 12, 4739, 4581, 2403, 534, 2791, 735, 272, 408, 2499, 7937, 570, 503, 675, 3411, 570, 14, 339, 961, 4884, 365, 4346, 367, 6425, 7937, 570, 543, 272, 2013, 1564, 12, 4739, 436, 2403, 14, 982, 931, 365, 440, 488, 12, 272, 652, 911, 506, 1202, 367, 3575, 1564, 14, 982, 314, 931, 3181, 1133, 272, 2187, 652, 7171, 506, 2737, 14, 339, 520, 635, 1564, 26, 1564, 367, 7937, 570, 14, 272, 520, 635, 931, 26, 2011, 465, 2725, 283, 694, 7, 367, 333, 6080, 808, 272, 520, 635, 4739, 26, 2011, 465, 2725, 283, 4511, 7, 367, 333, 6080, 808, 272, 520, 635, 2403, 26, 2011, 465, 2725, 283, 1861, 7, 367, 333, 6080, 808, 339, 2104, 2893, 26, 652, 883, 506, 1202, 315, 3050, 2295, 367, 6425, 272, 2897, 1584, 14, 272, 408, 272, 340, 931, 26, 267, 4868, 63, 2350, 8, 515, 9, 339, 334, 2592, 12, 931, 9, 275, 5549, 14, 17721, 8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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 ]
beni55/olympia
apps/amo/search.py
18
10622
import logging from django.conf import settings as dj_settings from django_statsd.clients import statsd from elasticsearch import Elasticsearch log = logging.getLogger('z.es') DEFAULT_HOSTS = ['localhost:9200'] DEFAULT_TIMEOUT = 5 DEFAULT_INDEXES = ['default'] DEFAULT_DUMP_CURL = None def get_es(hosts=None, timeout=None, **settings): """Create an ES object and return it.""" # Cheap way of de-None-ifying things hosts = hosts or getattr(dj_settings, 'ES_HOSTS', DEFAULT_HOSTS) timeout = (timeout if timeout is not None else getattr(dj_settings, 'ES_TIMEOUT', DEFAULT_TIMEOUT)) return Elasticsearch(hosts, timeout=timeout, **settings) class ES(object): def __init__(self, type_, index): self.type = type_ self.index = index self.steps = [] self.start = 0 self.stop = None self.as_list = self.as_dict = False self._results_cache = None def _clone(self, next_step=None): new = self.__class__(self.type, self.index) new.steps = list(self.steps) if next_step: new.steps.append(next_step) new.start = self.start new.stop = self.stop return new def values(self, *fields): return self._clone(next_step=('values', fields)) def values_dict(self, *fields): return self._clone(next_step=('values_dict', fields)) def order_by(self, *fields): return self._clone(next_step=('order_by', fields)) def query(self, **kw): return self._clone(next_step=('query', kw.items())) def filter(self, **kw): return self._clone(next_step=('filter', kw.items())) def facet(self, **kw): return self._clone(next_step=('facet', kw.items())) def source(self, *fields): return self._clone(next_step=('source', fields)) def extra(self, **kw): new = self._clone() actions = 'values values_dict order_by query filter facet'.split() for key, vals in kw.items(): assert key in actions if hasattr(vals, 'items'): new.steps.append((key, vals.items())) else: new.steps.append((key, vals)) return new def count(self): if self._results_cache: return self._results_cache.count else: return self[:0].raw()['hits']['total'] def __len__(self): return len(self._do_search()) def __getitem__(self, k): new = self._clone() # TODO: validate numbers and ranges if isinstance(k, slice): new.start, new.stop = k.start or 0, k.stop return new else: new.start, new.stop = k, k + 1 return list(new)[0] def _build_query(self): filters = [] queries = [] sort = [] fields = ['id'] source = [] facets = {} as_list = as_dict = False for action, value in self.steps: if action == 'order_by': for key in value: if key.startswith('-'): sort.append({key[1:]: 'desc'}) else: sort.append(key) elif action == 'values': fields.extend(value) as_list, as_dict = True, False elif action == 'values_dict': if not value: fields = [] else: fields.extend(value) as_list, as_dict = False, True elif action == 'query': queries.extend(self._process_queries(value)) elif action == 'filter': filters.extend(self._process_filters(value)) elif action == 'source': source.extend(value) elif action == 'facet': facets.update(value) else: raise NotImplementedError(action) if len(queries) > 1: qs = {'bool': {'must': queries}} elif queries: qs = queries[0] else: qs = {"match_all": {}} qs = { "function_score": { "query": qs, "functions": [{"field_value_factor": {"field": "boost"}}] } } if filters: if len(filters) > 1: filters = {"and": filters} qs = { "filtered": { "query": qs, "filter": filters } } body = {"query": qs} if sort: body['sort'] = sort if self.start: body['from'] = self.start if self.stop is not None: body['size'] = self.stop - self.start if facets: body['facets'] = facets if fields: body['fields'] = fields # As per version 1.0, ES has deprecated loading fields not stored from # '_source', plus non leaf fields are not allowed in fields. if source: body['_source'] = source self.fields, self.as_list, self.as_dict = fields, as_list, as_dict return body def _split(self, string): if '__' in string: return string.rsplit('__', 1) else: return string, None def _process_filters(self, value): rv = [] value = dict(value) or_ = value.pop('or_', []) for key, val in value.items(): key, field_action = self._split(key) if field_action is None: rv.append({'term': {key: val}}) if field_action == 'in': rv.append({'in': {key: val}}) elif field_action in ('gt', 'gte', 'lt', 'lte'): rv.append({'range': {key: {field_action: val}}}) elif field_action == 'range': from_, to = val rv.append({'range': {key: {'gte': from_, 'lte': to}}}) if or_: rv.append({'or': self._process_filters(or_.items())}) return rv def _process_queries(self, value): rv = [] value = dict(value) or_ = value.pop('or_', []) for key, val in value.items(): key, field_action = self._split(key) if field_action is None: rv.append({'term': {key: val}}) elif field_action in ('text', 'match'): rv.append({'match': {key: val}}) elif field_action in ('prefix', 'startswith'): rv.append({'prefix': {key: val}}) elif field_action in ('gt', 'gte', 'lt', 'lte'): rv.append({'range': {key: {field_action: val}}}) elif field_action == 'fuzzy': rv.append({'fuzzy': {key: val}}) if or_: rv.append({'bool': {'should': self._process_queries(or_.items())}}) return rv def _do_search(self): if not self._results_cache: hits = self.raw() if self.as_dict: ResultClass = DictSearchResults elif self.as_list: ResultClass = ListSearchResults else: ResultClass = ObjectSearchResults self._results_cache = ResultClass(self.type, hits, self.fields) return self._results_cache def raw(self): build_body = self._build_query() es = get_es() try: with statsd.timer('search.es.timer') as timer: hits = es.search( body=build_body, index=self.index, doc_type=self.type._meta.db_table ) except Exception: log.error(build_body) raise statsd.timing('search.es.took', hits['took']) log.debug('[%s] [%s] %s' % (hits['took'], timer.ms, build_body)) return hits def __iter__(self): return iter(self._do_search()) def raw_facets(self): return self._do_search().results.get('facets', {}) @property def facets(self): facets = {} for key, val in self.raw_facets().items(): if val['_type'] == 'terms': facets[key] = [v for v in val['terms']] elif val['_type'] == 'range': facets[key] = [v for v in val['ranges']] return facets class SearchResults(object): def __init__(self, type, results, fields): self.type = type self.took = results['took'] self.count = results['hits']['total'] self.results = results self.fields = fields self.set_objects(results['hits']['hits']) def set_objects(self, hits): raise NotImplementedError() def __iter__(self): return iter(self.objects) def __len__(self): return len(self.objects) class DictSearchResults(SearchResults): def set_objects(self, hits): objs = [] if self.fields: # When fields are specified in `values_dict(...)` we return the # fields. Each field is coerced to a list to match the # Elasticsearch >= 1.0 style. for h in hits: hit = {} fields = h['fields'] # If source is returned, it means that it has been asked, so # take it. if '_source' in h: fields.update(h['_source']) for field, value in fields.items(): if type(value) != list: value = [value] hit[field] = value objs.append(hit) self.objects = objs else: self.objects = [r['_source'] for r in hits] return self.objects class ListSearchResults(SearchResults): def set_objects(self, hits): key = 'fields' if self.fields else '_source' # When fields are specified in `values(...)` we return the fields. Each # field is coerced to a list to match the Elasticsearch >= 1.0 style. objs = [] for hit in hits: objs.append(tuple([v] if key == 'fields' and type(v) != list else v for v in hit[key].values())) self.objects = objs class ObjectSearchResults(SearchResults): def set_objects(self, hits): self.ids = [int(r['_id']) for r in hits] self.objects = self.type.objects.filter(id__in=self.ids) def __iter__(self): objs = dict((obj.id, obj) for obj in self.objects) return (objs[id] for id in self.ids if id in objs)
bsd-3-clause
[ 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 465, 366, 74, 63, 1751, 199, 199, 504, 1639, 63, 3200, 68, 14, 14555, 492, 5020, 68, 199, 504, 24380, 1733, 492, 19509, 1733, 421, 199, 793, 275, 2050, 14, 5572, 360, 90, 14, 397, 358, 421, 199, 3472, 63, 23775, 275, 788, 5967, 26, 25, 1840, 418, 199, 3472, 63, 8899, 275, 959, 199, 3472, 63, 10215, 654, 275, 788, 885, 418, 199, 3472, 63, 26406, 63, 35, 2632, 275, 488, 421, 199, 318, 664, 63, 397, 8, 5146, 29, 403, 12, 2653, 29, 403, 12, 1011, 1751, 304, 272, 408, 2499, 376, 10427, 909, 436, 372, 652, 1041, 272, 327, 445, 12492, 4340, 402, 477, 13, 403, 13, 2021, 316, 7645, 272, 7057, 275, 7057, 503, 2519, 8, 18256, 63, 1751, 12, 283, 654, 63, 23775, 297, 6186, 63, 23775, 9, 272, 2653, 275, 334, 2593, 340, 2653, 365, 440, 488, 587, 2049, 2519, 8, 18256, 63, 1751, 12, 283, 654, 63, 8899, 297, 6186, 63, 8899, 430, 339, 372, 19509, 1733, 8, 5146, 12, 2653, 29, 2593, 12, 1011, 1751, 9, 421, 199, 533, 10427, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 730, 3131, 1478, 304, 267, 291, 14, 466, 275, 730, 63, 267, 291, 14, 1080, 275, 1478, 267, 291, 14, 5895, 275, 942, 267, 291, 14, 928, 275, 378, 267, 291, 14, 2379, 275, 488, 267, 291, 14, 305, 63, 513, 275, 291, 14, 305, 63, 807, 275, 756, 267, 291, 423, 2604, 63, 1637, 275, 488, 339, 347, 485, 6311, 8, 277, 12, 2163, 63, 2926, 29, 403, 304, 267, 892, 275, 291, 855, 533, 721, 277, 14, 466, 12, 291, 14, 1080, 9, 267, 892, 14, 5895, 275, 769, 8, 277, 14, 5895, 9, 267, 340, 2163, 63, 2926, 26, 288, 892, 14, 5895, 14, 740, 8, 2184, 63, 2926, 9, 267, 892, 14, 928, 275, 291, 14, 928, 267, 892, 14, 2379, 275, 291, 14, 2379, 267, 372, 892, 339, 347, 1338, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1459, 297, 1504, 430, 339, 347, 1338, 63, 807, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1459, 63, 807, 297, 1504, 430, 339, 347, 1865, 63, 991, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1648, 63, 991, 297, 1504, 430, 339, 347, 1827, 8, 277, 12, 1011, 829, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1131, 297, 4775, 14, 1744, 4059, 339, 347, 2457, 8, 277, 12, 1011, 829, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1541, 297, 4775, 14, 1744, 4059, 339, 347, 8870, 84, 8, 277, 12, 1011, 829, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 24271, 297, 4775, 14, 1744, 4059, 339, 347, 1350, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1365, 297, 1504, 430, 339, 347, 2402, 8, 277, 12, 1011, 829, 304, 267, 892, 275, 291, 423, 6311, 342, 267, 5445, 275, 283, 1459, 1338, 63, 807, 1865, 63, 991, 1827, 2457, 8870, 84, 1370, 1294, 342, 267, 367, 790, 12, 5322, 315, 4775, 14, 1744, 837, 288, 702, 790, 315, 5445, 288, 340, 2688, 8, 3643, 12, 283, 1744, 735, 355, 892, 14, 5895, 14, 740, 1332, 498, 12, 5322, 14, 1744, 4059, 288, 587, 26, 355, 892, 14, 5895, 14, 740, 1332, 498, 12, 5322, 430, 267, 372, 892, 339, 347, 2338, 8, 277, 304, 267, 340, 291, 423, 2604, 63, 1637, 26, 288, 372, 291, 423, 2604, 63, 1637, 14, 835, 267, 587, 26, 288, 372, 291, 1491, 16, 1055, 1773, 12047, 16595, 2545, 2923, 418, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1117, 63, 1733, 1012, 339, 347, 636, 6095, 721, 277, 12, 1022, 304, 267, 892, 275, 291, 423, 6311, 342, 267, 327, 3254, 26, 4107, 5579, 436, 12271, 267, 340, 1228, 8, 75, 12, 6014, 304, 288, 892, 14, 928, 12, 892, 14, 2379, 275, 1022, 14, 928, 503, 378, 12, 1022, 14, 2379, 288, 372, 892, 267, 587, 26, 288, 892, 14, 928, 12, 892, 14, 2379, 275, 1022, 12, 1022, 435, 413, 288, 372, 769, 8, 1222, 2788, 16, 61, 339, 347, 485, 1506, 63, 1131, 8, 277, 304, 267, 4766, 275, 942, 267, 9212, 275, 942, 267, 4069, 275, 942, 267, 1504, 275, 788, 344, 418, 267, 1350, 275, 942, 267, 8870, 1086, 275, 1052, 267, 465, 63, 513, 275, 465, 63, 807, 275, 756, 267, 367, 1595, 12, 574, 315, 291, 14, 5895, 26, 288, 340, 1595, 508, 283, 1648, 63, 991, 356, 355, 367, 790, 315, 574, 26, 490, 340, 790, 14, 2460, 3654, 735, 717, 4069, 14, 740, 2561, 498, 59, 17, 10688, 283, 3257, 3071, 490, 587, 26, 717, 4069, 14, 740, 8, 498, 9, 288, 916, 1595, 508, 283, 1459, 356, 355, 1504, 14, 2880, 8, 585, 9, 355, 465, 63, 513, 12, 465, 63, 807, 275, 715, 12, 756, 288, 916, 1595, 508, 283, 1459, 63, 807, 356, 355, 340, 440, 574, 26, 490, 1504, 275, 942, 355, 587, 26, 490, 1504, 14, 2880, 8, 585, 9, 355, 465, 63, 513, 12, 465, 63, 807, 275, 756, 12, 715, 288, 916, 1595, 508, 283, 1131, 356, 355, 9212, 14, 2880, 8, 277, 423, 1412, 63, 10590, 8, 585, 430, 288, 916, 1595, 508, 283, 1541, 356, 355, 4766, 14, 2880, 8, 277, 423, 1412, 63, 4273, 8, 585, 430, 288, 916, 1595, 508, 283, 1365, 356, 355, 1350, 14, 2880, 8, 585, 9, 288, 916, 1595, 508, 283, 24271, 356, 355, 8870, 1086, 14, 873, 8, 585, 9, 288, 587, 26, 355, 746, 4279, 8, 1287, 9, 398, 340, 822, 8, 10590, 9, 690, 413, 26, 288, 6377, 275, 791, 2245, 356, 791, 7790, 356, 9212, 4863, 267, 916, 9212, 26, 288, 6377, 275, 9212, 59, 16, 61, 267, 587, 26, 288, 6377, 275, 2420, 1431, 63, 452, 582, 24312, 398, 6377, 275, 469, 288, 298, 1593, 63, 3397, 582 ]
[ 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 465, 366, 74, 63, 1751, 199, 199, 504, 1639, 63, 3200, 68, 14, 14555, 492, 5020, 68, 199, 504, 24380, 1733, 492, 19509, 1733, 421, 199, 793, 275, 2050, 14, 5572, 360, 90, 14, 397, 358, 421, 199, 3472, 63, 23775, 275, 788, 5967, 26, 25, 1840, 418, 199, 3472, 63, 8899, 275, 959, 199, 3472, 63, 10215, 654, 275, 788, 885, 418, 199, 3472, 63, 26406, 63, 35, 2632, 275, 488, 421, 199, 318, 664, 63, 397, 8, 5146, 29, 403, 12, 2653, 29, 403, 12, 1011, 1751, 304, 272, 408, 2499, 376, 10427, 909, 436, 372, 652, 1041, 272, 327, 445, 12492, 4340, 402, 477, 13, 403, 13, 2021, 316, 7645, 272, 7057, 275, 7057, 503, 2519, 8, 18256, 63, 1751, 12, 283, 654, 63, 23775, 297, 6186, 63, 23775, 9, 272, 2653, 275, 334, 2593, 340, 2653, 365, 440, 488, 587, 2049, 2519, 8, 18256, 63, 1751, 12, 283, 654, 63, 8899, 297, 6186, 63, 8899, 430, 339, 372, 19509, 1733, 8, 5146, 12, 2653, 29, 2593, 12, 1011, 1751, 9, 421, 199, 533, 10427, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 730, 3131, 1478, 304, 267, 291, 14, 466, 275, 730, 63, 267, 291, 14, 1080, 275, 1478, 267, 291, 14, 5895, 275, 942, 267, 291, 14, 928, 275, 378, 267, 291, 14, 2379, 275, 488, 267, 291, 14, 305, 63, 513, 275, 291, 14, 305, 63, 807, 275, 756, 267, 291, 423, 2604, 63, 1637, 275, 488, 339, 347, 485, 6311, 8, 277, 12, 2163, 63, 2926, 29, 403, 304, 267, 892, 275, 291, 855, 533, 721, 277, 14, 466, 12, 291, 14, 1080, 9, 267, 892, 14, 5895, 275, 769, 8, 277, 14, 5895, 9, 267, 340, 2163, 63, 2926, 26, 288, 892, 14, 5895, 14, 740, 8, 2184, 63, 2926, 9, 267, 892, 14, 928, 275, 291, 14, 928, 267, 892, 14, 2379, 275, 291, 14, 2379, 267, 372, 892, 339, 347, 1338, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1459, 297, 1504, 430, 339, 347, 1338, 63, 807, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1459, 63, 807, 297, 1504, 430, 339, 347, 1865, 63, 991, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1648, 63, 991, 297, 1504, 430, 339, 347, 1827, 8, 277, 12, 1011, 829, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1131, 297, 4775, 14, 1744, 4059, 339, 347, 2457, 8, 277, 12, 1011, 829, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1541, 297, 4775, 14, 1744, 4059, 339, 347, 8870, 84, 8, 277, 12, 1011, 829, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 24271, 297, 4775, 14, 1744, 4059, 339, 347, 1350, 8, 277, 12, 627, 955, 304, 267, 372, 291, 423, 6311, 8, 2184, 63, 2926, 7782, 1365, 297, 1504, 430, 339, 347, 2402, 8, 277, 12, 1011, 829, 304, 267, 892, 275, 291, 423, 6311, 342, 267, 5445, 275, 283, 1459, 1338, 63, 807, 1865, 63, 991, 1827, 2457, 8870, 84, 1370, 1294, 342, 267, 367, 790, 12, 5322, 315, 4775, 14, 1744, 837, 288, 702, 790, 315, 5445, 288, 340, 2688, 8, 3643, 12, 283, 1744, 735, 355, 892, 14, 5895, 14, 740, 1332, 498, 12, 5322, 14, 1744, 4059, 288, 587, 26, 355, 892, 14, 5895, 14, 740, 1332, 498, 12, 5322, 430, 267, 372, 892, 339, 347, 2338, 8, 277, 304, 267, 340, 291, 423, 2604, 63, 1637, 26, 288, 372, 291, 423, 2604, 63, 1637, 14, 835, 267, 587, 26, 288, 372, 291, 1491, 16, 1055, 1773, 12047, 16595, 2545, 2923, 418, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1117, 63, 1733, 1012, 339, 347, 636, 6095, 721, 277, 12, 1022, 304, 267, 892, 275, 291, 423, 6311, 342, 267, 327, 3254, 26, 4107, 5579, 436, 12271, 267, 340, 1228, 8, 75, 12, 6014, 304, 288, 892, 14, 928, 12, 892, 14, 2379, 275, 1022, 14, 928, 503, 378, 12, 1022, 14, 2379, 288, 372, 892, 267, 587, 26, 288, 892, 14, 928, 12, 892, 14, 2379, 275, 1022, 12, 1022, 435, 413, 288, 372, 769, 8, 1222, 2788, 16, 61, 339, 347, 485, 1506, 63, 1131, 8, 277, 304, 267, 4766, 275, 942, 267, 9212, 275, 942, 267, 4069, 275, 942, 267, 1504, 275, 788, 344, 418, 267, 1350, 275, 942, 267, 8870, 1086, 275, 1052, 267, 465, 63, 513, 275, 465, 63, 807, 275, 756, 267, 367, 1595, 12, 574, 315, 291, 14, 5895, 26, 288, 340, 1595, 508, 283, 1648, 63, 991, 356, 355, 367, 790, 315, 574, 26, 490, 340, 790, 14, 2460, 3654, 735, 717, 4069, 14, 740, 2561, 498, 59, 17, 10688, 283, 3257, 3071, 490, 587, 26, 717, 4069, 14, 740, 8, 498, 9, 288, 916, 1595, 508, 283, 1459, 356, 355, 1504, 14, 2880, 8, 585, 9, 355, 465, 63, 513, 12, 465, 63, 807, 275, 715, 12, 756, 288, 916, 1595, 508, 283, 1459, 63, 807, 356, 355, 340, 440, 574, 26, 490, 1504, 275, 942, 355, 587, 26, 490, 1504, 14, 2880, 8, 585, 9, 355, 465, 63, 513, 12, 465, 63, 807, 275, 756, 12, 715, 288, 916, 1595, 508, 283, 1131, 356, 355, 9212, 14, 2880, 8, 277, 423, 1412, 63, 10590, 8, 585, 430, 288, 916, 1595, 508, 283, 1541, 356, 355, 4766, 14, 2880, 8, 277, 423, 1412, 63, 4273, 8, 585, 430, 288, 916, 1595, 508, 283, 1365, 356, 355, 1350, 14, 2880, 8, 585, 9, 288, 916, 1595, 508, 283, 24271, 356, 355, 8870, 1086, 14, 873, 8, 585, 9, 288, 587, 26, 355, 746, 4279, 8, 1287, 9, 398, 340, 822, 8, 10590, 9, 690, 413, 26, 288, 6377, 275, 791, 2245, 356, 791, 7790, 356, 9212, 4863, 267, 916, 9212, 26, 288, 6377, 275, 9212, 59, 16, 61, 267, 587, 26, 288, 6377, 275, 2420, 1431, 63, 452, 582, 24312, 398, 6377, 275, 469, 288, 298, 1593, 63, 3397, 582, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sankhesh/VTK
Filters/Hybrid/Testing/Python/TestPCA.py
20
8348
#!/usr/bin/env python import vtk from vtk.test import Testing from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # This example shows how to visualise the variation in shape in a set of objects using # vtkPCAAnalysisFilter. # # We make three ellipsoids by distorting and translating a sphere and then align them together # using vtkProcrustesAlignmentFilter, and then pass the output to vtkPCAAnalysisFilter. We visualise # the first and second modes - the major sources of variation that were in the training set. sphere = vtk.vtkSphereSource() sphere.SetPhiResolution(36) sphere.SetThetaResolution(36) sphere.Update() # make two copies of the shape and distort them a little transform1 = vtk.vtkTransform() transform1.Translate(0.2,0.1,0.3) transform1.Scale(1.3,1.1,0.8) transform2 = vtk.vtkTransform() transform2.Translate(0.3,0.7,0.1) transform2.Scale(1.0,0.1,1.8) transformer1 = vtk.vtkTransformPolyDataFilter() transformer1.SetInputConnection(sphere.GetOutputPort()) transformer1.SetTransform(transform1) transformer1.Update() transformer2 = vtk.vtkTransformPolyDataFilter() transformer2.SetInputConnection(sphere.GetOutputPort()) transformer2.SetTransform(transform2) transformer2.Update() #------------------------------------------------------------------ # map these three shapes into the first renderer #------------------------------------------------------------------ map1a = vtk.vtkPolyDataMapper() map1a.SetInputConnection(sphere.GetOutputPort()) Actor1a = vtk.vtkActor() Actor1a.SetMapper(map1a) Actor1a.GetProperty().SetDiffuseColor(1.0000,0.3882,0.2784) map1b = vtk.vtkPolyDataMapper() map1b.SetInputConnection(transformer1.GetOutputPort()) Actor1b = vtk.vtkActor() Actor1b.SetMapper(map1b) Actor1b.GetProperty().SetDiffuseColor(0.3882,1.0000,0.2784) map1c = vtk.vtkPolyDataMapper() map1c.SetInputConnection(transformer2.GetOutputPort()) Actor1c = vtk.vtkActor() Actor1c.SetMapper(map1c) Actor1c.GetProperty().SetDiffuseColor(0.3882,0.2784,1.0000) #------------------------------------------------------------------ # align the shapes using Procrustes (using SetModeToRigidBody) # and map the aligned shapes into the second renderer #------------------------------------------------------------------ group = vtk.vtkMultiBlockDataGroupFilter() group.AddInputConnection(sphere.GetOutputPort()) group.AddInputConnection(transformer1.GetOutputPort()) group.AddInputConnection(transformer2.GetOutputPort()) procrustes = vtk.vtkProcrustesAlignmentFilter() procrustes.SetInputConnection(group.GetOutputPort()) procrustes.GetLandmarkTransform().SetModeToRigidBody() procrustes.Update() map2a = vtk.vtkPolyDataMapper() map2a.SetInputData(procrustes.GetOutput().GetBlock(0)) Actor2a = vtk.vtkActor() Actor2a.SetMapper(map2a) Actor2a.GetProperty().SetDiffuseColor(1.0000,0.3882,0.2784) map2b = vtk.vtkPolyDataMapper() map2b.SetInputData(procrustes.GetOutput().GetBlock(1)) Actor2b = vtk.vtkActor() Actor2b.SetMapper(map2b) Actor2b.GetProperty().SetDiffuseColor(0.3882,1.0000,0.2784) map2c = vtk.vtkPolyDataMapper() map2c.SetInputData(procrustes.GetOutput().GetBlock(2)) Actor2c = vtk.vtkActor() Actor2c.SetMapper(map2c) Actor2c.GetProperty().SetDiffuseColor(0.3882,0.2784,1.0000) #------------------------------------------------------------------ # pass the output of Procrustes to vtkPCAAnalysisFilter #------------------------------------------------------------------ pca = vtk.vtkPCAAnalysisFilter() pca.SetInputConnection(procrustes.GetOutputPort()) pca.Update() # we need to call Update because GetParameterisedShape is not # part of the normal SetInput/GetOutput pipeline #------------------------------------------------------------------ # map the first mode into the third renderer: # -3,0,3 standard deviations on the first mode # illustrate the extremes around the average shape #------------------------------------------------------------------ params = vtk.vtkFloatArray() params.SetNumberOfComponents(1) params.SetNumberOfTuples(1) params.SetTuple1(0,0.0) shapea = vtk.vtkPolyData() shapea.DeepCopy(sphere.GetOutput()) pca.GetParameterisedShape(params,shapea) normalsa = vtk.vtkPolyDataNormals() normalsa.SetInputData(shapea) map3a = vtk.vtkPolyDataMapper() map3a.SetInputConnection(normalsa.GetOutputPort()) Actor3a = vtk.vtkActor() Actor3a.SetMapper(map3a) Actor3a.GetProperty().SetDiffuseColor(1,1,1) params.SetTuple1(0,-3.0) shapeb = vtk.vtkPolyData() shapeb.DeepCopy(sphere.GetOutput()) pca.GetParameterisedShape(params,shapeb) normalsb = vtk.vtkPolyDataNormals() normalsb.SetInputData(shapeb) map3b = vtk.vtkPolyDataMapper() map3b.SetInputConnection(normalsb.GetOutputPort()) Actor3b = vtk.vtkActor() Actor3b.SetMapper(map3b) Actor3b.GetProperty().SetDiffuseColor(1,1,1) params.SetTuple1(0,3.0) shapec = vtk.vtkPolyData() shapec.DeepCopy(sphere.GetOutput()) pca.GetParameterisedShape(params,shapec) normalsc = vtk.vtkPolyDataNormals() normalsc.SetInputData(shapec) map3c = vtk.vtkPolyDataMapper() map3c.SetInputConnection(normalsc.GetOutputPort()) Actor3c = vtk.vtkActor() Actor3c.SetMapper(map3c) Actor3c.GetProperty().SetDiffuseColor(1,1,1) #------------------------------------------------------------------ # map the second mode into the fourth renderer: #------------------------------------------------------------------ params4 = vtk.vtkFloatArray() params4.SetNumberOfComponents(1) params4.SetNumberOfTuples(2) params4.SetTuple1(0,0.0) params4.SetTuple1(1,-3.0) shape4a = vtk.vtkPolyData() shape4a.DeepCopy(sphere.GetOutput()) pca.GetParameterisedShape(params4,shape4a) normals4a = vtk.vtkPolyDataNormals() normals4a.SetInputData(shape4a) map4a = vtk.vtkPolyDataMapper() map4a.SetInputConnection(normals4a.GetOutputPort()) Actor4a = vtk.vtkActor() Actor4a.SetMapper(map4a) Actor4a.GetProperty().SetDiffuseColor(1,1,1) params4.SetTuple1(1,0.0) shape4b = vtk.vtkPolyData() shape4b.DeepCopy(sphere.GetOutput()) pca.GetParameterisedShape(params4,shape4b) normals4b = vtk.vtkPolyDataNormals() normals4b.SetInputData(shape4b) map4b = vtk.vtkPolyDataMapper() map4b.SetInputConnection(normals4b.GetOutputPort()) Actor4b = vtk.vtkActor() Actor4b.SetMapper(map4b) Actor4b.GetProperty().SetDiffuseColor(1,1,1) params4.SetTuple1(1,3.0) shape4c = vtk.vtkPolyData() shape4c.DeepCopy(sphere.GetOutput()) pca.GetParameterisedShape(params4,shape4c) normals4c = vtk.vtkPolyDataNormals() normals4c.SetInputData(shape4c) map4c = vtk.vtkPolyDataMapper() map4c.SetInputConnection(normals4c.GetOutputPort()) Actor4c = vtk.vtkActor() Actor4c.SetMapper(map4c) Actor4c.GetProperty().SetDiffuseColor(1,1,1) #------------------------------------------------------------------ # Create the RenderWindow and its four Renderers #------------------------------------------------------------------ ren1 = vtk.vtkRenderer() ren2 = vtk.vtkRenderer() ren3 = vtk.vtkRenderer() ren4 = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren1) renWin.AddRenderer(ren2) renWin.AddRenderer(ren3) renWin.AddRenderer(ren4) renWin.SetSize(600,200) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) # Add the actors to the renderer ren1.AddActor(Actor1a) ren1.AddActor(Actor1b) ren1.AddActor(Actor1c) ren2.AddActor(Actor2a) ren2.AddActor(Actor2b) ren2.AddActor(Actor2c) ren3.AddActor(Actor3a) ren3.AddActor(Actor3b) ren3.AddActor(Actor3c) ren4.AddActor(Actor4a) ren4.AddActor(Actor4b) ren4.AddActor(Actor4c) # set the properties of the renderers ren1.SetBackground(1,1,1) ren1.SetViewport(0.0,0.0,0.25,1.0) ren1.ResetCamera() ren1.GetActiveCamera().SetPosition(1,-1,0) ren1.ResetCamera() ren2.SetBackground(1,1,1) ren2.SetViewport(0.25,0.0,0.5,1.0) ren2.ResetCamera() ren2.GetActiveCamera().SetPosition(1,-1,0) ren2.ResetCamera() ren3.SetBackground(1,1,1) ren3.SetViewport(0.5,0.0,0.75,1.0) ren3.ResetCamera() ren3.GetActiveCamera().SetPosition(1,-1,0) ren3.ResetCamera() ren4.SetBackground(1,1,1) ren4.SetViewport(0.75,0.0,1.0,1.0) ren4.ResetCamera() ren4.GetActiveCamera().SetPosition(1,-1,0) ren4.ResetCamera() # render the image # renWin.Render() # output the image to file (used to generate the initial regression image) #vtkWindowToImageFilter to_image #to_image SetInput renWin #vtkPNGWriter to_png #to_png SetFileName "TestPCA.png" #to_png SetInputConnection [to_image GetOutputPort] #to_png Write # prevent the tk window from showing up then start the event loop # --- end of script --
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 25702, 6405, 199, 8156, 43, 63, 3998, 63, 5441, 275, 11144, 25702, 6405, 342, 199, 199, 3, 961, 2893, 13703, 4212, 370, 13104, 572, 314, 29844, 315, 2215, 315, 282, 663, 402, 2251, 1808, 199, 3, 11144, 4222, 2276, 78, 2618, 2316, 4131, 14, 199, 3, 199, 3, 2136, 1852, 7795, 16028, 1152, 1580, 701, 2917, 361, 316, 436, 1752, 24615, 282, 26941, 436, 2066, 6998, 3062, 10451, 199, 3, 1808, 11144, 919, 1556, 527, 744, 16613, 4131, 12, 436, 2066, 986, 314, 1072, 370, 11144, 4222, 2276, 78, 2618, 2316, 4131, 14, 2136, 13104, 572, 199, 3, 314, 1642, 436, 3499, 12404, 446, 314, 12160, 5274, 402, 29844, 626, 4898, 315, 314, 6093, 663, 14, 199, 14980, 275, 11144, 14, 11919, 22385, 2980, 342, 199, 14980, 14, 1084, 5663, 73, 18508, 8, 1344, 9, 199, 14980, 14, 1084, 2719, 1841, 18508, 8, 1344, 9, 199, 14980, 14, 4152, 342, 199, 3, 1852, 2877, 6866, 402, 314, 2215, 436, 2917, 361, 3062, 282, 12050, 199, 4711, 17, 275, 11144, 14, 11919, 6939, 342, 199, 4711, 17, 14, 18355, 8, 16, 14, 18, 12, 16, 14, 17, 12, 16, 14, 19, 9, 199, 4711, 17, 14, 9944, 8, 17, 14, 19, 12, 17, 14, 17, 12, 16, 14, 24, 9, 199, 4711, 18, 275, 11144, 14, 11919, 6939, 342, 199, 4711, 18, 14, 18355, 8, 16, 14, 19, 12, 16, 14, 23, 12, 16, 14, 17, 9, 199, 4711, 18, 14, 9944, 8, 17, 14, 16, 12, 16, 14, 17, 12, 17, 14, 24, 9, 199, 19754, 17, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 19754, 17, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 19754, 17, 14, 1084, 6939, 8, 4711, 17, 9, 199, 19754, 17, 14, 4152, 342, 199, 19754, 18, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 19754, 18, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 19754, 18, 14, 1084, 6939, 8, 4711, 18, 9, 199, 19754, 18, 14, 4152, 342, 199, 7656, 306, 199, 3, 2341, 3520, 7795, 11751, 1901, 314, 1642, 11889, 199, 7656, 306, 199, 1130, 17, 65, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 17, 65, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 12258, 17, 65, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 17, 65, 14, 1084, 11880, 8, 1130, 17, 65, 9, 199, 12258, 17, 65, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 17, 14, 993, 12, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 9, 199, 1130, 17, 66, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 17, 66, 14, 32195, 8, 19754, 17, 14, 30810, 1012, 199, 12258, 17, 66, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 17, 66, 14, 1084, 11880, 8, 1130, 17, 66, 9, 199, 12258, 17, 66, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 17, 14, 993, 12, 16, 14, 1465, 1349, 9, 199, 1130, 17, 67, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 17, 67, 14, 32195, 8, 19754, 18, 14, 30810, 1012, 199, 12258, 17, 67, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 17, 67, 14, 1084, 11880, 8, 1130, 17, 67, 9, 199, 12258, 17, 67, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 12, 17, 14, 993, 9, 199, 7656, 306, 199, 3, 6998, 314, 11751, 1808, 2165, 1556, 527, 744, 334, 4941, 2494, 1385, 1378, 50, 528, 344, 8173, 9, 199, 3, 436, 2341, 314, 22569, 11751, 1901, 314, 3499, 11889, 199, 7656, 306, 199, 923, 275, 11144, 14, 11919, 3947, 3142, 1451, 2448, 4131, 342, 199, 923, 14, 1123, 3205, 3225, 8, 14980, 14, 30810, 1012, 199, 923, 14, 1123, 3205, 3225, 8, 19754, 17, 14, 30810, 1012, 199, 923, 14, 1123, 3205, 3225, 8, 19754, 18, 14, 30810, 1012, 199, 496, 1556, 527, 744, 275, 11144, 14, 11919, 919, 1556, 527, 744, 16613, 4131, 342, 199, 496, 1556, 527, 744, 14, 32195, 8, 923, 14, 30810, 1012, 199, 496, 1556, 527, 744, 14, 1002, 44, 460, 1657, 6939, 1252, 1084, 1385, 1378, 50, 528, 344, 8173, 342, 199, 496, 1556, 527, 744, 14, 4152, 342, 199, 1130, 18, 65, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 18, 65, 14, 24029, 1451, 8, 496, 1556, 527, 744, 14, 18614, 1252, 1002, 3142, 8, 16, 430, 199, 12258, 18, 65, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 18, 65, 14, 1084, 11880, 8, 1130, 18, 65, 9, 199, 12258, 18, 65, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 17, 14, 993, 12, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 9, 199, 1130, 18, 66, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 18, 66, 14, 24029, 1451, 8, 496, 1556, 527, 744, 14, 18614, 1252, 1002, 3142, 8, 17, 430, 199, 12258, 18, 66, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 18, 66, 14, 1084, 11880, 8, 1130, 18, 66, 9, 199, 12258, 18, 66, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 17, 14, 993, 12, 16, 14, 1465, 1349, 9, 199, 1130, 18, 67, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 18, 67, 14, 24029, 1451, 8, 496, 1556, 527, 744, 14, 18614, 1252, 1002, 3142, 8, 18, 430, 199, 12258, 18, 67, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 18, 67, 14, 1084, 11880, 8, 1130, 18, 67, 9, 199, 12258, 18, 67, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 12, 17, 14, 993, 9, 199, 7656, 306, 199, 3, 986, 314, 1072, 402, 2165, 1556, 527, 744, 370, 11144, 4222, 2276, 78, 2618, 2316, 4131, 199, 7656, 306, 199, 19247, 275, 11144, 14, 11919, 4222, 2276, 78, 2618, 2316, 4131, 342, 199, 19247, 14, 32195, 8, 496, 1556, 527, 744, 14, 30810, 1012, 199, 19247, 14, 4152, 342, 199, 3, 781 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 25702, 6405, 199, 8156, 43, 63, 3998, 63, 5441, 275, 11144, 25702, 6405, 342, 199, 199, 3, 961, 2893, 13703, 4212, 370, 13104, 572, 314, 29844, 315, 2215, 315, 282, 663, 402, 2251, 1808, 199, 3, 11144, 4222, 2276, 78, 2618, 2316, 4131, 14, 199, 3, 199, 3, 2136, 1852, 7795, 16028, 1152, 1580, 701, 2917, 361, 316, 436, 1752, 24615, 282, 26941, 436, 2066, 6998, 3062, 10451, 199, 3, 1808, 11144, 919, 1556, 527, 744, 16613, 4131, 12, 436, 2066, 986, 314, 1072, 370, 11144, 4222, 2276, 78, 2618, 2316, 4131, 14, 2136, 13104, 572, 199, 3, 314, 1642, 436, 3499, 12404, 446, 314, 12160, 5274, 402, 29844, 626, 4898, 315, 314, 6093, 663, 14, 199, 14980, 275, 11144, 14, 11919, 22385, 2980, 342, 199, 14980, 14, 1084, 5663, 73, 18508, 8, 1344, 9, 199, 14980, 14, 1084, 2719, 1841, 18508, 8, 1344, 9, 199, 14980, 14, 4152, 342, 199, 3, 1852, 2877, 6866, 402, 314, 2215, 436, 2917, 361, 3062, 282, 12050, 199, 4711, 17, 275, 11144, 14, 11919, 6939, 342, 199, 4711, 17, 14, 18355, 8, 16, 14, 18, 12, 16, 14, 17, 12, 16, 14, 19, 9, 199, 4711, 17, 14, 9944, 8, 17, 14, 19, 12, 17, 14, 17, 12, 16, 14, 24, 9, 199, 4711, 18, 275, 11144, 14, 11919, 6939, 342, 199, 4711, 18, 14, 18355, 8, 16, 14, 19, 12, 16, 14, 23, 12, 16, 14, 17, 9, 199, 4711, 18, 14, 9944, 8, 17, 14, 16, 12, 16, 14, 17, 12, 17, 14, 24, 9, 199, 19754, 17, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 19754, 17, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 19754, 17, 14, 1084, 6939, 8, 4711, 17, 9, 199, 19754, 17, 14, 4152, 342, 199, 19754, 18, 275, 11144, 14, 11919, 6939, 12747, 1451, 4131, 342, 199, 19754, 18, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 19754, 18, 14, 1084, 6939, 8, 4711, 18, 9, 199, 19754, 18, 14, 4152, 342, 199, 7656, 306, 199, 3, 2341, 3520, 7795, 11751, 1901, 314, 1642, 11889, 199, 7656, 306, 199, 1130, 17, 65, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 17, 65, 14, 32195, 8, 14980, 14, 30810, 1012, 199, 12258, 17, 65, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 17, 65, 14, 1084, 11880, 8, 1130, 17, 65, 9, 199, 12258, 17, 65, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 17, 14, 993, 12, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 9, 199, 1130, 17, 66, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 17, 66, 14, 32195, 8, 19754, 17, 14, 30810, 1012, 199, 12258, 17, 66, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 17, 66, 14, 1084, 11880, 8, 1130, 17, 66, 9, 199, 12258, 17, 66, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 17, 14, 993, 12, 16, 14, 1465, 1349, 9, 199, 1130, 17, 67, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 17, 67, 14, 32195, 8, 19754, 18, 14, 30810, 1012, 199, 12258, 17, 67, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 17, 67, 14, 1084, 11880, 8, 1130, 17, 67, 9, 199, 12258, 17, 67, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 12, 17, 14, 993, 9, 199, 7656, 306, 199, 3, 6998, 314, 11751, 1808, 2165, 1556, 527, 744, 334, 4941, 2494, 1385, 1378, 50, 528, 344, 8173, 9, 199, 3, 436, 2341, 314, 22569, 11751, 1901, 314, 3499, 11889, 199, 7656, 306, 199, 923, 275, 11144, 14, 11919, 3947, 3142, 1451, 2448, 4131, 342, 199, 923, 14, 1123, 3205, 3225, 8, 14980, 14, 30810, 1012, 199, 923, 14, 1123, 3205, 3225, 8, 19754, 17, 14, 30810, 1012, 199, 923, 14, 1123, 3205, 3225, 8, 19754, 18, 14, 30810, 1012, 199, 496, 1556, 527, 744, 275, 11144, 14, 11919, 919, 1556, 527, 744, 16613, 4131, 342, 199, 496, 1556, 527, 744, 14, 32195, 8, 923, 14, 30810, 1012, 199, 496, 1556, 527, 744, 14, 1002, 44, 460, 1657, 6939, 1252, 1084, 1385, 1378, 50, 528, 344, 8173, 342, 199, 496, 1556, 527, 744, 14, 4152, 342, 199, 1130, 18, 65, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 18, 65, 14, 24029, 1451, 8, 496, 1556, 527, 744, 14, 18614, 1252, 1002, 3142, 8, 16, 430, 199, 12258, 18, 65, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 18, 65, 14, 1084, 11880, 8, 1130, 18, 65, 9, 199, 12258, 18, 65, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 17, 14, 993, 12, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 9, 199, 1130, 18, 66, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 18, 66, 14, 24029, 1451, 8, 496, 1556, 527, 744, 14, 18614, 1252, 1002, 3142, 8, 17, 430, 199, 12258, 18, 66, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 18, 66, 14, 1084, 11880, 8, 1130, 18, 66, 9, 199, 12258, 18, 66, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 17, 14, 993, 12, 16, 14, 1465, 1349, 9, 199, 1130, 18, 67, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 18, 67, 14, 24029, 1451, 8, 496, 1556, 527, 744, 14, 18614, 1252, 1002, 3142, 8, 18, 430, 199, 12258, 18, 67, 275, 11144, 14, 11919, 12258, 342, 199, 12258, 18, 67, 14, 1084, 11880, 8, 1130, 18, 67, 9, 199, 12258, 18, 67, 14, 22845, 1252, 1084, 10746, 1180, 4117, 8, 16, 14, 11403, 18, 12, 16, 14, 1465, 1349, 12, 17, 14, 993, 9, 199, 7656, 306, 199, 3, 986, 314, 1072, 402, 2165, 1556, 527, 744, 370, 11144, 4222, 2276, 78, 2618, 2316, 4131, 199, 7656, 306, 199, 19247, 275, 11144, 14, 11919, 4222, 2276, 78, 2618, 2316, 4131, 342, 199, 19247, 14, 32195, 8, 496, 1556, 527, 744, 14, 30810, 1012, 199, 19247, 14, 4152, 342, 199, 3, 781, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
svn2github/django
django/conf/locale/sr/formats.py
655
1980
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j. F Y.' TIME_FORMAT = 'H:i' DATETIME_FORMAT = 'j. F Y. H:i' YEAR_MONTH_FORMAT = 'F Y.' MONTH_DAY_FORMAT = 'j. F' SHORT_DATE_FORMAT = 'j.m.Y.' SHORT_DATETIME_FORMAT = 'j.m.Y. H:i' FIRST_DAY_OF_WEEK = 1 # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = ( '%d.%m.%Y.', '%d.%m.%y.', # '25.10.2006.', '25.10.06.' '%d. %m. %Y.', '%d. %m. %y.', # '25. 10. 2006.', '25. 10. 06.' '%Y-%m-%d', # '2006-10-25' # '%d. %b %y.', '%d. %B %y.', # '25. Oct 06.', '25. October 06.' # '%d. %b \'%y.', '%d. %B \'%y.', # '25. Oct '06.', '25. October '06.' # '%d. %b %Y.', '%d. %B %Y.', # '25. Oct 2006.', '25. October 2006.' ) TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M', # '14:30' ) DATETIME_INPUT_FORMATS = ( '%d.%m.%Y. %H:%M:%S', # '25.10.2006. 14:30:59' '%d.%m.%Y. %H:%M', # '25.10.2006. 14:30' '%d.%m.%Y.', # '25.10.2006.' '%d.%m.%y. %H:%M:%S', # '25.10.06. 14:30:59' '%d.%m.%y. %H:%M', # '25.10.06. 14:30' '%d.%m.%y.', # '25.10.06.' '%d. %m. %Y. %H:%M:%S', # '25. 10. 2006. 14:30:59' '%d. %m. %Y. %H:%M', # '25. 10. 2006. 14:30' '%d. %m. %Y.', # '25. 10. 2006.' '%d. %m. %y. %H:%M:%S', # '25. 10. 06. 14:30:59' '%d. %m. %y. %H:%M', # '25. 10. 06. 14:30' '%d. %m. %y.', # '25. 10. 06.' '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%Y-%m-%d', # '2006-10-25' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '.' NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 481, 1488, 3530, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 481, 1488, 14, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 3530, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 14, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 1543, 68, 4111, 77, 4111, 89, 3130, 755, 327, 283, 821, 14, 709, 14, 7968, 3130, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 257, 327, 283, 821, 14, 1616, 14, 8315, 3130, 283, 821, 14, 1616, 14, 24293, 3530, 272, 1543, 57, 3295, 77, 3295, 68, 297, 9326, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 327, 1543, 68, 14, 450, 66, 450, 89, 3130, 1543, 68, 14, 450, 34, 450, 89, 3130, 258, 327, 283, 821, 14, 18365, 24293, 3130, 283, 821, 14, 18365, 22459, 24293, 3530, 272, 327, 1543, 68, 14, 450, 66, 19095, 89, 3130, 1543, 68, 14, 450, 34, 19095, 89, 3130, 327, 283, 821, 14, 18365, 283, 1690, 3130, 283, 821, 14, 18365, 22459, 283, 1690, 3530, 272, 327, 1543, 68, 14, 450, 66, 450, 57, 3130, 1543, 68, 14, 450, 34, 450, 57, 3130, 258, 327, 283, 821, 14, 18365, 8315, 3130, 283, 821, 14, 18365, 22459, 8315, 3530, 199, 9, 199, 4961, 63, 7321, 63, 14019, 275, 334, 272, 1543, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 297, 263, 327, 283, 1079, 26, 1216, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 4519, 327, 283, 821, 14, 709, 14, 7968, 3530, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 3130, 4519, 327, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 297, 420, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 3322, 327, 283, 821, 14, 1616, 14, 8315, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 297, 420, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 3322, 327, 283, 821, 14, 1616, 14, 24293, 3530, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 420, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 260, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 5185, 327, 283, 7968, 13, 709, 13, 821, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 7815, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 14, 481, 1488, 3530, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 14, 481, 1488, 14, 869, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 14, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 3530, 199, 13003, 63, 12488, 63, 4807, 275, 283, 74, 14, 77, 14, 57, 14, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 1543, 68, 4111, 77, 4111, 89, 3130, 755, 327, 283, 821, 14, 709, 14, 7968, 3130, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 257, 327, 283, 821, 14, 1616, 14, 8315, 3130, 283, 821, 14, 1616, 14, 24293, 3530, 272, 1543, 57, 3295, 77, 3295, 68, 297, 9326, 327, 283, 7968, 13, 709, 13, 821, 7, 272, 327, 1543, 68, 14, 450, 66, 450, 89, 3130, 1543, 68, 14, 450, 34, 450, 89, 3130, 258, 327, 283, 821, 14, 18365, 24293, 3130, 283, 821, 14, 18365, 22459, 24293, 3530, 272, 327, 1543, 68, 14, 450, 66, 19095, 89, 3130, 1543, 68, 14, 450, 34, 19095, 89, 3130, 327, 283, 821, 14, 18365, 283, 1690, 3130, 283, 821, 14, 18365, 22459, 283, 1690, 3530, 272, 327, 1543, 68, 14, 450, 66, 450, 57, 3130, 1543, 68, 14, 450, 34, 450, 57, 3130, 258, 327, 283, 821, 14, 18365, 8315, 3130, 283, 821, 14, 18365, 22459, 8315, 3530, 199, 9, 199, 4961, 63, 7321, 63, 14019, 275, 334, 272, 1543, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 297, 263, 327, 283, 1079, 26, 1216, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 3130, 4519, 327, 283, 821, 14, 709, 14, 7968, 3530, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 14, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 14, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 3130, 4519, 327, 283, 821, 14, 709, 14, 1690, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 14, 450, 40, 2689, 45, 297, 420, 327, 283, 821, 14, 1616, 14, 8315, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 57, 3130, 3322, 327, 283, 821, 14, 1616, 14, 8315, 3530, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 2689, 51, 297, 257, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 14, 450, 40, 2689, 45, 297, 420, 327, 283, 821, 14, 1616, 14, 24293, 14, 4329, 26, 1216, 7, 272, 1543, 68, 14, 450, 77, 14, 450, 89, 3130, 3322, 327, 283, 821, 14, 1616, 14, 24293, 3530, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 420, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 260, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 5185, 327, 283, 7968, 13, 709, 13, 821, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 7815, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
IllusionRom-deprecated/android_platform_external_chromium_org
tools/perf/benchmarks/spaceport.py
23
2422
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Runs spaceport.io's PerfMarks benchmark.""" import logging import os import sys from telemetry import test from telemetry.core import util from telemetry.page import page_measurement from telemetry.page import page_set class _SpaceportMeasurement(page_measurement.PageMeasurement): def CustomizeBrowserOptions(self, options): options.AppendExtraBrowserArgs('--disable-gpu-vsync') def MeasurePage(self, _, tab, results): tab.WaitForJavaScriptExpression( '!document.getElementById("start-performance-tests").disabled', 60) tab.ExecuteJavaScript(""" window.__results = {}; window.console.log = function(str) { if (!str) return; var key_val = str.split(': '); if (!key_val.length == 2) return; __results[key_val[0]] = key_val[1]; }; document.getElementById('start-performance-tests').click(); """) num_results = 0 num_tests_in_spaceport = 24 while num_results < num_tests_in_spaceport: tab.WaitForJavaScriptExpression( 'Object.keys(window.__results).length > %d' % num_results, 180) num_results = tab.EvaluateJavaScript( 'Object.keys(window.__results).length') logging.info('Completed test %d of %d' % (num_results, num_tests_in_spaceport)) result_dict = eval(tab.EvaluateJavaScript( 'JSON.stringify(window.__results)')) for key in result_dict: chart, trace = key.split('.', 1) results.Add(trace, 'objects (bigger is better)', float(result_dict[key]), chart_name=chart, data_type='unimportant') results.Add('Score', 'objects (bigger is better)', [float(x) for x in result_dict.values()]) class Spaceport(test.Test): """spaceport.io's PerfMarks benchmark.""" test = _SpaceportMeasurement # crbug.com/166703: This test frequently times out on Windows. enabled = sys.platform != 'darwin' and not sys.platform.startswith('win') def CreatePageSet(self, options): spaceport_dir = os.path.join(util.GetChromiumSrcDir(), 'chrome', 'test', 'data', 'third_party', 'spaceport') return page_set.PageSet.FromDict( {'pages': [{'url': 'file://index.html'}]}, spaceport_dir)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 16291, 4601, 719, 14, 2308, 1159, 31778, 6470, 83, 12338, 1041, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 199, 504, 17298, 492, 511, 199, 504, 17298, 14, 1018, 492, 4884, 199, 504, 17298, 14, 1606, 492, 2034, 63, 17912, 199, 504, 17298, 14, 1606, 492, 2034, 63, 409, 421, 199, 533, 485, 7643, 719, 18611, 434, 8, 1606, 63, 17912, 14, 3276, 18611, 434, 304, 523, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 1511, 14, 8310, 7426, 11930, 6213, 4517, 5993, 13, 6477, 13, 3122, 1870, 358, 819, 347, 22933, 3276, 8, 277, 12, 5501, 5174, 12, 2058, 304, 272, 5174, 14, 21433, 21986, 9093, 8, 267, 14597, 3554, 14, 26215, 480, 928, 13, 20576, 13, 2219, 3471, 7011, 297, 5212, 9, 339, 5174, 14, 12049, 21986, 4852, 267, 4353, 855, 2604, 275, 27978, 267, 4353, 14, 6614, 14, 793, 275, 805, 8, 495, 9, 469, 288, 340, 19452, 495, 9, 372, 27, 288, 2729, 790, 63, 637, 275, 620, 14, 1294, 6176, 283, 2736, 288, 340, 19452, 498, 63, 637, 14, 1267, 508, 499, 9, 372, 27, 288, 636, 2604, 59, 498, 63, 637, 59, 16, 2677, 275, 790, 63, 637, 59, 17, 11566, 267, 16735, 267, 2213, 14, 26215, 360, 928, 13, 20576, 13, 2219, 1959, 4891, 7303, 272, 7857, 339, 1967, 63, 2604, 275, 378, 272, 1967, 63, 2219, 63, 262, 63, 2638, 719, 275, 5504, 272, 1830, 1967, 63, 2604, 665, 1967, 63, 2219, 63, 262, 63, 2638, 719, 26, 489, 5174, 14, 21433, 21986, 9093, 8, 881, 283, 1692, 14, 1612, 8, 3806, 855, 2604, 680, 1267, 690, 450, 68, 7, 450, 1967, 63, 2604, 12, 13576, 9, 489, 1967, 63, 2604, 275, 5174, 14, 25002, 21986, 8, 881, 283, 1692, 14, 1612, 8, 3806, 855, 2604, 680, 1267, 358, 489, 2050, 14, 815, 360, 19908, 511, 450, 68, 402, 450, 68, 7, 450, 673, 334, 1507, 63, 2604, 12, 1967, 63, 2219, 63, 262, 63, 2638, 719, 430, 339, 754, 63, 807, 275, 3468, 8, 2902, 14, 25002, 21986, 8, 267, 283, 6243, 14, 875, 2021, 8, 3806, 855, 2604, 9, 1333, 272, 367, 790, 315, 754, 63, 807, 26, 489, 10943, 12, 3307, 275, 790, 14, 1294, 14078, 413, 9, 489, 2058, 14, 1123, 8, 3446, 12, 283, 1462, 334, 5076, 836, 365, 8034, 3196, 2069, 8, 1099, 63, 807, 59, 498, 2522, 2116, 10943, 63, 354, 29, 9019, 12, 666, 63, 466, 534, 324, 19559, 358, 272, 2058, 14, 1123, 360, 12642, 297, 283, 1462, 334, 5076, 836, 365, 8034, 3196, 355, 359, 1609, 8, 88, 9, 367, 671, 315, 754, 63, 807, 14, 1459, 9383, 421, 199, 533, 19326, 719, 8, 396, 14, 774, 304, 523, 408, 2638, 719, 14, 2308, 1159, 31778, 6470, 83, 12338, 1041, 523, 511, 275, 485, 7643, 719, 18611, 434, 819, 327, 2467, 1266, 14, 957, 15, 975, 1822, 1644, 26, 961, 511, 28914, 590, 5431, 734, 641, 5417, 14, 523, 5223, 275, 984, 14, 3246, 1137, 283, 13245, 7, 436, 440, 984, 14, 3246, 14, 2460, 360, 2676, 358, 819, 347, 2790, 3276, 1084, 8, 277, 12, 1511, 304, 272, 4601, 719, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1974, 14, 1002, 29381, 21261, 3567, 1062, 283, 9887, 297, 283, 396, 297, 267, 283, 576, 297, 283, 11470, 63, 7522, 297, 283, 2638, 719, 358, 272, 372, 2034, 63, 409, 14, 3276, 1084, 14, 2532, 2141, 8, 267, 791, 5856, 356, 9016, 633, 356, 283, 493, 921, 1080, 14, 1360, 936, 13888, 267, 4601, 719, 63, 694, 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 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 16291, 4601, 719, 14, 2308, 1159, 31778, 6470, 83, 12338, 1041, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 199, 504, 17298, 492, 511, 199, 504, 17298, 14, 1018, 492, 4884, 199, 504, 17298, 14, 1606, 492, 2034, 63, 17912, 199, 504, 17298, 14, 1606, 492, 2034, 63, 409, 421, 199, 533, 485, 7643, 719, 18611, 434, 8, 1606, 63, 17912, 14, 3276, 18611, 434, 304, 523, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 1511, 14, 8310, 7426, 11930, 6213, 4517, 5993, 13, 6477, 13, 3122, 1870, 358, 819, 347, 22933, 3276, 8, 277, 12, 5501, 5174, 12, 2058, 304, 272, 5174, 14, 21433, 21986, 9093, 8, 267, 14597, 3554, 14, 26215, 480, 928, 13, 20576, 13, 2219, 3471, 7011, 297, 5212, 9, 339, 5174, 14, 12049, 21986, 4852, 267, 4353, 855, 2604, 275, 27978, 267, 4353, 14, 6614, 14, 793, 275, 805, 8, 495, 9, 469, 288, 340, 19452, 495, 9, 372, 27, 288, 2729, 790, 63, 637, 275, 620, 14, 1294, 6176, 283, 2736, 288, 340, 19452, 498, 63, 637, 14, 1267, 508, 499, 9, 372, 27, 288, 636, 2604, 59, 498, 63, 637, 59, 16, 2677, 275, 790, 63, 637, 59, 17, 11566, 267, 16735, 267, 2213, 14, 26215, 360, 928, 13, 20576, 13, 2219, 1959, 4891, 7303, 272, 7857, 339, 1967, 63, 2604, 275, 378, 272, 1967, 63, 2219, 63, 262, 63, 2638, 719, 275, 5504, 272, 1830, 1967, 63, 2604, 665, 1967, 63, 2219, 63, 262, 63, 2638, 719, 26, 489, 5174, 14, 21433, 21986, 9093, 8, 881, 283, 1692, 14, 1612, 8, 3806, 855, 2604, 680, 1267, 690, 450, 68, 7, 450, 1967, 63, 2604, 12, 13576, 9, 489, 1967, 63, 2604, 275, 5174, 14, 25002, 21986, 8, 881, 283, 1692, 14, 1612, 8, 3806, 855, 2604, 680, 1267, 358, 489, 2050, 14, 815, 360, 19908, 511, 450, 68, 402, 450, 68, 7, 450, 673, 334, 1507, 63, 2604, 12, 1967, 63, 2219, 63, 262, 63, 2638, 719, 430, 339, 754, 63, 807, 275, 3468, 8, 2902, 14, 25002, 21986, 8, 267, 283, 6243, 14, 875, 2021, 8, 3806, 855, 2604, 9, 1333, 272, 367, 790, 315, 754, 63, 807, 26, 489, 10943, 12, 3307, 275, 790, 14, 1294, 14078, 413, 9, 489, 2058, 14, 1123, 8, 3446, 12, 283, 1462, 334, 5076, 836, 365, 8034, 3196, 2069, 8, 1099, 63, 807, 59, 498, 2522, 2116, 10943, 63, 354, 29, 9019, 12, 666, 63, 466, 534, 324, 19559, 358, 272, 2058, 14, 1123, 360, 12642, 297, 283, 1462, 334, 5076, 836, 365, 8034, 3196, 355, 359, 1609, 8, 88, 9, 367, 671, 315, 754, 63, 807, 14, 1459, 9383, 421, 199, 533, 19326, 719, 8, 396, 14, 774, 304, 523, 408, 2638, 719, 14, 2308, 1159, 31778, 6470, 83, 12338, 1041, 523, 511, 275, 485, 7643, 719, 18611, 434, 819, 327, 2467, 1266, 14, 957, 15, 975, 1822, 1644, 26, 961, 511, 28914, 590, 5431, 734, 641, 5417, 14, 523, 5223, 275, 984, 14, 3246, 1137, 283, 13245, 7, 436, 440, 984, 14, 3246, 14, 2460, 360, 2676, 358, 819, 347, 2790, 3276, 1084, 8, 277, 12, 1511, 304, 272, 4601, 719, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1974, 14, 1002, 29381, 21261, 3567, 1062, 283, 9887, 297, 283, 396, 297, 267, 283, 576, 297, 283, 11470, 63, 7522, 297, 283, 2638, 719, 358, 272, 372, 2034, 63, 409, 14, 3276, 1084, 14, 2532, 2141, 8, 267, 791, 5856, 356, 9016, 633, 356, 283, 493, 921, 1080, 14, 1360, 936, 13888, 267, 4601, 719, 63, 694, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ntt-sic/cinder
cinder/api/v2/router.py
2
4033
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2011 OpenStack Foundation # Copyright 2011 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ WSGI middleware for OpenStack Volume API. """ from cinder.api import extensions import cinder.api.openstack from cinder.api.v2 import limits from cinder.api.v2 import snapshot_metadata from cinder.api.v2 import snapshots from cinder.api.v2 import types from cinder.api.v2 import volume_metadata from cinder.api.v2 import volumes from cinder.api import versions from cinder.openstack.common import log as logging LOG = logging.getLogger(__name__) class APIRouter(cinder.api.openstack.APIRouter): """Routes requests on the API to the appropriate controller and method.""" ExtensionManager = extensions.ExtensionManager def _setup_routes(self, mapper, ext_mgr): self.resources['versions'] = versions.create_resource() mapper.connect("versions", "/", controller=self.resources['versions'], action='show') mapper.redirect("", "/") self.resources['volumes'] = volumes.create_resource(ext_mgr) mapper.resource("volume", "volumes", controller=self.resources['volumes'], collection={'detail': 'GET'}, member={'action': 'POST'}) self.resources['types'] = types.create_resource() mapper.resource("type", "types", controller=self.resources['types']) self.resources['snapshots'] = snapshots.create_resource(ext_mgr) mapper.resource("snapshot", "snapshots", controller=self.resources['snapshots'], collection={'detail': 'GET'}, member={'action': 'POST'}) self.resources['limits'] = limits.create_resource() mapper.resource("limit", "limits", controller=self.resources['limits']) self.resources['snapshot_metadata'] = \ snapshot_metadata.create_resource() snapshot_metadata_controller = self.resources['snapshot_metadata'] mapper.resource("snapshot_metadata", "metadata", controller=snapshot_metadata_controller, parent_resource=dict(member_name='snapshot', collection_name='snapshots')) mapper.connect("metadata", "/{project_id}/snapshots/{snapshot_id}/metadata", controller=snapshot_metadata_controller, action='update_all', conditions={"method": ['PUT']}) self.resources['volume_metadata'] = \ volume_metadata.create_resource() volume_metadata_controller = self.resources['volume_metadata'] mapper.resource("volume_metadata", "metadata", controller=volume_metadata_controller, parent_resource=dict(member_name='volume', collection_name='volumes')) mapper.connect("metadata", "/{project_id}/volumes/{volume_id}/metadata", controller=volume_metadata_controller, action='update_all', conditions={"method": ['PUT']})
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7760, 14260, 2752, 199, 3, 1898, 7760, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 16828, 10816, 367, 14260, 15018, 3261, 14, 199, 624, 199, 199, 504, 13069, 14, 1246, 492, 5478, 199, 646, 13069, 14, 1246, 14, 8512, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 10976, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 5740, 63, 2343, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 19076, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 2943, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 3301, 63, 2343, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 12158, 199, 504, 13069, 14, 1246, 492, 5459, 199, 504, 13069, 14, 8512, 14, 2330, 492, 943, 465, 2050, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3261, 11691, 8, 12372, 14, 1246, 14, 8512, 14, 3735, 11691, 304, 272, 408, 5407, 744, 4145, 641, 314, 3261, 370, 314, 5827, 7614, 436, 1083, 1041, 272, 13282, 2988, 275, 5478, 14, 6382, 2988, 339, 347, 485, 2758, 63, 13243, 8, 277, 12, 7796, 12, 1599, 63, 7755, 304, 267, 291, 14, 4435, 459, 6234, 418, 275, 5459, 14, 981, 63, 1927, 342, 267, 7796, 14, 2242, 480, 6234, 401, 3286, 401, 2432, 7614, 29, 277, 14, 4435, 459, 6234, 995, 2432, 1595, 534, 2384, 358, 398, 7796, 14, 4876, 12398, 3286, 531, 398, 291, 14, 4435, 459, 8838, 418, 275, 12158, 14, 981, 63, 1927, 8, 832, 63, 7755, 9, 267, 7796, 14, 1927, 480, 2405, 401, 298, 8838, 401, 717, 7614, 29, 277, 14, 4435, 459, 8838, 995, 717, 3245, 3713, 5506, 356, 283, 2970, 2267, 717, 3653, 3713, 1287, 356, 283, 4030, 3071, 398, 291, 14, 4435, 459, 1313, 418, 275, 2943, 14, 981, 63, 1927, 342, 267, 7796, 14, 1927, 480, 466, 401, 298, 1313, 401, 717, 7614, 29, 277, 14, 4435, 459, 1313, 1105, 398, 291, 14, 4435, 459, 15331, 418, 275, 19076, 14, 981, 63, 1927, 8, 832, 63, 7755, 9, 267, 7796, 14, 1927, 480, 4753, 401, 298, 15331, 401, 717, 7614, 29, 277, 14, 4435, 459, 15331, 995, 717, 3245, 3713, 5506, 356, 283, 2970, 2267, 717, 3653, 3713, 1287, 356, 283, 4030, 3071, 398, 291, 14, 4435, 459, 9368, 418, 275, 10976, 14, 981, 63, 1927, 342, 267, 7796, 14, 1927, 480, 3097, 401, 298, 9368, 401, 717, 7614, 29, 277, 14, 4435, 459, 9368, 1105, 398, 291, 14, 4435, 459, 4753, 63, 2343, 418, 275, 971, 288, 5740, 63, 2343, 14, 981, 63, 1927, 342, 267, 5740, 63, 2343, 63, 5538, 275, 291, 14, 4435, 459, 4753, 63, 2343, 418, 398, 7796, 14, 1927, 480, 4753, 63, 2343, 401, 298, 2343, 401, 717, 7614, 29, 4753, 63, 2343, 63, 5538, 12, 717, 1676, 63, 1927, 29, 807, 8, 1114, 63, 354, 534, 4753, 297, 6163, 3245, 63, 354, 534, 15331, 1333, 398, 7796, 14, 2242, 480, 2343, 401, 2432, 3286, 91, 1715, 63, 344, 5995, 15331, 5321, 4753, 63, 344, 5995, 2343, 401, 2432, 7614, 29, 4753, 63, 2343, 63, 5538, 12, 2432, 1595, 534, 873, 63, 452, 297, 2432, 3704, 8871, 765, 582, 788, 4013, 13678, 398, 291, 14, 4435, 459, 2405, 63, 2343, 418, 275, 971, 288, 3301, 63, 2343, 14, 981, 63, 1927, 342, 267, 3301, 63, 2343, 63, 5538, 275, 291, 14, 4435, 459, 2405, 63, 2343, 418, 398, 7796, 14, 1927, 480, 2405, 63, 2343, 401, 298, 2343, 401, 717, 7614, 29, 2405, 63, 2343, 63, 5538, 12, 717, 1676, 63, 1927, 29, 807, 8, 1114, 63, 354, 534, 2405, 297, 6163, 3245, 63, 354, 534, 8838, 1333, 398, 7796, 14, 2242, 480, 2343, 401, 2432, 3286, 91, 1715, 63, 344, 5995, 8838, 5321, 2405, 63, 344, 5995, 2343, 401, 2432, 7614, 29, 2405, 63, 2343, 63, 5538, 12, 2432, 1595, 534, 873, 63, 452, 297, 2432, 3704, 8871, 765, 582, 788, 4013, 13678, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 7760, 14260, 2752, 199, 3, 1898, 7760, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 16828, 10816, 367, 14260, 15018, 3261, 14, 199, 624, 199, 199, 504, 13069, 14, 1246, 492, 5478, 199, 646, 13069, 14, 1246, 14, 8512, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 10976, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 5740, 63, 2343, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 19076, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 2943, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 3301, 63, 2343, 199, 504, 13069, 14, 1246, 14, 86, 18, 492, 12158, 199, 504, 13069, 14, 1246, 492, 5459, 199, 504, 13069, 14, 8512, 14, 2330, 492, 943, 465, 2050, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3261, 11691, 8, 12372, 14, 1246, 14, 8512, 14, 3735, 11691, 304, 272, 408, 5407, 744, 4145, 641, 314, 3261, 370, 314, 5827, 7614, 436, 1083, 1041, 272, 13282, 2988, 275, 5478, 14, 6382, 2988, 339, 347, 485, 2758, 63, 13243, 8, 277, 12, 7796, 12, 1599, 63, 7755, 304, 267, 291, 14, 4435, 459, 6234, 418, 275, 5459, 14, 981, 63, 1927, 342, 267, 7796, 14, 2242, 480, 6234, 401, 3286, 401, 2432, 7614, 29, 277, 14, 4435, 459, 6234, 995, 2432, 1595, 534, 2384, 358, 398, 7796, 14, 4876, 12398, 3286, 531, 398, 291, 14, 4435, 459, 8838, 418, 275, 12158, 14, 981, 63, 1927, 8, 832, 63, 7755, 9, 267, 7796, 14, 1927, 480, 2405, 401, 298, 8838, 401, 717, 7614, 29, 277, 14, 4435, 459, 8838, 995, 717, 3245, 3713, 5506, 356, 283, 2970, 2267, 717, 3653, 3713, 1287, 356, 283, 4030, 3071, 398, 291, 14, 4435, 459, 1313, 418, 275, 2943, 14, 981, 63, 1927, 342, 267, 7796, 14, 1927, 480, 466, 401, 298, 1313, 401, 717, 7614, 29, 277, 14, 4435, 459, 1313, 1105, 398, 291, 14, 4435, 459, 15331, 418, 275, 19076, 14, 981, 63, 1927, 8, 832, 63, 7755, 9, 267, 7796, 14, 1927, 480, 4753, 401, 298, 15331, 401, 717, 7614, 29, 277, 14, 4435, 459, 15331, 995, 717, 3245, 3713, 5506, 356, 283, 2970, 2267, 717, 3653, 3713, 1287, 356, 283, 4030, 3071, 398, 291, 14, 4435, 459, 9368, 418, 275, 10976, 14, 981, 63, 1927, 342, 267, 7796, 14, 1927, 480, 3097, 401, 298, 9368, 401, 717, 7614, 29, 277, 14, 4435, 459, 9368, 1105, 398, 291, 14, 4435, 459, 4753, 63, 2343, 418, 275, 971, 288, 5740, 63, 2343, 14, 981, 63, 1927, 342, 267, 5740, 63, 2343, 63, 5538, 275, 291, 14, 4435, 459, 4753, 63, 2343, 418, 398, 7796, 14, 1927, 480, 4753, 63, 2343, 401, 298, 2343, 401, 717, 7614, 29, 4753, 63, 2343, 63, 5538, 12, 717, 1676, 63, 1927, 29, 807, 8, 1114, 63, 354, 534, 4753, 297, 6163, 3245, 63, 354, 534, 15331, 1333, 398, 7796, 14, 2242, 480, 2343, 401, 2432, 3286, 91, 1715, 63, 344, 5995, 15331, 5321, 4753, 63, 344, 5995, 2343, 401, 2432, 7614, 29, 4753, 63, 2343, 63, 5538, 12, 2432, 1595, 534, 873, 63, 452, 297, 2432, 3704, 8871, 765, 582, 788, 4013, 13678, 398, 291, 14, 4435, 459, 2405, 63, 2343, 418, 275, 971, 288, 3301, 63, 2343, 14, 981, 63, 1927, 342, 267, 3301, 63, 2343, 63, 5538, 275, 291, 14, 4435, 459, 2405, 63, 2343, 418, 398, 7796, 14, 1927, 480, 2405, 63, 2343, 401, 298, 2343, 401, 717, 7614, 29, 2405, 63, 2343, 63, 5538, 12, 717, 1676, 63, 1927, 29, 807, 8, 1114, 63, 354, 534, 2405, 297, 6163, 3245, 63, 354, 534, 8838, 1333, 398, 7796, 14, 2242, 480, 2343, 401, 2432, 3286, 91, 1715, 63, 344, 5995, 8838, 5321, 2405, 63, 344, 5995, 2343, 401, 2432, 7614, 29, 2405, 63, 2343, 63, 5538, 12, 2432, 1595, 534, 873, 63, 452, 297, 2432, 3704, 8871, 765, 582, 788, 4013, 13678, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
sriprasanna/django-1.3.1
tests/regressiontests/get_or_create_regress/tests.py
88
2540
from django.test import TestCase from models import Author, Publisher class GetOrCreateTests(TestCase): def test_related(self): p = Publisher.objects.create(name="Acme Publishing") # Create a book through the publisher. book, created = p.books.get_or_create(name="The Book of Ed & Fred") self.assertTrue(created) # The publisher should have one book. self.assertEqual(p.books.count(), 1) # Try get_or_create again, this time nothing should be created. book, created = p.books.get_or_create(name="The Book of Ed & Fred") self.assertFalse(created) # And the publisher should still have one book. self.assertEqual(p.books.count(), 1) # Add an author to the book. ed, created = book.authors.get_or_create(name="Ed") self.assertTrue(created) # The book should have one author. self.assertEqual(book.authors.count(), 1) # Try get_or_create again, this time nothing should be created. ed, created = book.authors.get_or_create(name="Ed") self.assertFalse(created) # And the book should still have one author. self.assertEqual(book.authors.count(), 1) # Add a second author to the book. fred, created = book.authors.get_or_create(name="Fred") self.assertTrue(created) # The book should have two authors now. self.assertEqual(book.authors.count(), 2) # Create an Author not tied to any books. Author.objects.create(name="Ted") # There should be three Authors in total. The book object should have two. self.assertEqual(Author.objects.count(), 3) self.assertEqual(book.authors.count(), 2) # Try creating a book through an author. _, created = ed.books.get_or_create(name="Ed's Recipes", publisher=p) self.assertTrue(created) # Now Ed has two Books, Fred just one. self.assertEqual(ed.books.count(), 2) self.assertEqual(fred.books.count(), 1) # Use the publisher's primary key value instead of a model instance. _, created = ed.books.get_or_create(name='The Great Book of Ed', publisher_id=p.id) self.assertTrue(created) # Try get_or_create again, this time nothing should be created. _, created = ed.books.get_or_create(name='The Great Book of Ed', publisher_id=p.id) self.assertFalse(created) # The publisher should have three books. self.assertEqual(p.books.count(), 3)
bsd-3-clause
[ 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1709, 492, 6529, 12, 19952, 281, 421, 199, 533, 2372, 2844, 2499, 2925, 8, 1746, 304, 272, 347, 511, 63, 2407, 8, 277, 304, 267, 299, 275, 19952, 281, 14, 1462, 14, 981, 8, 354, 628, 1945, 278, 19952, 316, 531, 267, 327, 2790, 282, 6719, 4012, 314, 19704, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 19704, 1077, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 19704, 1077, 5139, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 2654, 376, 4132, 370, 314, 6719, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 6719, 1077, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 6719, 1077, 5139, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 2654, 282, 3499, 4132, 370, 314, 6719, 14, 267, 289, 581, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 38, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 710, 6719, 1077, 1172, 2877, 11462, 3063, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 2790, 376, 6529, 440, 29142, 370, 1263, 19040, 14, 267, 6529, 14, 1462, 14, 981, 8, 354, 628, 52, 379, 531, 398, 327, 6006, 1077, 506, 7795, 6642, 315, 3141, 14, 710, 6719, 909, 1077, 1172, 2877, 14, 267, 291, 14, 629, 8, 5949, 14, 1462, 14, 835, 1062, 650, 9, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 7649, 6425, 282, 6719, 4012, 376, 4132, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 1159, 799, 8233, 83, 401, 19704, 29, 80, 9, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 7356, 17379, 965, 2877, 8944, 83, 12, 481, 581, 2951, 1373, 14, 267, 291, 14, 629, 8, 379, 14, 8858, 14, 835, 1062, 499, 9, 267, 291, 14, 629, 8, 22980, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 3645, 314, 19704, 1159, 5062, 790, 574, 3140, 402, 282, 1402, 1256, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 534, 1918, 598, 8319, 8944, 402, 17379, 297, 19704, 63, 344, 29, 80, 14, 344, 9, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 534, 1918, 598, 8319, 8944, 402, 17379, 297, 19704, 63, 344, 29, 80, 14, 344, 9, 267, 291, 14, 3334, 8, 3966, 9, 398, 327, 710, 19704, 1077, 1172, 7795, 19040, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 650, 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 ]
[ 1639, 14, 396, 492, 7640, 199, 199, 504, 1709, 492, 6529, 12, 19952, 281, 421, 199, 533, 2372, 2844, 2499, 2925, 8, 1746, 304, 272, 347, 511, 63, 2407, 8, 277, 304, 267, 299, 275, 19952, 281, 14, 1462, 14, 981, 8, 354, 628, 1945, 278, 19952, 316, 531, 267, 327, 2790, 282, 6719, 4012, 314, 19704, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 19704, 1077, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 6719, 12, 2737, 275, 299, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 1918, 8944, 402, 17379, 1253, 481, 581, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 19704, 1077, 5139, 1172, 1373, 6719, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 2654, 376, 4132, 370, 314, 6719, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 1815, 8, 3966, 9, 267, 327, 710, 6719, 1077, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 3988, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 531, 267, 291, 14, 3334, 8, 3966, 9, 267, 327, 6061, 314, 6719, 1077, 5139, 1172, 1373, 4132, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 413, 9, 398, 327, 2654, 282, 3499, 4132, 370, 314, 6719, 14, 267, 289, 581, 12, 2737, 275, 6719, 14, 8149, 14, 362, 63, 269, 63, 981, 8, 354, 628, 38, 581, 531, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 710, 6719, 1077, 1172, 2877, 11462, 3063, 14, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 2790, 376, 6529, 440, 29142, 370, 1263, 19040, 14, 267, 6529, 14, 1462, 14, 981, 8, 354, 628, 52, 379, 531, 398, 327, 6006, 1077, 506, 7795, 6642, 315, 3141, 14, 710, 6719, 909, 1077, 1172, 2877, 14, 267, 291, 14, 629, 8, 5949, 14, 1462, 14, 835, 1062, 650, 9, 267, 291, 14, 629, 8, 2706, 14, 8149, 14, 835, 1062, 499, 9, 398, 327, 7649, 6425, 282, 6719, 4012, 376, 4132, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 628, 8751, 1159, 799, 8233, 83, 401, 19704, 29, 80, 9, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 7356, 17379, 965, 2877, 8944, 83, 12, 481, 581, 2951, 1373, 14, 267, 291, 14, 629, 8, 379, 14, 8858, 14, 835, 1062, 499, 9, 267, 291, 14, 629, 8, 22980, 14, 8858, 14, 835, 1062, 413, 9, 398, 327, 3645, 314, 19704, 1159, 5062, 790, 574, 3140, 402, 282, 1402, 1256, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 534, 1918, 598, 8319, 8944, 402, 17379, 297, 19704, 63, 344, 29, 80, 14, 344, 9, 267, 291, 14, 1815, 8, 3966, 9, 398, 327, 7649, 664, 63, 269, 63, 981, 4020, 12, 642, 900, 6548, 1077, 506, 2737, 14, 267, 5501, 2737, 275, 3988, 14, 8858, 14, 362, 63, 269, 63, 981, 8, 354, 534, 1918, 598, 8319, 8944, 402, 17379, 297, 19704, 63, 344, 29, 80, 14, 344, 9, 267, 291, 14, 3334, 8, 3966, 9, 398, 327, 710, 19704, 1077, 1172, 7795, 19040, 14, 267, 291, 14, 629, 8, 80, 14, 8858, 14, 835, 1062, 650, 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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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 ]
kmoocdev/edx-platform
common/lib/xmodule/xmodule/tests/test_word_cloud.py
28
1793
# -*- coding: utf-8 -*- """Test for Word cloud Xmodule functional logic.""" from webob.multidict import MultiDict from xmodule.word_cloud_module import WordCloudDescriptor from . import LogicTest class WordCloudModuleTest(LogicTest): """Logic tests for Word Cloud Xmodule.""" descriptor_class = WordCloudDescriptor raw_field_data = { 'all_words': {'cat': 10, 'dog': 5, 'mom': 1, 'dad': 2}, 'top_words': {'cat': 10, 'dog': 5, 'dad': 2}, 'submitted': False } def test_bad_ajax_request(self): "Make sure that answer for incorrect request is error json" response = self.ajax_request('bad_dispatch', {}) self.assertDictEqual(response, { 'status': 'fail', 'error': 'Unknown Command!' }) def test_good_ajax_request(self): "Make shure that ajax request works correctly" post_data = MultiDict(('student_words[]', word) for word in ['cat', 'cat', 'dog', 'sun']) response = self.ajax_request('submit', post_data) self.assertEqual(response['status'], 'success') self.assertEqual(response['submitted'], True) self.assertEqual(response['total_count'], 22) self.assertDictEqual( response['student_words'], {'sun': 1, 'dog': 6, 'cat': 12} ) self.assertListEqual( response['top_words'], [{'text': 'dad', 'size': 2, 'percent': 9.0}, {'text': 'sun', 'size': 1, 'percent': 5.0}, {'text': 'dog', 'size': 6, 'percent': 27.0}, {'text': 'mom', 'size': 1, 'percent': 5.0}, {'text': 'cat', 'size': 12, 'percent': 54.0}] ) self.assertEqual( 100.0, sum(i['percent'] for i in response['top_words']))
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 774, 367, 14644, 8002, 1323, 578, 22380, 9661, 1041, 199, 199, 504, 14568, 14, 3029, 807, 492, 29393, 199, 504, 9872, 14, 1027, 63, 4091, 63, 578, 492, 14644, 9089, 4311, 199, 504, 1275, 492, 5297, 530, 774, 421, 199, 533, 14644, 9089, 2377, 774, 8, 32140, 774, 304, 272, 408, 32140, 2295, 367, 14644, 8142, 1323, 578, 1041, 272, 5872, 63, 533, 275, 14644, 9089, 4311, 272, 3066, 63, 698, 63, 576, 275, 469, 267, 283, 452, 63, 3148, 356, 791, 3385, 356, 1616, 12, 283, 13889, 356, 959, 12, 283, 31714, 356, 413, 12, 283, 25805, 356, 499, 1386, 267, 283, 2119, 63, 3148, 356, 791, 3385, 356, 1616, 12, 283, 13889, 356, 959, 12, 283, 25805, 356, 499, 1386, 267, 283, 23736, 356, 756, 272, 789, 339, 347, 511, 63, 4087, 63, 12774, 63, 1069, 8, 277, 304, 267, 298, 5483, 3238, 626, 6385, 367, 8927, 1056, 365, 1125, 2022, 2, 267, 1177, 275, 291, 14, 12774, 63, 1069, 360, 4087, 63, 6052, 297, 5009, 267, 291, 14, 19512, 8, 1310, 12, 469, 288, 283, 1205, 356, 283, 1633, 297, 288, 283, 705, 356, 283, 5912, 5817, 11213, 267, 3828, 339, 347, 511, 63, 8302, 63, 12774, 63, 1069, 8, 277, 304, 267, 298, 5483, 1033, 608, 626, 25930, 1056, 5419, 6657, 2, 267, 2963, 63, 576, 275, 29393, 4725, 5500, 63, 3148, 59, 4300, 4349, 9, 367, 4349, 315, 788, 3385, 297, 283, 3385, 297, 283, 13889, 297, 283, 11846, 1105, 267, 1177, 275, 291, 14, 12774, 63, 1069, 360, 7275, 297, 2963, 63, 576, 9, 267, 291, 14, 629, 8, 1310, 459, 1205, 995, 283, 3742, 358, 267, 291, 14, 629, 8, 1310, 459, 23736, 995, 715, 9, 267, 291, 14, 629, 8, 1310, 459, 2923, 63, 835, 995, 6928, 9, 267, 291, 14, 19512, 8, 288, 1177, 459, 5500, 63, 3148, 995, 288, 791, 11846, 356, 413, 12, 283, 13889, 356, 1227, 12, 283, 3385, 356, 3144, 93, 267, 776, 267, 291, 14, 16671, 8, 288, 1177, 459, 2119, 63, 3148, 995, 288, 9016, 505, 356, 283, 25805, 297, 283, 890, 356, 499, 12, 283, 7045, 356, 1749, 14, 16, 1386, 1467, 791, 505, 356, 283, 11846, 297, 283, 890, 356, 413, 12, 283, 7045, 356, 959, 14, 16, 1386, 1467, 791, 505, 356, 283, 13889, 297, 283, 890, 356, 1227, 12, 283, 7045, 356, 8087, 14, 16, 1386, 1467, 791, 505, 356, 283, 31714, 297, 283, 890, 356, 413, 12, 283, 7045, 356, 959, 14, 16, 1386, 1467, 791, 505, 356, 283, 3385, 297, 283, 890, 356, 3144, 12, 283, 7045, 356, 13470, 14, 16, 11049, 267, 776, 398, 291, 14, 629, 8, 288, 2948, 14, 16, 12, 288, 3089, 8, 73, 459, 7045, 418, 367, 284, 315, 1177, 459, 2119, 63, 3148, 5156, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 774, 367, 14644, 8002, 1323, 578, 22380, 9661, 1041, 199, 199, 504, 14568, 14, 3029, 807, 492, 29393, 199, 504, 9872, 14, 1027, 63, 4091, 63, 578, 492, 14644, 9089, 4311, 199, 504, 1275, 492, 5297, 530, 774, 421, 199, 533, 14644, 9089, 2377, 774, 8, 32140, 774, 304, 272, 408, 32140, 2295, 367, 14644, 8142, 1323, 578, 1041, 272, 5872, 63, 533, 275, 14644, 9089, 4311, 272, 3066, 63, 698, 63, 576, 275, 469, 267, 283, 452, 63, 3148, 356, 791, 3385, 356, 1616, 12, 283, 13889, 356, 959, 12, 283, 31714, 356, 413, 12, 283, 25805, 356, 499, 1386, 267, 283, 2119, 63, 3148, 356, 791, 3385, 356, 1616, 12, 283, 13889, 356, 959, 12, 283, 25805, 356, 499, 1386, 267, 283, 23736, 356, 756, 272, 789, 339, 347, 511, 63, 4087, 63, 12774, 63, 1069, 8, 277, 304, 267, 298, 5483, 3238, 626, 6385, 367, 8927, 1056, 365, 1125, 2022, 2, 267, 1177, 275, 291, 14, 12774, 63, 1069, 360, 4087, 63, 6052, 297, 5009, 267, 291, 14, 19512, 8, 1310, 12, 469, 288, 283, 1205, 356, 283, 1633, 297, 288, 283, 705, 356, 283, 5912, 5817, 11213, 267, 3828, 339, 347, 511, 63, 8302, 63, 12774, 63, 1069, 8, 277, 304, 267, 298, 5483, 1033, 608, 626, 25930, 1056, 5419, 6657, 2, 267, 2963, 63, 576, 275, 29393, 4725, 5500, 63, 3148, 59, 4300, 4349, 9, 367, 4349, 315, 788, 3385, 297, 283, 3385, 297, 283, 13889, 297, 283, 11846, 1105, 267, 1177, 275, 291, 14, 12774, 63, 1069, 360, 7275, 297, 2963, 63, 576, 9, 267, 291, 14, 629, 8, 1310, 459, 1205, 995, 283, 3742, 358, 267, 291, 14, 629, 8, 1310, 459, 23736, 995, 715, 9, 267, 291, 14, 629, 8, 1310, 459, 2923, 63, 835, 995, 6928, 9, 267, 291, 14, 19512, 8, 288, 1177, 459, 5500, 63, 3148, 995, 288, 791, 11846, 356, 413, 12, 283, 13889, 356, 1227, 12, 283, 3385, 356, 3144, 93, 267, 776, 267, 291, 14, 16671, 8, 288, 1177, 459, 2119, 63, 3148, 995, 288, 9016, 505, 356, 283, 25805, 297, 283, 890, 356, 499, 12, 283, 7045, 356, 1749, 14, 16, 1386, 1467, 791, 505, 356, 283, 11846, 297, 283, 890, 356, 413, 12, 283, 7045, 356, 959, 14, 16, 1386, 1467, 791, 505, 356, 283, 13889, 297, 283, 890, 356, 1227, 12, 283, 7045, 356, 8087, 14, 16, 1386, 1467, 791, 505, 356, 283, 31714, 297, 283, 890, 356, 413, 12, 283, 7045, 356, 959, 14, 16, 1386, 1467, 791, 505, 356, 283, 3385, 297, 283, 890, 356, 3144, 12, 283, 7045, 356, 13470, 14, 16, 11049, 267, 776, 398, 291, 14, 629, 8, 288, 2948, 14, 16, 12, 288, 3089, 8, 73, 459, 7045, 418, 367, 284, 315, 1177, 459, 2119, 63, 3148, 5156, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
stu314159/pyNFC
partition_suggestion.py
1
5450
""" partition_suggestion.py purpose: Given Nx, Ny, Nz and a number of processes, suggest a partitioning strategy that would result in more-or-less cube-shaped partitions """ import random from collections import deque def random_partition(factors,n_factors): """ factors = list of prime factors of a number n_factors = three-tuple [#px, #py, #pz] indicating the number of prime factors that should be chosen (at random) for each direction returns [px,py,pz] """ l_factors = factors[:] # make a local copy p_list = [1,1,1] for d in range(3): for i in range(n_factors[d]): c = random.choice(l_factors) l_factors.remove(c) p_list[d]*=c return p_list class Partition: def __init__(self,Nx,Ny,Nz,part): self.Nx = Nx self.Ny = Ny self.Nz = Nz self.px = part[0] self.py = part[1] self.pz = part[2] self.set_score() def set_score(self): lx = self.Nx/float(self.px) ly = self.Ny/float(self.py) lz = self.Nz/float(self.pz) # obviously, change this measure if it proves crappy. # estimate surface to volume ratio of the typical partition vol = lx*ly*lz surf = 2.*lx*ly + 2.*lx*lz + 2.*lz*ly self.score = surf/vol #vol = lx*ly*lz #surf = 2.*lx*ly + 2.*lx*lz + 2.*lz*ly #interior = vol - surf #self.score = (surf/interior) def get_score(self): return self.score def get_partition(self): return [self.px, self.py, self.pz] def partitionfunc(n,k,l=1): '''n is the integer to partition, k is the length of partitions, l is the min partition element size''' if k < 1: raise StopIteration if k == 1: if n >= l: yield (n,) raise StopIteration for i in range(l,n+1): for result in partitionfunc(n-i,k-1,i): yield (i,)+result def primes(n): """ return a list containing the prime factorization of positive integer n n = positive integer """ primfac = [] d = 2 while d*d <= n: while (n % d) == 0: primfac.append(d) # supposing you want multiple factors repeated n //= d d += 1 if n > 1: primfac.append(n) return primfac def factors(n): """ n = positive integer returns a list of the factors of n in (more-or-less) standard form """ return filter(lambda i: n % i == 0, range(1, n + 1)) def part_advisor(Nx,Ny,Nz,num_procs, numTrials = 2000): """ Nx = number of points in the x-direction Ny = number of points in the y-direction Nz = number of points in the z-direction num_procs = the number of partitions to create returns a suggested px,py,pz """ p_facts = primes(num_procs) p_facts.append(1) p_facts.append(1) # to allow effectively 1-D partitioning if that is best.... bestScore = float("inf") bestPartition = None #numTrials = 4000 # not clear to me how big this should be... for p in partitionfunc(len(p_facts),3): #print p """ set up some partitions and keep track of the one with the best score. """ p_deque = deque(p); for i in range(3): p_deque.rotate(1) #shift the groupings # take numTrials samples for trial in range(numTrials): r_part = random_partition(p_facts,p_deque) sample_partition = Partition(Nx,Ny,Nz,r_part) sample_score = sample_partition.get_score() if sample_score < bestScore: bestPartition = Partition(Nx,Ny,Nz,r_part) return bestPartition.get_partition() """ partitionfunc will let me generate groupings of the prime factors """ """ if there are fewer than 3 prime factors, then there is no way to solve the problem; an error should be returned and the user should be prompted to provide a value for num_procs that has more prime factors. """ if len(p_facts)<3: print 'Error! num_procs is prime and cannot be used for 3D partitioning' raise RuntimeError print p_facts """ concept: use the prime factors listed in p_facts and put them into 3 groups such that, as close as possible, Nx/g1, Ny/g2 and Nz/g3 are nearly equal. To do this, for each grouping, I will compute the variance of the partition dimensions. I will then select the grouping that has the lowest variance. 1. Enumerate all of the possible groupings of the prime factors. 2. Compute the partition dimension variance for each grouping 3. Pick the smallest one. """ if __name__=="__main__": """ write test code here... """ Nx = 150 Ny = 150 Nz = 1000 num_procs = 8 partition = part_advisor(Nx,Ny,Nz,num_procs) bestPartition = Partition(Nx,Ny,Nz,partition) print 'Best partition found has score = %g \n'%bestPartition.get_score() print bestPartition.get_partition() print 'Block sizes approximately %i x %i x %i'%(Nx/partition[0],Ny/partition[1],Nz/partition[2])
mit
[ 624, 199, 5312, 63, 19957, 1636, 14, 647, 199, 199, 22615, 26, 9138, 653, 88, 12, 653, 89, 12, 653, 90, 436, 282, 1329, 402, 10358, 12, 18453, 282, 6484, 316, 10054, 626, 3955, 754, 315, 199, 6878, 13, 269, 13, 2003, 15681, 13, 1392, 68, 16394, 199, 199, 624, 199, 646, 2196, 199, 504, 5055, 492, 15782, 421, 199, 318, 2196, 63, 5312, 8, 16125, 12, 78, 63, 16125, 304, 272, 408, 272, 17704, 275, 769, 402, 21619, 17704, 402, 282, 1329, 272, 302, 63, 16125, 275, 7795, 13, 2960, 10149, 5326, 12, 327, 647, 12, 327, 80, 90, 61, 9297, 314, 1329, 272, 402, 21619, 17704, 626, 1077, 506, 12414, 334, 292, 2196, 9, 367, 1924, 7581, 2286, 2529, 359, 5326, 12, 647, 12, 80, 90, 61, 2286, 408, 2286, 634, 63, 16125, 275, 17704, 5873, 327, 1852, 282, 2257, 1331, 2286, 299, 63, 513, 275, 359, 17, 12, 17, 12, 17, 61, 2286, 367, 366, 315, 1425, 8, 19, 304, 267, 367, 284, 315, 1425, 8, 78, 63, 16125, 59, 68, 4682, 288, 286, 275, 2196, 14, 5095, 8, 76, 63, 16125, 9, 288, 634, 63, 16125, 14, 2168, 8, 67, 9, 288, 299, 63, 513, 59, 68, 3672, 29, 67, 272, 372, 299, 63, 513, 4388, 199, 533, 27353, 26, 272, 347, 636, 826, 721, 277, 12, 46, 88, 12, 22781, 12, 23406, 12, 2064, 304, 267, 291, 14, 46, 88, 275, 653, 88, 267, 291, 14, 22781, 275, 653, 89, 267, 291, 14, 23406, 275, 653, 90, 267, 291, 14, 5326, 275, 1777, 59, 16, 61, 267, 291, 14, 647, 275, 1777, 59, 17, 61, 267, 291, 14, 80, 90, 275, 1777, 59, 18, 61, 2728, 291, 14, 409, 63, 3397, 342, 5493, 347, 663, 63, 3397, 8, 277, 304, 267, 634, 88, 275, 291, 14, 46, 88, 15, 1609, 8, 277, 14, 5326, 9, 267, 21559, 275, 291, 14, 22781, 15, 1609, 8, 277, 14, 647, 9, 267, 634, 90, 275, 291, 14, 23406, 15, 1609, 8, 277, 14, 80, 90, 9, 2728, 327, 25259, 590, 12, 1570, 642, 9775, 340, 652, 557, 2310, 286, 1330, 647, 14, 2728, 327, 14497, 13195, 370, 3301, 10463, 402, 314, 25780, 6484, 267, 5236, 275, 634, 88, 10, 590, 10, 28997, 267, 24802, 275, 499, 2795, 23605, 10, 590, 435, 499, 2795, 23605, 10, 28997, 435, 499, 2795, 28997, 10, 590, 267, 291, 14, 3397, 275, 24802, 15, 5650, 2728, 327, 5650, 275, 634, 88, 10, 590, 10, 28997, 267, 327, 21579, 275, 499, 2795, 23605, 10, 590, 435, 499, 2795, 23605, 10, 28997, 435, 499, 2795, 28997, 10, 590, 267, 327, 5707, 17942, 275, 5236, 446, 24802, 2728, 327, 277, 14, 3397, 275, 334, 21579, 15, 5707, 17942, 9, 268, 268, 268, 5493, 347, 664, 63, 3397, 8, 277, 304, 267, 372, 291, 14, 3397, 2286, 347, 664, 63, 5312, 8, 277, 304, 267, 372, 359, 277, 14, 5326, 12, 291, 14, 647, 12, 291, 14, 80, 90, 61, 4388, 199, 318, 6484, 1532, 8, 78, 12, 75, 12, 76, 29, 17, 304, 272, 1449, 78, 365, 314, 3000, 370, 6484, 12, 1022, 365, 314, 2582, 402, 16394, 12, 634, 365, 314, 1748, 6484, 1819, 1568, 2344, 272, 340, 1022, 665, 413, 26, 267, 746, 10852, 272, 340, 1022, 508, 413, 26, 267, 340, 302, 2356, 634, 26, 288, 1995, 334, 78, 4258, 267, 746, 10852, 272, 367, 284, 315, 1425, 8, 76, 12, 78, 11, 17, 304, 267, 367, 754, 315, 6484, 1532, 8, 78, 13, 73, 12, 75, 13, 17, 12, 73, 304, 288, 1995, 334, 73, 4258, 11, 1099, 421, 199, 318, 1979, 6415, 8, 78, 304, 272, 408, 272, 372, 282, 769, 3035, 314, 21619, 6535, 2072, 402, 7317, 3000, 302, 272, 302, 275, 7317, 3000, 2286, 408, 272, 1979, 11821, 645, 275, 942, 272, 366, 275, 499, 272, 1830, 366, 10, 68, 2695, 302, 26, 267, 1830, 334, 78, 450, 366, 9, 508, 378, 26, 288, 1979, 11821, 645, 14, 740, 8, 68, 9, 221, 327, 1029, 555, 1044, 1265, 2934, 3663, 17704, 10877, 288, 302, 5001, 29, 366, 267, 366, 847, 413, 272, 340, 302, 690, 413, 26, 2126, 1979, 11821, 645, 14, 740, 8, 78, 9, 272, 372, 1979, 11821, 645, 199, 199, 318, 17704, 8, 78, 304, 272, 408, 272, 302, 275, 7317, 3000, 272, 2529, 282, 769, 402, 314, 17704, 402, 302, 315, 334, 6878, 13, 269, 13, 2003, 9, 4465, 1824, 2286, 408, 272, 372, 2457, 8, 2734, 284, 26, 302, 450, 284, 508, 378, 12, 1425, 8, 17, 12, 302, 435, 413, 430, 199, 199, 318, 1777, 63, 350, 8286, 8, 46, 88, 12, 22781, 12, 23406, 12, 1507, 63, 24463, 12, 1967, 52, 1383, 83, 275, 12293, 304, 272, 408, 272, 653, 88, 275, 1329, 402, 4501, 315, 314, 671, 13, 6874, 272, 653, 89, 275, 1329, 402, 4501, 315, 314, 612, 13, 6874, 272, 653, 90, 275, 1329, 402, 4501, 315, 314, 1315, 13, 6874, 272, 1967, 63, 24463, 275, 314, 1329, 402, 16394, 370, 1218, 2286, 2529, 282, 25697, 21162, 12, 647, 12, 80, 90, 2286, 408, 5493, 299, 63, 5047, 275, 1979, 6415, 8, 1507, 63, 24463, 9, 272, 299, 63, 5047, 14, 740, 8, 17, 9, 272, 299, 63, 5047, 14, 740, 8, 17, 9, 327, 370, 2040, 27881, 413, 13, 36, 6484, 316, 340, 626, 365, 5526, 4496, 2286, 5526, 12642, 275, 2069, 480, 4904, 531, 272, 5526, 13068, 275, 488, 272, 327, 1507, 52, 1383, 83, 275, 31092, 327, 440, 5436, 370, 562, 4212, 7282, 642, 1077, 506, 1396, 2286, 367, 299, 315, 6484, 1532, 8, 552, 8, 80, 63, 5047, 395, 19, 304, 267, 327, 1361, 299, 267, 408, 267, 663, 1536, 2005, 16394, 436, 4215, 4426, 402, 314, 1373, 543, 314, 5526, 5396, 14, 2728, 408, 267, 299, 63, 22983, 275, 15782, 8, 80, 2736, 267, 367, 284, 315, 1425, 8, 19, 304, 288, 299, 63, 22983, 14, 12873, 8, 17, 9, 327, 4723, 314, 1572, 780, 288, 327, 5452, 1967, 52, 1383, 83, 5845, 288, 367, 16324, 315, 1425, 8, 1507, 52, 1383, 83, 304, 355, 519, 63, 2064, 275, 2196, 63, 5312, 8, 80, 63, 5047, 12, 80 ]
[ 199, 5312, 63, 19957, 1636, 14, 647, 199, 199, 22615, 26, 9138, 653, 88, 12, 653, 89, 12, 653, 90, 436, 282, 1329, 402, 10358, 12, 18453, 282, 6484, 316, 10054, 626, 3955, 754, 315, 199, 6878, 13, 269, 13, 2003, 15681, 13, 1392, 68, 16394, 199, 199, 624, 199, 646, 2196, 199, 504, 5055, 492, 15782, 421, 199, 318, 2196, 63, 5312, 8, 16125, 12, 78, 63, 16125, 304, 272, 408, 272, 17704, 275, 769, 402, 21619, 17704, 402, 282, 1329, 272, 302, 63, 16125, 275, 7795, 13, 2960, 10149, 5326, 12, 327, 647, 12, 327, 80, 90, 61, 9297, 314, 1329, 272, 402, 21619, 17704, 626, 1077, 506, 12414, 334, 292, 2196, 9, 367, 1924, 7581, 2286, 2529, 359, 5326, 12, 647, 12, 80, 90, 61, 2286, 408, 2286, 634, 63, 16125, 275, 17704, 5873, 327, 1852, 282, 2257, 1331, 2286, 299, 63, 513, 275, 359, 17, 12, 17, 12, 17, 61, 2286, 367, 366, 315, 1425, 8, 19, 304, 267, 367, 284, 315, 1425, 8, 78, 63, 16125, 59, 68, 4682, 288, 286, 275, 2196, 14, 5095, 8, 76, 63, 16125, 9, 288, 634, 63, 16125, 14, 2168, 8, 67, 9, 288, 299, 63, 513, 59, 68, 3672, 29, 67, 272, 372, 299, 63, 513, 4388, 199, 533, 27353, 26, 272, 347, 636, 826, 721, 277, 12, 46, 88, 12, 22781, 12, 23406, 12, 2064, 304, 267, 291, 14, 46, 88, 275, 653, 88, 267, 291, 14, 22781, 275, 653, 89, 267, 291, 14, 23406, 275, 653, 90, 267, 291, 14, 5326, 275, 1777, 59, 16, 61, 267, 291, 14, 647, 275, 1777, 59, 17, 61, 267, 291, 14, 80, 90, 275, 1777, 59, 18, 61, 2728, 291, 14, 409, 63, 3397, 342, 5493, 347, 663, 63, 3397, 8, 277, 304, 267, 634, 88, 275, 291, 14, 46, 88, 15, 1609, 8, 277, 14, 5326, 9, 267, 21559, 275, 291, 14, 22781, 15, 1609, 8, 277, 14, 647, 9, 267, 634, 90, 275, 291, 14, 23406, 15, 1609, 8, 277, 14, 80, 90, 9, 2728, 327, 25259, 590, 12, 1570, 642, 9775, 340, 652, 557, 2310, 286, 1330, 647, 14, 2728, 327, 14497, 13195, 370, 3301, 10463, 402, 314, 25780, 6484, 267, 5236, 275, 634, 88, 10, 590, 10, 28997, 267, 24802, 275, 499, 2795, 23605, 10, 590, 435, 499, 2795, 23605, 10, 28997, 435, 499, 2795, 28997, 10, 590, 267, 291, 14, 3397, 275, 24802, 15, 5650, 2728, 327, 5650, 275, 634, 88, 10, 590, 10, 28997, 267, 327, 21579, 275, 499, 2795, 23605, 10, 590, 435, 499, 2795, 23605, 10, 28997, 435, 499, 2795, 28997, 10, 590, 267, 327, 5707, 17942, 275, 5236, 446, 24802, 2728, 327, 277, 14, 3397, 275, 334, 21579, 15, 5707, 17942, 9, 268, 268, 268, 5493, 347, 664, 63, 3397, 8, 277, 304, 267, 372, 291, 14, 3397, 2286, 347, 664, 63, 5312, 8, 277, 304, 267, 372, 359, 277, 14, 5326, 12, 291, 14, 647, 12, 291, 14, 80, 90, 61, 4388, 199, 318, 6484, 1532, 8, 78, 12, 75, 12, 76, 29, 17, 304, 272, 1449, 78, 365, 314, 3000, 370, 6484, 12, 1022, 365, 314, 2582, 402, 16394, 12, 634, 365, 314, 1748, 6484, 1819, 1568, 2344, 272, 340, 1022, 665, 413, 26, 267, 746, 10852, 272, 340, 1022, 508, 413, 26, 267, 340, 302, 2356, 634, 26, 288, 1995, 334, 78, 4258, 267, 746, 10852, 272, 367, 284, 315, 1425, 8, 76, 12, 78, 11, 17, 304, 267, 367, 754, 315, 6484, 1532, 8, 78, 13, 73, 12, 75, 13, 17, 12, 73, 304, 288, 1995, 334, 73, 4258, 11, 1099, 421, 199, 318, 1979, 6415, 8, 78, 304, 272, 408, 272, 372, 282, 769, 3035, 314, 21619, 6535, 2072, 402, 7317, 3000, 302, 272, 302, 275, 7317, 3000, 2286, 408, 272, 1979, 11821, 645, 275, 942, 272, 366, 275, 499, 272, 1830, 366, 10, 68, 2695, 302, 26, 267, 1830, 334, 78, 450, 366, 9, 508, 378, 26, 288, 1979, 11821, 645, 14, 740, 8, 68, 9, 221, 327, 1029, 555, 1044, 1265, 2934, 3663, 17704, 10877, 288, 302, 5001, 29, 366, 267, 366, 847, 413, 272, 340, 302, 690, 413, 26, 2126, 1979, 11821, 645, 14, 740, 8, 78, 9, 272, 372, 1979, 11821, 645, 199, 199, 318, 17704, 8, 78, 304, 272, 408, 272, 302, 275, 7317, 3000, 272, 2529, 282, 769, 402, 314, 17704, 402, 302, 315, 334, 6878, 13, 269, 13, 2003, 9, 4465, 1824, 2286, 408, 272, 372, 2457, 8, 2734, 284, 26, 302, 450, 284, 508, 378, 12, 1425, 8, 17, 12, 302, 435, 413, 430, 199, 199, 318, 1777, 63, 350, 8286, 8, 46, 88, 12, 22781, 12, 23406, 12, 1507, 63, 24463, 12, 1967, 52, 1383, 83, 275, 12293, 304, 272, 408, 272, 653, 88, 275, 1329, 402, 4501, 315, 314, 671, 13, 6874, 272, 653, 89, 275, 1329, 402, 4501, 315, 314, 612, 13, 6874, 272, 653, 90, 275, 1329, 402, 4501, 315, 314, 1315, 13, 6874, 272, 1967, 63, 24463, 275, 314, 1329, 402, 16394, 370, 1218, 2286, 2529, 282, 25697, 21162, 12, 647, 12, 80, 90, 2286, 408, 5493, 299, 63, 5047, 275, 1979, 6415, 8, 1507, 63, 24463, 9, 272, 299, 63, 5047, 14, 740, 8, 17, 9, 272, 299, 63, 5047, 14, 740, 8, 17, 9, 327, 370, 2040, 27881, 413, 13, 36, 6484, 316, 340, 626, 365, 5526, 4496, 2286, 5526, 12642, 275, 2069, 480, 4904, 531, 272, 5526, 13068, 275, 488, 272, 327, 1507, 52, 1383, 83, 275, 31092, 327, 440, 5436, 370, 562, 4212, 7282, 642, 1077, 506, 1396, 2286, 367, 299, 315, 6484, 1532, 8, 552, 8, 80, 63, 5047, 395, 19, 304, 267, 327, 1361, 299, 267, 408, 267, 663, 1536, 2005, 16394, 436, 4215, 4426, 402, 314, 1373, 543, 314, 5526, 5396, 14, 2728, 408, 267, 299, 63, 22983, 275, 15782, 8, 80, 2736, 267, 367, 284, 315, 1425, 8, 19, 304, 288, 299, 63, 22983, 14, 12873, 8, 17, 9, 327, 4723, 314, 1572, 780, 288, 327, 5452, 1967, 52, 1383, 83, 5845, 288, 367, 16324, 315, 1425, 8, 1507, 52, 1383, 83, 304, 355, 519, 63, 2064, 275, 2196, 63, 5312, 8, 80, 63, 5047, 12, 80, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Softmotions/edx-platform
lms/djangoapps/instructor/tests/test_api_email_localization.py
64
3576
# -*- coding: utf-8 -*- """ Unit tests for the localization of emails sent by instructor.api methods. """ from django.core import mail from django.core.urlresolvers import reverse from nose.plugins.attrib import attr from courseware.tests.factories import InstructorFactory from lang_pref import LANGUAGE_KEY from student.models import CourseEnrollment from student.tests.factories import UserFactory from openedx.core.djangoapps.user_api.preferences.api import set_user_preference from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase @attr('shard_1') class TestInstructorAPIEnrollmentEmailLocalization(SharedModuleStoreTestCase): """ Test whether the enroll, unenroll and beta role emails are sent in the proper language, i.e: the student's language. """ @classmethod def setUpClass(cls): super(TestInstructorAPIEnrollmentEmailLocalization, cls).setUpClass() cls.course = CourseFactory.create() def setUp(self): super(TestInstructorAPIEnrollmentEmailLocalization, self).setUp() # Platform language is English, instructor's language is Chinese, # student's language is French, so the emails should all be sent in # French. self.instructor = InstructorFactory(course_key=self.course.id) set_user_preference(self.instructor, LANGUAGE_KEY, 'zh-cn') self.client.login(username=self.instructor.username, password='test') self.student = UserFactory.create() set_user_preference(self.student, LANGUAGE_KEY, 'fr') def update_enrollement(self, action, student_email): """ Update the current student enrollment status. """ url = reverse('students_update_enrollment', kwargs={'course_id': self.course.id.to_deprecated_string()}) args = {'identifiers': student_email, 'email_students': 'true', 'action': action, 'reason': 'testing'} response = self.client.post(url, args) return response def check_outbox_is_french(self): """ Check that the email outbox contains exactly one message for which both the message subject and body contain a certain French string. """ return self.check_outbox(u"Vous avez été") def check_outbox(self, expected_message): """ Check that the email outbox contains exactly one message for which both the message subject and body contain a certain string. """ self.assertEqual(1, len(mail.outbox)) self.assertIn(expected_message, mail.outbox[0].subject) self.assertIn(expected_message, mail.outbox[0].body) def test_enroll(self): self.update_enrollement("enroll", self.student.email) self.check_outbox_is_french() def test_unenroll(self): CourseEnrollment.enroll( self.student, self.course.id ) self.update_enrollement("unenroll", self.student.email) self.check_outbox_is_french() def test_set_beta_role(self): url = reverse('bulk_beta_modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()}) self.client.post(url, {'identifiers': self.student.email, 'action': 'add', 'email_students': 'true'}) self.check_outbox_is_french() def test_enroll_unsubscribed_student(self): # Student is unknown, so the platform language should be used self.update_enrollement("enroll", "newuser@hotmail.com") self.check_outbox("You have been")
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 5072, 2295, 367, 314, 2257, 2072, 402, 14931, 4847, 701, 17724, 14, 1246, 3102, 14, 199, 624, 199, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 20736, 14, 2219, 14, 15406, 492, 26150, 2927, 199, 504, 6339, 63, 13829, 492, 30508, 2962, 63, 3078, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 22709, 14, 1018, 14, 16432, 14, 751, 63, 1246, 14, 18063, 14, 1246, 492, 663, 63, 751, 63, 14994, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 23752, 27863, 421, 199, 32, 962, 360, 10810, 63, 17, 358, 199, 533, 1379, 30742, 3735, 13842, 7035, 5339, 2072, 8, 12197, 27863, 304, 272, 408, 272, 1379, 3775, 314, 26361, 12, 625, 14695, 436, 8201, 4719, 14931, 787, 4847, 315, 314, 272, 5576, 2637, 12, 284, 14, 69, 26, 314, 6474, 1159, 2637, 14, 272, 408, 272, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 774, 30742, 3735, 13842, 7035, 5339, 2072, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 30742, 3735, 13842, 7035, 5339, 2072, 12, 291, 680, 5996, 342, 398, 327, 16078, 2637, 365, 20144, 12, 17724, 1159, 2637, 365, 2799, 26883, 12, 267, 327, 6474, 1159, 2637, 365, 481, 15148, 12, 880, 314, 14931, 1077, 1006, 506, 4847, 315, 267, 327, 481, 15148, 14, 267, 291, 14, 14891, 275, 26150, 2927, 8, 1972, 63, 498, 29, 277, 14, 1972, 14, 344, 9, 267, 663, 63, 751, 63, 14994, 8, 277, 14, 14891, 12, 30508, 2962, 63, 3078, 12, 283, 3951, 13, 6413, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 14891, 14, 2473, 12, 2505, 534, 396, 358, 398, 291, 14, 5500, 275, 16047, 14, 981, 342, 267, 663, 63, 751, 63, 14994, 8, 277, 14, 5500, 12, 30508, 2962, 63, 3078, 12, 283, 4391, 358, 339, 347, 1678, 63, 287, 8459, 968, 8, 277, 12, 1595, 12, 6474, 63, 2123, 304, 267, 408, 267, 6162, 314, 1453, 6474, 14869, 2004, 14, 267, 408, 267, 1166, 275, 3837, 360, 17921, 63, 873, 63, 12214, 297, 2074, 3713, 1972, 63, 344, 356, 291, 14, 1972, 14, 344, 14, 475, 63, 6667, 63, 875, 22804, 267, 1249, 275, 791, 14227, 356, 6474, 63, 2123, 12, 283, 2123, 63, 17921, 356, 283, 2052, 297, 283, 1287, 356, 1595, 12, 283, 5764, 356, 283, 4776, 936, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 633, 12, 1249, 9, 267, 372, 1177, 339, 347, 1104, 63, 17244, 63, 374, 63, 20874, 8, 277, 304, 267, 408, 267, 2670, 626, 314, 3031, 734, 1977, 3509, 8840, 1373, 1245, 367, 1314, 3865, 267, 314, 1245, 5420, 436, 2396, 1395, 282, 9842, 481, 15148, 1059, 14, 267, 408, 267, 372, 291, 14, 1074, 63, 17244, 8, 85, 2, 54, 1785, 282, 432, 90, 26785, 84, 5741, 531, 339, 347, 1104, 63, 17244, 8, 277, 12, 1420, 63, 1188, 304, 267, 408, 267, 2670, 626, 314, 3031, 734, 1977, 3509, 8840, 1373, 1245, 367, 1314, 3865, 267, 314, 1245, 5420, 436, 2396, 1395, 282, 9842, 1059, 14, 267, 408, 267, 291, 14, 629, 8, 17, 12, 822, 8, 1198, 14, 17244, 430, 267, 291, 14, 4080, 8, 2062, 63, 1188, 12, 6016, 14, 17244, 59, 16, 1055, 5875, 9, 267, 291, 14, 4080, 8, 2062, 63, 1188, 12, 6016, 14, 17244, 59, 16, 1055, 2030, 9, 339, 347, 511, 63, 14695, 8, 277, 304, 267, 291, 14, 873, 63, 287, 8459, 968, 480, 14695, 401, 291, 14, 5500, 14, 2123, 9, 398, 291, 14, 1074, 63, 17244, 63, 374, 63, 20874, 342, 339, 347, 511, 63, 324, 14695, 8, 277, 304, 267, 18946, 14, 14695, 8, 288, 291, 14, 5500, 12, 288, 291, 14, 1972, 14, 344, 267, 776, 267, 291, 14, 873, 63, 287, 8459, 968, 480, 324, 14695, 401, 291, 14, 5500, 14, 2123, 9, 398, 291, 14, 1074, 63, 17244, 63, 374, 63, 20874, 342, 339, 347, 511, 63, 409, 63, 5683, 63, 3756, 8, 277, 304, 267, 1166, 275, 3837, 360, 9377, 63, 5683, 63, 8951, 63, 2732, 297, 2074, 3713, 1972, 63, 344, 356, 291, 14, 1972, 14, 344, 14, 475, 63, 6667, 63, 875, 22804, 267, 291, 14, 1258, 14, 1932, 8, 633, 12, 791, 14227, 356, 291, 14, 5500, 14, 2123, 12, 283, 1287, 356, 283, 525, 297, 283, 2123, 63, 17921, 356, 283, 2052, 3071, 398, 291, 14, 1074, 63, 17244, 63, 374, 63, 20874, 342, 339, 347, 511, 63, 14695, 63, 324, 23178, 63, 5500, 8, 277, 304, 267, 327, 17246, 365, 5809, 12, 880, 314, 4298, 2637, 1077, 506, 1202, 267, 291, 14, 873, 63, 287, 8459, 968, 480, 14695, 401, 298, 1222, 751, 32, 8885, 1198, 14, 957, 531, 267, 291, 14, 1074, 63, 17244, 480, 5556, 1172, 2757, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 5072, 2295, 367, 314, 2257, 2072, 402, 14931, 4847, 701, 17724, 14, 1246, 3102, 14, 199, 624, 199, 199, 504, 1639, 14, 1018, 492, 6016, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 199, 504, 20736, 14, 2219, 14, 15406, 492, 26150, 2927, 199, 504, 6339, 63, 13829, 492, 30508, 2962, 63, 3078, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 22709, 14, 1018, 14, 16432, 14, 751, 63, 1246, 14, 18063, 14, 1246, 492, 663, 63, 751, 63, 14994, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 23752, 27863, 421, 199, 32, 962, 360, 10810, 63, 17, 358, 199, 533, 1379, 30742, 3735, 13842, 7035, 5339, 2072, 8, 12197, 27863, 304, 272, 408, 272, 1379, 3775, 314, 26361, 12, 625, 14695, 436, 8201, 4719, 14931, 787, 4847, 315, 314, 272, 5576, 2637, 12, 284, 14, 69, 26, 314, 6474, 1159, 2637, 14, 272, 408, 272, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 774, 30742, 3735, 13842, 7035, 5339, 2072, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 30742, 3735, 13842, 7035, 5339, 2072, 12, 291, 680, 5996, 342, 398, 327, 16078, 2637, 365, 20144, 12, 17724, 1159, 2637, 365, 2799, 26883, 12, 267, 327, 6474, 1159, 2637, 365, 481, 15148, 12, 880, 314, 14931, 1077, 1006, 506, 4847, 315, 267, 327, 481, 15148, 14, 267, 291, 14, 14891, 275, 26150, 2927, 8, 1972, 63, 498, 29, 277, 14, 1972, 14, 344, 9, 267, 663, 63, 751, 63, 14994, 8, 277, 14, 14891, 12, 30508, 2962, 63, 3078, 12, 283, 3951, 13, 6413, 358, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 14891, 14, 2473, 12, 2505, 534, 396, 358, 398, 291, 14, 5500, 275, 16047, 14, 981, 342, 267, 663, 63, 751, 63, 14994, 8, 277, 14, 5500, 12, 30508, 2962, 63, 3078, 12, 283, 4391, 358, 339, 347, 1678, 63, 287, 8459, 968, 8, 277, 12, 1595, 12, 6474, 63, 2123, 304, 267, 408, 267, 6162, 314, 1453, 6474, 14869, 2004, 14, 267, 408, 267, 1166, 275, 3837, 360, 17921, 63, 873, 63, 12214, 297, 2074, 3713, 1972, 63, 344, 356, 291, 14, 1972, 14, 344, 14, 475, 63, 6667, 63, 875, 22804, 267, 1249, 275, 791, 14227, 356, 6474, 63, 2123, 12, 283, 2123, 63, 17921, 356, 283, 2052, 297, 283, 1287, 356, 1595, 12, 283, 5764, 356, 283, 4776, 936, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 633, 12, 1249, 9, 267, 372, 1177, 339, 347, 1104, 63, 17244, 63, 374, 63, 20874, 8, 277, 304, 267, 408, 267, 2670, 626, 314, 3031, 734, 1977, 3509, 8840, 1373, 1245, 367, 1314, 3865, 267, 314, 1245, 5420, 436, 2396, 1395, 282, 9842, 481, 15148, 1059, 14, 267, 408, 267, 372, 291, 14, 1074, 63, 17244, 8, 85, 2, 54, 1785, 282, 432, 90, 26785, 84, 5741, 531, 339, 347, 1104, 63, 17244, 8, 277, 12, 1420, 63, 1188, 304, 267, 408, 267, 2670, 626, 314, 3031, 734, 1977, 3509, 8840, 1373, 1245, 367, 1314, 3865, 267, 314, 1245, 5420, 436, 2396, 1395, 282, 9842, 1059, 14, 267, 408, 267, 291, 14, 629, 8, 17, 12, 822, 8, 1198, 14, 17244, 430, 267, 291, 14, 4080, 8, 2062, 63, 1188, 12, 6016, 14, 17244, 59, 16, 1055, 5875, 9, 267, 291, 14, 4080, 8, 2062, 63, 1188, 12, 6016, 14, 17244, 59, 16, 1055, 2030, 9, 339, 347, 511, 63, 14695, 8, 277, 304, 267, 291, 14, 873, 63, 287, 8459, 968, 480, 14695, 401, 291, 14, 5500, 14, 2123, 9, 398, 291, 14, 1074, 63, 17244, 63, 374, 63, 20874, 342, 339, 347, 511, 63, 324, 14695, 8, 277, 304, 267, 18946, 14, 14695, 8, 288, 291, 14, 5500, 12, 288, 291, 14, 1972, 14, 344, 267, 776, 267, 291, 14, 873, 63, 287, 8459, 968, 480, 324, 14695, 401, 291, 14, 5500, 14, 2123, 9, 398, 291, 14, 1074, 63, 17244, 63, 374, 63, 20874, 342, 339, 347, 511, 63, 409, 63, 5683, 63, 3756, 8, 277, 304, 267, 1166, 275, 3837, 360, 9377, 63, 5683, 63, 8951, 63, 2732, 297, 2074, 3713, 1972, 63, 344, 356, 291, 14, 1972, 14, 344, 14, 475, 63, 6667, 63, 875, 22804, 267, 291, 14, 1258, 14, 1932, 8, 633, 12, 791, 14227, 356, 291, 14, 5500, 14, 2123, 12, 283, 1287, 356, 283, 525, 297, 283, 2123, 63, 17921, 356, 283, 2052, 3071, 398, 291, 14, 1074, 63, 17244, 63, 374, 63, 20874, 342, 339, 347, 511, 63, 14695, 63, 324, 23178, 63, 5500, 8, 277, 304, 267, 327, 17246, 365, 5809, 12, 880, 314, 4298, 2637, 1077, 506, 1202, 267, 291, 14, 873, 63, 287, 8459, 968, 480, 14695, 401, 298, 1222, 751, 32, 8885, 1198, 14, 957, 531, 267, 291, 14, 1074, 63, 17244, 480, 5556, 1172, 2757, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
hubertokf/lupsEdgeServer
projects/lupsEdgeServer/EngineRules/setuptools-20.10.1/setuptools/lib2to3_ex.py
907
1998
""" Customized Mixin2to3 support: - adds support for converting doctests This module raises an ImportError on Python 2. """ from distutils.util import Mixin2to3 as _Mixin2to3 from distutils import log from lib2to3.refactor import RefactoringTool, get_fixers_from_package import setuptools class DistutilsRefactoringTool(RefactoringTool): def log_error(self, msg, *args, **kw): log.error(msg, *args) def log_message(self, msg, *args): log.info(msg, *args) def log_debug(self, msg, *args): log.debug(msg, *args) class Mixin2to3(_Mixin2to3): def run_2to3(self, files, doctests = False): # See of the distribution option has been set, otherwise check the # setuptools default. if self.distribution.use_2to3 is not True: return if not files: return log.info("Fixing "+" ".join(files)) self.__build_fixer_names() self.__exclude_fixers() if doctests: if setuptools.run_2to3_on_doctests: r = DistutilsRefactoringTool(self.fixer_names) r.refactor(files, write=True, doctests_only=True) else: _Mixin2to3.run_2to3(self, files) def __build_fixer_names(self): if self.fixer_names: return self.fixer_names = [] for p in setuptools.lib2to3_fixer_packages: self.fixer_names.extend(get_fixers_from_package(p)) if self.distribution.use_2to3_fixers is not None: for p in self.distribution.use_2to3_fixers: self.fixer_names.extend(get_fixers_from_package(p)) def __exclude_fixers(self): excluded_fixers = getattr(self, 'exclude_fixers', []) if self.distribution.use_2to3_exclude_fixers is not None: excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers) for fixer_name in excluded_fixers: if fixer_name in self.fixer_names: self.fixer_names.remove(fixer_name)
mit
[ 624, 199, 7223, 1759, 28438, 18, 475, 19, 2291, 26, 421, 446, 9584, 2291, 367, 13806, 26721, 421, 199, 2765, 859, 6534, 376, 3545, 641, 2018, 499, 14, 199, 624, 199, 199, 504, 7065, 14, 1974, 492, 28438, 18, 475, 19, 465, 485, 4256, 18, 475, 19, 199, 504, 7065, 492, 943, 199, 504, 1973, 18, 475, 19, 14, 264, 4778, 492, 799, 4778, 316, 5157, 12, 664, 63, 970, 1192, 63, 504, 63, 2491, 199, 646, 9116, 199, 199, 533, 12577, 497, 4778, 316, 5157, 8, 497, 4778, 316, 5157, 304, 272, 347, 943, 63, 705, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 829, 304, 267, 943, 14, 705, 8, 1328, 12, 627, 589, 9, 339, 347, 943, 63, 1188, 8, 277, 12, 1499, 12, 627, 589, 304, 267, 943, 14, 815, 8, 1328, 12, 627, 589, 9, 339, 347, 943, 63, 1757, 8, 277, 12, 1499, 12, 627, 589, 304, 267, 943, 14, 1757, 8, 1328, 12, 627, 589, 9, 199, 199, 533, 28438, 18, 475, 19, 1547, 4256, 18, 475, 19, 304, 272, 347, 1255, 63, 18, 475, 19, 8, 277, 12, 1584, 12, 26721, 275, 756, 304, 267, 327, 1666, 402, 314, 4084, 945, 965, 2757, 663, 12, 4257, 1104, 314, 267, 327, 9116, 849, 14, 267, 340, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 365, 440, 715, 26, 288, 372, 267, 340, 440, 1584, 26, 288, 372, 267, 943, 14, 815, 480, 11985, 316, 298, 5207, 3680, 904, 8, 1725, 430, 267, 291, 855, 1506, 63, 25973, 63, 1247, 342, 267, 291, 855, 5473, 63, 970, 1192, 342, 267, 340, 26721, 26, 288, 340, 9116, 14, 1065, 63, 18, 475, 19, 63, 265, 63, 1301, 2219, 26, 355, 519, 275, 12577, 497, 4778, 316, 5157, 8, 277, 14, 25973, 63, 1247, 9, 355, 519, 14, 264, 4778, 8, 1725, 12, 2218, 29, 549, 12, 26721, 63, 2118, 29, 549, 9, 267, 587, 26, 288, 485, 4256, 18, 475, 19, 14, 1065, 63, 18, 475, 19, 8, 277, 12, 1584, 9, 339, 347, 636, 1506, 63, 25973, 63, 1247, 8, 277, 304, 267, 340, 291, 14, 25973, 63, 1247, 26, 372, 267, 291, 14, 25973, 63, 1247, 275, 942, 267, 367, 299, 315, 9116, 14, 773, 18, 475, 19, 63, 25973, 63, 5154, 26, 288, 291, 14, 25973, 63, 1247, 14, 2880, 8, 362, 63, 970, 1192, 63, 504, 63, 2491, 8, 80, 430, 267, 340, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 970, 1192, 365, 440, 488, 26, 288, 367, 299, 315, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 970, 1192, 26, 355, 291, 14, 25973, 63, 1247, 14, 2880, 8, 362, 63, 970, 1192, 63, 504, 63, 2491, 8, 80, 430, 339, 347, 636, 5473, 63, 970, 1192, 8, 277, 304, 267, 8789, 63, 970, 1192, 275, 2519, 8, 277, 12, 283, 5473, 63, 970, 1192, 297, 3073, 267, 340, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 5473, 63, 970, 1192, 365, 440, 488, 26, 288, 8789, 63, 970, 1192, 14, 2880, 8, 277, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 5473, 63, 970, 1192, 9, 267, 367, 24739, 63, 354, 315, 8789, 63, 970, 1192, 26, 288, 340, 24739, 63, 354, 315, 291, 14, 25973, 63, 1247, 26, 355, 291, 14, 25973, 63, 1247, 14, 2168, 8, 25973, 63, 354, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7223, 1759, 28438, 18, 475, 19, 2291, 26, 421, 446, 9584, 2291, 367, 13806, 26721, 421, 199, 2765, 859, 6534, 376, 3545, 641, 2018, 499, 14, 199, 624, 199, 199, 504, 7065, 14, 1974, 492, 28438, 18, 475, 19, 465, 485, 4256, 18, 475, 19, 199, 504, 7065, 492, 943, 199, 504, 1973, 18, 475, 19, 14, 264, 4778, 492, 799, 4778, 316, 5157, 12, 664, 63, 970, 1192, 63, 504, 63, 2491, 199, 646, 9116, 199, 199, 533, 12577, 497, 4778, 316, 5157, 8, 497, 4778, 316, 5157, 304, 272, 347, 943, 63, 705, 8, 277, 12, 1499, 12, 627, 589, 12, 1011, 829, 304, 267, 943, 14, 705, 8, 1328, 12, 627, 589, 9, 339, 347, 943, 63, 1188, 8, 277, 12, 1499, 12, 627, 589, 304, 267, 943, 14, 815, 8, 1328, 12, 627, 589, 9, 339, 347, 943, 63, 1757, 8, 277, 12, 1499, 12, 627, 589, 304, 267, 943, 14, 1757, 8, 1328, 12, 627, 589, 9, 199, 199, 533, 28438, 18, 475, 19, 1547, 4256, 18, 475, 19, 304, 272, 347, 1255, 63, 18, 475, 19, 8, 277, 12, 1584, 12, 26721, 275, 756, 304, 267, 327, 1666, 402, 314, 4084, 945, 965, 2757, 663, 12, 4257, 1104, 314, 267, 327, 9116, 849, 14, 267, 340, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 365, 440, 715, 26, 288, 372, 267, 340, 440, 1584, 26, 288, 372, 267, 943, 14, 815, 480, 11985, 316, 298, 5207, 3680, 904, 8, 1725, 430, 267, 291, 855, 1506, 63, 25973, 63, 1247, 342, 267, 291, 855, 5473, 63, 970, 1192, 342, 267, 340, 26721, 26, 288, 340, 9116, 14, 1065, 63, 18, 475, 19, 63, 265, 63, 1301, 2219, 26, 355, 519, 275, 12577, 497, 4778, 316, 5157, 8, 277, 14, 25973, 63, 1247, 9, 355, 519, 14, 264, 4778, 8, 1725, 12, 2218, 29, 549, 12, 26721, 63, 2118, 29, 549, 9, 267, 587, 26, 288, 485, 4256, 18, 475, 19, 14, 1065, 63, 18, 475, 19, 8, 277, 12, 1584, 9, 339, 347, 636, 1506, 63, 25973, 63, 1247, 8, 277, 304, 267, 340, 291, 14, 25973, 63, 1247, 26, 372, 267, 291, 14, 25973, 63, 1247, 275, 942, 267, 367, 299, 315, 9116, 14, 773, 18, 475, 19, 63, 25973, 63, 5154, 26, 288, 291, 14, 25973, 63, 1247, 14, 2880, 8, 362, 63, 970, 1192, 63, 504, 63, 2491, 8, 80, 430, 267, 340, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 970, 1192, 365, 440, 488, 26, 288, 367, 299, 315, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 970, 1192, 26, 355, 291, 14, 25973, 63, 1247, 14, 2880, 8, 362, 63, 970, 1192, 63, 504, 63, 2491, 8, 80, 430, 339, 347, 636, 5473, 63, 970, 1192, 8, 277, 304, 267, 8789, 63, 970, 1192, 275, 2519, 8, 277, 12, 283, 5473, 63, 970, 1192, 297, 3073, 267, 340, 291, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 5473, 63, 970, 1192, 365, 440, 488, 26, 288, 8789, 63, 970, 1192, 14, 2880, 8, 277, 14, 4972, 14, 1180, 63, 18, 475, 19, 63, 5473, 63, 970, 1192, 9, 267, 367, 24739, 63, 354, 315, 8789, 63, 970, 1192, 26, 288, 340, 24739, 63, 354, 315, 291, 14, 25973, 63, 1247, 26, 355, 291, 14, 25973, 63, 1247, 14, 2168, 8, 25973, 63, 354, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
domsooch/mapreduce-python
mapreduce/handlers.py
4
68593
#!/usr/bin/env python # Copyright 2010 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """Defines executor tasks handlers for MapReduce implementation.""" # pylint: disable=protected-access # pylint: disable=g-bad-name import datetime import logging import math import os import random import sys import time import traceback from mapreduce.third_party import simplejson from google.appengine.ext import ndb from google.appengine import runtime from google.appengine.api import datastore_errors from google.appengine.api import logservice from google.appengine.api import modules from google.appengine.api import taskqueue from google.appengine.ext import db from mapreduce import base_handler from mapreduce import context from mapreduce import errors from mapreduce import input_readers from mapreduce import model from mapreduce import operation from mapreduce import output_writers from mapreduce import parameters from mapreduce import util from mapreduce.api import map_job from mapreduce.api.map_job import shard_life_cycle from google.appengine.runtime import apiproxy_errors # pylint: disable=g-import-not-at-top try: import cloudstorage # In 25 runtime, the above code will be scrubbed to import the stub version # of cloudstorage. All occurences of the following if condition in MR # codebase is to tell it apart. # TODO(user): Remove after 25 runtime MR is abondoned. if hasattr(cloudstorage, "_STUB"): cloudstorage = None except ImportError: cloudstorage = None # CloudStorage library not available # A guide to logging. # log.critical: messages user absolutely should see, e.g. failed job. # log.error: exceptions during processing user data, or unexpected # errors detected by mr framework. # log.warning: errors mr framework knows how to handle. # log.info: other expected events. # Set of strings of various test-injected faults. _TEST_INJECTED_FAULTS = set() def _run_task_hook(hooks, method, task, queue_name): """Invokes hooks.method(task, queue_name). Args: hooks: A hooks.Hooks instance or None. method: The name of the method to invoke on the hooks class e.g. "enqueue_kickoff_task". task: The taskqueue.Task to pass to the hook method. queue_name: The name of the queue to pass to the hook method. Returns: True if the hooks.Hooks instance handled the method, False otherwise. """ if hooks is not None: try: getattr(hooks, method)(task, queue_name) except NotImplementedError: # Use the default task addition implementation. return False return True return False class MapperWorkerCallbackHandler(base_handler.HugeTaskHandler): """Callback handler for mapreduce worker task.""" # These directives instruct self.__return() how to set state and enqueue task. _TASK_DIRECTIVE = util._enum( # Task is running as expected. PROCEED_TASK="proceed_task", # Need to retry task. Lock was NOT acquired when the error occur. # Don't change payload or datastore. RETRY_TASK="retry_task", # Need to retry task. Lock was acquired when the error occurr. # Don't change payload or datastore. RETRY_SLICE="retry_slice", # Drop the task (due to duplicated task). Must log permanent drop. DROP_TASK="drop_task", # See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery. RECOVER_SLICE="recover_slice", # Need to retry the shard. RETRY_SHARD="retry_shard", # Need to drop task and fail the shard. Log permanent failure. FAIL_TASK="fail_task", # Need to abort the shard. ABORT_SHARD="abort_shard") def __init__(self, *args): """Constructor.""" super(MapperWorkerCallbackHandler, self).__init__(*args) self._time = time.time def _drop_gracefully(self): """Drop worker task gracefully. Set current shard_state to failed. Controller logic will take care of other shards and the entire MR. """ shard_id = self.request.headers[util._MR_SHARD_ID_TASK_HEADER] mr_id = self.request.headers[util._MR_ID_TASK_HEADER] shard_state, mr_state = db.get([ model.ShardState.get_key_by_shard_id(shard_id), model.MapreduceState.get_key_by_job_id(mr_id)]) if shard_state and shard_state.active: shard_state.set_for_failure() config = util.create_datastore_write_config(mr_state.mapreduce_spec) shard_state.put(config=config) def _try_acquire_lease(self, shard_state, tstate): """Validate datastore and the task payload are consistent. If so, attempt to get a lease on this slice's execution. See model.ShardState doc on slice_start_time. Args: shard_state: model.ShardState from datastore. tstate: model.TransientShardState from taskqueue paylod. Returns: A _TASK_DIRECTIVE enum. PROCEED_TASK if lock is acquired. RETRY_TASK if task should be retried, DROP_TASK if task should be dropped. Only old tasks (comparing to datastore state) will be dropped. Future tasks are retried until they naturally become old so that we don't ever stuck MR. """ # Controller will tally shard_states and properly handle the situation. if not shard_state: logging.warning("State not found for shard %s; Possible spurious task " "execution. Dropping this task.", tstate.shard_id) return self._TASK_DIRECTIVE.DROP_TASK if not shard_state.active: logging.warning("Shard %s is not active. Possible spurious task " "execution. Dropping this task.", tstate.shard_id) logging.warning(str(shard_state)) return self._TASK_DIRECTIVE.DROP_TASK # Validate shard retry count. if shard_state.retries > tstate.retries: logging.warning( "Got shard %s from previous shard retry %s. Possible spurious " "task execution. Dropping this task.", tstate.shard_id, tstate.retries) logging.warning(str(shard_state)) return self._TASK_DIRECTIVE.DROP_TASK elif shard_state.retries < tstate.retries: # By the end of last slice, task enqueue succeeded but datastore commit # failed. That transaction will be retried and adding the same task # will pass. logging.warning( "ShardState for %s is behind slice. Waiting for it to catch up", shard_state.shard_id) return self._TASK_DIRECTIVE.RETRY_TASK # Validate slice id. # Taskqueue executes old successful tasks. if shard_state.slice_id > tstate.slice_id: logging.warning( "Task %s-%s is behind ShardState %s. Dropping task.""", tstate.shard_id, tstate.slice_id, shard_state.slice_id) return self._TASK_DIRECTIVE.DROP_TASK # By the end of last slice, task enqueue succeeded but datastore commit # failed. That transaction will be retried and adding the same task # will pass. User data is duplicated in this case. elif shard_state.slice_id < tstate.slice_id: logging.warning( "Task %s-%s is ahead of ShardState %s. Waiting for it to catch up.", tstate.shard_id, tstate.slice_id, shard_state.slice_id) return self._TASK_DIRECTIVE.RETRY_TASK # Check potential duplicated tasks for the same slice. # See model.ShardState doc. if shard_state.slice_start_time: countdown = self._wait_time(shard_state, parameters._LEASE_DURATION_SEC) if countdown > 0: logging.warning( "Last retry of slice %s-%s may be still running." "Will try again in %s seconds", tstate.shard_id, tstate.slice_id, countdown) # TODO(user): There might be a better way. Taskqueue's countdown # only applies to add new tasks, not retry of tasks. # Reduce contention. time.sleep(countdown) return self._TASK_DIRECTIVE.RETRY_TASK # lease could have expired. Verify with logs API. else: if self._wait_time(shard_state, parameters._MAX_LEASE_DURATION_SEC): if not self._has_old_request_ended(shard_state): logging.warning( "Last retry of slice %s-%s is still in flight with request_id " "%s. Will try again later.", tstate.shard_id, tstate.slice_id, shard_state.slice_request_id) return self._TASK_DIRECTIVE.RETRY_TASK else: logging.warning( "Last retry of slice %s-%s has no log entry and has" "timed out after %s seconds", tstate.shard_id, tstate.slice_id, parameters._MAX_LEASE_DURATION_SEC) # Lease expired or slice_start_time not set. config = util.create_datastore_write_config(tstate.mapreduce_spec) @db.transactional(retries=5) def _tx(): """Use datastore to set slice_start_time to now. If failed for any reason, raise error to retry the task (hence all the previous validation code). The task would die naturally eventually. Raises: Rollback: If the shard state is missing. Returns: A _TASK_DIRECTIVE enum. """ fresh_state = model.ShardState.get_by_shard_id(tstate.shard_id) if not fresh_state: logging.warning("ShardState missing.") raise db.Rollback() if (fresh_state.active and fresh_state.slice_id == shard_state.slice_id and fresh_state.slice_start_time == shard_state.slice_start_time): shard_state.slice_start_time = datetime.datetime.now() shard_state.slice_request_id = os.environ.get("REQUEST_LOG_ID") shard_state.acquired_once = True shard_state.put(config=config) return self._TASK_DIRECTIVE.PROCEED_TASK else: logging.warning( "Contention on slice %s-%s execution. Will retry again.", tstate.shard_id, tstate.slice_id) # One proposer should win. In case all lost, back off arbitrarily. time.sleep(random.randrange(1, 5)) return self._TASK_DIRECTIVE.RETRY_TASK return _tx() def _has_old_request_ended(self, shard_state): """Whether previous slice retry has ended according to Logs API. Args: shard_state: shard state. Returns: True if the request of previous slice retry has ended. False if it has not or unknown. """ assert shard_state.slice_start_time is not None assert shard_state.slice_request_id is not None request_ids = [shard_state.slice_request_id] logs = list(logservice.fetch( request_ids=request_ids, # TODO(user): Remove after b/8173230 is fixed. module_versions=[(os.environ["CURRENT_MODULE_ID"], modules.get_current_version_name())])) if not logs or not logs[0].finished: return False return True def _wait_time(self, shard_state, secs, now=datetime.datetime.now): """Time to wait until slice_start_time is secs ago from now. Args: shard_state: shard state. secs: duration in seconds. now: a func that gets now. Returns: 0 if no wait. A positive int in seconds otherwise. Always around up. """ assert shard_state.slice_start_time is not None delta = now() - shard_state.slice_start_time duration = datetime.timedelta(seconds=secs) if delta < duration: return util.total_seconds(duration - delta) else: return 0 def _try_free_lease(self, shard_state, slice_retry=False): """Try to free lease. A lightweight transaction to update shard_state and unset slice_start_time to allow the next retry to happen without blocking. We don't care if this fails or not because the lease will expire anyway. Under normal execution, _save_state_and_schedule_next is the exit point. It updates/saves shard state and schedules the next slice or returns. Other exit points are: 1. _are_states_consistent: at the beginning of handle, checks if datastore states and the task are in sync. If not, raise or return. 2. _attempt_slice_retry: may raise exception to taskqueue. 3. _save_state_and_schedule_next: may raise exception when taskqueue/db unreachable. This handler should try to free the lease on every exceptional exit point. Args: shard_state: model.ShardState. slice_retry: whether to count this as a failed slice execution. """ @db.transactional def _tx(): fresh_state = model.ShardState.get_by_shard_id(shard_state.shard_id) if fresh_state and fresh_state.active: # Free lease. fresh_state.slice_start_time = None fresh_state.slice_request_id = None if slice_retry: fresh_state.slice_retries += 1 fresh_state.put() try: _tx() # pylint: disable=broad-except except Exception, e: logging.warning(e) logging.warning( "Release lock for shard %s failed. Wait for lease to expire.", shard_state.shard_id) def _maintain_LC(self, obj, slice_id, last_slice=False, begin_slice=True, shard_ctx=None, slice_ctx=None): """Makes sure shard life cycle interface are respected. Args: obj: the obj that may have implemented _ShardLifeCycle. slice_id: current slice_id last_slice: whether this is the last slice. begin_slice: whether this is the beginning or the end of a slice. shard_ctx: shard ctx for dependency injection. If None, it will be read from self. slice_ctx: slice ctx for dependency injection. If None, it will be read from self. """ if obj is None or not isinstance(obj, shard_life_cycle._ShardLifeCycle): return shard_context = shard_ctx or self.shard_context slice_context = slice_ctx or self.slice_context if begin_slice: if slice_id == 0: obj.begin_shard(shard_context) obj.begin_slice(slice_context) else: obj.end_slice(slice_context) if last_slice: obj.end_shard(shard_context) def handle(self): """Handle request. This method has to be careful to pass the same ShardState instance to its subroutines calls if the calls mutate or read from ShardState. Note especially that Context instance caches and updates the ShardState instance. Returns: Set HTTP status code and always returns None. """ # Reconstruct basic states. self._start_time = self._time() shard_id = self.request.headers[util._MR_SHARD_ID_TASK_HEADER] mr_id = self.request.headers[util._MR_ID_TASK_HEADER] spec = model.MapreduceSpec._get_mapreduce_spec(mr_id) shard_state, control = db.get([ model.ShardState.get_key_by_shard_id(shard_id), model.MapreduceControl.get_key_by_job_id(mr_id), ]) # Set context before any IO code is called. ctx = context.Context(spec, shard_state, task_retry_count=self.task_retry_count()) context.Context._set(ctx) # Unmarshall input reader, output writer, and other transient states. tstate = model.TransientShardState.from_request(self.request) # Try acquire a lease on the shard. if shard_state: is_this_a_retry = shard_state.acquired_once task_directive = self._try_acquire_lease(shard_state, tstate) if task_directive in (self._TASK_DIRECTIVE.RETRY_TASK, self._TASK_DIRECTIVE.DROP_TASK): return self.__return(shard_state, tstate, task_directive) assert task_directive == self._TASK_DIRECTIVE.PROCEED_TASK # Abort shard if received signal. if control and control.command == model.MapreduceControl.ABORT: task_directive = self._TASK_DIRECTIVE.ABORT_SHARD return self.__return(shard_state, tstate, task_directive) # Retry shard if user disabled slice retry. if (is_this_a_retry and parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS <= 1): task_directive = self._TASK_DIRECTIVE.RETRY_SHARD return self.__return(shard_state, tstate, task_directive) # TODO(user): Find a better way to set these per thread configs. # E.g. what if user change it? util._set_ndb_cache_policy() job_config = map_job.JobConfig._to_map_job_config( spec, os.environ.get("HTTP_X_APPENGINE_QUEUENAME")) job_context = map_job.JobContext(job_config) self.shard_context = map_job.ShardContext(job_context, shard_state) self.slice_context = map_job.SliceContext(self.shard_context, shard_state, tstate) try: slice_id = tstate.slice_id self._maintain_LC(tstate.handler, slice_id) self._maintain_LC(tstate.input_reader, slice_id) self._maintain_LC(tstate.output_writer, slice_id) if is_this_a_retry: task_directive = self._attempt_slice_recovery(shard_state, tstate) if task_directive != self._TASK_DIRECTIVE.PROCEED_TASK: return self.__return(shard_state, tstate, task_directive) last_slice = self._process_inputs( tstate.input_reader, shard_state, tstate, ctx) self._maintain_LC(tstate.handler, slice_id, last_slice, False) self._maintain_LC(tstate.input_reader, slice_id, last_slice, False) self._maintain_LC(tstate.output_writer, slice_id, last_slice, False) ctx.flush() if last_slice: # Since there was no exception raised, we can finalize output writer # safely. Otherwise writer might be stuck in some bad state. if (tstate.output_writer and isinstance(tstate.output_writer, output_writers.OutputWriter)): # It's possible that finalization is successful but # saving state failed. In this case this shard will retry upon # finalization error. # TODO(user): make finalize method idempotent! tstate.output_writer.finalize(ctx, shard_state) shard_state.set_for_success() # pylint: disable=broad-except except Exception, e: logging.warning("Shard %s got error.", shard_state.shard_id) logging.error(traceback.format_exc()) # Fail fast. if type(e) is errors.FailJobError: logging.error("Got FailJobError.") task_directive = self._TASK_DIRECTIVE.FAIL_TASK else: task_directive = self._TASK_DIRECTIVE.RETRY_SLICE self.__return(shard_state, tstate, task_directive) def __return(self, shard_state, tstate, task_directive): """Handler should always call this as the last statement.""" task_directive = self._set_state(shard_state, tstate, task_directive) self._save_state_and_schedule_next(shard_state, tstate, task_directive) def _process_inputs(self, input_reader, shard_state, tstate, ctx): """Read inputs, process them, and write out outputs. This is the core logic of MapReduce. It reads inputs from input reader, invokes user specified mapper function, and writes output with output writer. It also updates shard_state accordingly. e.g. if shard processing is done, set shard_state.active to False. If errors.FailJobError is caught, it will fail this MR job. All other exceptions will be logged and raised to taskqueue for retry until the number of retries exceeds a limit. Args: input_reader: input reader. shard_state: shard state. tstate: transient shard state. ctx: mapreduce context. Returns: Whether this shard has finished processing all its input split. """ processing_limit = self._processing_limit(tstate.mapreduce_spec) if processing_limit == 0: return finished_shard = True # Input reader may not be an iterator. It is only a container. iterator = iter(input_reader) while True: try: entity = iterator.next() except StopIteration: break # Reading input got exception. If we assume # 1. The input reader have done enough retries. # 2. The input reader can still serialize correctly after this exception. # 3. The input reader, upon resume, will try to re-read this failed # record. # 4. This exception doesn't imply the input reader is permanently stuck. # we can serialize current slice immediately to avoid duplicated # outputs. # TODO(user): Validate these assumptions on all readers. MR should # also have a way to detect fake forward progress. if isinstance(entity, db.Model): shard_state.last_work_item = repr(entity.key()) elif isinstance(entity, ndb.Model): shard_state.last_work_item = repr(entity.key) else: shard_state.last_work_item = repr(entity)[:100] processing_limit -= 1 if not self._process_datum( entity, input_reader, ctx, tstate): finished_shard = False break elif processing_limit == 0: finished_shard = False break # Flush context and its pools. self.slice_context.incr( context.COUNTER_MAPPER_WALLTIME_MS, int((self._time() - self._start_time)*1000)) return finished_shard def _process_datum(self, data, input_reader, ctx, transient_shard_state): """Process a single data piece. Call mapper handler on the data. Args: data: a datum to process. input_reader: input reader. ctx: mapreduce context transient_shard_state: transient shard state. Returns: True if scan should be continued, False if scan should be stopped. """ if data is not input_readers.ALLOW_CHECKPOINT: self.slice_context.incr(context.COUNTER_MAPPER_CALLS) handler = transient_shard_state.handler if isinstance(handler, map_job.Mapper): handler(self.slice_context, data) else: if input_reader.expand_parameters: result = handler(*data) else: result = handler(data) if util.is_generator(result): for output in result: if isinstance(output, operation.Operation): output(ctx) else: output_writer = transient_shard_state.output_writer if not output_writer: logging.warning( "Handler yielded %s, but no output writer is set.", output) else: output_writer.write(output) if self._time() - self._start_time >= parameters.config._SLICE_DURATION_SEC: return False return True def _set_state(self, shard_state, tstate, task_directive): """Set shard_state and tstate based on task_directive. Args: shard_state: model.ShardState for current shard. tstate: model.TransientShardState for current shard. task_directive: self._TASK_DIRECTIVE for current shard. Returns: A _TASK_DIRECTIVE enum. PROCEED_TASK if task should proceed normally. RETRY_SHARD if shard should be retried. RETRY_SLICE if slice should be retried. FAIL_TASK if sahrd should fail. RECOVER_SLICE if slice should be recovered. ABORT_SHARD if shard should be aborted. RETRY_TASK if task should be retried. DROP_TASK if task should be dropped. """ if task_directive in (self._TASK_DIRECTIVE.RETRY_TASK, self._TASK_DIRECTIVE.DROP_TASK): return task_directive if task_directive == self._TASK_DIRECTIVE.ABORT_SHARD: shard_state.set_for_abort() return task_directive if task_directive == self._TASK_DIRECTIVE.PROCEED_TASK: shard_state.advance_for_next_slice() tstate.advance_for_next_slice() return task_directive if task_directive == self._TASK_DIRECTIVE.RECOVER_SLICE: tstate.advance_for_next_slice(recovery_slice=True) shard_state.advance_for_next_slice(recovery_slice=True) return task_directive if task_directive == self._TASK_DIRECTIVE.RETRY_SLICE: task_directive = self._attempt_slice_retry(shard_state, tstate) if task_directive == self._TASK_DIRECTIVE.RETRY_SHARD: task_directive = self._attempt_shard_retry(shard_state, tstate) if task_directive == self._TASK_DIRECTIVE.FAIL_TASK: shard_state.set_for_failure() return task_directive def _save_state_and_schedule_next(self, shard_state, tstate, task_directive): """Save state and schedule task. Save shard state to datastore. Schedule next slice if needed. Set HTTP response code. No modification to any shard_state or tstate. Args: shard_state: model.ShardState for current shard. tstate: model.TransientShardState for current shard. task_directive: enum _TASK_DIRECTIVE. Returns: The task to retry if applicable. """ spec = tstate.mapreduce_spec if task_directive == self._TASK_DIRECTIVE.DROP_TASK: return if task_directive in (self._TASK_DIRECTIVE.RETRY_SLICE, self._TASK_DIRECTIVE.RETRY_TASK): # Set HTTP code to 500. return self.retry_task() elif task_directive == self._TASK_DIRECTIVE.ABORT_SHARD: logging.info("Aborting shard %d of job '%s'", shard_state.shard_number, shard_state.mapreduce_id) task = None elif task_directive == self._TASK_DIRECTIVE.FAIL_TASK: logging.critical("Shard %s failed permanently.", shard_state.shard_id) task = None elif task_directive == self._TASK_DIRECTIVE.RETRY_SHARD: logging.warning("Shard %s is going to be attempted for the %s time.", shard_state.shard_id, shard_state.retries + 1) task = self._state_to_task(tstate, shard_state) elif task_directive == self._TASK_DIRECTIVE.RECOVER_SLICE: logging.warning("Shard %s slice %s is being recovered.", shard_state.shard_id, shard_state.slice_id) task = self._state_to_task(tstate, shard_state) else: assert task_directive == self._TASK_DIRECTIVE.PROCEED_TASK countdown = self._get_countdown_for_next_slice(spec) task = self._state_to_task(tstate, shard_state, countdown=countdown) # Prepare parameters for db transaction and taskqueue. queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", # For test only. # TODO(user): Remove this. "default") config = util.create_datastore_write_config(spec) @db.transactional(retries=5) def _tx(): """The Transaction helper.""" fresh_shard_state = model.ShardState.get_by_shard_id(tstate.shard_id) if not fresh_shard_state: raise db.Rollback() if (not fresh_shard_state.active or "worker_active_state_collision" in _TEST_INJECTED_FAULTS): logging.warning("Shard %s is not active. Possible spurious task " "execution. Dropping this task.", tstate.shard_id) logging.warning("Datastore's %s", str(fresh_shard_state)) logging.warning("Slice's %s", str(shard_state)) return fresh_shard_state.copy_from(shard_state) fresh_shard_state.put(config=config) # Add task in the same datastore transaction. # This way we guarantee taskqueue is never behind datastore states. # Old tasks will be dropped. # Future task won't run until datastore states catches up. if fresh_shard_state.active: # Not adding task transactionally. # transactional enqueue requires tasks with no name. self._add_task(task, spec, queue_name) try: _tx() except (datastore_errors.Error, taskqueue.Error, runtime.DeadlineExceededError, apiproxy_errors.Error), e: logging.warning( "Can't transactionally continue shard. " "Will retry slice %s %s for the %s time.", tstate.shard_id, tstate.slice_id, self.task_retry_count() + 1) self._try_free_lease(shard_state) raise e def _attempt_slice_recovery(self, shard_state, tstate): """Recover a slice. This is run when a slice had been previously attempted and output may have been written. If an output writer requires slice recovery, we run those logic to remove output duplicates. Otherwise we just retry the slice. If recovery is needed, then the entire slice will be dedicated to recovery logic. No data processing will take place. Thus we call the slice "recovery slice". This is needed for correctness: An output writer instance can be out of sync from its physical medium only when the slice dies after acquring the shard lock but before committing shard state to db. The worst failure case is when shard state failed to commit after the NAMED task for the next slice was added. Thus, recovery slice has a special logic to increment current slice_id n to n+2. If the task for n+1 had been added, it will be dropped because it is behind shard state. Args: shard_state: an instance of Model.ShardState. tstate: an instance of Model.TransientShardState. Returns: _TASK_DIRECTIVE.PROCEED_TASK to continue with this retry. _TASK_DIRECTIVE.RECOVER_SLICE to recover this slice. The next slice will start at the same input as this slice but output to a new instance of output writer. Combining outputs from all writer instances is up to implementation. """ mapper_spec = tstate.mapreduce_spec.mapper if not (tstate.output_writer and tstate.output_writer._supports_slice_recovery(mapper_spec)): return self._TASK_DIRECTIVE.PROCEED_TASK tstate.output_writer = tstate.output_writer._recover( tstate.mapreduce_spec, shard_state.shard_number, shard_state.retries + 1) return self._TASK_DIRECTIVE.RECOVER_SLICE def _attempt_shard_retry(self, shard_state, tstate): """Whether to retry shard. This method may modify shard_state and tstate to prepare for retry or fail. Args: shard_state: model.ShardState for current shard. tstate: model.TransientShardState for current shard. Returns: A _TASK_DIRECTIVE enum. RETRY_SHARD if shard should be retried. FAIL_TASK otherwise. """ shard_attempts = shard_state.retries + 1 if shard_attempts >= parameters.config.SHARD_MAX_ATTEMPTS: logging.warning( "Shard attempt %s exceeded %s max attempts.", shard_attempts, parameters.config.SHARD_MAX_ATTEMPTS) return self._TASK_DIRECTIVE.FAIL_TASK if tstate.output_writer and ( not tstate.output_writer._supports_shard_retry(tstate)): logging.warning("Output writer %s does not support shard retry.", tstate.output_writer.__class__.__name__) return self._TASK_DIRECTIVE.FAIL_TASK shard_state.reset_for_retry() logging.warning("Shard %s attempt %s failed with up to %s attempts.", shard_state.shard_id, shard_state.retries, parameters.config.SHARD_MAX_ATTEMPTS) output_writer = None if tstate.output_writer: output_writer = tstate.output_writer.create( tstate.mapreduce_spec, shard_state.shard_number, shard_attempts + 1) tstate.reset_for_retry(output_writer) return self._TASK_DIRECTIVE.RETRY_SHARD def _attempt_slice_retry(self, shard_state, tstate): """Attempt to retry this slice. This method may modify shard_state and tstate to prepare for retry or fail. Args: shard_state: model.ShardState for current shard. tstate: model.TransientShardState for current shard. Returns: A _TASK_DIRECTIVE enum. RETRY_SLICE if slice should be retried. RETRY_SHARD if shard retry should be attempted. """ if (shard_state.slice_retries + 1 < parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS): logging.warning( "Slice %s %s failed for the %s of up to %s attempts " "(%s of %s taskqueue execution attempts). " "Will retry now.", tstate.shard_id, tstate.slice_id, shard_state.slice_retries + 1, parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS, self.task_retry_count() + 1, parameters.config.TASK_MAX_ATTEMPTS) # Clear info related to current exception. Otherwise, the real # callstack that includes a frame for this method will show up # in log. sys.exc_clear() self._try_free_lease(shard_state, slice_retry=True) return self._TASK_DIRECTIVE.RETRY_SLICE if parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS > 0: logging.warning("Slice attempt %s exceeded %s max attempts.", self.task_retry_count() + 1, parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS) return self._TASK_DIRECTIVE.RETRY_SHARD @staticmethod def get_task_name(shard_id, slice_id, retry=0): """Compute single worker task name. Args: shard_id: shard id. slice_id: slice id. retry: current shard retry count. Returns: task name which should be used to process specified shard/slice. """ # Prefix the task name with something unique to this framework's # namespace so we don't conflict with user tasks on the queue. return "appengine-mrshard-%s-%s-retry-%s" % ( shard_id, slice_id, retry) def _get_countdown_for_next_slice(self, spec): """Get countdown for next slice's task. When user sets processing rate, we set countdown to delay task execution. Args: spec: model.MapreduceSpec Returns: countdown in int. """ countdown = 0 if self._processing_limit(spec) != -1: countdown = max( int(parameters.config._SLICE_DURATION_SEC - (self._time() - self._start_time)), 0) return countdown @classmethod def _state_to_task(cls, tstate, shard_state, eta=None, countdown=None): """Generate task for slice according to current states. Args: tstate: An instance of TransientShardState. shard_state: An instance of ShardState. eta: Absolute time when the MR should execute. May not be specified if 'countdown' is also supplied. This may be timezone-aware or timezone-naive. countdown: Time in seconds into the future that this MR should execute. Defaults to zero. Returns: A model.HugeTask instance for the slice specified by current states. """ base_path = tstate.base_path task_name = MapperWorkerCallbackHandler.get_task_name( tstate.shard_id, tstate.slice_id, tstate.retries) headers = util._get_task_headers(tstate.mapreduce_spec.mapreduce_id) headers[util._MR_SHARD_ID_TASK_HEADER] = tstate.shard_id worker_task = model.HugeTask( url=base_path + "/worker_callback/" + tstate.shard_id, params=tstate.to_dict(), name=task_name, eta=eta, countdown=countdown, parent=shard_state, headers=headers) return worker_task @classmethod def _add_task(cls, worker_task, mapreduce_spec, queue_name): """Schedule slice scanning by adding it to the task queue. Args: worker_task: a model.HugeTask task for slice. This is NOT a taskqueue task. mapreduce_spec: an instance of model.MapreduceSpec. queue_name: Optional queue to run on; uses the current queue of execution or the default queue if unspecified. """ if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_worker_task", worker_task, queue_name): try: # Not adding transactionally because worker_task has name. # Named task is not allowed for transactional add. worker_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", worker_task.name, e.__class__, e) def _processing_limit(self, spec): """Get the limit on the number of map calls allowed by this slice. Args: spec: a Mapreduce spec. Returns: The limit as a positive int if specified by user. -1 otherwise. """ processing_rate = float(spec.mapper.params.get("processing_rate", 0)) slice_processing_limit = -1 if processing_rate > 0: slice_processing_limit = int(math.ceil( parameters.config._SLICE_DURATION_SEC*processing_rate/ int(spec.mapper.shard_count))) return slice_processing_limit # Deprecated. Only used by old test cases. # TODO(user): clean up tests. @classmethod def _schedule_slice(cls, shard_state, tstate, queue_name=None, eta=None, countdown=None): """Schedule slice scanning by adding it to the task queue. Args: shard_state: An instance of ShardState. tstate: An instance of TransientShardState. queue_name: Optional queue to run on; uses the current queue of execution or the default queue if unspecified. eta: Absolute time when the MR should execute. May not be specified if 'countdown' is also supplied. This may be timezone-aware or timezone-naive. countdown: Time in seconds into the future that this MR should execute. Defaults to zero. """ queue_name = queue_name or os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") task = cls._state_to_task(tstate, shard_state, eta, countdown) cls._add_task(task, tstate.mapreduce_spec, queue_name) class ControllerCallbackHandler(base_handler.HugeTaskHandler): """Supervises mapreduce execution. Is also responsible for gathering execution status from shards together. This task is "continuously" running by adding itself again to taskqueue if and only if mapreduce is still active. A mapreduce is active if it has actively running shards. """ def __init__(self, *args): """Constructor.""" super(ControllerCallbackHandler, self).__init__(*args) self._time = time.time def _drop_gracefully(self): """Gracefully drop controller task. This method is called when decoding controller task payload failed. Upon this we mark ShardState and MapreduceState as failed so all tasks can stop. Writing to datastore is forced (ignore read-only mode) because we want the tasks to stop badly, and if force_writes was False, the job would have never been started. """ mr_id = self.request.headers[util._MR_ID_TASK_HEADER] state = model.MapreduceState.get_by_job_id(mr_id) if not state or not state.active: return state.active = False state.result_status = model.MapreduceState.RESULT_FAILED config = util.create_datastore_write_config(state.mapreduce_spec) puts = [] for ss in model.ShardState.find_all_by_mapreduce_state(state): if ss.active: ss.set_for_failure() puts.append(ss) # Avoid having too many shard states in memory. if len(puts) > model.ShardState._MAX_STATES_IN_MEMORY: db.put(puts, config=config) puts = [] db.put(puts, config=config) # Put mr_state only after all shard_states are put. db.put(state, config=config) def handle(self): """Handle request.""" spec = model.MapreduceSpec.from_json_str( self.request.get("mapreduce_spec")) state, control = db.get([ model.MapreduceState.get_key_by_job_id(spec.mapreduce_id), model.MapreduceControl.get_key_by_job_id(spec.mapreduce_id), ]) if not state: logging.warning("State not found for MR '%s'; dropping controller task.", spec.mapreduce_id) return if not state.active: logging.warning( "MR %r is not active. Looks like spurious controller task execution.", spec.mapreduce_id) self._clean_up_mr(spec) return shard_states = model.ShardState.find_all_by_mapreduce_state(state) self._update_state_from_shard_states(state, shard_states, control) if state.active: ControllerCallbackHandler.reschedule( state, spec, self.serial_id() + 1) def _update_state_from_shard_states(self, state, shard_states, control): """Update mr state by examing shard states. Args: state: current mapreduce state as MapreduceState. shard_states: an iterator over shard states. control: model.MapreduceControl entity. """ # Initialize vars. state.active_shards, state.aborted_shards, state.failed_shards = 0, 0, 0 total_shards = 0 processed_counts = [] state.counters_map.clear() # Tally across shard states once. for s in shard_states: total_shards += 1 if s.active: state.active_shards += 1 if s.result_status == model.ShardState.RESULT_ABORTED: state.aborted_shards += 1 elif s.result_status == model.ShardState.RESULT_FAILED: state.failed_shards += 1 # Update stats in mapreduce state by aggregating stats from shard states. state.counters_map.add_map(s.counters_map) processed_counts.append(s.counters_map.get(context.COUNTER_MAPPER_CALLS)) state.set_processed_counts(processed_counts) state.last_poll_time = datetime.datetime.utcfromtimestamp(self._time()) spec = state.mapreduce_spec if total_shards != spec.mapper.shard_count: logging.error("Found %d shard states. Expect %d. " "Issuing abort command to job '%s'", total_shards, spec.mapper.shard_count, spec.mapreduce_id) # We issue abort command to allow shards to stop themselves. model.MapreduceControl.abort(spec.mapreduce_id) # If any shard is active then the mr is active. # This way, controller won't prematurely stop before all the shards have. state.active = bool(state.active_shards) if not control and (state.failed_shards or state.aborted_shards): # Issue abort command if there are failed shards. model.MapreduceControl.abort(spec.mapreduce_id) if not state.active: # Set final result status derived from shard states. if state.failed_shards or not total_shards: state.result_status = model.MapreduceState.RESULT_FAILED # It's important failed shards is checked before aborted shards # because failed shards will trigger other shards to abort. elif state.aborted_shards: state.result_status = model.MapreduceState.RESULT_ABORTED else: state.result_status = model.MapreduceState.RESULT_SUCCESS self._finalize_outputs(spec, state) self._finalize_job(spec, state) else: @db.transactional(retries=5) def _put_state(): """The helper for storing the state.""" fresh_state = model.MapreduceState.get_by_job_id(spec.mapreduce_id) # We don't check anything other than active because we are only # updating stats. It's OK if they are briefly inconsistent. if not fresh_state.active: logging.warning( "Job %s is not active. Looks like spurious task execution. " "Dropping controller task.", spec.mapreduce_id) return config = util.create_datastore_write_config(spec) state.put(config=config) _put_state() def serial_id(self): """Get serial unique identifier of this task from request. Returns: serial identifier as int. """ return int(self.request.get("serial_id")) @classmethod def _finalize_outputs(cls, mapreduce_spec, mapreduce_state): """Finalize outputs. Args: mapreduce_spec: an instance of MapreduceSpec. mapreduce_state: an instance of MapreduceState. """ # Only finalize the output writers if the job is successful. if (mapreduce_spec.mapper.output_writer_class() and mapreduce_state.result_status == model.MapreduceState.RESULT_SUCCESS): mapreduce_spec.mapper.output_writer_class().finalize_job(mapreduce_state) @classmethod def _finalize_job(cls, mapreduce_spec, mapreduce_state): """Finalize job execution. Invokes done callback and save mapreduce state in a transaction, and schedule necessary clean ups. This method is idempotent. Args: mapreduce_spec: an instance of MapreduceSpec mapreduce_state: an instance of MapreduceState """ config = util.create_datastore_write_config(mapreduce_spec) queue_name = util.get_queue_name(mapreduce_spec.params.get( model.MapreduceSpec.PARAM_DONE_CALLBACK_QUEUE)) done_callback = mapreduce_spec.params.get( model.MapreduceSpec.PARAM_DONE_CALLBACK) done_task = None if done_callback: done_task = taskqueue.Task( url=done_callback, headers=util._get_task_headers(mapreduce_spec.mapreduce_id, util.CALLBACK_MR_ID_TASK_HEADER), method=mapreduce_spec.params.get("done_callback_method", "POST")) @db.transactional(retries=5) def _put_state(): """Helper to store state.""" fresh_state = model.MapreduceState.get_by_job_id( mapreduce_spec.mapreduce_id) if not fresh_state.active: logging.warning( "Job %s is not active. Looks like spurious task execution. " "Dropping task.", mapreduce_spec.mapreduce_id) return mapreduce_state.put(config=config) # Enqueue done_callback if needed. if done_task and not _run_task_hook( mapreduce_spec.get_hooks(), "enqueue_done_task", done_task, queue_name): done_task.add(queue_name, transactional=True) _put_state() logging.info("Final result for job '%s' is '%s'", mapreduce_spec.mapreduce_id, mapreduce_state.result_status) cls._clean_up_mr(mapreduce_spec) @classmethod def _clean_up_mr(cls, mapreduce_spec): FinalizeJobHandler.schedule(mapreduce_spec) @staticmethod def get_task_name(mapreduce_spec, serial_id): """Compute single controller task name. Args: mapreduce_spec: specification of the mapreduce. serial_id: id of the invocation as int. Returns: task name which should be used to process specified shard/slice. """ # Prefix the task name with something unique to this framework's # namespace so we don't conflict with user tasks on the queue. return "appengine-mrcontrol-%s-%s" % ( mapreduce_spec.mapreduce_id, serial_id) @staticmethod def controller_parameters(mapreduce_spec, serial_id): """Fill in controller task parameters. Returned parameters map is to be used as task payload, and it contains all the data, required by controller to perform its function. Args: mapreduce_spec: specification of the mapreduce. serial_id: id of the invocation as int. Returns: string->string map of parameters to be used as task payload. """ return {"mapreduce_spec": mapreduce_spec.to_json_str(), "serial_id": str(serial_id)} @classmethod def reschedule(cls, mapreduce_state, mapreduce_spec, serial_id, queue_name=None): """Schedule new update status callback task. Args: mapreduce_state: mapreduce state as model.MapreduceState mapreduce_spec: mapreduce specification as MapreduceSpec. serial_id: id of the invocation as int. queue_name: The queue to schedule this task on. Will use the current queue of execution if not supplied. """ task_name = ControllerCallbackHandler.get_task_name( mapreduce_spec, serial_id) task_params = ControllerCallbackHandler.controller_parameters( mapreduce_spec, serial_id) if not queue_name: queue_name = os.environ.get("HTTP_X_APPENGINE_QUEUENAME", "default") controller_callback_task = model.HugeTask( url=(mapreduce_spec.params["base_path"] + "/controller_callback/" + mapreduce_spec.mapreduce_id), name=task_name, params=task_params, countdown=parameters.config._CONTROLLER_PERIOD_SEC, parent=mapreduce_state, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", controller_callback_task, queue_name): try: controller_callback_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r with params %r already exists. %s: %s", task_name, task_params, e.__class__, e) class KickOffJobHandler(base_handler.TaskQueueHandler): """Taskqueue handler which kicks off a mapreduce processing. This handler is idempotent. Precondition: The Model.MapreduceState entity for this mr is already created and saved to datastore by StartJobHandler._start_map. Request Parameters: mapreduce_id: in string. """ # Datastore key used to save json serialized input readers. _SERIALIZED_INPUT_READERS_KEY = "input_readers_for_mr_%s" def handle(self): """Handles kick off request.""" # Get and verify mr state. mr_id = self.request.get("mapreduce_id") # Log the mr_id since this is started in an unnamed task logging.info("Processing kickoff for job %s", mr_id) state = model.MapreduceState.get_by_job_id(mr_id) if not self._check_mr_state(state, mr_id): return # Create input readers. readers, serialized_readers_entity = self._get_input_readers(state) if readers is None: # We don't have any data. Finish map. logging.warning("Found no mapper input data to process.") state.active = False state.result_status = model.MapreduceState.RESULT_SUCCESS ControllerCallbackHandler._finalize_job( state.mapreduce_spec, state) return False # Create output writers. self._setup_output_writer(state) # Save states and make sure we use the saved input readers for # subsequent operations. result = self._save_states(state, serialized_readers_entity) if result is None: readers, _ = self._get_input_readers(state) elif not result: return queue_name = self.request.headers.get("X-AppEngine-QueueName") KickOffJobHandler._schedule_shards(state.mapreduce_spec, readers, queue_name, state.mapreduce_spec.params["base_path"], state) ControllerCallbackHandler.reschedule( state, state.mapreduce_spec, serial_id=0, queue_name=queue_name) def _drop_gracefully(self): """See parent.""" mr_id = self.request.get("mapreduce_id") logging.error("Failed to kick off job %s", mr_id) state = model.MapreduceState.get_by_job_id(mr_id) if not self._check_mr_state(state, mr_id): return # Issue abort command just in case there are running tasks. config = util.create_datastore_write_config(state.mapreduce_spec) model.MapreduceControl.abort(mr_id, config=config) # Finalize job and invoke callback. state.active = False state.result_status = model.MapreduceState.RESULT_FAILED ControllerCallbackHandler._finalize_job(state.mapreduce_spec, state) def _get_input_readers(self, state): """Get input readers. Args: state: a MapreduceState model. Returns: A tuple: (a list of input readers, a model._HugeTaskPayload entity). The payload entity contains the json serialized input readers. (None, None) when input reader inplitting returned no data to process. """ serialized_input_readers_key = (self._SERIALIZED_INPUT_READERS_KEY % state.key().id_or_name()) serialized_input_readers = model._HugeTaskPayload.get_by_key_name( serialized_input_readers_key, parent=state) # Initialize input readers. input_reader_class = state.mapreduce_spec.mapper.input_reader_class() split_param = state.mapreduce_spec.mapper if issubclass(input_reader_class, map_job.InputReader): split_param = map_job.JobConfig._to_map_job_config( state.mapreduce_spec, os.environ.get("HTTP_X_APPENGINE_QUEUENAME")) if serialized_input_readers is None: readers = input_reader_class.split_input(split_param) else: readers = [input_reader_class.from_json_str(json) for json in simplejson.loads(serialized_input_readers.payload)] if not readers: return None, None # Update state and spec with actual shard count. state.mapreduce_spec.mapper.shard_count = len(readers) state.active_shards = len(readers) # Prepare to save serialized input readers. if serialized_input_readers is None: # Use mr_state as parent so it can be easily cleaned up later. serialized_input_readers = model._HugeTaskPayload( key_name=serialized_input_readers_key, parent=state) readers_json_str = [i.to_json_str() for i in readers] serialized_input_readers.payload = simplejson.dumps(readers_json_str) return readers, serialized_input_readers def _setup_output_writer(self, state): if not state.writer_state: output_writer_class = state.mapreduce_spec.mapper.output_writer_class() if output_writer_class: output_writer_class.init_job(state) @db.transactional def _save_states(self, state, serialized_readers_entity): """Run transaction to save state. Args: state: a model.MapreduceState entity. serialized_readers_entity: a model._HugeTaskPayload entity containing json serialized input readers. Returns: False if a fatal error is encountered and this task should be dropped immediately. True if transaction is successful. None if a previous attempt of this same transaction has already succeeded. """ mr_id = state.key().id_or_name() fresh_state = model.MapreduceState.get_by_job_id(mr_id) if not self._check_mr_state(fresh_state, mr_id): return False if fresh_state.active_shards != 0: logging.warning( "Mapreduce %s already has active shards. Looks like spurious task " "execution.", mr_id) return None config = util.create_datastore_write_config(state.mapreduce_spec) db.put([state, serialized_readers_entity], config=config) return True @classmethod def _schedule_shards(cls, spec, readers, queue_name, base_path, mr_state): """Prepares shard states and schedules their execution. Even though this method does not schedule shard task and save shard state transactionally, it's safe for taskqueue to retry this logic because the initial shard_state for each shard is the same from any retry. This is an important yet reasonable assumption on model.ShardState. Args: spec: mapreduce specification as MapreduceSpec. readers: list of InputReaders describing shard splits. queue_name: The queue to run this job on. base_path: The base url path of mapreduce callbacks. mr_state: The MapReduceState of current job. """ # Create shard states. shard_states = [] for shard_number, input_reader in enumerate(readers): shard_state = model.ShardState.create_new(spec.mapreduce_id, shard_number) shard_state.shard_description = str(input_reader) shard_states.append(shard_state) # Retrieves already existing shard states. existing_shard_states = db.get(shard.key() for shard in shard_states) existing_shard_keys = set(shard.key() for shard in existing_shard_states if shard is not None) # Save non existent shard states. # Note: we could do this transactionally if necessary. db.put((shard for shard in shard_states if shard.key() not in existing_shard_keys), config=util.create_datastore_write_config(spec)) # Create output writers. writer_class = spec.mapper.output_writer_class() writers = [None] * len(readers) if writer_class: for shard_number, shard_state in enumerate(shard_states): writers[shard_number] = writer_class.create( mr_state.mapreduce_spec, shard_state.shard_number, shard_state.retries + 1, mr_state.writer_state) # Schedule ALL shard tasks. # Since each task is named, _add_task will fall back gracefully if a # task already exists. for shard_number, (input_reader, output_writer) in enumerate( zip(readers, writers)): shard_id = model.ShardState.shard_id_from_number( spec.mapreduce_id, shard_number) task = MapperWorkerCallbackHandler._state_to_task( model.TransientShardState( base_path, spec, shard_id, 0, input_reader, input_reader, output_writer=output_writer, handler=spec.mapper.handler), shard_states[shard_number]) MapperWorkerCallbackHandler._add_task(task, spec, queue_name) @classmethod def _check_mr_state(cls, state, mr_id): """Check MapreduceState. Args: state: an MapreduceState instance. mr_id: mapreduce id. Returns: True if state is valid. False if not and this task should be dropped. """ if state is None: logging.warning( "Mapreduce State for job %s is missing. Dropping Task.", mr_id) return False if not state.active: logging.warning( "Mapreduce %s is not active. Looks like spurious task " "execution. Dropping Task.", mr_id) return False return True class StartJobHandler(base_handler.PostJsonHandler): """Command handler starts a mapreduce job. This handler allows user to start a mr via a web form. It's _start_map method can also be used independently to start a mapreduce. """ def handle(self): """Handles start request.""" # Mapper spec as form arguments. mapreduce_name = self._get_required_param("name") mapper_input_reader_spec = self._get_required_param("mapper_input_reader") mapper_handler_spec = self._get_required_param("mapper_handler") mapper_output_writer_spec = self.request.get("mapper_output_writer") mapper_params = self._get_params( "mapper_params_validator", "mapper_params.") params = self._get_params( "params_validator", "params.") # Default values. mr_params = map_job.JobConfig._get_default_mr_params() mr_params.update(params) if "queue_name" in mapper_params: mr_params["queue_name"] = mapper_params["queue_name"] # Set some mapper param defaults if not present. mapper_params["processing_rate"] = int(mapper_params.get( "processing_rate") or parameters.config.PROCESSING_RATE_PER_SEC) # Validate the Mapper spec, handler, and input reader. mapper_spec = model.MapperSpec( mapper_handler_spec, mapper_input_reader_spec, mapper_params, int(mapper_params.get("shard_count", parameters.config.SHARD_COUNT)), output_writer_spec=mapper_output_writer_spec) mapreduce_id = self._start_map( mapreduce_name, mapper_spec, mr_params, queue_name=mr_params["queue_name"], _app=mapper_params.get("_app")) self.json_response["mapreduce_id"] = mapreduce_id def _get_params(self, validator_parameter, name_prefix): """Retrieves additional user-supplied params for the job and validates them. Args: validator_parameter: name of the request parameter which supplies validator for this parameter set. name_prefix: common prefix for all parameter names in the request. Raises: Any exception raised by the 'params_validator' request parameter if the params fail to validate. Returns: The user parameters. """ params_validator = self.request.get(validator_parameter) user_params = {} for key in self.request.arguments(): if key.startswith(name_prefix): values = self.request.get_all(key) adjusted_key = key[len(name_prefix):] if len(values) == 1: user_params[adjusted_key] = values[0] else: user_params[adjusted_key] = values if params_validator: resolved_validator = util.for_name(params_validator) resolved_validator(user_params) return user_params def _get_required_param(self, param_name): """Get a required request parameter. Args: param_name: name of request parameter to fetch. Returns: parameter value Raises: errors.NotEnoughArgumentsError: if parameter is not specified. """ value = self.request.get(param_name) if not value: raise errors.NotEnoughArgumentsError(param_name + " not specified") return value @classmethod def _start_map(cls, name, mapper_spec, mapreduce_params, queue_name, eta=None, countdown=None, hooks_class_name=None, _app=None, in_xg_transaction=False): # pylint: disable=g-doc-args # pylint: disable=g-doc-return-or-yield """See control.start_map. Requirements for this method: 1. The request that invokes this method can either be regular or from taskqueue. So taskqueue specific headers can not be used. 2. Each invocation transactionally starts an isolated mapreduce job with a unique id. MapreduceState should be immediately available after returning. See control.start_map's doc on transactional. 3. Method should be lightweight. """ # Validate input reader. mapper_input_reader_class = mapper_spec.input_reader_class() mapper_input_reader_class.validate(mapper_spec) # Validate output writer. mapper_output_writer_class = mapper_spec.output_writer_class() if mapper_output_writer_class: mapper_output_writer_class.validate(mapper_spec) # Create a new id and mr spec. mapreduce_id = model.MapreduceState.new_mapreduce_id() mapreduce_spec = model.MapreduceSpec( name, mapreduce_id, mapper_spec.to_json(), mapreduce_params, hooks_class_name) # Validate mapper handler. ctx = context.Context(mapreduce_spec, None) context.Context._set(ctx) try: # pylint: disable=pointless-statement mapper_spec.handler finally: context.Context._set(None) # Save states and enqueue task. if in_xg_transaction: propagation = db.MANDATORY else: propagation = db.INDEPENDENT @db.transactional(propagation=propagation) def _txn(): cls._create_and_save_state(mapreduce_spec, _app) cls._add_kickoff_task(mapreduce_params["base_path"], mapreduce_spec, eta, countdown, queue_name) _txn() return mapreduce_id @classmethod def _create_and_save_state(cls, mapreduce_spec, _app): """Save mapreduce state to datastore. Save state to datastore so that UI can see it immediately. Args: mapreduce_spec: model.MapreduceSpec, _app: app id if specified. None otherwise. Returns: The saved Mapreduce state. """ state = model.MapreduceState.create_new(mapreduce_spec.mapreduce_id) state.mapreduce_spec = mapreduce_spec state.active = True state.active_shards = 0 if _app: state.app_id = _app config = util.create_datastore_write_config(mapreduce_spec) state.put(config=config) return state @classmethod def _add_kickoff_task(cls, base_path, mapreduce_spec, eta, countdown, queue_name): """Enqueues a new kickoff task.""" params = {"mapreduce_id": mapreduce_spec.mapreduce_id} # Task is not named so that it can be added within a transaction. kickoff_task = taskqueue.Task( url=base_path + "/kickoffjob_callback/" + mapreduce_spec.mapreduce_id, headers=util._get_task_headers(mapreduce_spec.mapreduce_id), params=params, eta=eta, countdown=countdown) hooks = mapreduce_spec.get_hooks() if hooks is not None: try: hooks.enqueue_kickoff_task(kickoff_task, queue_name) return except NotImplementedError: pass kickoff_task.add(queue_name, transactional=True) class FinalizeJobHandler(base_handler.TaskQueueHandler): """Finalize map job by deleting all temporary entities.""" def handle(self): mapreduce_id = self.request.get("mapreduce_id") mapreduce_state = model.MapreduceState.get_by_job_id(mapreduce_id) if mapreduce_state: config = ( util.create_datastore_write_config(mapreduce_state.mapreduce_spec)) keys = [model.MapreduceControl.get_key_by_job_id(mapreduce_id)] for ss in model.ShardState.find_all_by_mapreduce_state(mapreduce_state): keys.extend(list( model._HugeTaskPayload.all().ancestor(ss).run(keys_only=True))) keys.extend(list(model._HugeTaskPayload.all().ancestor( mapreduce_state).run(keys_only=True))) db.delete(keys, config=config) @classmethod def schedule(cls, mapreduce_spec): """Schedule finalize task. Args: mapreduce_spec: mapreduce specification as MapreduceSpec. """ task_name = mapreduce_spec.mapreduce_id + "-finalize" finalize_task = taskqueue.Task( name=task_name, url=(mapreduce_spec.params["base_path"] + "/finalizejob_callback/" + mapreduce_spec.mapreduce_id), params={"mapreduce_id": mapreduce_spec.mapreduce_id}, headers=util._get_task_headers(mapreduce_spec.mapreduce_id)) queue_name = util.get_queue_name(None) if not _run_task_hook(mapreduce_spec.get_hooks(), "enqueue_controller_task", finalize_task, queue_name): try: finalize_task.add(queue_name) except (taskqueue.TombstonedTaskError, taskqueue.TaskAlreadyExistsError), e: logging.warning("Task %r already exists. %s: %s", task_name, e.__class__, e) class CleanUpJobHandler(base_handler.PostJsonHandler): """Command to kick off tasks to clean up a job's data.""" def handle(self): mapreduce_id = self.request.get("mapreduce_id") mapreduce_state = model.MapreduceState.get_by_job_id(mapreduce_id) if mapreduce_state: shard_keys = model.ShardState.calculate_keys_by_mapreduce_state( mapreduce_state) db.delete(shard_keys) db.delete(mapreduce_state) self.json_response["status"] = ("Job %s successfully cleaned up." % mapreduce_id) class AbortJobHandler(base_handler.PostJsonHandler): """Command to abort a running job.""" def handle(self): model.MapreduceControl.abort(self.request.get("mapreduce_id")) self.json_response["status"] = "Abort signal sent."
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 7129, 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, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 23891, 13270, 6527, 8297, 367, 9672, 21822, 4514, 1041, 4388, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 354, 199, 199, 646, 2197, 199, 646, 2050, 199, 646, 3473, 199, 646, 747, 199, 646, 2196, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 199, 504, 2341, 5270, 14, 11470, 63, 7522, 492, 13804, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 199, 504, 6233, 14, 15358, 492, 8836, 199, 504, 6233, 14, 15358, 14, 1246, 492, 12007, 63, 2550, 199, 504, 6233, 14, 15358, 14, 1246, 492, 943, 1364, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4621, 199, 504, 6233, 14, 15358, 14, 1246, 492, 2120, 1825, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 504, 2341, 5270, 492, 1300, 63, 2232, 199, 504, 2341, 5270, 492, 1067, 199, 504, 2341, 5270, 492, 2552, 199, 504, 2341, 5270, 492, 1324, 63, 27056, 199, 504, 2341, 5270, 492, 1402, 199, 504, 2341, 5270, 492, 3439, 199, 504, 2341, 5270, 492, 1072, 63, 26224, 199, 504, 2341, 5270, 492, 2633, 199, 504, 2341, 5270, 492, 4884, 199, 504, 2341, 5270, 14, 1246, 492, 2341, 63, 2423, 199, 504, 2341, 5270, 14, 1246, 14, 1130, 63, 2423, 492, 11814, 63, 13602, 63, 7612, 199, 504, 6233, 14, 15358, 14, 7726, 492, 2986, 3280, 63, 2550, 199, 199, 3, 4287, 26, 3507, 29, 71, 13, 646, 13, 1397, 13, 292, 13, 2119, 199, 893, 26, 523, 492, 8002, 3494, 523, 327, 1010, 5661, 8836, 12, 314, 3432, 1233, 911, 506, 19270, 456, 6123, 370, 492, 314, 10098, 1015, 523, 327, 402, 8002, 3494, 14, 2900, 14706, 608, 78, 823, 402, 314, 2569, 340, 5558, 315, 603, 50, 523, 327, 1233, 1095, 365, 370, 11480, 652, 29430, 14, 523, 327, 3254, 8, 751, 304, 5852, 2410, 5661, 8836, 603, 50, 365, 2236, 265, 4456, 68, 14, 523, 340, 2688, 8, 4091, 3494, 12, 2668, 840, 2533, 2349, 272, 8002, 3494, 275, 488, 199, 2590, 3545, 26, 523, 8002, 3494, 275, 488, 221, 327, 8142, 6408, 3555, 440, 2808, 421, 199, 3, 437, 22885, 370, 2050, 14, 199, 3, 943, 14, 13138, 26, 3788, 922, 3679, 590, 1077, 1937, 12, 325, 14, 71, 14, 3405, 3906, 14, 199, 3, 943, 14, 705, 26, 4967, 5309, 6661, 922, 666, 12, 503, 10537, 199, 3, 2552, 10501, 701, 25478, 10059, 14, 199, 3, 943, 14, 3764, 26, 2552, 25478, 10059, 19428, 4212, 370, 2429, 14, 199, 3, 943, 14, 815, 26, 1163, 1420, 4474, 14, 421, 199, 3, 2494, 402, 3326, 402, 7750, 511, 13, 30785, 16898, 83, 14, 199, 63, 2864, 63, 568, 5550, 1149, 63, 2794, 51, 275, 663, 342, 421, 199, 318, 485, 1065, 63, 1765, 63, 3664, 8, 7922, 12, 1083, 12, 2120, 12, 4126, 63, 354, 304, 523, 408, 14883, 22652, 12604, 14, 765, 8, 1765, 12, 4126, 63, 354, 680, 819, 3033, 26, 272, 12604, 26, 437, 12604, 14, 8481, 83, 1256, 503, 488, 14, 272, 1083, 26, 710, 536, 402, 314, 1083, 370, 12677, 641, 314, 12604, 1021, 325, 14, 71, 14, 267, 298, 12456, 63, 31257, 1997, 63, 1765, 1674, 272, 2120, 26, 710, 2120, 1825, 14, 4476, 370, 986, 370, 314, 5759, 1083, 14, 272, 4126, 63, 354, 26, 710, 536, 402, 314, 4126, 370, 986, 370, 314, 5759, 1083, 14, 819, 1803, 26, 272, 715, 340, 314, 12604, 14, 8481, 83, 1256, 8860, 314, 1083, 12, 756, 4257, 14, 523, 408, 523, 340, 12604, 365, 440, 488, 26, 272, 862, 26, 489, 2519, 8, 7922, 12, 1083, 5130, 1765, 12, 4126, 63, 354, 9, 272, 871, 4279, 26, 489, 327, 3645, 314, 849, 2120, 10234, 4514, 14, 489, 372, 756, 339, 372, 715, 523, 372, 756, 421, 199, 533, 9672, 529, 12678, 2806, 2461, 8, 1095, 63, 2232, 14, 40, 17730, 4476, 2461, 304, 523, 408, 2806, 3016, 367, 2341, 5270, 7239, 2120, 1041, 819, 327, 5723, 13502, 315, 1820, 291, 855, 1107, 342, 4212, 370, 663, 1174, 436, 14892, 2120, 14, 523, 485, 17179, 63, 6098, 5399, 275, 4884, 423, 4869, 8, 489, 327, 8495, 365, 3879, 465, 1420, 14, 489, 3611, 2089, 1149, 63, 17179, 628, 496, 15648, 63, 1765, 401, 489, 327, 14012, 370, 7269, 2120, 14, 15536, 1990, 2845, 28320, 1380, 314, 1125, 4781, 14, 489, 327, 7529, 1133, 1570, 4886, 503, 12007, 14, 489, 17409, 5782, 63, 17179, 628, 7154, 63, 1765, 401, 489, 327, 14012, 370, 7269, 2120, 14, 15536, 1990, 28320, 1380, 314, 1125, 4781, 82, 14, 489, 327, 7529, 1133, 1570, 4886, 503, 12007, 14, 489, 17409, 5782, 63, 51, 2507, 37, 628, 7154, 63, 5224, 401, 489, 327, 18110, 314, 2120, 334, 11933, 370, 21747, 2120, 680, 9498, 943, 19860, 5978, 14, 489, 26704, 63, 17179, 628, 4824, 63, 1765, 401, 489, 327, 1666, 8297, 14, 11880, 12678, 2806, 2461, 423, 16880, 63, 5224, 63, 29920, 14, 489, 5363, 19052, 63, 51, 2507, 37, 628, 23131, 63, 5224, 401, 489, 327, 14012, 370, 7269, 314, 11814, 14, 489, 17409, 5782, 63, 3234, 7816, 628, 7154, 63, 10810, 401, 489, 327, 14012, 370, 5978, 2120, 436, 2449, 314, 11814, 14, 5297, 19860, 5988, 14, 489, 10341, 63, 17179, 628, 1633, 63, 1765 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 7129, 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, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 23891, 13270, 6527, 8297, 367, 9672, 21822, 4514, 1041, 4388, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 3, 4287, 26, 3507, 29, 71, 13, 4087, 13, 354, 199, 199, 646, 2197, 199, 646, 2050, 199, 646, 3473, 199, 646, 747, 199, 646, 2196, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 199, 504, 2341, 5270, 14, 11470, 63, 7522, 492, 13804, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 199, 504, 6233, 14, 15358, 492, 8836, 199, 504, 6233, 14, 15358, 14, 1246, 492, 12007, 63, 2550, 199, 504, 6233, 14, 15358, 14, 1246, 492, 943, 1364, 199, 504, 6233, 14, 15358, 14, 1246, 492, 4621, 199, 504, 6233, 14, 15358, 14, 1246, 492, 2120, 1825, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 504, 2341, 5270, 492, 1300, 63, 2232, 199, 504, 2341, 5270, 492, 1067, 199, 504, 2341, 5270, 492, 2552, 199, 504, 2341, 5270, 492, 1324, 63, 27056, 199, 504, 2341, 5270, 492, 1402, 199, 504, 2341, 5270, 492, 3439, 199, 504, 2341, 5270, 492, 1072, 63, 26224, 199, 504, 2341, 5270, 492, 2633, 199, 504, 2341, 5270, 492, 4884, 199, 504, 2341, 5270, 14, 1246, 492, 2341, 63, 2423, 199, 504, 2341, 5270, 14, 1246, 14, 1130, 63, 2423, 492, 11814, 63, 13602, 63, 7612, 199, 504, 6233, 14, 15358, 14, 7726, 492, 2986, 3280, 63, 2550, 199, 199, 3, 4287, 26, 3507, 29, 71, 13, 646, 13, 1397, 13, 292, 13, 2119, 199, 893, 26, 523, 492, 8002, 3494, 523, 327, 1010, 5661, 8836, 12, 314, 3432, 1233, 911, 506, 19270, 456, 6123, 370, 492, 314, 10098, 1015, 523, 327, 402, 8002, 3494, 14, 2900, 14706, 608, 78, 823, 402, 314, 2569, 340, 5558, 315, 603, 50, 523, 327, 1233, 1095, 365, 370, 11480, 652, 29430, 14, 523, 327, 3254, 8, 751, 304, 5852, 2410, 5661, 8836, 603, 50, 365, 2236, 265, 4456, 68, 14, 523, 340, 2688, 8, 4091, 3494, 12, 2668, 840, 2533, 2349, 272, 8002, 3494, 275, 488, 199, 2590, 3545, 26, 523, 8002, 3494, 275, 488, 221, 327, 8142, 6408, 3555, 440, 2808, 421, 199, 3, 437, 22885, 370, 2050, 14, 199, 3, 943, 14, 13138, 26, 3788, 922, 3679, 590, 1077, 1937, 12, 325, 14, 71, 14, 3405, 3906, 14, 199, 3, 943, 14, 705, 26, 4967, 5309, 6661, 922, 666, 12, 503, 10537, 199, 3, 2552, 10501, 701, 25478, 10059, 14, 199, 3, 943, 14, 3764, 26, 2552, 25478, 10059, 19428, 4212, 370, 2429, 14, 199, 3, 943, 14, 815, 26, 1163, 1420, 4474, 14, 421, 199, 3, 2494, 402, 3326, 402, 7750, 511, 13, 30785, 16898, 83, 14, 199, 63, 2864, 63, 568, 5550, 1149, 63, 2794, 51, 275, 663, 342, 421, 199, 318, 485, 1065, 63, 1765, 63, 3664, 8, 7922, 12, 1083, 12, 2120, 12, 4126, 63, 354, 304, 523, 408, 14883, 22652, 12604, 14, 765, 8, 1765, 12, 4126, 63, 354, 680, 819, 3033, 26, 272, 12604, 26, 437, 12604, 14, 8481, 83, 1256, 503, 488, 14, 272, 1083, 26, 710, 536, 402, 314, 1083, 370, 12677, 641, 314, 12604, 1021, 325, 14, 71, 14, 267, 298, 12456, 63, 31257, 1997, 63, 1765, 1674, 272, 2120, 26, 710, 2120, 1825, 14, 4476, 370, 986, 370, 314, 5759, 1083, 14, 272, 4126, 63, 354, 26, 710, 536, 402, 314, 4126, 370, 986, 370, 314, 5759, 1083, 14, 819, 1803, 26, 272, 715, 340, 314, 12604, 14, 8481, 83, 1256, 8860, 314, 1083, 12, 756, 4257, 14, 523, 408, 523, 340, 12604, 365, 440, 488, 26, 272, 862, 26, 489, 2519, 8, 7922, 12, 1083, 5130, 1765, 12, 4126, 63, 354, 9, 272, 871, 4279, 26, 489, 327, 3645, 314, 849, 2120, 10234, 4514, 14, 489, 372, 756, 339, 372, 715, 523, 372, 756, 421, 199, 533, 9672, 529, 12678, 2806, 2461, 8, 1095, 63, 2232, 14, 40, 17730, 4476, 2461, 304, 523, 408, 2806, 3016, 367, 2341, 5270, 7239, 2120, 1041, 819, 327, 5723, 13502, 315, 1820, 291, 855, 1107, 342, 4212, 370, 663, 1174, 436, 14892, 2120, 14, 523, 485, 17179, 63, 6098, 5399, 275, 4884, 423, 4869, 8, 489, 327, 8495, 365, 3879, 465, 1420, 14, 489, 3611, 2089, 1149, 63, 17179, 628, 496, 15648, 63, 1765, 401, 489, 327, 14012, 370, 7269, 2120, 14, 15536, 1990, 2845, 28320, 1380, 314, 1125, 4781, 14, 489, 327, 7529, 1133, 1570, 4886, 503, 12007, 14, 489, 17409, 5782, 63, 17179, 628, 7154, 63, 1765, 401, 489, 327, 14012, 370, 7269, 2120, 14, 15536, 1990, 28320, 1380, 314, 1125, 4781, 82, 14, 489, 327, 7529, 1133, 1570, 4886, 503, 12007, 14, 489, 17409, 5782, 63, 51, 2507, 37, 628, 7154, 63, 5224, 401, 489, 327, 18110, 314, 2120, 334, 11933, 370, 21747, 2120, 680, 9498, 943, 19860, 5978, 14, 489, 26704, 63, 17179, 628, 4824, 63, 1765, 401, 489, 327, 1666, 8297, 14, 11880, 12678, 2806, 2461, 423, 16880, 63, 5224, 63, 29920, 14, 489, 5363, 19052, 63, 51, 2507, 37, 628, 23131, 63, 5224, 401, 489, 327, 14012, 370, 7269, 314, 11814, 14, 489, 17409, 5782, 63, 3234, 7816, 628, 7154, 63, 10810, 401, 489, 327, 14012, 370, 5978, 2120, 436, 2449, 314, 11814, 14, 5297, 19860, 5988, 14, 489, 10341, 63, 17179, 628, 1633, 63, 1765, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
josephcslater/scipy
scipy/ndimage/tests/test_regression.py
123
1429
from __future__ import division, print_function, absolute_import import numpy as np from numpy.testing import assert_array_almost_equal, run_module_suite import scipy.ndimage as ndimage def test_byte_order_median(): """Regression test for #413: median_filter does not handle bytes orders.""" a = np.arange(9, dtype='<f4').reshape(3, 3) ref = ndimage.filters.median_filter(a,(3, 3)) b = np.arange(9, dtype='>f4').reshape(3, 3) t = ndimage.filters.median_filter(b, (3, 3)) assert_array_almost_equal(ref, t) def test_zoom_output_shape(): """Ticket #643""" x = np.arange(12).reshape((3,4)) ndimage.zoom(x, 2, output=np.zeros((6,8))) def test_ticket_742(): def SE(img, thresh=.7, size=4): mask = img > thresh rank = len(mask.shape) la, co = ndimage.label(mask, ndimage.generate_binary_structure(rank, rank)) slices = ndimage.find_objects(la) if np.dtype(np.intp) != np.dtype('i'): shape = (3,1240,1240) a = np.random.rand(np.product(shape)).reshape(shape) # shouldn't crash SE(a) def test_gh_issue_3025(): """Github issue #3025 - improper merging of labels""" d = np.zeros((60,320)) d[:,:257] = 1 d[:,260:] = 1 d[36,257] = 1 d[35,258] = 1 d[35,259] = 1 assert ndimage.label(d, np.ones((3,3)))[1] == 1 if __name__ == "__main__": run_module_suite()
bsd-3-clause
[ 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 12, 1255, 63, 578, 63, 5768, 199, 199, 646, 7026, 14, 78, 23335, 465, 302, 23335, 421, 199, 318, 511, 63, 4414, 63, 1648, 63, 13106, 837, 272, 408, 13013, 511, 367, 327, 23663, 26, 17312, 63, 1541, 1630, 440, 2429, 2783, 15460, 1041, 272, 282, 275, 980, 14, 5605, 8, 25, 12, 2152, 15829, 70, 20, 1959, 5217, 8, 19, 12, 650, 9, 272, 2984, 275, 302, 23335, 14, 4273, 14, 13106, 63, 1541, 8, 65, 12803, 19, 12, 650, 430, 272, 330, 275, 980, 14, 5605, 8, 25, 12, 2152, 534, 30, 70, 20, 1959, 5217, 8, 19, 12, 650, 9, 272, 307, 275, 302, 23335, 14, 4273, 14, 13106, 63, 1541, 8, 66, 12, 334, 19, 12, 650, 430, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 1121, 12, 307, 9, 421, 199, 318, 511, 63, 10598, 63, 1199, 63, 1392, 837, 272, 408, 25813, 327, 14637, 624, 272, 671, 275, 980, 14, 5605, 8, 713, 680, 5217, 1332, 19, 12, 20, 430, 272, 302, 23335, 14, 10598, 8, 88, 12, 499, 12, 1072, 29, 1590, 14, 4250, 1332, 22, 12, 24, 1724, 421, 199, 318, 511, 63, 9201, 63, 16498, 837, 272, 347, 5795, 8, 4060, 12, 16126, 15856, 23, 12, 1568, 29, 20, 304, 267, 3656, 275, 6050, 690, 16126, 267, 6915, 275, 822, 8, 2629, 14, 1392, 9, 267, 1127, 12, 512, 275, 302, 23335, 14, 1302, 8, 2629, 12, 3044, 302, 23335, 14, 4208, 63, 3008, 63, 6976, 8, 4648, 12, 6915, 430, 267, 17184, 275, 302, 23335, 14, 1623, 63, 1462, 8, 416, 9, 339, 340, 980, 14, 2271, 8, 1590, 14, 25319, 9, 1137, 980, 14, 2271, 360, 73, 735, 267, 2215, 275, 334, 19, 12, 713, 2167, 12, 713, 2167, 9, 267, 282, 275, 980, 14, 2355, 14, 3759, 8, 1590, 14, 2558, 8, 1392, 4992, 5217, 8, 1392, 9, 267, 327, 9296, 1133, 12420, 267, 5795, 8, 65, 9, 421, 199, 318, 511, 63, 3561, 63, 5237, 63, 1216, 821, 837, 272, 408, 14772, 4976, 327, 1216, 821, 446, 1742, 9198, 22537, 402, 3628, 624, 272, 366, 275, 980, 14, 4250, 1332, 2259, 12, 12122, 430, 272, 366, 3981, 26, 11551, 61, 275, 413, 272, 366, 3981, 13085, 2938, 275, 413, 272, 366, 59, 1344, 12, 11551, 61, 275, 413, 272, 366, 59, 1276, 12, 12234, 61, 275, 413, 272, 366, 59, 1276, 12, 11990, 61, 275, 413, 272, 702, 302, 23335, 14, 1302, 8, 68, 12, 980, 14, 4548, 1332, 19, 12, 19, 1724, 59, 17, 61, 508, 413, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1255, 63, 578, 63, 5768, 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 ]
[ 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 12, 1255, 63, 578, 63, 5768, 199, 199, 646, 7026, 14, 78, 23335, 465, 302, 23335, 421, 199, 318, 511, 63, 4414, 63, 1648, 63, 13106, 837, 272, 408, 13013, 511, 367, 327, 23663, 26, 17312, 63, 1541, 1630, 440, 2429, 2783, 15460, 1041, 272, 282, 275, 980, 14, 5605, 8, 25, 12, 2152, 15829, 70, 20, 1959, 5217, 8, 19, 12, 650, 9, 272, 2984, 275, 302, 23335, 14, 4273, 14, 13106, 63, 1541, 8, 65, 12803, 19, 12, 650, 430, 272, 330, 275, 980, 14, 5605, 8, 25, 12, 2152, 534, 30, 70, 20, 1959, 5217, 8, 19, 12, 650, 9, 272, 307, 275, 302, 23335, 14, 4273, 14, 13106, 63, 1541, 8, 66, 12, 334, 19, 12, 650, 430, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 1121, 12, 307, 9, 421, 199, 318, 511, 63, 10598, 63, 1199, 63, 1392, 837, 272, 408, 25813, 327, 14637, 624, 272, 671, 275, 980, 14, 5605, 8, 713, 680, 5217, 1332, 19, 12, 20, 430, 272, 302, 23335, 14, 10598, 8, 88, 12, 499, 12, 1072, 29, 1590, 14, 4250, 1332, 22, 12, 24, 1724, 421, 199, 318, 511, 63, 9201, 63, 16498, 837, 272, 347, 5795, 8, 4060, 12, 16126, 15856, 23, 12, 1568, 29, 20, 304, 267, 3656, 275, 6050, 690, 16126, 267, 6915, 275, 822, 8, 2629, 14, 1392, 9, 267, 1127, 12, 512, 275, 302, 23335, 14, 1302, 8, 2629, 12, 3044, 302, 23335, 14, 4208, 63, 3008, 63, 6976, 8, 4648, 12, 6915, 430, 267, 17184, 275, 302, 23335, 14, 1623, 63, 1462, 8, 416, 9, 339, 340, 980, 14, 2271, 8, 1590, 14, 25319, 9, 1137, 980, 14, 2271, 360, 73, 735, 267, 2215, 275, 334, 19, 12, 713, 2167, 12, 713, 2167, 9, 267, 282, 275, 980, 14, 2355, 14, 3759, 8, 1590, 14, 2558, 8, 1392, 4992, 5217, 8, 1392, 9, 267, 327, 9296, 1133, 12420, 267, 5795, 8, 65, 9, 421, 199, 318, 511, 63, 3561, 63, 5237, 63, 1216, 821, 837, 272, 408, 14772, 4976, 327, 1216, 821, 446, 1742, 9198, 22537, 402, 3628, 624, 272, 366, 275, 980, 14, 4250, 1332, 2259, 12, 12122, 430, 272, 366, 3981, 26, 11551, 61, 275, 413, 272, 366, 3981, 13085, 2938, 275, 413, 272, 366, 59, 1344, 12, 11551, 61, 275, 413, 272, 366, 59, 1276, 12, 12234, 61, 275, 413, 272, 366, 59, 1276, 12, 11990, 61, 275, 413, 272, 702, 302, 23335, 14, 1302, 8, 68, 12, 980, 14, 4548, 1332, 19, 12, 19, 1724, 59, 17, 61, 508, 413, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1255, 63, 578, 63, 5768, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
UdK-VPT/Open_eQuarter
mole3/stat_corr/rb_present_roofprj1_uvalue_LMFH_by_building_age_lookup.py
2
2352
# coding: utf8 # OeQ autogenerated lookup function for 'U-Values of Roofs as Projection (method 1) in correlation to year of construction, based on the source data of the survey for the "German Building Typology developed by the "Institut für Wohnen und Umwelt", Darmstadt/Germany, 2011-2013' import math import numpy as np from . import oeqLookuptable as oeq def get(*xin): l_lookup = oeq.lookuptable( [ 1849,0.72, 1850,0.72, 1851,0.72, 1852,0.72, 1853,0.72, 1854,0.72, 1855,0.72, 1856,0.72, 1857,0.72, 1858,0.72, 1859,0.72, 1860,0.72, 1861,0.72, 1862,0.72, 1863,0.72, 1864,0.72, 1865,0.72, 1866,0.72, 1867,0.72, 1868,0.72, 1869,0.72, 1870,0.72, 1871,0.72, 1872,0.72, 1873,0.72, 1874,0.72, 1875,0.72, 1876,0.72, 1877,0.72, 1878,0.72, 1879,0.72, 1880,0.72, 1881,0.72, 1882,0.72, 1883,0.72, 1884,0.72, 1885,0.72, 1886,0.72, 1887,0.72, 1888,0.72, 1889,0.72, 1890,0.72, 1891,0.72, 1892,0.72, 1893,0.72, 1894,0.72, 1895,0.72, 1896,0.72, 1897,0.72, 1898,0.72, 1899,0.72, 1900,0.72, 1901,0.72, 1902,0.72, 1903,0.72, 1904,0.72, 1905,0.72, 1906,0.72, 1907,0.72, 1908,0.72, 1909,0.721, 1910,0.721, 1911,0.72, 1912,0.718, 1913,0.717, 1914,0.717, 1915,0.72, 1916,0.726, 1917,0.736, 1918,0.747, 1919,0.76, 1920,0.773, 1921,0.784, 1922,0.794, 1923,0.8, 1924,0.803, 1925,0.803, 1926,0.802, 1927,0.8, 1928,0.799, 1929,0.799, 1930,0.8, 1931,0.8, 1932,0.8, 1933,0.8, 1934,0.8, 1935,0.8, 1936,0.801, 1937,0.802, 1938,0.802, 1939,0.8, 1940,0.797, 1941,0.794, 1942,0.794, 1943,0.8, 1944,0.814, 1945,0.843, 1946,0.89, 1947,0.963, 1948,1.067, 1949,1.201, 1950,1.347, 1951,1.479, 1952,1.572, 1953,1.6, 1954,1.547, 1955,1.429, 1956,1.272, 1957,1.1, 1958,0.936, 1959,0.792, 1960,0.677, 1961,0.6, 1962,0.566, 1963,0.565, 1964,0.581, 1965,0.6, 1966,0.609, 1967,0.61, 1968,0.605, 1969,0.6, 1970,0.597, 1971,0.596, 1972,0.597, 1973,0.6, 1974,0.605, 1975,0.608, 1976,0.607, 1977,0.6, 1978,0.584, 1979,0.56, 1980,0.531, 1981,0.5, 1982,0.469, 1983,0.44, 1984,0.416, 1985,0.4, 1986,0.4, 1987,0.4, 1988,0.4, 1989,0.4, 1990,0.402, 1991,0.402, 1992,0.401, 1993,0.4, 1994,0.4, 1995,0.4, 1996,0.4, 1997,0.4, 1998,0.4, 1999,0.4, 2000,0.4, 2001,0.4, 2002,0.4, 2003,0.4, 2004,0.4, 2005,0.4, 2006,0.4, 2007,0.4, 2008,0.4, 2009,0.4, 2010,0.4, 2011,0.4, 2012,0.4, 2013,0.4, 2014,0.4, 2015,0.4, 2016,0.4, 2017,0.4, 2018,0.4, 2019,0.4, 2020,0.4, 2021,0.4]) return(l_lookup.lookup(xin))
gpl-2.0
[ 3, 2803, 26, 2774, 24, 199, 3, 593, 69, 49, 18392, 4237, 805, 367, 283, 53, 13, 6550, 402, 820, 1534, 2319, 465, 2165, 8923, 334, 765, 413, 9, 315, 21280, 370, 5361, 402, 14538, 12, 4079, 641, 314, 1350, 666, 402, 314, 16576, 367, 314, 298, 27866, 1237, 6516, 316, 377, 89, 555, 4956, 477, 27813, 701, 314, 298, 607, 6329, 337, 289, 17709, 82, 644, 79, 6164, 287, 625, 68, 738, 14716, 15330, 401, 577, 5362, 270, 350, 84, 15, 27866, 3479, 12, 7760, 13, 6965, 7, 199, 199, 646, 3473, 199, 646, 2680, 465, 980, 199, 504, 1275, 492, 312, 4077, 7521, 1224, 465, 312, 4077, 199, 318, 664, 2031, 88, 262, 304, 2378, 634, 63, 3892, 275, 312, 4077, 14, 3892, 1224, 8, 199, 59, 199, 1085, 1887, 12, 16, 14, 2819, 12, 199, 1085, 1400, 12, 16, 14, 2819, 12, 199, 1085, 2869, 12, 16, 14, 2819, 12, 199, 1085, 2528, 12, 16, 14, 2819, 12, 199, 1085, 2481, 12, 16, 14, 2819, 12, 199, 1085, 1477, 12, 16, 14, 2819, 12, 199, 1085, 1229, 12, 16, 14, 2819, 12, 199, 1085, 1367, 12, 16, 14, 2819, 12, 199, 1085, 1641, 12, 16, 14, 2819, 12, 199, 1085, 2010, 12, 16, 14, 2819, 12, 199, 1085, 1427, 12, 16, 14, 2819, 12, 199, 1085, 2259, 12, 16, 14, 2819, 12, 199, 1085, 2976, 12, 16, 14, 2819, 12, 199, 1085, 2789, 12, 16, 14, 2819, 12, 199, 1085, 2766, 12, 16, 14, 2819, 12, 199, 1085, 772, 12, 16, 14, 2819, 12, 199, 1085, 2182, 12, 16, 14, 2819, 12, 199, 1085, 1272, 12, 16, 14, 2819, 12, 199, 1085, 1822, 12, 16, 14, 2819, 12, 199, 1085, 2333, 12, 16, 14, 2819, 12, 199, 1085, 1876, 12, 16, 14, 2819, 12, 199, 1085, 2760, 12, 16, 14, 2819, 12, 199, 1085, 3172, 12, 16, 14, 2819, 12, 199, 1085, 2819, 12, 16, 14, 2819, 12, 199, 1085, 2898, 12, 16, 14, 2819, 12, 199, 1085, 1342, 12, 16, 14, 2819, 12, 199, 1085, 2194, 12, 16, 14, 2819, 12, 199, 1085, 2114, 12, 16, 14, 2819, 12, 199, 1085, 1138, 12, 16, 14, 2819, 12, 199, 1085, 2277, 12, 16, 14, 2819, 12, 199, 1085, 1965, 12, 16, 14, 2819, 12, 199, 1085, 1257, 12, 16, 14, 2819, 12, 199, 1085, 2835, 12, 16, 14, 2819, 12, 199, 1085, 2564, 12, 16, 14, 2819, 12, 199, 1085, 2658, 12, 16, 14, 2819, 12, 199, 1085, 1349, 12, 16, 14, 2819, 12, 199, 1085, 2426, 12, 16, 14, 2819, 12, 199, 1085, 1184, 12, 16, 14, 2819, 12, 199, 1085, 1555, 12, 16, 14, 2819, 12, 199, 1085, 1299, 12, 16, 14, 2819, 12, 199, 1085, 1407, 12, 16, 14, 2819, 12, 199, 1085, 2710, 12, 16, 14, 2819, 12, 199, 1085, 3328, 12, 16, 14, 2819, 12, 199, 1085, 2942, 12, 16, 14, 2819, 12, 199, 1085, 3129, 12, 16, 14, 2819, 12, 199, 1085, 2635, 12, 16, 14, 2819, 12, 199, 1085, 2720, 12, 16, 14, 2819, 12, 199, 1085, 2534, 12, 16, 14, 2819, 12, 199, 1085, 2576, 12, 16, 14, 2819, 12, 199, 1085, 2905, 12, 16, 14, 2819, 12, 199, 1085, 1020, 12, 16, 14, 2819, 12, 199, 26631, 12, 16, 14, 2819, 12, 199, 1167, 614, 12, 16, 14, 2819, 12, 199, 1167, 996, 12, 16, 14, 2819, 12, 199, 1167, 1644, 12, 16, 14, 2819, 12, 199, 1167, 966, 12, 16, 14, 2819, 12, 199, 1167, 1717, 12, 16, 14, 2819, 12, 199, 1167, 1690, 12, 16, 14, 2819, 12, 199, 1167, 1780, 12, 16, 14, 2819, 12, 199, 1167, 2036, 12, 16, 14, 2819, 12, 199, 1167, 1643, 12, 16, 14, 23, 2025, 12, 199, 1167, 709, 12, 16, 14, 23, 2025, 12, 199, 1167, 845, 12, 16, 14, 2819, 12, 199, 1167, 713, 12, 16, 14, 26948, 12, 199, 1167, 969, 12, 16, 14, 31462, 12, 199, 1167, 1079, 12, 16, 14, 31462, 12, 199, 1167, 1046, 12, 16, 14, 2819, 12, 199, 1167, 975, 12, 16, 14, 31229, 12, 199, 1167, 1196, 12, 16, 14, 30665, 12, 199, 1167, 1085, 12, 16, 14, 17592, 12, 199, 1167, 1167, 12, 16, 14, 2114, 12, 199, 1167, 1165, 12, 16, 14, 18507, 12, 199, 1167, 2025, 12, 16, 14, 28394, 12, 199, 1167, 1081, 12, 16, 14, 21618, 12, 199, 1167, 1789, 12, 16, 14, 24, 12, 199, 1167, 1194, 12, 16, 14, 14187, 12, 199, 1167, 821, 12, 16, 14, 14187, 12, 199, 1167, 1479, 12, 16, 14, 11366, 12, 199, 1167, 1465, 12, 16, 14, 24, 12, 199, 1167, 1651, 12, 16, 14, 31486, 12, 199, 1167, 1398, 12, 16, 14, 31486, 12, 199, 1167, 1216, 12, 16, 14, 24, 12, 199, 1167, 2192, 12, 16, 14, 24, 12, 199, 1167, 708, 12, 16, 14, 24, 12, 199, 1167, 1153, 12, 16, 14, 24, 12, 199, 1167, 1082, 12, 16, 14, 24, 12, 199, 1167, 1276, 12, 16, 14, 24, 12, 199, 1167, 1344, 12, 16, 14, 26172, 12, 199, 1167, 1401, 12, 16, 14, 11366, 12, 199, 1167, 1703, 12, 16, 14, 11366, 12, 199, 1167, 1355, 12, 16, 14, 24, 12, 199, 30614, 12, 16, 14, 21422, 12, 199, 1167, 2953, 12, 16, 14, 21618, 12, 199, 1167, 2260, 12, 16, 14, 21618, 12, 199, 1167, 2824, 12, 16, 14, 24, 12, 199, 1167, 1602, 12, 16, 14, 29153, 12, 199, 1167, 2322, 12, 16, 14, 14349, 12, 199, 1167, 2466, 12, 16, 14, 1407, 12, 199, 1167, 2417, 12, 16, 14, 24548, 12, 199, 1167, 2006, 12, 17, 14, 19338, 12, 199, 1167, 1887, 12, 17, 14, 1797, 12, 199, 1167, 1400, 12, 17, 14, 12532, 12, 199, 16545, 12, 17, 14, 14847, 12, 199, 1167, 2528, 12, 17, 14, 17802, 12, 199, 1167, 2481, 12, 17, 14, 22, 12, 199, 1167, 1477, 12, 17, 14, 16710, 12, 199, 1167, 1229, 12, 17, 14, 14372, 12, 199, 1167, 1367, 12, 17, 14, 12900, 12, 199, 1167, 1641, 12, 17, 14, 17, 12, 199, 1167, 2010, 12, 16, 14, 29959, 12, 199, 1167, 1427, 12, 16, 14, 22364, 12, 199, 1167, 2259, 12, 16, 14, 28542, 12 ]
[ 2803, 26, 2774, 24, 199, 3, 593, 69, 49, 18392, 4237, 805, 367, 283, 53, 13, 6550, 402, 820, 1534, 2319, 465, 2165, 8923, 334, 765, 413, 9, 315, 21280, 370, 5361, 402, 14538, 12, 4079, 641, 314, 1350, 666, 402, 314, 16576, 367, 314, 298, 27866, 1237, 6516, 316, 377, 89, 555, 4956, 477, 27813, 701, 314, 298, 607, 6329, 337, 289, 17709, 82, 644, 79, 6164, 287, 625, 68, 738, 14716, 15330, 401, 577, 5362, 270, 350, 84, 15, 27866, 3479, 12, 7760, 13, 6965, 7, 199, 199, 646, 3473, 199, 646, 2680, 465, 980, 199, 504, 1275, 492, 312, 4077, 7521, 1224, 465, 312, 4077, 199, 318, 664, 2031, 88, 262, 304, 2378, 634, 63, 3892, 275, 312, 4077, 14, 3892, 1224, 8, 199, 59, 199, 1085, 1887, 12, 16, 14, 2819, 12, 199, 1085, 1400, 12, 16, 14, 2819, 12, 199, 1085, 2869, 12, 16, 14, 2819, 12, 199, 1085, 2528, 12, 16, 14, 2819, 12, 199, 1085, 2481, 12, 16, 14, 2819, 12, 199, 1085, 1477, 12, 16, 14, 2819, 12, 199, 1085, 1229, 12, 16, 14, 2819, 12, 199, 1085, 1367, 12, 16, 14, 2819, 12, 199, 1085, 1641, 12, 16, 14, 2819, 12, 199, 1085, 2010, 12, 16, 14, 2819, 12, 199, 1085, 1427, 12, 16, 14, 2819, 12, 199, 1085, 2259, 12, 16, 14, 2819, 12, 199, 1085, 2976, 12, 16, 14, 2819, 12, 199, 1085, 2789, 12, 16, 14, 2819, 12, 199, 1085, 2766, 12, 16, 14, 2819, 12, 199, 1085, 772, 12, 16, 14, 2819, 12, 199, 1085, 2182, 12, 16, 14, 2819, 12, 199, 1085, 1272, 12, 16, 14, 2819, 12, 199, 1085, 1822, 12, 16, 14, 2819, 12, 199, 1085, 2333, 12, 16, 14, 2819, 12, 199, 1085, 1876, 12, 16, 14, 2819, 12, 199, 1085, 2760, 12, 16, 14, 2819, 12, 199, 1085, 3172, 12, 16, 14, 2819, 12, 199, 1085, 2819, 12, 16, 14, 2819, 12, 199, 1085, 2898, 12, 16, 14, 2819, 12, 199, 1085, 1342, 12, 16, 14, 2819, 12, 199, 1085, 2194, 12, 16, 14, 2819, 12, 199, 1085, 2114, 12, 16, 14, 2819, 12, 199, 1085, 1138, 12, 16, 14, 2819, 12, 199, 1085, 2277, 12, 16, 14, 2819, 12, 199, 1085, 1965, 12, 16, 14, 2819, 12, 199, 1085, 1257, 12, 16, 14, 2819, 12, 199, 1085, 2835, 12, 16, 14, 2819, 12, 199, 1085, 2564, 12, 16, 14, 2819, 12, 199, 1085, 2658, 12, 16, 14, 2819, 12, 199, 1085, 1349, 12, 16, 14, 2819, 12, 199, 1085, 2426, 12, 16, 14, 2819, 12, 199, 1085, 1184, 12, 16, 14, 2819, 12, 199, 1085, 1555, 12, 16, 14, 2819, 12, 199, 1085, 1299, 12, 16, 14, 2819, 12, 199, 1085, 1407, 12, 16, 14, 2819, 12, 199, 1085, 2710, 12, 16, 14, 2819, 12, 199, 1085, 3328, 12, 16, 14, 2819, 12, 199, 1085, 2942, 12, 16, 14, 2819, 12, 199, 1085, 3129, 12, 16, 14, 2819, 12, 199, 1085, 2635, 12, 16, 14, 2819, 12, 199, 1085, 2720, 12, 16, 14, 2819, 12, 199, 1085, 2534, 12, 16, 14, 2819, 12, 199, 1085, 2576, 12, 16, 14, 2819, 12, 199, 1085, 2905, 12, 16, 14, 2819, 12, 199, 1085, 1020, 12, 16, 14, 2819, 12, 199, 26631, 12, 16, 14, 2819, 12, 199, 1167, 614, 12, 16, 14, 2819, 12, 199, 1167, 996, 12, 16, 14, 2819, 12, 199, 1167, 1644, 12, 16, 14, 2819, 12, 199, 1167, 966, 12, 16, 14, 2819, 12, 199, 1167, 1717, 12, 16, 14, 2819, 12, 199, 1167, 1690, 12, 16, 14, 2819, 12, 199, 1167, 1780, 12, 16, 14, 2819, 12, 199, 1167, 2036, 12, 16, 14, 2819, 12, 199, 1167, 1643, 12, 16, 14, 23, 2025, 12, 199, 1167, 709, 12, 16, 14, 23, 2025, 12, 199, 1167, 845, 12, 16, 14, 2819, 12, 199, 1167, 713, 12, 16, 14, 26948, 12, 199, 1167, 969, 12, 16, 14, 31462, 12, 199, 1167, 1079, 12, 16, 14, 31462, 12, 199, 1167, 1046, 12, 16, 14, 2819, 12, 199, 1167, 975, 12, 16, 14, 31229, 12, 199, 1167, 1196, 12, 16, 14, 30665, 12, 199, 1167, 1085, 12, 16, 14, 17592, 12, 199, 1167, 1167, 12, 16, 14, 2114, 12, 199, 1167, 1165, 12, 16, 14, 18507, 12, 199, 1167, 2025, 12, 16, 14, 28394, 12, 199, 1167, 1081, 12, 16, 14, 21618, 12, 199, 1167, 1789, 12, 16, 14, 24, 12, 199, 1167, 1194, 12, 16, 14, 14187, 12, 199, 1167, 821, 12, 16, 14, 14187, 12, 199, 1167, 1479, 12, 16, 14, 11366, 12, 199, 1167, 1465, 12, 16, 14, 24, 12, 199, 1167, 1651, 12, 16, 14, 31486, 12, 199, 1167, 1398, 12, 16, 14, 31486, 12, 199, 1167, 1216, 12, 16, 14, 24, 12, 199, 1167, 2192, 12, 16, 14, 24, 12, 199, 1167, 708, 12, 16, 14, 24, 12, 199, 1167, 1153, 12, 16, 14, 24, 12, 199, 1167, 1082, 12, 16, 14, 24, 12, 199, 1167, 1276, 12, 16, 14, 24, 12, 199, 1167, 1344, 12, 16, 14, 26172, 12, 199, 1167, 1401, 12, 16, 14, 11366, 12, 199, 1167, 1703, 12, 16, 14, 11366, 12, 199, 1167, 1355, 12, 16, 14, 24, 12, 199, 30614, 12, 16, 14, 21422, 12, 199, 1167, 2953, 12, 16, 14, 21618, 12, 199, 1167, 2260, 12, 16, 14, 21618, 12, 199, 1167, 2824, 12, 16, 14, 24, 12, 199, 1167, 1602, 12, 16, 14, 29153, 12, 199, 1167, 2322, 12, 16, 14, 14349, 12, 199, 1167, 2466, 12, 16, 14, 1407, 12, 199, 1167, 2417, 12, 16, 14, 24548, 12, 199, 1167, 2006, 12, 17, 14, 19338, 12, 199, 1167, 1887, 12, 17, 14, 1797, 12, 199, 1167, 1400, 12, 17, 14, 12532, 12, 199, 16545, 12, 17, 14, 14847, 12, 199, 1167, 2528, 12, 17, 14, 17802, 12, 199, 1167, 2481, 12, 17, 14, 22, 12, 199, 1167, 1477, 12, 17, 14, 16710, 12, 199, 1167, 1229, 12, 17, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Shengliang/mbed
workspace_tools/export/uvision5.py
3
4120
""" mbed SDK Copyright (c) 2016 ARM Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from os.path import basename, join, dirname from project_generator_definitions.definitions import ProGenDef from workspace_tools.export.exporters import Exporter from workspace_tools.targets import TARGET_MAP, TARGET_NAMES # If you wish to add a new target, add it to project_generator_definitions, and then # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``) # There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl class Uvision5(Exporter): """ Exporter class for uvision5. This class uses project generator. """ # These 2 are currently for exporters backward compatiblity NAME = 'uVision5' TOOLCHAIN = 'ARM' # PROGEN_ACTIVE contains information for exporter scripts that this is using progen PROGEN_ACTIVE = True # backward compatibility with our scripts TARGETS = [] for target in TARGET_NAMES: try: if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])): TARGETS.append(target) except AttributeError: # target is not supported yet continue def get_toolchain(self): return TARGET_MAP[self.target].default_toolchain def generate(self): """ Generates the project files """ project_data = self.progen_get_project_data() tool_specific = {} # Expand tool specific settings by uvision specific settings which are required try: if TARGET_MAP[self.target].progen['uvision5']['template']: tool_specific['uvision5'] = TARGET_MAP[self.target].progen['uvision5'] except KeyError: # use default template # by the mbed projects tool_specific['uvision5'] = { 'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')], } project_data['tool_specific'] = {} project_data['tool_specific'].update(tool_specific) # get flags from toolchain and apply project_data['tool_specific']['uvision5']['misc'] = {} project_data['tool_specific']['uvision5']['misc']['asm_flags'] = list(set(self.toolchain.flags['common'] + self.toolchain.flags['asm'])) project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(self.toolchain.flags['common'] + self.toolchain.flags['c'])) # not compatible with c99 flag set in the template project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99") project_data['tool_specific']['uvision5']['misc']['cxx_flags'] = list(set(self.toolchain.flags['common'] + self.toolchain.flags['ld'])) project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.toolchain.flags['ld'] i = 0 for macro in project_data['common']['macros']: # armasm does not like floating numbers in macros, timestamp to int if macro.startswith('MBED_BUILD_TIMESTAMP'): timestamp = macro[len('MBED_BUILD_TIMESTAMP='):] project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp))) # armasm does not even accept MACRO=string if macro.startswith('MBED_USERNAME'): project_data['common']['macros'].pop(i) i += 1 project_data['common']['macros'].append('__ASSERT_MSG') self.progen_gen_file('uvision5', project_data)
apache-2.0
[ 624, 199, 3665, 15610, 199, 7384, 334, 67, 9, 7800, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 504, 747, 14, 515, 492, 9593, 12, 4263, 12, 9017, 199, 504, 2199, 63, 4679, 63, 15388, 14, 15388, 492, 2165, 8168, 6172, 199, 199, 504, 14466, 63, 2537, 14, 3790, 14, 1474, 27568, 492, 7910, 3968, 199, 504, 14466, 63, 2537, 14, 4684, 492, 26134, 63, 5443, 12, 26134, 63, 14546, 199, 199, 3, 982, 1265, 13809, 370, 1050, 282, 892, 1347, 12, 1050, 652, 370, 2199, 63, 4679, 63, 15388, 12, 436, 2066, 199, 3, 5627, 557, 2268, 63, 1375, 536, 315, 314, 1347, 1021, 15693, 291, 14, 496, 2268, 63, 1375, 275, 283, 1662, 63, 1375, 63, 354, 7, 1124, 9, 199, 3, 6006, 787, 499, 849, 333, 6123, 7009, 334, 657, 4037, 2202, 9, 399, 2317, 14, 9154, 5468, 436, 20879, 5468, 63, 6453, 773, 14, 9154, 5468, 14, 11510, 199, 533, 738, 2317, 21, 8, 30341, 304, 272, 408, 272, 7910, 3968, 1021, 367, 399, 2317, 21, 14, 961, 1021, 4440, 2199, 4306, 14, 272, 408, 272, 327, 5723, 499, 787, 5544, 367, 1437, 27568, 13388, 1013, 2159, 66, 5075, 272, 13637, 275, 283, 85, 2201, 438, 21, 7, 272, 2296, 2228, 25256, 275, 283, 12482, 7, 272, 327, 3611, 9289, 63, 10401, 3509, 2556, 367, 1437, 3968, 10554, 626, 642, 365, 1808, 557, 2268, 272, 3611, 9289, 63, 10401, 275, 715, 339, 327, 13388, 7163, 543, 4154, 10554, 272, 26134, 51, 275, 942, 272, 367, 1347, 315, 26134, 63, 14546, 26, 267, 862, 26, 288, 340, 334, 919, 8168, 6172, 360, 85, 2317, 21, 1959, 374, 63, 4946, 8, 495, 8, 9268, 63, 5443, 59, 1375, 2459, 503, 355, 2165, 8168, 6172, 360, 85, 2317, 21, 1959, 374, 63, 4946, 8, 9268, 63, 5443, 59, 1375, 1055, 496, 2268, 459, 1375, 26536, 355, 26134, 51, 14, 740, 8, 1375, 9, 267, 871, 4281, 26, 288, 327, 1347, 365, 440, 3748, 5966, 288, 1980, 339, 347, 664, 63, 22572, 8, 277, 304, 267, 372, 26134, 63, 5443, 59, 277, 14, 1375, 1055, 885, 63, 22572, 339, 347, 3550, 8, 277, 304, 267, 408, 21687, 314, 2199, 1584, 408, 267, 2199, 63, 576, 275, 291, 14, 496, 2268, 63, 362, 63, 1715, 63, 576, 342, 267, 4744, 63, 6100, 275, 1052, 267, 327, 18890, 4744, 2488, 2202, 701, 399, 2317, 2488, 2202, 1314, 787, 1415, 267, 862, 26, 288, 340, 26134, 63, 5443, 59, 277, 14, 1375, 1055, 496, 2268, 459, 85, 2317, 21, 2545, 1160, 2565, 355, 4744, 63, 6100, 459, 85, 2317, 21, 418, 275, 26134, 63, 5443, 59, 277, 14, 1375, 1055, 496, 2268, 459, 85, 2317, 21, 418, 267, 871, 4067, 26, 288, 327, 675, 849, 1978, 288, 327, 701, 314, 333, 6123, 11336, 288, 4744, 63, 6100, 459, 85, 2317, 21, 418, 275, 469, 490, 283, 1160, 356, 359, 904, 8, 3475, 3460, 493, 10139, 221, 283, 85, 2317, 14, 9154, 5468, 14, 11510, 2665, 288, 789, 398, 2199, 63, 576, 459, 3557, 63, 6100, 418, 275, 1052, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2278, 873, 8, 3557, 63, 6100, 9, 398, 327, 664, 3285, 687, 22689, 436, 4838, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 418, 275, 1052, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 11374, 63, 2469, 418, 275, 769, 8, 409, 8, 277, 14, 22572, 14, 2469, 459, 2330, 418, 435, 291, 14, 22572, 14, 2469, 459, 11374, 5156, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 67, 63, 2469, 418, 275, 769, 8, 409, 8, 277, 14, 22572, 14, 2469, 459, 2330, 418, 435, 291, 14, 22572, 14, 2469, 459, 67, 5156, 267, 327, 440, 9025, 543, 286, 1020, 3305, 663, 315, 314, 1978, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 67, 63, 2469, 2278, 2168, 6739, 67, 1020, 531, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 9634, 63, 2469, 418, 275, 769, 8, 409, 8, 277, 14, 22572, 14, 2469, 459, 2330, 418, 435, 291, 14, 22572, 14, 2469, 459, 1447, 5156, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 1447, 63, 2469, 418, 275, 291, 14, 22572, 14, 2469, 459, 1447, 418, 398, 284, 275, 378, 267, 367, 9559, 315, 2199, 63, 576, 459, 2330, 2545, 16358, 2565, 288, 327, 601, 5892, 77, 1630, 440, 2839, 8402, 5579, 315, 16954, 12, 4913, 370, 1109, 288, 340, 9559, 14, 2460, 360, 4567, 1149, 63, 8248, 63, 20277, 735, 355, 4913, 275, 9559, 59, 552, 360, 4567, 1149, 63, 8248, 63, 20277, 534, 15405, 355, 2199, 63, 576, 459, 2330, 2545, 16358, 3488, 73, 61, 275, 283, 4567, 1149, 63, 8248, 63, 20277, 534, 435, 620, 8, 442, 8, 1609, 8, 3954, 1724, 288, 327, 601, 5892, 77, 1630, 440, 2755, 4729, 13347, 1092, 29, 875, 288, 340, 9559, 14, 2460, 360, 4567, 1149, 63, 11958, 735, 355, 2199, 63, 576, 459, 2330, 2545, 16358, 2278, 1935, 8, 73, 9, 288, 284, 847, 413, 267, 2199, 63, 576, 459, 2330, 2545, 16358, 2278, 740, 10714, 24790, 63, 9740, 358, 267, 291, 14, 496, 2268, 63, 2268, 63, 493, 360, 85, 2317, 21, 297, 2199, 63, 576, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3665, 15610, 199, 7384, 334, 67, 9, 7800, 27155, 23954, 199, 199, 31661, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 339, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 504, 747, 14, 515, 492, 9593, 12, 4263, 12, 9017, 199, 504, 2199, 63, 4679, 63, 15388, 14, 15388, 492, 2165, 8168, 6172, 199, 199, 504, 14466, 63, 2537, 14, 3790, 14, 1474, 27568, 492, 7910, 3968, 199, 504, 14466, 63, 2537, 14, 4684, 492, 26134, 63, 5443, 12, 26134, 63, 14546, 199, 199, 3, 982, 1265, 13809, 370, 1050, 282, 892, 1347, 12, 1050, 652, 370, 2199, 63, 4679, 63, 15388, 12, 436, 2066, 199, 3, 5627, 557, 2268, 63, 1375, 536, 315, 314, 1347, 1021, 15693, 291, 14, 496, 2268, 63, 1375, 275, 283, 1662, 63, 1375, 63, 354, 7, 1124, 9, 199, 3, 6006, 787, 499, 849, 333, 6123, 7009, 334, 657, 4037, 2202, 9, 399, 2317, 14, 9154, 5468, 436, 20879, 5468, 63, 6453, 773, 14, 9154, 5468, 14, 11510, 199, 533, 738, 2317, 21, 8, 30341, 304, 272, 408, 272, 7910, 3968, 1021, 367, 399, 2317, 21, 14, 961, 1021, 4440, 2199, 4306, 14, 272, 408, 272, 327, 5723, 499, 787, 5544, 367, 1437, 27568, 13388, 1013, 2159, 66, 5075, 272, 13637, 275, 283, 85, 2201, 438, 21, 7, 272, 2296, 2228, 25256, 275, 283, 12482, 7, 272, 327, 3611, 9289, 63, 10401, 3509, 2556, 367, 1437, 3968, 10554, 626, 642, 365, 1808, 557, 2268, 272, 3611, 9289, 63, 10401, 275, 715, 339, 327, 13388, 7163, 543, 4154, 10554, 272, 26134, 51, 275, 942, 272, 367, 1347, 315, 26134, 63, 14546, 26, 267, 862, 26, 288, 340, 334, 919, 8168, 6172, 360, 85, 2317, 21, 1959, 374, 63, 4946, 8, 495, 8, 9268, 63, 5443, 59, 1375, 2459, 503, 355, 2165, 8168, 6172, 360, 85, 2317, 21, 1959, 374, 63, 4946, 8, 9268, 63, 5443, 59, 1375, 1055, 496, 2268, 459, 1375, 26536, 355, 26134, 51, 14, 740, 8, 1375, 9, 267, 871, 4281, 26, 288, 327, 1347, 365, 440, 3748, 5966, 288, 1980, 339, 347, 664, 63, 22572, 8, 277, 304, 267, 372, 26134, 63, 5443, 59, 277, 14, 1375, 1055, 885, 63, 22572, 339, 347, 3550, 8, 277, 304, 267, 408, 21687, 314, 2199, 1584, 408, 267, 2199, 63, 576, 275, 291, 14, 496, 2268, 63, 362, 63, 1715, 63, 576, 342, 267, 4744, 63, 6100, 275, 1052, 267, 327, 18890, 4744, 2488, 2202, 701, 399, 2317, 2488, 2202, 1314, 787, 1415, 267, 862, 26, 288, 340, 26134, 63, 5443, 59, 277, 14, 1375, 1055, 496, 2268, 459, 85, 2317, 21, 2545, 1160, 2565, 355, 4744, 63, 6100, 459, 85, 2317, 21, 418, 275, 26134, 63, 5443, 59, 277, 14, 1375, 1055, 496, 2268, 459, 85, 2317, 21, 418, 267, 871, 4067, 26, 288, 327, 675, 849, 1978, 288, 327, 701, 314, 333, 6123, 11336, 288, 4744, 63, 6100, 459, 85, 2317, 21, 418, 275, 469, 490, 283, 1160, 356, 359, 904, 8, 3475, 3460, 493, 10139, 221, 283, 85, 2317, 14, 9154, 5468, 14, 11510, 2665, 288, 789, 398, 2199, 63, 576, 459, 3557, 63, 6100, 418, 275, 1052, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2278, 873, 8, 3557, 63, 6100, 9, 398, 327, 664, 3285, 687, 22689, 436, 4838, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 418, 275, 1052, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 11374, 63, 2469, 418, 275, 769, 8, 409, 8, 277, 14, 22572, 14, 2469, 459, 2330, 418, 435, 291, 14, 22572, 14, 2469, 459, 11374, 5156, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 67, 63, 2469, 418, 275, 769, 8, 409, 8, 277, 14, 22572, 14, 2469, 459, 2330, 418, 435, 291, 14, 22572, 14, 2469, 459, 67, 5156, 267, 327, 440, 9025, 543, 286, 1020, 3305, 663, 315, 314, 1978, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 67, 63, 2469, 2278, 2168, 6739, 67, 1020, 531, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 9634, 63, 2469, 418, 275, 769, 8, 409, 8, 277, 14, 22572, 14, 2469, 459, 2330, 418, 435, 291, 14, 22572, 14, 2469, 459, 1447, 5156, 267, 2199, 63, 576, 459, 3557, 63, 6100, 2545, 85, 2317, 21, 2545, 9923, 2545, 1447, 63, 2469, 418, 275, 291, 14, 22572, 14, 2469, 459, 1447, 418, 398, 284, 275, 378, 267, 367, 9559, 315, 2199, 63, 576, 459, 2330, 2545, 16358, 2565, 288, 327, 601, 5892, 77, 1630, 440, 2839, 8402, 5579, 315, 16954, 12, 4913, 370, 1109, 288, 340, 9559, 14, 2460, 360, 4567, 1149, 63, 8248, 63, 20277, 735, 355, 4913, 275, 9559, 59, 552, 360, 4567, 1149, 63, 8248, 63, 20277, 534, 15405, 355, 2199, 63, 576, 459, 2330, 2545, 16358, 3488, 73, 61, 275, 283, 4567, 1149, 63, 8248, 63, 20277, 534, 435, 620, 8, 442, 8, 1609, 8, 3954, 1724, 288, 327, 601, 5892, 77, 1630, 440, 2755, 4729, 13347, 1092, 29, 875, 288, 340, 9559, 14, 2460, 360, 4567, 1149, 63, 11958, 735, 355, 2199, 63, 576, 459, 2330, 2545, 16358, 2278, 1935, 8, 73, 9, 288, 284, 847, 413, 267, 2199, 63, 576, 459, 2330, 2545, 16358, 2278, 740, 10714, 24790, 63, 9740, 358, 267, 291, 14, 496, 2268, 63, 2268, 63, 493, 360, 85, 2317, 21, 297, 2199, 63, 576, 9, 421, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
provaleks/o8
addons/base_report_designer/wizard/__init__.py
421
1081
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import base_report_designer_modify # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 1300, 63, 3070, 63, 14748, 281, 63, 8951, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 1300, 63, 3070, 63, 14748, 281, 63, 8951, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
VladimirFilonov/django-yandex-kassa
setup.py
1
1336
# -*- coding: utf-8 -*- import os from distutils.core import setup from setuptools import find_packages __author__ = 'Alexei Kuzmin' __version__ = "0.9.13" os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-yandex-kassa', version=__version__, packages=find_packages(), include_package_data=True, url='https://github.com/DrMartiner/django-yandex-kassa', license='MIT', author=__author__, author_email='DrMartiner@GMail.Com', keywords=['django', 'yandex', 'money', 'kassa', 'payment', 'pay', 'payment', 'ecommerce', 'shop', 'cart'], description='Integrating django project with yandex-kassa', classifiers=[ 'Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], install_requires=[ 'Django>1.6', 'ecdsa==0.13', 'pycrypto==2.6.1', 'django-annoying', 'lxml', 'six' ], )
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 504, 7065, 14, 1018, 492, 3272, 199, 504, 9116, 492, 2342, 63, 5154, 199, 199, 363, 2502, 363, 275, 283, 33, 274, 1845, 73, 1804, 9494, 827, 7, 199, 363, 1023, 363, 275, 298, 16, 14, 25, 14, 969, 2, 199, 199, 736, 14, 8563, 8, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 3460, 493, 10139, 747, 14, 21386, 1724, 199, 199, 2758, 8, 272, 536, 534, 1176, 13, 89, 290, 731, 13, 75, 405, 65, 297, 272, 1015, 18971, 1023, 3108, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 21733, 45, 580, 16187, 15, 1176, 13, 89, 290, 731, 13, 75, 405, 65, 297, 272, 4190, 534, 13965, 297, 272, 4132, 18971, 2502, 3108, 272, 4132, 63, 2123, 534, 21733, 45, 580, 16187, 32, 39, 13681, 14, 4373, 297, 272, 7681, 2968, 1176, 297, 283, 89, 290, 731, 297, 283, 27468, 297, 283, 75, 405, 65, 297, 283, 7948, 297, 1598, 283, 5989, 297, 283, 7948, 297, 283, 69, 32711, 297, 283, 10568, 297, 283, 8153, 995, 272, 1369, 534, 8309, 2587, 1958, 1639, 2199, 543, 612, 290, 731, 13, 75, 405, 65, 297, 272, 19137, 1524, 267, 283, 8263, 3800, 6001, 9711, 297, 267, 283, 16442, 3800, 5634, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 267, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 297, 267, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 21907, 6646, 297, 272, 2156, 272, 3907, 63, 6537, 1524, 267, 283, 9323, 30, 17, 14, 22, 297, 267, 283, 825, 24760, 389, 16, 14, 969, 297, 267, 283, 647, 10316, 389, 18, 14, 22, 14, 17, 297, 267, 283, 1176, 13, 25264, 22440, 297, 267, 283, 22899, 297, 267, 283, 4174, 7, 272, 2156, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 504, 7065, 14, 1018, 492, 3272, 199, 504, 9116, 492, 2342, 63, 5154, 199, 199, 363, 2502, 363, 275, 283, 33, 274, 1845, 73, 1804, 9494, 827, 7, 199, 363, 1023, 363, 275, 298, 16, 14, 25, 14, 969, 2, 199, 199, 736, 14, 8563, 8, 736, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 3460, 493, 10139, 747, 14, 21386, 1724, 199, 199, 2758, 8, 272, 536, 534, 1176, 13, 89, 290, 731, 13, 75, 405, 65, 297, 272, 1015, 18971, 1023, 3108, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 21733, 45, 580, 16187, 15, 1176, 13, 89, 290, 731, 13, 75, 405, 65, 297, 272, 4190, 534, 13965, 297, 272, 4132, 18971, 2502, 3108, 272, 4132, 63, 2123, 534, 21733, 45, 580, 16187, 32, 39, 13681, 14, 4373, 297, 272, 7681, 2968, 1176, 297, 283, 89, 290, 731, 297, 283, 27468, 297, 283, 75, 405, 65, 297, 283, 7948, 297, 1598, 283, 5989, 297, 283, 7948, 297, 283, 69, 32711, 297, 283, 10568, 297, 283, 8153, 995, 272, 1369, 534, 8309, 2587, 1958, 1639, 2199, 543, 612, 290, 731, 13, 75, 405, 65, 297, 272, 19137, 1524, 267, 283, 8263, 3800, 6001, 9711, 297, 267, 283, 16442, 3800, 5634, 297, 267, 283, 23910, 23975, 3800, 23493, 297, 267, 283, 3761, 3800, 25718, 26330, 3800, 10697, 844, 297, 267, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 267, 283, 11411, 8466, 3800, 2018, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 22, 297, 267, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 267, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 297, 267, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 21907, 6646, 297, 272, 2156, 272, 3907, 63, 6537, 1524, 267, 283, 9323, 30, 17, 14, 22, 297, 267, 283, 825, 24760, 389, 16, 14, 969, 297, 267, 283, 647, 10316, 389, 18, 14, 22, 14, 17, 297, 267, 283, 1176, 13, 25264, 22440, 297, 267, 283, 22899, 297, 267, 283, 4174, 7, 272, 2156, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
rchrd2/markdown-keyval
key_val.py
1
2188
""" KeyValue Extension for Python-Markdown ============================================= A simple example: Apple: Pomaceous fruit of plants of the genus Malus in. Orange: The fruit of an evergreen tree of the genus Citrus. @todo get this to print out in a table """ from __future__ import absolute_import from __future__ import unicode_literals from markdown import Extension from markdown.blockprocessors import BlockProcessor, ListIndentProcessor from markdown.util import etree import re class KeyValProcessor(BlockProcessor): """ Process Key Value Pairs. """ # Regex for key value RE = re.compile(r'^(?P<key>[^\s]+):\s+(?P<value>.+)(\n|$)') def test(self, parent, block): return bool(self.RE.search(block)) def run(self, parent, blocks): block = blocks.pop(0) m = self.RE.search(block) if m: before = block[:m.start()] # All lines before header after = block[m.end():] # All lines after header #if before: # # As the header was not the first line of the block and the # # lines before the header must be parsed first, # # recursively parse this lines as a block. # self.parser.parseBlocks(parent, [before]) # Create header using named groups from RE h = etree.SubElement(parent, 'div') #template = "<dl><dt>%s</dt><dd>%s</dd></dl>" template = "<b>%s</b>: %s" #template = "<tr><td>%s</td><td>%s</td></tr>" h.text = template % (m.group('key').strip(), m.group('value').strip()) if after: # Insert remaining lines as first block for future parsing. blocks.insert(0, after) else: # This should never happen, but just in case... logger.warn("We've got a problem header: %r" % block) class KeyValExtension(Extension): """ Add keyvalues to Markdown. """ def extendMarkdown(self, md, md_globals): md.parser.blockprocessors.add('keyval', KeyValProcessor(md.parser), '>ulist') def makeExtension(configs={}): return KeyValExtension(configs=configs)
mit
[ 624, 199, 25720, 13282, 367, 2018, 13, 30916, 199, 2486, 9152, 199, 199, 33, 3486, 2893, 26, 199, 199, 25051, 26, 4376, 391, 301, 1785, 9513, 4993, 402, 1620, 2285, 402, 314, 3805, 527, 29936, 527, 315, 14, 199, 47, 1842, 26, 710, 9513, 4993, 402, 376, 14433, 7731, 3123, 402, 314, 3805, 527, 445, 390, 20791, 14, 199, 199, 32, 11396, 664, 642, 370, 870, 734, 315, 282, 1817, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 18502, 492, 13282, 199, 504, 18502, 14, 1457, 10547, 492, 8651, 10438, 12, 3820, 7583, 10438, 199, 504, 18502, 14, 1974, 492, 7559, 199, 646, 295, 421, 199, 533, 2606, 7562, 10438, 8, 3142, 10438, 304, 272, 408, 7132, 2606, 1594, 510, 8387, 83, 14, 408, 339, 327, 12939, 367, 790, 574, 272, 5363, 275, 295, 14, 2014, 8, 82, 24550, 48, 28, 498, 13489, 60, 83, 2807, 17211, 83, 11, 2229, 48, 28, 585, 31411, 10127, 78, 92, 4, 5942, 339, 347, 511, 8, 277, 12, 1676, 12, 1853, 304, 267, 372, 2155, 8, 277, 14, 907, 14, 1733, 8, 1457, 430, 339, 347, 1255, 8, 277, 12, 1676, 12, 5664, 304, 267, 1853, 275, 5664, 14, 1935, 8, 16, 9, 267, 333, 275, 291, 14, 907, 14, 1733, 8, 1457, 9, 267, 340, 333, 26, 288, 2544, 275, 1853, 1491, 77, 14, 928, 5106, 327, 2900, 2385, 2544, 1406, 288, 2410, 275, 1853, 59, 77, 14, 500, 837, 61, 259, 327, 2900, 2385, 2410, 1406, 288, 327, 692, 2544, 26, 288, 327, 259, 327, 3709, 314, 1406, 1990, 440, 314, 1642, 1004, 402, 314, 1853, 436, 314, 288, 327, 259, 327, 2385, 2544, 314, 1406, 1471, 506, 4565, 1642, 12, 288, 327, 259, 327, 15035, 2198, 642, 2385, 465, 282, 1853, 14, 288, 327, 259, 291, 14, 2087, 14, 1122, 24996, 8, 1708, 12, 359, 5182, 566, 7846, 327, 2790, 1406, 1808, 4310, 4652, 687, 5363, 288, 394, 275, 7559, 14, 10571, 8, 1708, 12, 283, 3015, 358, 288, 327, 1160, 275, 3886, 5030, 2535, 3583, 6598, 83, 1108, 3583, 2535, 617, 6598, 83, 1108, 617, 2957, 5030, 4335, 288, 1978, 275, 3886, 66, 6598, 83, 1108, 66, 20020, 450, 83, 2, 288, 327, 1160, 275, 3886, 454, 2535, 2076, 6598, 83, 1108, 2076, 2535, 2076, 6598, 83, 1108, 2076, 2957, 454, 4335, 288, 394, 14, 505, 275, 1978, 450, 334, 77, 14, 923, 360, 498, 1959, 1913, 1062, 333, 14, 923, 360, 585, 1959, 1913, 1012, 288, 340, 2410, 26, 355, 327, 15496, 7971, 2385, 465, 1642, 1853, 367, 6466, 6057, 14, 355, 5664, 14, 3176, 8, 16, 12, 2410, 9, 267, 587, 26, 288, 327, 961, 1077, 7078, 5992, 12, 1325, 2951, 315, 1930, 1396, 288, 2512, 14, 4050, 480, 6004, 9064, 4788, 282, 5160, 1406, 26, 450, 82, 2, 450, 1853, 9, 421, 199, 533, 2606, 7562, 6382, 8, 6382, 304, 272, 408, 2654, 790, 1459, 370, 24537, 14, 408, 339, 347, 12247, 30916, 8, 277, 12, 6128, 12, 6128, 63, 8473, 304, 267, 6128, 14, 2087, 14, 1457, 10547, 14, 525, 360, 31217, 297, 2606, 7562, 10438, 8, 1064, 14, 2087, 395, 12696, 85, 513, 358, 421, 199, 318, 1852, 6382, 8, 7532, 16420, 272, 372, 2606, 7562, 6382, 8, 7532, 29, 7532, 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 ]
[ 199, 25720, 13282, 367, 2018, 13, 30916, 199, 2486, 9152, 199, 199, 33, 3486, 2893, 26, 199, 199, 25051, 26, 4376, 391, 301, 1785, 9513, 4993, 402, 1620, 2285, 402, 314, 3805, 527, 29936, 527, 315, 14, 199, 47, 1842, 26, 710, 9513, 4993, 402, 376, 14433, 7731, 3123, 402, 314, 3805, 527, 445, 390, 20791, 14, 199, 199, 32, 11396, 664, 642, 370, 870, 734, 315, 282, 1817, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 18502, 492, 13282, 199, 504, 18502, 14, 1457, 10547, 492, 8651, 10438, 12, 3820, 7583, 10438, 199, 504, 18502, 14, 1974, 492, 7559, 199, 646, 295, 421, 199, 533, 2606, 7562, 10438, 8, 3142, 10438, 304, 272, 408, 7132, 2606, 1594, 510, 8387, 83, 14, 408, 339, 327, 12939, 367, 790, 574, 272, 5363, 275, 295, 14, 2014, 8, 82, 24550, 48, 28, 498, 13489, 60, 83, 2807, 17211, 83, 11, 2229, 48, 28, 585, 31411, 10127, 78, 92, 4, 5942, 339, 347, 511, 8, 277, 12, 1676, 12, 1853, 304, 267, 372, 2155, 8, 277, 14, 907, 14, 1733, 8, 1457, 430, 339, 347, 1255, 8, 277, 12, 1676, 12, 5664, 304, 267, 1853, 275, 5664, 14, 1935, 8, 16, 9, 267, 333, 275, 291, 14, 907, 14, 1733, 8, 1457, 9, 267, 340, 333, 26, 288, 2544, 275, 1853, 1491, 77, 14, 928, 5106, 327, 2900, 2385, 2544, 1406, 288, 2410, 275, 1853, 59, 77, 14, 500, 837, 61, 259, 327, 2900, 2385, 2410, 1406, 288, 327, 692, 2544, 26, 288, 327, 259, 327, 3709, 314, 1406, 1990, 440, 314, 1642, 1004, 402, 314, 1853, 436, 314, 288, 327, 259, 327, 2385, 2544, 314, 1406, 1471, 506, 4565, 1642, 12, 288, 327, 259, 327, 15035, 2198, 642, 2385, 465, 282, 1853, 14, 288, 327, 259, 291, 14, 2087, 14, 1122, 24996, 8, 1708, 12, 359, 5182, 566, 7846, 327, 2790, 1406, 1808, 4310, 4652, 687, 5363, 288, 394, 275, 7559, 14, 10571, 8, 1708, 12, 283, 3015, 358, 288, 327, 1160, 275, 3886, 5030, 2535, 3583, 6598, 83, 1108, 3583, 2535, 617, 6598, 83, 1108, 617, 2957, 5030, 4335, 288, 1978, 275, 3886, 66, 6598, 83, 1108, 66, 20020, 450, 83, 2, 288, 327, 1160, 275, 3886, 454, 2535, 2076, 6598, 83, 1108, 2076, 2535, 2076, 6598, 83, 1108, 2076, 2957, 454, 4335, 288, 394, 14, 505, 275, 1978, 450, 334, 77, 14, 923, 360, 498, 1959, 1913, 1062, 333, 14, 923, 360, 585, 1959, 1913, 1012, 288, 340, 2410, 26, 355, 327, 15496, 7971, 2385, 465, 1642, 1853, 367, 6466, 6057, 14, 355, 5664, 14, 3176, 8, 16, 12, 2410, 9, 267, 587, 26, 288, 327, 961, 1077, 7078, 5992, 12, 1325, 2951, 315, 1930, 1396, 288, 2512, 14, 4050, 480, 6004, 9064, 4788, 282, 5160, 1406, 26, 450, 82, 2, 450, 1853, 9, 421, 199, 533, 2606, 7562, 6382, 8, 6382, 304, 272, 408, 2654, 790, 1459, 370, 24537, 14, 408, 339, 347, 12247, 30916, 8, 277, 12, 6128, 12, 6128, 63, 8473, 304, 267, 6128, 14, 2087, 14, 1457, 10547, 14, 525, 360, 31217, 297, 2606, 7562, 10438, 8, 1064, 14, 2087, 395, 12696, 85, 513, 358, 421, 199, 318, 1852, 6382, 8, 7532, 16420, 272, 372, 2606, 7562, 6382, 8, 7532, 29, 7532, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kvesteri/flask-storage
flask_storage/amazon.py
1
9418
from functools import wraps import mimetypes from boto.s3.connection import S3Connection, SubdomainCallingFormat from boto.exception import S3ResponseError, S3CreateError from boto.s3.key import Key from flask import current_app from .base import ( FileNotFoundError, Storage, StorageException, StorageFile, reraise ) class S3BotoStorage(Storage): def __init__( self, folder_name=None, access_key=None, secret_key=None, bucket_acl=None, acl=None, headers=None, gzip=None, gzip_content_types=None, querystring_auth=None, querystring_expire=None, reduced_redundancy=None, custom_domain=None, secure_urls=None, location=None, file_name_charset=None, preload_metadata=None, calling_format=None, file_overwrite=None, auto_create_bucket=None): self.access_key = access_key or \ current_app.config.get('AWS_ACCESS_KEY_ID', None) self.secret_key = secret_key or \ current_app.config.get('AWS_SECRET_ACCESS_KEY', None) self.calling_format = calling_format or \ current_app.config.get( 'AWS_S3_CALLING_FORMAT', SubdomainCallingFormat() ) self.auto_create_bucket = auto_create_bucket or \ current_app.config.get('AWS_AUTO_CREATE_BUCKET', False) self.bucket_name = folder_name or \ current_app.config.get('AWS_STORAGE_BUCKET_NAME', None) self.acl = acl or \ current_app.config.get('AWS_DEFAULT_ACL', 'public-read') self.bucket_acl = bucket_acl or \ current_app.config.get('AWS_BUCKET_ACL', self.acl) self.file_overwrite = file_overwrite or \ current_app.config.get('AWS_S3_FILE_OVERWRITE', False) self.headers = headers or \ current_app.config.get('AWS_HEADERS', {}) self.preload_metadata = preload_metadata or \ current_app.config.get('AWS_PRELOAD_METADATA', False) self.gzip = gzip or \ current_app.config.get('AWS_IS_GZIPPED', False) self.gzip_content_types = gzip_content_types or \ current_app.config.get( 'GZIP_CONTENT_TYPES', ( 'text/css', 'application/javascript', 'application/x-javascript', ) ) self.querystring_auth = querystring_auth or \ current_app.config.get('AWS_QUERYSTRING_AUTH', True) self.querystring_expire = querystring_expire or \ current_app.config.get('AWS_QUERYSTRING_EXPIRE', 3600) self.reduced_redundancy = reduced_redundancy or \ current_app.config.get('AWS_REDUCED_REDUNDANCY', False) self.custom_domain = custom_domain or \ current_app.config.get('AWS_S3_CUSTOM_DOMAIN', None) self.secure_urls = secure_urls or \ current_app.config.get('AWS_S3_SECURE_URLS', True) self.location = location or current_app.config.get('AWS_LOCATION', '') self.location = self.location.lstrip('/') self.file_name_charset = file_name_charset or \ current_app.config.get('AWS_S3_FILE_NAME_CHARSET', 'utf-8') self._connection = None self._entries = {} @property def connection(self): if self._connection is None: self._connection = S3Connection( self.access_key, self.secret_key, calling_format=self.calling_format ) return self._connection @property def folder_name(self): return self.bucket_name @property def bucket(self): """ Get the current bucket. If there is no current bucket object create it. """ if not hasattr(self, '_bucket'): self._bucket = self._get_or_create_bucket(self.bucket_name) return self._bucket def list_folders(self): return [bucket.name for bucket in self.connection.get_all_buckets()] @property def folder(self): return self.bucket def list_files(self): return [ self.file_class(self, key.name) for key in self.bucket.list() ] def create_folder(self, name=None): if not name: name = self.folder_name try: bucket = self.connection.create_bucket(name) bucket.set_acl(self.bucket_acl) except S3CreateError, e: reraise(e) return bucket def _get_or_create_bucket(self, name): """Retrieves a bucket if it exists, otherwise creates it.""" try: return self.connection.get_bucket( name, validate=self.auto_create_bucket ) except S3ResponseError: if self.auto_create_bucket: bucket = self.connection.create_bucket(name) bucket.set_acl(self.bucket_acl) return bucket raise RuntimeError( "Bucket specified by " "S3_BUCKET_NAME does not exist. " "Buckets can be automatically created by setting " "AWS_AUTO_CREATE_BUCKET=True") def _save(self, name, content): cleaned_name = self._clean_name(name) name = self._normalize_name(cleaned_name) headers = self.headers.copy() name = cleaned_name content_type = mimetypes.guess_type(name)[0] or Key.DefaultContentType encoded_name = self._encode_name(name) key = self.bucket.new_key(encoded_name) if self.preload_metadata: self._entries[encoded_name] = key key.set_metadata('Content-Type', content_type) if isinstance(content, basestring): key.set_contents_from_string( content, headers=headers, policy=self.acl, reduced_redundancy=self.reduced_redundancy ) else: content.name = cleaned_name key.set_contents_from_file( content, headers=headers, policy=self.acl, reduced_redundancy=self.reduced_redundancy ) return self.open(encoded_name) def _open(self, name, mode='r'): return self.file_class(self, name=name, mode=mode) def delete_folder(self, name=None): if name is None: name = self.folder_name self.bucket.delete() def delete(self, name): name = self._encode_name(self._normalize_name(self._clean_name(name))) if self.bucket.lookup(name) is None: raise FileNotFoundError(name, 404) self.bucket.delete_key(name) def exists(self, name): name = self._normalize_name(self._clean_name(name)) return bool(self.bucket.lookup(self._encode_name(name))) def url(self, name): name = self._normalize_name(self._clean_name(name)) if self.custom_domain: return "%s://%s/%s" % ('https' if self.secure_urls else 'http', self.custom_domain, name) return self.connection.generate_url( self.querystring_expire, method='GET', bucket=self.bucket.name, key=self._encode_name(name), query_auth=self.querystring_auth, force_http=not self.secure_urls ) @property def file_class(self): return S3BotoStorageFile def require_opening(func): @wraps(func) def wrapper(self, *args, **kwargs): if not self._is_open: self._key.open(self._mode) self._is_open = True return func(self, *args, **kwargs) return wrapper class S3BotoStorageFile(StorageFile): def __init__(self, storage, name=None, prefix='', mode='r'): if mode == 'rb': mode = 'r' # rb is not supported self._storage = storage self.prefix = prefix self._key = Key(storage.bucket) self._mode = mode if name is not None: self.name = name self._pos = 0 self._is_open = False @property def content_type(self): return getattr( self._key.content, 'content_type', mimetypes.guess_type(self.name)[0] or Key.DefaultContentType ) @property def file(self): return self._key @property @require_opening def size(self): return self._key.size @property @require_opening def last_modified(self): return self._key.last_modified @property def url(self): return self._storage.url(self._key.name) @StorageFile.name.setter def name(self, value): if self._name: raise StorageException( "You can't rename files this way. Use rename method instead." ) self._name = self.prefix + self._storage._clean_name(value) self._key.name = self._name @require_opening def read(self, size=0): return self.file.read(size) def seek(self, *args, **kw): raise NotImplementedError def write(self, *args, **kw): raise NotImplementedError
mit
[ 504, 9143, 492, 14018, 199, 646, 13290, 199, 199, 504, 6055, 14, 83, 19, 14, 2105, 492, 428, 19, 3225, 12, 4804, 2261, 23796, 3484, 199, 504, 6055, 14, 1971, 492, 428, 19, 19712, 12, 428, 19, 2499, 547, 199, 504, 6055, 14, 83, 19, 14, 498, 492, 2606, 199, 199, 504, 7209, 492, 1453, 63, 571, 199, 199, 504, 1275, 1095, 492, 334, 272, 3814, 10870, 12, 272, 10533, 12, 272, 10533, 1726, 12, 272, 10533, 1173, 12, 272, 24139, 199, 9, 421, 199, 533, 428, 19, 20380, 6408, 8, 6408, 304, 272, 347, 636, 826, 721, 288, 291, 12, 288, 4922, 63, 354, 29, 403, 12, 288, 2879, 63, 498, 29, 403, 12, 288, 7565, 63, 498, 29, 403, 12, 288, 5315, 63, 5853, 29, 403, 12, 288, 15316, 29, 403, 12, 288, 2323, 29, 403, 12, 288, 11756, 29, 403, 12, 288, 11756, 63, 1317, 63, 1313, 29, 403, 12, 288, 1827, 875, 63, 1178, 29, 403, 12, 288, 1827, 875, 63, 14691, 29, 403, 12, 288, 14953, 63, 581, 32270, 29, 403, 12, 288, 3537, 63, 2261, 29, 403, 12, 288, 11153, 63, 3603, 29, 403, 12, 288, 2909, 29, 403, 12, 288, 570, 63, 354, 63, 6043, 29, 403, 12, 288, 32511, 63, 2343, 29, 403, 12, 288, 6358, 63, 908, 29, 403, 12, 288, 570, 63, 14658, 29, 403, 12, 288, 2599, 63, 981, 63, 4623, 29, 403, 304, 398, 291, 14, 2732, 63, 498, 275, 2879, 63, 498, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 11074, 63, 3078, 63, 998, 297, 488, 9, 267, 291, 14, 4731, 63, 498, 275, 7565, 63, 498, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 12961, 63, 11074, 63, 3078, 297, 488, 9, 267, 291, 14, 25566, 63, 908, 275, 6358, 63, 908, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 8, 355, 283, 13226, 63, 51, 19, 63, 11978, 1206, 63, 4807, 297, 355, 4804, 2261, 23796, 3484, 342, 288, 776, 267, 291, 14, 2495, 63, 981, 63, 4623, 275, 2599, 63, 981, 63, 4623, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 13883, 63, 8366, 63, 20156, 297, 756, 9, 267, 291, 14, 4623, 63, 354, 275, 4922, 63, 354, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 17467, 63, 20156, 63, 2339, 297, 488, 9, 267, 291, 14, 5853, 275, 15316, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 3472, 63, 18765, 297, 283, 3455, 13, 739, 358, 267, 291, 14, 4623, 63, 5853, 275, 5315, 63, 5853, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 20156, 63, 18765, 297, 291, 14, 5853, 9, 267, 291, 14, 493, 63, 14658, 275, 570, 63, 14658, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 3817, 63, 14336, 10387, 297, 756, 9, 267, 291, 14, 2139, 275, 2323, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 21178, 297, 5009, 267, 291, 14, 28795, 63, 2343, 275, 32511, 63, 2343, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 4225, 7405, 63, 8314, 297, 756, 9, 267, 291, 14, 12256, 275, 11756, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 1311, 63, 39, 16977, 19359, 297, 756, 9, 267, 291, 14, 12256, 63, 1317, 63, 1313, 275, 11756, 63, 1317, 63, 1313, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 8, 355, 283, 39, 16977, 63, 9663, 63, 7893, 297, 334, 490, 283, 505, 15, 3919, 297, 490, 283, 3578, 15, 9554, 297, 490, 283, 3578, 15, 88, 13, 9554, 297, 355, 776, 288, 776, 267, 291, 14, 1131, 875, 63, 1178, 275, 1827, 875, 63, 1178, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 11938, 5353, 63, 5580, 297, 715, 9, 267, 291, 14, 1131, 875, 63, 14691, 275, 1827, 875, 63, 14691, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 11938, 5353, 63, 25632, 907, 297, 15751, 9, 267, 291, 14, 19523, 63, 581, 32270, 275, 14953, 63, 581, 32270, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 907, 4980, 25927, 63, 7387, 6131, 879, 15068, 297, 756, 9, 267, 291, 14, 4229, 63, 2261, 275, 3537, 63, 2261, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 20519, 63, 7378, 297, 488, 9, 267, 291, 14, 7817, 63, 3603, 275, 11153, 63, 3603, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 20696, 63, 31582, 297, 715, 9, 267, 291, 14, 1985, 275, 2909, 503, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 16575, 297, 4074, 267, 291, 14, 1985, 275, 291, 14, 1985, 14, 10124, 7825, 267, 291, 14, 493, 63, 354, 63, 6043, 275, 570, 63, 354, 63, 6043, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 3817, 63, 2339, 63, 23969, 297, 283, 1624, 13, 24, 358, 398, 291, 423, 2105, 275, 488, 267, 291, 423, 3189, 275, 1052, 339, 768, 1829, 272, 347, 1950, 8, 277, 304, 267, 340, 291, 423, 2105, 365, 488, 26, 288, 291, 423, 2105, 275, 428, 19, 3225, 8, 355, 291, 14, 2732, 63, 498, 12, 291, 14, 4731, 63, 498, 12, 355, 6358, 63, 908, 29, 277, 14, 25566, 63, 908, 288, 776, 267, 372, 291, 423, 2105, 339, 768, 1829, 272, 347, 4922, 63, 354, 8, 277, 304, 267, 372, 291, 14, 4623, 63, 354, 339, 768, 1829, 272, 347, 5315, 8, 277, 304, 267, 408, 267, 2372, 314, 1453, 5315, 14, 982, 2337, 365, 949, 1453, 5315, 909, 267, 1218, 652, 14, 267, 408, 267, 340, 440, 2688, 8, 277, 12, 2513, 4623, 735, 288, 291, 423, 4623, 275, 291, 423, 362, 63, 269, 63, 981, 63, 4623, 8, 277, 14, 4623, 63, 354, 9, 267, 372, 291, 423, 4623, 339 ]
[ 9143, 492, 14018, 199, 646, 13290, 199, 199, 504, 6055, 14, 83, 19, 14, 2105, 492, 428, 19, 3225, 12, 4804, 2261, 23796, 3484, 199, 504, 6055, 14, 1971, 492, 428, 19, 19712, 12, 428, 19, 2499, 547, 199, 504, 6055, 14, 83, 19, 14, 498, 492, 2606, 199, 199, 504, 7209, 492, 1453, 63, 571, 199, 199, 504, 1275, 1095, 492, 334, 272, 3814, 10870, 12, 272, 10533, 12, 272, 10533, 1726, 12, 272, 10533, 1173, 12, 272, 24139, 199, 9, 421, 199, 533, 428, 19, 20380, 6408, 8, 6408, 304, 272, 347, 636, 826, 721, 288, 291, 12, 288, 4922, 63, 354, 29, 403, 12, 288, 2879, 63, 498, 29, 403, 12, 288, 7565, 63, 498, 29, 403, 12, 288, 5315, 63, 5853, 29, 403, 12, 288, 15316, 29, 403, 12, 288, 2323, 29, 403, 12, 288, 11756, 29, 403, 12, 288, 11756, 63, 1317, 63, 1313, 29, 403, 12, 288, 1827, 875, 63, 1178, 29, 403, 12, 288, 1827, 875, 63, 14691, 29, 403, 12, 288, 14953, 63, 581, 32270, 29, 403, 12, 288, 3537, 63, 2261, 29, 403, 12, 288, 11153, 63, 3603, 29, 403, 12, 288, 2909, 29, 403, 12, 288, 570, 63, 354, 63, 6043, 29, 403, 12, 288, 32511, 63, 2343, 29, 403, 12, 288, 6358, 63, 908, 29, 403, 12, 288, 570, 63, 14658, 29, 403, 12, 288, 2599, 63, 981, 63, 4623, 29, 403, 304, 398, 291, 14, 2732, 63, 498, 275, 2879, 63, 498, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 11074, 63, 3078, 63, 998, 297, 488, 9, 267, 291, 14, 4731, 63, 498, 275, 7565, 63, 498, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 12961, 63, 11074, 63, 3078, 297, 488, 9, 267, 291, 14, 25566, 63, 908, 275, 6358, 63, 908, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 8, 355, 283, 13226, 63, 51, 19, 63, 11978, 1206, 63, 4807, 297, 355, 4804, 2261, 23796, 3484, 342, 288, 776, 267, 291, 14, 2495, 63, 981, 63, 4623, 275, 2599, 63, 981, 63, 4623, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 13883, 63, 8366, 63, 20156, 297, 756, 9, 267, 291, 14, 4623, 63, 354, 275, 4922, 63, 354, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 17467, 63, 20156, 63, 2339, 297, 488, 9, 267, 291, 14, 5853, 275, 15316, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 3472, 63, 18765, 297, 283, 3455, 13, 739, 358, 267, 291, 14, 4623, 63, 5853, 275, 5315, 63, 5853, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 20156, 63, 18765, 297, 291, 14, 5853, 9, 267, 291, 14, 493, 63, 14658, 275, 570, 63, 14658, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 3817, 63, 14336, 10387, 297, 756, 9, 267, 291, 14, 2139, 275, 2323, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 21178, 297, 5009, 267, 291, 14, 28795, 63, 2343, 275, 32511, 63, 2343, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 4225, 7405, 63, 8314, 297, 756, 9, 267, 291, 14, 12256, 275, 11756, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 1311, 63, 39, 16977, 19359, 297, 756, 9, 267, 291, 14, 12256, 63, 1317, 63, 1313, 275, 11756, 63, 1317, 63, 1313, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 8, 355, 283, 39, 16977, 63, 9663, 63, 7893, 297, 334, 490, 283, 505, 15, 3919, 297, 490, 283, 3578, 15, 9554, 297, 490, 283, 3578, 15, 88, 13, 9554, 297, 355, 776, 288, 776, 267, 291, 14, 1131, 875, 63, 1178, 275, 1827, 875, 63, 1178, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 11938, 5353, 63, 5580, 297, 715, 9, 267, 291, 14, 1131, 875, 63, 14691, 275, 1827, 875, 63, 14691, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 11938, 5353, 63, 25632, 907, 297, 15751, 9, 267, 291, 14, 19523, 63, 581, 32270, 275, 14953, 63, 581, 32270, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 907, 4980, 25927, 63, 7387, 6131, 879, 15068, 297, 756, 9, 267, 291, 14, 4229, 63, 2261, 275, 3537, 63, 2261, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 20519, 63, 7378, 297, 488, 9, 267, 291, 14, 7817, 63, 3603, 275, 11153, 63, 3603, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 20696, 63, 31582, 297, 715, 9, 267, 291, 14, 1985, 275, 2909, 503, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 16575, 297, 4074, 267, 291, 14, 1985, 275, 291, 14, 1985, 14, 10124, 7825, 267, 291, 14, 493, 63, 354, 63, 6043, 275, 570, 63, 354, 63, 6043, 503, 971, 288, 1453, 63, 571, 14, 888, 14, 362, 360, 13226, 63, 51, 19, 63, 3817, 63, 2339, 63, 23969, 297, 283, 1624, 13, 24, 358, 398, 291, 423, 2105, 275, 488, 267, 291, 423, 3189, 275, 1052, 339, 768, 1829, 272, 347, 1950, 8, 277, 304, 267, 340, 291, 423, 2105, 365, 488, 26, 288, 291, 423, 2105, 275, 428, 19, 3225, 8, 355, 291, 14, 2732, 63, 498, 12, 291, 14, 4731, 63, 498, 12, 355, 6358, 63, 908, 29, 277, 14, 25566, 63, 908, 288, 776, 267, 372, 291, 423, 2105, 339, 768, 1829, 272, 347, 4922, 63, 354, 8, 277, 304, 267, 372, 291, 14, 4623, 63, 354, 339, 768, 1829, 272, 347, 5315, 8, 277, 304, 267, 408, 267, 2372, 314, 1453, 5315, 14, 982, 2337, 365, 949, 1453, 5315, 909, 267, 1218, 652, 14, 267, 408, 267, 340, 440, 2688, 8, 277, 12, 2513, 4623, 735, 288, 291, 423, 4623, 275, 291,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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 ]
kmonsoor/pyglet
contrib/wydget/wydget/widgets/menu.py
29
2966
import sys import xml.sax.saxutils from pyglet.gl import * from pyglet.window import mouse, key from wydget import event, layouts, loadxml from wydget.widgets.frame import Frame from wydget.widgets.label import Label class MenuItem(Label): name = 'menu-item' @event.default('menu-item') def on_element_enter(item, x, y): item._save_bgcolor = item.bgcolor item.bgcolor = (.9, .9, 1, 1) return event.EVENT_HANDLED @event.default('menu-item') def on_element_leave(item, x, y): item.bgcolor = item._save_bgcolor return event.EVENT_HANDLED @event.default('menu-item') def on_click(widget, *args): menu = widget.parent menu.hide() return event.EVENT_HANDLED class PopupMenu(Frame): '''A menu that should appear under the mouse when activated. The static method `isActivatingClick(buttons, modifiers)` may be used to determine whether the menu should be shown. ''' name = 'popup-menu' is_focusable = True def __init__(self, parent, items, **kw): super(PopupMenu, self).__init__(parent, border="black", is_visible=False, **kw) for n, (label, id) in enumerate(items): MenuItem(self, text=label, id=id, width='100%', bgcolor=((.95, .95, .95, 1), (1, 1, 1, 1))[n%2]) self.layout = layouts.Vertical(self) def expose(self, mouse): w = self.getGUI().window w, h = w.width, w.height self.center = map(int, mouse) if self.x < 0: self.x = 0 if self.y < 0: self.y = 0 if self.x + self.width > w: self.x = w - self.width if self.y + self.height > h: self.y = h - self.height self.setVisible(True) self.gainFocus() def hide(self): self.setVisible(False) @classmethod def fromXML(cls, element, parent): '''Create the object from the XML element and attach it to the parent. If scrollable then put all children loaded into a container frame. ''' kw = loadxml.parseAttributes(element) items = [] for child in element.getchildren(): text = xml.sax.saxutils.unescape(child.text) items.append((text, child.attrib['id'])) return cls(parent, items, **kw) @staticmethod def isActivatingClick(button, modifiers): '''Determine whether the mouse button / modifiers combine to be a popup menu activation click or not. On all platforms a RMB click is allowed. On OS X a control-LMB is allowed. ''' if sys.platform == 'darwin': if button & mouse.LEFT and modifiers & key.MOD_CTRL: return True return button & mouse.RIGHT @event.default('popup-menu', 'on_gain_focus') def on_menu_gain_focus(menu, method): # catch focus return event.EVENT_HANDLED @event.default('popup-menu', 'on_lose_focus') def on_menu_lose_focus(menu, method): menu.hide() return event.EVENT_HANDLED
bsd-3-clause
[ 646, 984, 199, 646, 2748, 14, 14338, 14, 14338, 1208, 199, 199, 504, 23409, 14, 3528, 492, 627, 199, 504, 23409, 14, 3806, 492, 12817, 12, 790, 199, 199, 504, 336, 89, 14080, 492, 1566, 12, 7054, 83, 12, 2248, 1652, 199, 504, 336, 89, 14080, 14, 8583, 14, 1943, 492, 11726, 199, 504, 336, 89, 14080, 14, 8583, 14, 1302, 492, 10354, 199, 199, 533, 18281, 2081, 8, 4314, 304, 272, 536, 275, 283, 4470, 13, 1053, 7, 199, 199, 32, 1430, 14, 885, 360, 4470, 13, 1053, 358, 199, 318, 641, 63, 2108, 63, 4200, 8, 1053, 12, 671, 12, 612, 304, 272, 1242, 423, 2117, 63, 28710, 275, 1242, 14, 28710, 272, 1242, 14, 28710, 275, 17048, 25, 12, 1275, 25, 12, 413, 12, 413, 9, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 199, 199, 32, 1430, 14, 885, 360, 4470, 13, 1053, 358, 199, 318, 641, 63, 2108, 63, 12422, 8, 1053, 12, 671, 12, 612, 304, 272, 1242, 14, 28710, 275, 1242, 423, 2117, 63, 28710, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 199, 199, 32, 1430, 14, 885, 360, 4470, 13, 1053, 358, 199, 318, 641, 63, 4891, 8, 3440, 12, 627, 589, 304, 272, 6269, 275, 3938, 14, 1708, 272, 6269, 14, 8191, 342, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 421, 199, 533, 13244, 384, 5977, 8, 3160, 304, 272, 1449, 33, 6269, 626, 1077, 7468, 1334, 314, 12817, 1380, 22225, 14, 339, 710, 2955, 1083, 658, 374, 13767, 86, 1958, 12040, 8, 15687, 12, 9933, 12544, 1443, 506, 1202, 272, 370, 6705, 3775, 314, 6269, 1077, 506, 9164, 14, 272, 1449, 272, 536, 275, 283, 16020, 13, 4470, 7, 272, 365, 63, 12283, 461, 275, 715, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 2974, 12, 1011, 829, 304, 267, 1613, 8, 26168, 5977, 12, 291, 2843, 826, 721, 1708, 12, 9162, 628, 8399, 401, 288, 365, 63, 6604, 29, 797, 12, 1011, 829, 9, 398, 367, 302, 12, 334, 1302, 12, 1305, 9, 315, 3874, 8, 1744, 304, 288, 18281, 2081, 8, 277, 12, 1318, 29, 1302, 12, 1305, 29, 344, 12, 3462, 534, 1960, 28575, 355, 12994, 2326, 31934, 14, 2720, 12, 1275, 2720, 12, 1275, 2720, 12, 413, 395, 334, 17, 12, 413, 12, 413, 12, 413, 11515, 78, 5, 18, 566, 398, 291, 14, 4209, 275, 7054, 83, 14, 19462, 8, 277, 9, 339, 347, 23705, 8, 277, 12, 12817, 304, 267, 336, 275, 291, 14, 362, 14438, 1252, 3806, 267, 336, 12, 394, 275, 336, 14, 2063, 12, 336, 14, 3333, 267, 291, 14, 4218, 275, 2341, 8, 442, 12, 12817, 9, 267, 340, 291, 14, 88, 665, 378, 26, 291, 14, 88, 275, 378, 267, 340, 291, 14, 89, 665, 378, 26, 291, 14, 89, 275, 378, 267, 340, 291, 14, 88, 435, 291, 14, 2063, 690, 336, 26, 291, 14, 88, 275, 336, 446, 291, 14, 2063, 267, 340, 291, 14, 89, 435, 291, 14, 3333, 690, 394, 26, 291, 14, 89, 275, 394, 446, 291, 14, 3333, 267, 291, 14, 32232, 8, 549, 9, 267, 291, 14, 13020, 17310, 342, 339, 347, 13714, 8, 277, 304, 267, 291, 14, 32232, 8, 797, 9, 339, 768, 3744, 272, 347, 687, 4317, 8, 1886, 12, 1819, 12, 1676, 304, 267, 1449, 2499, 314, 909, 687, 314, 4692, 1819, 436, 6554, 652, 370, 314, 1676, 14, 398, 982, 13704, 461, 2066, 5324, 1006, 4978, 6511, 1901, 282, 3970, 2787, 14, 267, 1449, 267, 4775, 275, 2248, 1652, 14, 1122, 5379, 8, 2108, 9, 267, 2974, 275, 942, 267, 367, 1982, 315, 1819, 14, 362, 3223, 837, 288, 1318, 275, 2748, 14, 14338, 14, 14338, 1208, 14, 22726, 8, 1739, 14, 505, 9, 288, 2974, 14, 740, 1332, 505, 12, 1982, 14, 6640, 459, 344, 5156, 267, 372, 843, 8, 1708, 12, 2974, 12, 1011, 829, 9, 339, 768, 4639, 272, 347, 365, 13767, 86, 1958, 12040, 8, 3887, 12, 9933, 304, 267, 1449, 21767, 3775, 314, 12817, 5528, 1182, 9933, 13323, 370, 506, 282, 267, 22365, 6269, 10361, 8968, 503, 440, 14, 398, 4068, 1006, 10677, 282, 820, 4567, 8968, 365, 4370, 14, 267, 4068, 4403, 1323, 282, 3304, 13, 44, 4567, 365, 4370, 14, 267, 1449, 267, 340, 984, 14, 3246, 508, 283, 13245, 356, 288, 340, 5528, 1253, 12817, 14, 9894, 436, 9933, 1253, 790, 14, 8816, 63, 22584, 26, 355, 372, 715, 267, 372, 5528, 1253, 12817, 14, 12811, 199, 199, 32, 1430, 14, 885, 360, 16020, 13, 4470, 297, 283, 265, 63, 13020, 63, 12283, 358, 199, 318, 641, 63, 4470, 63, 13020, 63, 12283, 8, 4470, 12, 1083, 304, 272, 327, 8579, 16470, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 199, 199, 32, 1430, 14, 885, 360, 16020, 13, 4470, 297, 283, 265, 63, 22641, 63, 12283, 358, 199, 318, 641, 63, 4470, 63, 22641, 63, 12283, 8, 4470, 12, 1083, 304, 272, 6269, 14, 8191, 342, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 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 ]
[ 984, 199, 646, 2748, 14, 14338, 14, 14338, 1208, 199, 199, 504, 23409, 14, 3528, 492, 627, 199, 504, 23409, 14, 3806, 492, 12817, 12, 790, 199, 199, 504, 336, 89, 14080, 492, 1566, 12, 7054, 83, 12, 2248, 1652, 199, 504, 336, 89, 14080, 14, 8583, 14, 1943, 492, 11726, 199, 504, 336, 89, 14080, 14, 8583, 14, 1302, 492, 10354, 199, 199, 533, 18281, 2081, 8, 4314, 304, 272, 536, 275, 283, 4470, 13, 1053, 7, 199, 199, 32, 1430, 14, 885, 360, 4470, 13, 1053, 358, 199, 318, 641, 63, 2108, 63, 4200, 8, 1053, 12, 671, 12, 612, 304, 272, 1242, 423, 2117, 63, 28710, 275, 1242, 14, 28710, 272, 1242, 14, 28710, 275, 17048, 25, 12, 1275, 25, 12, 413, 12, 413, 9, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 199, 199, 32, 1430, 14, 885, 360, 4470, 13, 1053, 358, 199, 318, 641, 63, 2108, 63, 12422, 8, 1053, 12, 671, 12, 612, 304, 272, 1242, 14, 28710, 275, 1242, 423, 2117, 63, 28710, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 199, 199, 32, 1430, 14, 885, 360, 4470, 13, 1053, 358, 199, 318, 641, 63, 4891, 8, 3440, 12, 627, 589, 304, 272, 6269, 275, 3938, 14, 1708, 272, 6269, 14, 8191, 342, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 421, 199, 533, 13244, 384, 5977, 8, 3160, 304, 272, 1449, 33, 6269, 626, 1077, 7468, 1334, 314, 12817, 1380, 22225, 14, 339, 710, 2955, 1083, 658, 374, 13767, 86, 1958, 12040, 8, 15687, 12, 9933, 12544, 1443, 506, 1202, 272, 370, 6705, 3775, 314, 6269, 1077, 506, 9164, 14, 272, 1449, 272, 536, 275, 283, 16020, 13, 4470, 7, 272, 365, 63, 12283, 461, 275, 715, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 2974, 12, 1011, 829, 304, 267, 1613, 8, 26168, 5977, 12, 291, 2843, 826, 721, 1708, 12, 9162, 628, 8399, 401, 288, 365, 63, 6604, 29, 797, 12, 1011, 829, 9, 398, 367, 302, 12, 334, 1302, 12, 1305, 9, 315, 3874, 8, 1744, 304, 288, 18281, 2081, 8, 277, 12, 1318, 29, 1302, 12, 1305, 29, 344, 12, 3462, 534, 1960, 28575, 355, 12994, 2326, 31934, 14, 2720, 12, 1275, 2720, 12, 1275, 2720, 12, 413, 395, 334, 17, 12, 413, 12, 413, 12, 413, 11515, 78, 5, 18, 566, 398, 291, 14, 4209, 275, 7054, 83, 14, 19462, 8, 277, 9, 339, 347, 23705, 8, 277, 12, 12817, 304, 267, 336, 275, 291, 14, 362, 14438, 1252, 3806, 267, 336, 12, 394, 275, 336, 14, 2063, 12, 336, 14, 3333, 267, 291, 14, 4218, 275, 2341, 8, 442, 12, 12817, 9, 267, 340, 291, 14, 88, 665, 378, 26, 291, 14, 88, 275, 378, 267, 340, 291, 14, 89, 665, 378, 26, 291, 14, 89, 275, 378, 267, 340, 291, 14, 88, 435, 291, 14, 2063, 690, 336, 26, 291, 14, 88, 275, 336, 446, 291, 14, 2063, 267, 340, 291, 14, 89, 435, 291, 14, 3333, 690, 394, 26, 291, 14, 89, 275, 394, 446, 291, 14, 3333, 267, 291, 14, 32232, 8, 549, 9, 267, 291, 14, 13020, 17310, 342, 339, 347, 13714, 8, 277, 304, 267, 291, 14, 32232, 8, 797, 9, 339, 768, 3744, 272, 347, 687, 4317, 8, 1886, 12, 1819, 12, 1676, 304, 267, 1449, 2499, 314, 909, 687, 314, 4692, 1819, 436, 6554, 652, 370, 314, 1676, 14, 398, 982, 13704, 461, 2066, 5324, 1006, 4978, 6511, 1901, 282, 3970, 2787, 14, 267, 1449, 267, 4775, 275, 2248, 1652, 14, 1122, 5379, 8, 2108, 9, 267, 2974, 275, 942, 267, 367, 1982, 315, 1819, 14, 362, 3223, 837, 288, 1318, 275, 2748, 14, 14338, 14, 14338, 1208, 14, 22726, 8, 1739, 14, 505, 9, 288, 2974, 14, 740, 1332, 505, 12, 1982, 14, 6640, 459, 344, 5156, 267, 372, 843, 8, 1708, 12, 2974, 12, 1011, 829, 9, 339, 768, 4639, 272, 347, 365, 13767, 86, 1958, 12040, 8, 3887, 12, 9933, 304, 267, 1449, 21767, 3775, 314, 12817, 5528, 1182, 9933, 13323, 370, 506, 282, 267, 22365, 6269, 10361, 8968, 503, 440, 14, 398, 4068, 1006, 10677, 282, 820, 4567, 8968, 365, 4370, 14, 267, 4068, 4403, 1323, 282, 3304, 13, 44, 4567, 365, 4370, 14, 267, 1449, 267, 340, 984, 14, 3246, 508, 283, 13245, 356, 288, 340, 5528, 1253, 12817, 14, 9894, 436, 9933, 1253, 790, 14, 8816, 63, 22584, 26, 355, 372, 715, 267, 372, 5528, 1253, 12817, 14, 12811, 199, 199, 32, 1430, 14, 885, 360, 16020, 13, 4470, 297, 283, 265, 63, 13020, 63, 12283, 358, 199, 318, 641, 63, 4470, 63, 13020, 63, 12283, 8, 4470, 12, 1083, 304, 272, 327, 8579, 16470, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 199, 199, 32, 1430, 14, 885, 360, 16020, 13, 4470, 297, 283, 265, 63, 22641, 63, 12283, 358, 199, 318, 641, 63, 4470, 63, 22641, 63, 12283, 8, 4470, 12, 1083, 304, 272, 6269, 14, 8191, 342, 272, 372, 1566, 14, 8193, 63, 10854, 5290, 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,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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 ]
tomsilver/nupic
tests/unit/nupic/support/custom_configuration_test.py
4
42107
#!/usr/bin/env python # ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2013, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # 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. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- from copy import copy import os import shutil from StringIO import StringIO import sys import tempfile import unittest2 as unittest import uuid from mock import Mock, patch from pkg_resources import resource_filename from xml.parsers.expat import ExpatError # ParseError not present in xml module for python2.6 try: from xml.etree.ElementTree import ParseError except ImportError: from xml.parsers.expat import ExpatError as ParseError import nupic import nupic.support.configuration_custom as configuration import configuration_test class ConfigurationCustomTest(unittest.TestCase): def setUp(self): if "NTA_DYNAMIC_CONF_DIR" in os.environ: # Remove it to make sure our in-proc tests won't accidentally # mess with actual files oldNtaDynamicConfDir = os.environ["NTA_DYNAMIC_CONF_DIR"] del os.environ["NTA_DYNAMIC_CONF_DIR"] self.addCleanup(os.environ.update, dict(NTA_DYNAMIC_CONF_DIR=oldNtaDynamicConfDir)) self.files = dict() tmpDir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, tmpDir) with open(os.path.join(tmpDir, 'nupic-default.xml-unittest'), 'w') as fp: with open(resource_filename(__name__, 'conf/nupic-default.xml')) as inp: fp.write(inp.read()) self.files['nupic-default.xml'] = fp.name with open(os.path.join(tmpDir, 'nupic-site.xml-unittest'), 'w') as fp: with open(resource_filename(__name__, 'conf/nupic-site.xml')) as inp: fp.write(inp.read()) self.files['nupic-site.xml'] = fp.name with open(os.path.join(tmpDir, 'nupic-custom.xml'), 'w') as fp: with open(resource_filename(__name__, 'conf/nupic-custom.xml')) as inp: fp.write(inp.read()) self.files['nupic-custom.xml'] = fp.name self.customParam = 'nupic.custom.hello' self.customValue = 'world' configuration.Configuration.clear() #################################################################### # Custom Configuration Tests # Todo: Share tests between two configuration_test files #################################################################### @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testCustomFileCreated(self, findConfigFile, environ): environ.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.setCustomProperty('param', 'val') self.assertTrue(os.path.exists(self.files['nupic-custom.xml'])) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGet(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>'+self.customParam+'</name>', ' <value>'+self.customValue+'</value>', ' </property>', '</configuration>'))) self.assertEqual( configuration.Configuration.get(self.customParam), self.customValue) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testSetCustomProperty(self, findConfigFile, environ): environ.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get environ.get.return_value = None configuration.Configuration.clear() findConfigFile.side_effect = self.files.get with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>' + self.customParam + '</name>', ' <value>' + self.customValue + '</value>', ' </property>', '</configuration>'))) configuration.Configuration.setCustomProperty('PersistProp', 'PersistVal') self.assertEqual( configuration.Configuration.get('PersistProp'),'PersistVal') configuration.Configuration.clear() self.assertEqual( configuration.Configuration.get('PersistProp'),'PersistVal') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testSetCustomProperties(self, findConfigFile, environ): environ.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get environ.get.return_value = None findConfigFile.side_effect = self.files.get with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>' + self.customParam + '</name>', ' <value>' + self.customValue + '</value>', ' </property>', '</configuration>'))) configuration.Configuration.clear() originalProps = copy(configuration.Configuration.dict()) configuration.Configuration.setCustomProperties( {'PersistProp' : 'PersistVal', 'apple' : 'pear'}) expectedProps = {'PersistProp' : 'PersistVal', 'apple' : 'pear'} expectedProps.update(originalProps) self.assertEqual(configuration.Configuration.dict(), expectedProps) configuration.Configuration.clear() self.assertEqual(configuration.Configuration.dict(), expectedProps) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testDictWithTemp(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>param</name>', ' <value>value</value>', ' </property>', ' <property>', ' <name>param2</name>', ' <value>value2</value>', ' </property>', '</configuration>'))) customDict = configuration.Configuration.dict() self.assertTrue('param' in customDict) self.assertTrue('param2' in customDict) self.assertEqual(customDict['param'], 'value') self.assertEqual(customDict['param2'], 'value2') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testCustomConfigOverrides(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() paramNames = configuration.Configuration.dict().keys() customValue = 'NewValue' with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>'+paramNames[0]+'</name>', ' <value>'+customValue+'</value>', ' </property>', '</configuration>'))) configuration.Configuration.clear() self.assertEqual(configuration.Configuration.get(paramNames[0]), \ customValue) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testCustomConfigDict(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>CustomParam</name>', ' <value>CustomValue</value>', ' </property>', '</configuration>'))) configuration.Configuration.clear() self.assertEqual(configuration.Configuration.get('CustomParam'), \ 'CustomValue') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testClearInvalidFile(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<foo/>'))) configuration.Configuration.clear() with patch('sys.stderr', new_callable=StringIO): self.assertRaises(RuntimeError, configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testSetInvalidFile(self, findConfigFile, environ): environ.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get configuration.Configuration.clear() with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<foo/>'))) with patch('sys.stderr', new_callable=StringIO): with self.assertRaises(RuntimeError) as cm: configuration.Configuration.setCustomProperty('foo', 'value') self.assertIn("Expected top-level element to be 'configuration'", cm.exception.args[0]) with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join((''))) with patch('sys.stderr', new_callable=StringIO): with self.assertRaises(RuntimeError) as cm: configuration.Configuration.setCustomProperty('foo', 'value') self.assertIn("File contents of custom configuration is corrupt.", cm.exception.args[0]) # NTA_CONF_PATH is not being mocked out in this test, so we have to mock out # findConfigFile to return the right path to the config file. findConfigFile.return_value = self.files['nupic-custom.xml'] configuration.Configuration.resetCustomConfig() configuration.Configuration.setCustomProperty('foo', 'value') self.assertEqual(configuration.Configuration.getCustomDict(), {'foo': 'value'}) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetCustomDict(self, findConfigFile, environ): environ.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-custom.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>CustomParam</name>', ' <value>CustomValue</value>', ' </property>', '</configuration>'))) self.assertEqual(configuration.Configuration.getCustomDict(), dict(CustomParam='CustomValue')) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetCustomDictNoFile(self, findConfigFile, environ): environ.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.resetCustomConfig() self.assertEqual(configuration.Configuration.getCustomDict(), dict()) del self.files['nupic-custom.xml'] ############################################### # Replicated Tests From configuration_test.py ############################################### @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetStringMissingRaisesKeyError(self, findConfigFileMock, environMock): findConfigFileMock.side_effect = self.files.get environMock.get.return_value = None configuration.Configuration.clear() with self.assertRaises(KeyError): configuration.Configuration.getString(uuid.uuid1().hex) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetString(self, findConfigFileMock, environMock): environMock.get.return_value = None findConfigFileMock.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foo', 'bar') result = configuration.Configuration.getString('foo') self.assertEqual(result, 'bar') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetBoolMissingRaisesKeyError(self, findConfigFileMock, environMock): findConfigFileMock.side_effect = self.files.get environMock.get.return_value = None configuration.Configuration.clear() with self.assertRaises(KeyError): configuration.Configuration.getBool(uuid.uuid1().hex) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetBoolOutOfRangeRaisesValueError(self, findConfigFileMock, environMock): environMock.get.return_value = None findConfigFileMock.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foobool2', '2') with self.assertRaises(ValueError): configuration.Configuration.getBool('foobool2') configuration.Configuration.set('fooboolneg1', '-1') with self.assertRaises(ValueError): configuration.Configuration.getBool('fooboolneg1') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetBool(self, findConfigFileMock, environMock): environMock.get.return_value = None findConfigFileMock.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foobool0', '0') result = configuration.Configuration.getBool('foobool0') self.assertEqual(result, False) configuration.Configuration.set('foobool1', '1') result = configuration.Configuration.getBool('foobool1') self.assertEqual(result, True) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetIntMissingRaisesKeyError(self, findConfigFileMock, environMock): findConfigFileMock.side_effect = self.files.get environMock.get.return_value = None configuration.Configuration.clear() with self.assertRaises(KeyError): configuration.Configuration.getInt(uuid.uuid1().hex) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetInt(self, findConfigFileMock, environMock): environMock.get.return_value = None findConfigFileMock.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('fooint', '-127') result = configuration.Configuration.getInt('fooint') self.assertEqual(result, -127) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetFloatMissingRaisesKeyError(self, findConfigFileMock, environMock): findConfigFileMock.side_effect = self.files.get environMock.get.return_value = None configuration.Configuration.clear() with self.assertRaises(KeyError): configuration.Configuration.getFloat(uuid.uuid1().hex) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetFloat(self, findConfigFileMock, environMock): environMock.get.return_value = None findConfigFileMock.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foofloat', '-127.65') result = configuration.Configuration.getFloat('foofloat') self.assertEqual(result, -127.65) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetMissingReturnsNone(self, findConfigFile, environ): findConfigFile.side_effect = self.files.get environ.get.return_value = None configuration.Configuration.clear() result = configuration.Configuration.get(str(uuid.uuid4())) self.assertTrue(result is None) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testSetAndGet(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foo', 'bar') result = configuration.Configuration.get('foo') self.assertTrue(result == 'bar') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testDict(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foo', 'bar') configuration.Configuration.set('apple', 'banana') result = configuration.Configuration.dict() self.assertTrue(isinstance(result, dict)) self.assertTrue('foo' in result) self.assertTrue(result['foo'] == 'bar') self.assertTrue('apple' in result) self.assertTrue(result['apple'] == 'banana') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testDictReadsFilesFirstTime(self, findConfigFile, environ): # pylint: disable=W0613 environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() result = configuration.Configuration.dict() self.assertTrue(isinstance(result, dict)) self.assertTrue(len(result) == 1, result) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testDictReplacesKeysFromEnvironment(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() key = str(uuid.uuid4()) env = {'NTA_CONF_PROP_' + key: 'foo'} environ.keys.side_effect = env.keys environ.__getitem__.side_effect = env.__getitem__ result = configuration.Configuration.dict() self.assertTrue(key in result) self.assertTrue(result[key] == 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testClear(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() configuration.Configuration.set('foo', 'bar') configuration.Configuration.set('apple', 'banana') self.assertTrue(configuration.Configuration.get('foo') == 'bar') self.assertTrue(configuration.Configuration.get('apple') == 'banana') configuration.Configuration.clear() self.assertTrue(configuration.Configuration.get('foo') is None) self.assertTrue(configuration.Configuration.get('apple') is None) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testGetFromEnvironment(self, findConfigFile, environ): findConfigFile.side_effect = self.files.get configuration.Configuration.clear() key = str(uuid.uuid4()) environ.get.side_effect = {'NTA_CONF_PROP_' + key: 'foo'}.get self.assertTrue(configuration.Configuration.get(key) == 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileFromPath(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() prefix, _, filename = self.files['nupic-default.xml'].rpartition(os.sep) configuration.Configuration.readConfigFile(filename, prefix) self.assertTrue(configuration.Configuration.get('dummy') == 'dummy value') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileUnexpectedElementAtRoot(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<foo/>'))) with patch('sys.stderr', new_callable=StringIO): self.assertRaises(RuntimeError, configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileMissingDocumentRoot(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>'))) with patch('sys.stderr', new_callable=StringIO): self.assertRaises((ExpatError, ParseError), configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileMissingNonPropertyConfigurationChildren( self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <foo>bar<baz/></foo>', '</configuration>'))) self.assertEqual(configuration.Configuration.dict(), \ dict(dummy='dummy value')) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileEmptyValue(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>foo</name>', ' </property>', '</configuration>'))) with patch('sys.stderr', new_callable=StringIO): self.assertRaises(Exception, configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileEmptyNameAndValue(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name></name>', ' <value></value>', ' </property>', '</configuration>'))) with patch('sys.stderr', new_callable=StringIO): self.assertRaises(RuntimeError, configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileMissingEnvVars(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>foo</name>', ' <value>${env.foo}</value>', ' </property>', '</configuration>'))) with patch('sys.stderr', new_callable=StringIO): self.assertRaises(RuntimeError, configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileMalformedEnvReference(self, findConfigFile, environ): # pylint: disable=W0613 environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>foo</name>', ' <value>${env.foo</value>', ' </property>', '</configuration>'))) with patch('sys.stderr', new_callable=StringIO): self.assertRaises(RuntimeError, configuration.Configuration.get, 'foo') @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testReadConfigFileEnvironmentOverride(self, findConfigFile, environ): environ.get.return_value = None findConfigFile.side_effect = self.files.get configuration.Configuration.clear() with open(self.files['nupic-default.xml'], 'w') as fp: fp.write('\n'.join(( '<?xml version="1.0"?>', '<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>', '<configuration>', ' <property>', ' <name>foo</name>', ' <value>${env.NTA_CONF_PROP_foo}</value>', ' </property>', '</configuration>'))) env = {'NTA_CONF_PROP_foo': 'bar'} environ.__getitem__.side_effect = env.__getitem__ environ.get.side_effect = env.get environ.__contains__.side_effect = env.__contains__ result = configuration.Configuration.get('foo') self.assertEqual(result, 'bar') @patch.object(configuration.Configuration, 'getConfigPaths', spec=configuration.Configuration.getConfigPaths) def testFindConfigFile(self, getConfigPaths): prefix, _, filename = self.files['nupic-default.xml'].rpartition(os.sep) def replacePaths(**_): return [prefix] getConfigPaths.side_effect = replacePaths configuration.Configuration.clear() result = configuration.Configuration.findConfigFile(filename) self.assertTrue(result == self.files['nupic-default.xml']) getConfigPaths.assert_called_with() @patch.object(configuration.Configuration, 'getConfigPaths', spec=configuration.Configuration.getConfigPaths) def testFindConfigFileReturnsNoneForMissingFile(self, getConfigPaths): prefix, _, _ = self.files['nupic-default.xml'].rpartition(os.sep) def replacePaths(**_): return [prefix] getConfigPaths.side_effect = replacePaths configuration.Configuration.clear() result = configuration.Configuration.findConfigFile(str(uuid.uuid4())) self.assertTrue(result is None) getConfigPaths.assert_called_with() @patch.object(configuration.Configuration, '_configPaths', spec=configuration.Configuration._configPaths) @patch.object(configuration.os, 'environ', spec=dict) def testGetConfigPaths( self, environ, configPaths): # pylint: disable=W0613 result = configuration.Configuration.getConfigPaths() self.assertEqual(result, configPaths) @unittest.skip('NUP-2081') @patch.object(configuration.Configuration, '_configPaths', spec=configuration.Configuration._configPaths) @patch.object(configuration.os, 'environ', spec=dict) def testGetConfigPathsForNone( self, environ, configPaths): # pylint: disable=W0613 configuration.Configuration._configPaths = None # pylint: disable=W0212 result = configuration.Configuration.getConfigPaths() self.assertTrue(isinstance(result, list)) self.assertEqual(result, [os.path.join(os.environ['NUPIC'], 'config', 'default')]) @patch.object(configuration.Configuration, '_configPaths', spec=configuration.Configuration._configPaths) @patch.object(configuration.os, 'environ', spec=dict) def testGetConfigPathsForNoneWithNTA_CONF_PATHInEnv( self, environ, configPaths): # pylint: disable=W0613 configuration.Configuration._configPaths = None # pylint: disable=W0212 env = {'NTA_CONF_PATH': ''} environ.__getitem__.side_effect = env.__getitem__ environ.get.side_effect = env.get environ.__contains__.side_effect = env.__contains__ result = configuration.Configuration.getConfigPaths() self.assertTrue(isinstance(result, list)) self.assertEqual(len(result), 1) self.assertEqual(result[0], env['NTA_CONF_PATH']) def testSetConfigPathsForNoneWithNTA_CONF_PATHInEnv(self): paths = [Mock()] configuration.Configuration.setConfigPaths(paths) self.assertEqual( paths, configuration.Configuration._configPaths) # pylint: disable=W0212 @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testEmptyGetCustomDict(self, findConfigFile, environMock): findConfigFile.side_effect = self.files.get environMock.__getitem__.side_effect = dict( NTA_DYNAMIC_CONF_DIR=os.path.dirname(self.files['nupic-custom.xml'])).get configuration.Configuration.resetCustomConfig() self.assertEqual(configuration.Configuration.getCustomDict(), dict()) @patch.object(configuration.os, 'environ', spec=dict) @patch.object(configuration.Configuration, 'findConfigFile', spec=configuration.Configuration.findConfigFile) def testConfiguration(self, findConfigFile, environ): configuration.Configuration.clear() findConfigFile.side_effect = self.files.get with open(self.files['nupic-default.xml'], 'w') as fp: with open(resource_filename(__name__, 'conf/testFile1.xml')) as inp: fp.write(inp.read()) with open(self.files['nupic-site.xml'], 'w') as fp: with open(resource_filename(__name__, 'conf/testFile2.xml')) as inp: fp.write(inp.read()) env = {'USER': 'foo', 'HOME': 'bar'} environ.__getitem__.side_effect = env.__getitem__ environ.get.side_effect = env.get environ.__contains__.side_effect = env.__contains__ environ.keys.side_effect = env.keys # Test the resulting configuration self.assertEqual(configuration.Configuration.get('database.host'), 'TestHost') self.assertEqual(configuration.Configuration.get('database.password'), 'pass') self.assertEqual(configuration.Configuration.get('database.emptypassword'), '') self.assertEqual(configuration.Configuration.get('database.missingfield'), None) self.assertEqual(configuration.Configuration.get('database.user'), 'root') expectedValue = 'foo' actualValue = configuration.Configuration.get( 'var.environment.standalone.user') self.assertTrue(actualValue == expectedValue, "expected %r, but got %r" % (expectedValue, actualValue)) expectedValue = "The user " + os.environ['USER'] + " rocks!" actualValue = configuration.Configuration.get( 'var.environment.user.in.the.middle') self.assertTrue(actualValue == expectedValue, "expected %r, but got %r" % (expectedValue, actualValue)) expectedValue = ("User " + os.environ['USER'] + " and home " + os.environ['HOME'] + " in the middle") actualValue = configuration.Configuration.get( 'var.environment.user.and.home.in.the.middle') self.assertTrue(actualValue == expectedValue, "expected %r, but got %r" % (expectedValue, actualValue)) env['NTA_CONF_PROP_database_host'] = 'FooBar' self.assertEqual(configuration.Configuration.get('database.host'), 'FooBar') allProps = configuration.Configuration.dict() self.assertTrue(allProps['database.host'] == 'FooBar') del env['NTA_CONF_PROP_database_host'] environ.__getitem__.side_effect = env.__getitem__ environ.get.side_effect = env.get environ.__contains__.side_effect = env.__contains__ # Change a property configuration.Configuration.set('database.host', 'matrix') self.assertEqual(configuration.Configuration.get('database.host'), 'matrix') @patch.object(configuration.os, 'environ', spec=dict) def testConfiguration2(self, environ): configuration.Configuration.clear() tmpDir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, tmpDir) with open(os.path.join(tmpDir, 'nupic-default.xml'), 'w') as fp: with open(resource_filename(__name__, 'conf/testFile1.xml')) as inp: fp.write(inp.read()) with open(os.path.join(tmpDir, 'nupic-site.xml'), 'w') as fp: with open(resource_filename(__name__, 'conf/testFile2.xml')) as inp: fp.write(inp.read()) env = { 'USER': 'foo', 'HOME': 'bar', 'NTA_CONF_PATH': tmpDir } environ.__getitem__.side_effect = env.__getitem__ environ.get.side_effect = env.get environ.__contains__.side_effect = env.__contains__ environ.keys.side_effect = env.keys # Test the resulting configuration self.assertEqual(configuration.Configuration.get('database.host'), 'TestHost') self.assertEqual(configuration.Configuration.get('database.password'), 'pass') self.assertEqual( configuration.Configuration.get('database.emptypassword'), '') self.assertEqual(configuration.Configuration.get('database.missingfield'), None) self.assertEqual(configuration.Configuration.get('database.user'), 'root') expectedValue = 'foo' actualValue = configuration.Configuration.get( 'var.environment.standalone.user') self.assertEqual(actualValue, expectedValue, "expected %r, but got %r" % (expectedValue, actualValue)) expectedValue = "The user " + os.environ['USER'] + " rocks!" actualValue = configuration.Configuration.get( 'var.environment.user.in.the.middle') self.assertEqual(actualValue, expectedValue, "expected %r, but got %r" % (expectedValue, actualValue)) expectedValue = ("User " + os.environ['USER'] + " and home " + os.environ['HOME'] + " in the middle") actualValue = configuration.Configuration.get( 'var.environment.user.and.home.in.the.middle') self.assertEqual(actualValue, expectedValue, "expected %r, but got %r" % (expectedValue, actualValue)) env['NTA_CONF_PROP_database_host'] = 'FooBar' self.assertEqual(configuration.Configuration.get('database.host'), 'FooBar') allProps = configuration.Configuration.dict() self.assertEqual(allProps['database.host'], 'FooBar') del env['NTA_CONF_PROP_database_host'] # Change a property configuration.Configuration.set('database.host', 'matrix') self.assertEqual(configuration.Configuration.get('database.host'), 'matrix') configuration.Configuration.clear() tmpDir = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, tmpDir) with open(os.path.join(tmpDir, 'nupic-default.xml'), 'w') as fp: with open(resource_filename(__name__, 'conf/testFile1.xml')) as inp: fp.write(inp.read()) with open(os.path.join(tmpDir, 'nupic-site.xml'), 'w') as fp: with open(resource_filename(__name__, 'conf/testFile2.xml')) as inp: fp.write(inp.read()) tmpDir2 = tempfile.mkdtemp() self.addCleanup(shutil.rmtree, tmpDir2) with open(os.path.join(tmpDir2, 'nupic-site.xml'), 'w') as fp: with open(resource_filename(__name__, 'conf/testFile3.xml')) as inp: fp.write(inp.read()) env['NTA_CONF_PATH'] = os.pathsep.join([tmpDir, tmpDir2]) # Test the resulting configuration self.assertEqual(configuration.Configuration.get('database.host'), 'TestHost') self.assertEqual(configuration.Configuration.get('database.password'), 'pass') self.assertEqual( configuration.Configuration.get('database.emptypassword'), '') self.assertEqual(configuration.Configuration.get('database.missingfield'), None) self.assertEqual(configuration.Configuration.get('database.user'), 'root') # Change a property configuration.Configuration.set('database.host', 'matrix') self.assertEqual(configuration.Configuration.get('database.host'), 'matrix') if __name__ == '__main__': unittest.main(argv=[sys.argv[0], "--verbose"] + sys.argv[1:])
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 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, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 504, 1331, 492, 1331, 199, 646, 747, 199, 646, 5145, 199, 504, 5228, 492, 5228, 199, 646, 984, 199, 646, 5549, 199, 646, 2882, 18, 465, 2882, 199, 646, 5377, 199, 199, 504, 1683, 492, 4420, 12, 3371, 199, 504, 5496, 63, 4435, 492, 2073, 63, 1501, 199, 504, 2748, 14, 11531, 14, 27098, 492, 7910, 292, 547, 199, 3, 21743, 440, 3451, 315, 2748, 859, 367, 2366, 18, 14, 22, 199, 893, 26, 272, 687, 2748, 14, 9464, 14, 15325, 492, 21743, 199, 2590, 3545, 26, 272, 687, 2748, 14, 11531, 14, 27098, 492, 7910, 292, 547, 465, 21743, 199, 199, 646, 26084, 199, 199, 646, 26084, 14, 4058, 14, 4758, 63, 4229, 465, 2897, 199, 199, 646, 2897, 63, 396, 4388, 199, 533, 11595, 7223, 774, 8, 2796, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 339, 340, 298, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 2, 315, 747, 14, 2314, 26, 489, 327, 5852, 652, 370, 1852, 3238, 4154, 315, 13, 4687, 2295, 7859, 1133, 24634, 1183, 489, 327, 15634, 543, 3503, 1584, 489, 2269, 46, 502, 14451, 8930, 3567, 275, 747, 14, 2314, 905, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 937, 489, 2150, 747, 14, 2314, 905, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 937, 489, 291, 14, 12808, 8, 736, 14, 2314, 14, 873, 12, 1993, 1211, 8, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 29, 1753, 46, 502, 14451, 8930, 3567, 430, 339, 291, 14, 1725, 275, 1211, 342, 339, 3529, 3567, 275, 5549, 14, 11983, 342, 272, 291, 14, 12808, 8, 20938, 14, 9242, 12, 3529, 3567, 9, 2378, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 2791, 3567, 12, 283, 14596, 530, 13, 885, 14, 1652, 13, 2796, 659, 283, 87, 358, 465, 4090, 26, 489, 543, 1551, 8, 1927, 63, 1501, 3460, 354, 3108, 283, 2190, 15, 14596, 530, 13, 885, 14, 1652, 1333, 465, 10702, 26, 267, 4090, 14, 952, 8, 11416, 14, 739, 1012, 267, 291, 14, 1725, 459, 14596, 530, 13, 885, 14, 1652, 418, 275, 4090, 14, 354, 339, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 2791, 3567, 12, 283, 14596, 530, 13, 2124, 14, 1652, 13, 2796, 659, 283, 87, 358, 465, 4090, 26, 489, 543, 1551, 8, 1927, 63, 1501, 3460, 354, 3108, 283, 2190, 15, 14596, 530, 13, 2124, 14, 1652, 1333, 465, 10702, 26, 267, 4090, 14, 952, 8, 11416, 14, 739, 1012, 267, 291, 14, 1725, 459, 14596, 530, 13, 2124, 14, 1652, 418, 275, 4090, 14, 354, 339, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 2791, 3567, 12, 283, 14596, 530, 13, 4229, 14, 1652, 659, 283, 87, 358, 465, 4090, 26, 489, 543, 1551, 8, 1927, 63, 1501, 3460, 354, 3108, 283, 2190, 15, 14596, 530, 13, 4229, 14, 1652, 1333, 465, 10702, 26, 267, 4090, 14, 952, 8, 11416, 14, 739, 1012, 267, 291, 14, 1725, 459, 14596, 530, 13, 4229, 14, 1652, 418, 275, 4090, 14, 354, 339, 291, 14, 4229, 4098, 275, 283, 14596, 530, 14, 4229, 14, 5006, 7, 272, 291, 14, 4229, 1110, 275, 283, 7617, 7, 339, 2897, 14, 5688, 14, 3584, 342, 421, 819, 15779, 381, 523, 327, 8388, 11595, 6496, 523, 327, 377, 19657, 26, 5244, 1530, 2295, 3382, 2877, 2897, 63, 396, 1584, 523, 15779, 381, 819, 768, 2068, 14, 785, 8, 4758, 14, 736, 12, 283, 2314, 297, 3158, 29, 807, 9, 523, 768, 2068, 14, 785, 8, 4758, 14, 5688, 12, 283, 1623, 2028, 1173, 297, 355, 3158, 29, 4758, 14, 5688, 14, 1623, 2028, 1173, 9, 523, 347, 511, 7223, 1173, 10502, 8, 277, 12, 2342, 2028, 1173, 12, 6160, 304, 272, 6160, 855, 6095, 4343, 2441, 63, 5881, 275, 1211, 8, 489, 653, 6166, 63, 28080, 63, 3103, 63, 3022, 29, 736, 14, 515, 14, 3475, 8, 277, 14, 1725, 459, 14596, 530, 13, 4229, 14, 1652, 418, 4992, 362, 272, 6160, 14, 362, 14, 1107, 63, 585, 275, 488, 272, 2342, 2028, 1173, 14, 2441, 63, 5881, 275, 291, 14, 1725, 14, 362, 272, 2897, 14, 5688, 14, 3584, 342, 272, 2897, 14, 5688, 14, 409, 7223, 3697, 360, 635, 297, 283, 637, 358, 272, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 1725, 459, 14596, 530, 13, 4229, 14, 1652, 5156, 819, 768, 2068, 14, 785, 8, 4758, 14, 736, 12, 283, 2314, 297, 3158, 29, 807, 9, 523, 768, 2068, 14, 785, 8, 4758, 14, 5688, 12, 283, 1623, 2028, 1173, 297, 355, 3158, 29, 4758, 14, 5688, 14, 1623, 2028, 1173, 9, 523, 347, 19970, 8, 277, 12, 2342, 2028, 1173, 12, 6160, 304, 272, 6160, 14, 362, 14, 1107, 63, 585, 275, 488, 272, 2342, 2028, 1173, 14, 2441, 63, 5881, 275, 291, 14, 1725, 14, 362, 272, 2897, 14, 5688, 14, 3584, 342, 272, 543 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 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, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 504, 1331, 492, 1331, 199, 646, 747, 199, 646, 5145, 199, 504, 5228, 492, 5228, 199, 646, 984, 199, 646, 5549, 199, 646, 2882, 18, 465, 2882, 199, 646, 5377, 199, 199, 504, 1683, 492, 4420, 12, 3371, 199, 504, 5496, 63, 4435, 492, 2073, 63, 1501, 199, 504, 2748, 14, 11531, 14, 27098, 492, 7910, 292, 547, 199, 3, 21743, 440, 3451, 315, 2748, 859, 367, 2366, 18, 14, 22, 199, 893, 26, 272, 687, 2748, 14, 9464, 14, 15325, 492, 21743, 199, 2590, 3545, 26, 272, 687, 2748, 14, 11531, 14, 27098, 492, 7910, 292, 547, 465, 21743, 199, 199, 646, 26084, 199, 199, 646, 26084, 14, 4058, 14, 4758, 63, 4229, 465, 2897, 199, 199, 646, 2897, 63, 396, 4388, 199, 533, 11595, 7223, 774, 8, 2796, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 339, 340, 298, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 2, 315, 747, 14, 2314, 26, 489, 327, 5852, 652, 370, 1852, 3238, 4154, 315, 13, 4687, 2295, 7859, 1133, 24634, 1183, 489, 327, 15634, 543, 3503, 1584, 489, 2269, 46, 502, 14451, 8930, 3567, 275, 747, 14, 2314, 905, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 937, 489, 2150, 747, 14, 2314, 905, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 937, 489, 291, 14, 12808, 8, 736, 14, 2314, 14, 873, 12, 1993, 1211, 8, 46, 6166, 63, 28080, 63, 3103, 63, 3022, 29, 1753, 46, 502, 14451, 8930, 3567, 430, 339, 291, 14, 1725, 275, 1211, 342, 339, 3529, 3567, 275, 5549, 14, 11983, 342, 272, 291, 14, 12808, 8, 20938, 14, 9242, 12, 3529, 3567, 9, 2378, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 2791, 3567, 12, 283, 14596, 530, 13, 885, 14, 1652, 13, 2796, 659, 283, 87, 358, 465, 4090, 26, 489, 543, 1551, 8, 1927, 63, 1501, 3460, 354, 3108, 283, 2190, 15, 14596, 530, 13, 885, 14, 1652, 1333, 465, 10702, 26, 267, 4090, 14, 952, 8, 11416, 14, 739, 1012, 267, 291, 14, 1725, 459, 14596, 530, 13, 885, 14, 1652, 418, 275, 4090, 14, 354, 339, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 2791, 3567, 12, 283, 14596, 530, 13, 2124, 14, 1652, 13, 2796, 659, 283, 87, 358, 465, 4090, 26, 489, 543, 1551, 8, 1927, 63, 1501, 3460, 354, 3108, 283, 2190, 15, 14596, 530, 13, 2124, 14, 1652, 1333, 465, 10702, 26, 267, 4090, 14, 952, 8, 11416, 14, 739, 1012, 267, 291, 14, 1725, 459, 14596, 530, 13, 2124, 14, 1652, 418, 275, 4090, 14, 354, 339, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 2791, 3567, 12, 283, 14596, 530, 13, 4229, 14, 1652, 659, 283, 87, 358, 465, 4090, 26, 489, 543, 1551, 8, 1927, 63, 1501, 3460, 354, 3108, 283, 2190, 15, 14596, 530, 13, 4229, 14, 1652, 1333, 465, 10702, 26, 267, 4090, 14, 952, 8, 11416, 14, 739, 1012, 267, 291, 14, 1725, 459, 14596, 530, 13, 4229, 14, 1652, 418, 275, 4090, 14, 354, 339, 291, 14, 4229, 4098, 275, 283, 14596, 530, 14, 4229, 14, 5006, 7, 272, 291, 14, 4229, 1110, 275, 283, 7617, 7, 339, 2897, 14, 5688, 14, 3584, 342, 421, 819, 15779, 381, 523, 327, 8388, 11595, 6496, 523, 327, 377, 19657, 26, 5244, 1530, 2295, 3382, 2877, 2897, 63, 396, 1584, 523, 15779, 381, 819, 768, 2068, 14, 785, 8, 4758, 14, 736, 12, 283, 2314, 297, 3158, 29, 807, 9, 523, 768, 2068, 14, 785, 8, 4758, 14, 5688, 12, 283, 1623, 2028, 1173, 297, 355, 3158, 29, 4758, 14, 5688, 14, 1623, 2028, 1173, 9, 523, 347, 511, 7223, 1173, 10502, 8, 277, 12, 2342, 2028, 1173, 12, 6160, 304, 272, 6160, 855, 6095, 4343, 2441, 63, 5881, 275, 1211, 8, 489, 653, 6166, 63, 28080, 63, 3103, 63, 3022, 29, 736, 14, 515, 14, 3475, 8, 277, 14, 1725, 459, 14596, 530, 13, 4229, 14, 1652, 418, 4992, 362, 272, 6160, 14, 362, 14, 1107, 63, 585, 275, 488, 272, 2342, 2028, 1173, 14, 2441, 63, 5881, 275, 291, 14, 1725, 14, 362, 272, 2897, 14, 5688, 14, 3584, 342, 272, 2897, 14, 5688, 14, 409, 7223, 3697, 360, 635, 297, 283, 637, 358, 272, 291, 14, 1815, 8, 736, 14, 515, 14, 2444, 8, 277, 14, 1725, 459, 14596, 530, 13, 4229, 14, 1652, 5156, 819, 768, 2068, 14, 785, 8, 4758, 14, 736, 12, 283, 2314, 297, 3158, 29, 807, 9, 523, 768, 2068, 14, 785, 8, 4758, 14, 5688, 12, 283, 1623, 2028, 1173, 297, 355, 3158, 29, 4758, 14, 5688, 14, 1623, 2028, 1173, 9, 523, 347, 19970, 8, 277, 12, 2342, 2028, 1173, 12, 6160, 304, 272, 6160, 14, 362, 14, 1107, 63, 585, 275, 488, 272, 2342, 2028, 1173, 14, 2441, 63, 5881, 275, 291, 14, 1725, 14, 362, 272, 2897, 14, 5688, 14, 3584, 342, 272, 543, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jinnykoo/wuyisj.com
src/oscar/apps/dashboard/catalogue/forms.py
5
16311
from django import forms from django.core import exceptions from django.forms.models import inlineformset_factory from django.utils.translation import ugettext_lazy as _ from treebeard.forms import movenodeform_factory from oscar.core.loading import get_class, get_model from oscar.core.utils import slugify from oscar.forms.widgets import ImageInput Product = get_model('catalogue', 'Product') ProductClass = get_model('catalogue', 'ProductClass') ProductAttribute = get_model('catalogue', 'ProductAttribute') Category = get_model('catalogue', 'Category') StockRecord = get_model('partner', 'StockRecord') ProductCategory = get_model('catalogue', 'ProductCategory') ProductImage = get_model('catalogue', 'ProductImage') ProductRecommendation = get_model('catalogue', 'ProductRecommendation') ProductSelect = get_class('dashboard.catalogue.widgets', 'ProductSelect') CategoryForm = movenodeform_factory( Category, fields=['name', 'description', 'image']) class ProductClassSelectForm(forms.Form): """ Form which is used before creating a product to select it's product class """ product_class = forms.ModelChoiceField( label=_("Create a new product of type"), empty_label=_("-- Choose type --"), queryset=ProductClass.objects.all()) def __init__(self, *args, **kwargs): """ If there's only one product class, pre-select it """ super(ProductClassSelectForm, self).__init__(*args, **kwargs) qs = self.fields['product_class'].queryset if not kwargs.get('initial') and len(qs) == 1: self.fields['product_class'].initial = qs[0] class ProductSearchForm(forms.Form): upc = forms.CharField(max_length=16, required=False, label=_('UPC')) title = forms.CharField( max_length=255, required=False, label=_('Product title')) def clean(self): cleaned_data = super(ProductSearchForm, self).clean() cleaned_data['upc'] = cleaned_data['upc'].strip() cleaned_data['title'] = cleaned_data['title'].strip() return cleaned_data class StockRecordForm(forms.ModelForm): def __init__(self, product_class, user, *args, **kwargs): # The user kwarg is not used by stock StockRecordForm. We pass it # anyway in case one wishes to customise the partner queryset self.user = user super(StockRecordForm, self).__init__(*args, **kwargs) # If not tracking stock, we hide the fields if not product_class.track_stock: del self.fields['num_in_stock'] del self.fields['low_stock_threshold'] else: self.fields['price_excl_tax'].required = True self.fields['num_in_stock'].required = True class Meta: model = StockRecord fields = [ 'partner', 'partner_sku', 'price_currency', 'price_excl_tax', 'price_retail', 'cost_price', 'num_in_stock', 'low_stock_threshold', ] BaseStockRecordFormSet = inlineformset_factory( Product, StockRecord, form=StockRecordForm, extra=1) class StockRecordFormSet(BaseStockRecordFormSet): def __init__(self, product_class, user, *args, **kwargs): self.user = user self.require_user_stockrecord = not user.is_staff self.product_class = product_class super(StockRecordFormSet, self).__init__(*args, **kwargs) self.set_initial_data() def set_initial_data(self): """ If user has only one partner associated, set the first stock record's partner to it. Can't pre-select for staff users as they're allowed to save a product without a stock record. This is intentionally done after calling __init__ as passing initial data to __init__ creates a form for each list item. So depending on whether we can pre-select the partner or not, we'd end up with 1 or 2 forms for an unbound form. """ if self.require_user_stockrecord: try: user_partner = self.user.partners.get() except (exceptions.ObjectDoesNotExist, exceptions.MultipleObjectsReturned): pass else: partner_field = self.forms[0].fields.get('partner', None) if partner_field and partner_field.initial is None: partner_field.initial = user_partner def _construct_form(self, i, **kwargs): kwargs['product_class'] = self.product_class kwargs['user'] = self.user return super(StockRecordFormSet, self)._construct_form( i, **kwargs) def clean(self): """ If the user isn't a staff user, this validation ensures that at least one stock record's partner is associated with a users partners. """ if any(self.errors): return if self.require_user_stockrecord: stockrecord_partners = set([form.cleaned_data.get('partner', None) for form in self.forms]) user_partners = set(self.user.partners.all()) if not user_partners & stockrecord_partners: raise exceptions.ValidationError( _("At least one stock record must be set to a partner that" " you're associated with.")) def _attr_text_field(attribute): return forms.CharField(label=attribute.name, required=attribute.required) def _attr_textarea_field(attribute): return forms.CharField(label=attribute.name, widget=forms.Textarea(), required=attribute.required) def _attr_integer_field(attribute): return forms.IntegerField(label=attribute.name, required=attribute.required) def _attr_boolean_field(attribute): return forms.BooleanField(label=attribute.name, required=attribute.required) def _attr_float_field(attribute): return forms.FloatField(label=attribute.name, required=attribute.required) def _attr_date_field(attribute): return forms.DateField(label=attribute.name, required=attribute.required, widget=forms.widgets.DateInput) def _attr_option_field(attribute): return forms.ModelChoiceField( label=attribute.name, required=attribute.required, queryset=attribute.option_group.options.all()) def _attr_multi_option_field(attribute): return forms.ModelMultipleChoiceField( label=attribute.name, required=attribute.required, queryset=attribute.option_group.options.all()) def _attr_entity_field(attribute): # Product entities don't have out-of-the-box supported in the ProductForm. # There is no ModelChoiceField for generic foreign keys, and there's no # good default behaviour anyway; offering a choice of *all* model instances # is hardly useful. return None def _attr_numeric_field(attribute): return forms.FloatField(label=attribute.name, required=attribute.required) def _attr_file_field(attribute): return forms.FileField( label=attribute.name, required=attribute.required) def _attr_image_field(attribute): return forms.ImageField( label=attribute.name, required=attribute.required) class ProductForm(forms.ModelForm): FIELD_FACTORIES = { "text": _attr_text_field, "richtext": _attr_textarea_field, "integer": _attr_integer_field, "boolean": _attr_boolean_field, "float": _attr_float_field, "date": _attr_date_field, "option": _attr_option_field, "multi_option": _attr_multi_option_field, "entity": _attr_entity_field, "numeric": _attr_numeric_field, "file": _attr_file_field, "image": _attr_image_field, } class Meta: model = Product fields = [ 'title', 'upc', 'description', 'is_discountable', 'structure'] widgets = { 'structure': forms.HiddenInput() } def __init__(self, product_class, data=None, parent=None, *args, **kwargs): self.set_initial(product_class, parent, kwargs) super(ProductForm, self).__init__(data, *args, **kwargs) if parent: self.instance.parent = parent # We need to set the correct product structures explicitly to pass # attribute validation and child product validation. Note that # those changes are not persisted. self.instance.structure = Product.CHILD self.instance.parent.structure = Product.PARENT self.delete_non_child_fields() else: # Only set product class for non-child products self.instance.product_class = product_class self.add_attribute_fields(product_class, self.instance.is_parent) if 'title' in self.fields: self.fields['title'].widget = forms.TextInput( attrs={'autocomplete': 'off'}) def set_initial(self, product_class, parent, kwargs): """ Set initial data for the form. Sets the correct product structure and fetches initial values for the dynamically constructed attribute fields. """ if 'initial' not in kwargs: kwargs['initial'] = {} self.set_initial_attribute_values(product_class, kwargs) if parent: kwargs['initial']['structure'] = Product.CHILD def set_initial_attribute_values(self, product_class, kwargs): """ Update the kwargs['initial'] value to have the initial values based on the product instance's attributes """ instance = kwargs.get('instance') if instance is None: return for attribute in product_class.attributes.all(): try: value = instance.attribute_values.get( attribute=attribute).value except exceptions.ObjectDoesNotExist: pass else: kwargs['initial']['attr_%s' % attribute.code] = value def add_attribute_fields(self, product_class, is_parent=False): """ For each attribute specified by the product class, this method dynamically adds form fields to the product form. """ for attribute in product_class.attributes.all(): field = self.get_attribute_field(attribute) if field: self.fields['attr_%s' % attribute.code] = field # Attributes are not required for a parent product if is_parent: self.fields['attr_%s' % attribute.code].required = False def get_attribute_field(self, attribute): """ Gets the correct form field for a given attribute type. """ return self.FIELD_FACTORIES[attribute.type](attribute) def delete_non_child_fields(self): """ Deletes any fields not needed for child products. Override this if you want to e.g. keep the description field. """ for field_name in ['description', 'is_discountable']: if field_name in self.fields: del self.fields[field_name] def _post_clean(self): """ Set attributes before ModelForm calls the product's clean method (which it does in _post_clean), which in turn validates attributes. """ product_class = self.instance.get_product_class() for attribute in product_class.attributes.all(): field_name = 'attr_%s' % attribute.code # An empty text field won't show up in cleaned_data. if field_name in self.cleaned_data: value = self.cleaned_data[field_name] setattr(self.instance.attr, attribute.code, value) super(ProductForm, self)._post_clean() class StockAlertSearchForm(forms.Form): status = forms.CharField(label=_('Status')) class ProductCategoryForm(forms.ModelForm): class Meta: model = ProductCategory fields = ('category', ) BaseProductCategoryFormSet = inlineformset_factory( Product, ProductCategory, form=ProductCategoryForm, extra=1, can_delete=True) class ProductCategoryFormSet(BaseProductCategoryFormSet): def __init__(self, product_class, user, *args, **kwargs): # This function just exists to drop the extra arguments super(ProductCategoryFormSet, self).__init__(*args, **kwargs) def clean(self): if not self.instance.is_child and self.get_num_categories() == 0: raise forms.ValidationError( _("Stand-alone and parent products " "must have at least one category")) if self.instance.is_child and self.get_num_categories() > 0: raise forms.ValidationError( _("A child product should not have categories")) def get_num_categories(self): num_categories = 0 for i in range(0, self.total_form_count()): form = self.forms[i] if (hasattr(form, 'cleaned_data') and form.cleaned_data.get('category', None) and not form.cleaned_data.get('DELETE', False)): num_categories += 1 return num_categories class ProductImageForm(forms.ModelForm): class Meta: model = ProductImage fields = ['product', 'original', 'caption'] # use ImageInput widget to create HTML displaying the # actual uploaded image and providing the upload dialog # when clicking on the actual image. widgets = { 'original': ImageInput(), } def save(self, *args, **kwargs): # We infer the display order of the image based on the order of the # image fields within the formset. kwargs['commit'] = False obj = super(ProductImageForm, self).save(*args, **kwargs) obj.display_order = self.get_display_order() obj.save() return obj def get_display_order(self): return self.prefix.split('-').pop() BaseProductImageFormSet = inlineformset_factory( Product, ProductImage, form=ProductImageForm, extra=2) class ProductImageFormSet(BaseProductImageFormSet): def __init__(self, product_class, user, *args, **kwargs): super(ProductImageFormSet, self).__init__(*args, **kwargs) class ProductRecommendationForm(forms.ModelForm): class Meta: model = ProductRecommendation fields = ['primary', 'recommendation', 'ranking'] widgets = { 'recommendation': ProductSelect, } BaseProductRecommendationFormSet = inlineformset_factory( Product, ProductRecommendation, form=ProductRecommendationForm, extra=5, fk_name="primary") class ProductRecommendationFormSet(BaseProductRecommendationFormSet): def __init__(self, product_class, user, *args, **kwargs): super(ProductRecommendationFormSet, self).__init__(*args, **kwargs) class ProductClassForm(forms.ModelForm): class Meta: model = ProductClass fields = ['name', 'requires_shipping', 'track_stock', 'options'] class ProductAttributesForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ProductAttributesForm, self).__init__(*args, **kwargs) # because we'll allow submission of the form with blank # codes so that we can generate them. self.fields["code"].required = False self.fields["option_group"].help_text = _("Select an option group") def clean_code(self): code = self.cleaned_data.get("code") title = self.cleaned_data.get("name") if not code and title: code = slugify(title) return code class Meta: model = ProductAttribute fields = ["name", "code", "type", "option_group", "required"] ProductAttributesFormSet = inlineformset_factory(ProductClass, ProductAttribute, form=ProductAttributesForm, extra=3)
bsd-3-clause
[ 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 492, 4967, 199, 504, 1639, 14, 3351, 14, 992, 492, 8308, 10724, 63, 3702, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 3123, 15283, 14, 3351, 492, 1303, 1856, 79, 318, 1025, 63, 3702, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 533, 12, 664, 63, 1238, 199, 504, 312, 22707, 14, 1018, 14, 1208, 492, 29864, 199, 504, 312, 22707, 14, 3351, 14, 8583, 492, 6047, 3205, 199, 199, 5884, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 358, 199, 5884, 2543, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 2543, 358, 199, 5884, 1646, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 1646, 358, 199, 7841, 275, 664, 63, 1238, 360, 22330, 297, 283, 7841, 358, 199, 17103, 5433, 275, 664, 63, 1238, 360, 3899, 297, 283, 17103, 5433, 358, 199, 5884, 7841, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 7841, 358, 199, 5884, 3491, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 3491, 358, 199, 5884, 497, 22105, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 497, 22105, 358, 199, 5884, 5446, 275, 664, 63, 533, 360, 9743, 14, 22330, 14, 8583, 297, 283, 5884, 5446, 358, 199, 199, 7841, 2821, 275, 1303, 1856, 79, 318, 1025, 63, 3702, 8, 272, 13573, 12, 272, 1504, 2968, 354, 297, 283, 1802, 297, 283, 1569, 1105, 421, 199, 533, 12705, 2543, 5446, 2821, 8, 3351, 14, 2821, 304, 272, 408, 272, 8204, 1314, 365, 1202, 2544, 6425, 282, 3336, 370, 3504, 652, 1159, 3336, 1021, 272, 408, 339, 3336, 63, 533, 275, 4513, 14, 1685, 15792, 8, 267, 1768, 9384, 2499, 282, 892, 3336, 402, 730, 1288, 267, 2701, 63, 1302, 3699, 6739, 29826, 730, 1553, 1288, 267, 7594, 29, 5884, 2543, 14, 1462, 14, 452, 1012, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 982, 2337, 1159, 1454, 1373, 3336, 1021, 12, 876, 13, 2416, 652, 267, 408, 267, 1613, 8, 5884, 2543, 5446, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 6377, 275, 291, 14, 955, 459, 2558, 63, 533, 2278, 7924, 267, 340, 440, 2074, 14, 362, 360, 2747, 358, 436, 822, 8, 6177, 9, 508, 413, 26, 288, 291, 14, 955, 459, 2558, 63, 533, 2278, 2747, 275, 6377, 59, 16, 61, 421, 199, 533, 12705, 5278, 2821, 8, 3351, 14, 2821, 304, 272, 1536, 67, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 975, 12, 1415, 29, 797, 12, 1768, 12397, 2160, 35, 1333, 272, 2538, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 1415, 29, 797, 12, 1768, 12397, 5884, 2538, 1333, 339, 347, 3633, 8, 277, 304, 267, 12364, 63, 576, 275, 1613, 8, 5884, 5278, 2821, 12, 291, 680, 3118, 342, 267, 12364, 63, 576, 459, 384, 67, 418, 275, 12364, 63, 576, 459, 384, 67, 2278, 1913, 342, 267, 12364, 63, 576, 459, 1213, 418, 275, 12364, 63, 576, 459, 1213, 2278, 1913, 342, 267, 372, 12364, 63, 576, 421, 199, 533, 28406, 5433, 2821, 8, 3351, 14, 15937, 304, 339, 347, 636, 826, 721, 277, 12, 3336, 63, 533, 12, 922, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 710, 922, 17582, 365, 440, 1202, 701, 10952, 28406, 5433, 2821, 14, 2136, 986, 652, 267, 327, 15988, 315, 1930, 1373, 13809, 397, 370, 3537, 572, 314, 5854, 7594, 267, 291, 14, 751, 275, 922, 267, 1613, 8, 17103, 5433, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 327, 982, 440, 15161, 10952, 12, 781, 13714, 314, 1504, 267, 340, 440, 3336, 63, 533, 14, 3885, 63, 6088, 26, 288, 2150, 291, 14, 955, 459, 1507, 63, 262, 63, 6088, 418, 288, 2150, 291, 14, 955, 459, 674, 63, 6088, 63, 7227, 418, 267, 587, 26, 288, 291, 14, 955, 459, 4777, 63, 476, 429, 63, 5530, 2278, 2427, 275, 715, 288, 291, 14, 955, 459, 1507, 63, 262, 63, 6088, 2278, 2427, 275, 715, 339, 1021, 6288, 26, 267, 1402, 275, 28406, 5433, 267, 1504, 275, 359, 288, 283, 3899, 297, 283, 3899, 63, 27772, 297, 288, 283, 4777, 63, 4968, 297, 283, 4777, 63, 476, 429, 63, 5530, 297, 283, 4777, 63, 264, 1521, 297, 283, 6336, 63, 4777, 297, 288, 283, 1507, 63, 262, 63, 6088, 297, 283, 674, 63, 6088, 63, 7227, 297, 267, 1622, 421, 199, 1563, 17103, 5433, 14736, 275, 8308, 10724, 63, 3702, 8, 272, 12705, 12, 28406, 5433, 12, 1824, 29, 17103, 5433, 2821, 12, 2402, 29, 17, 9, 421, 199, 533, 28406, 5433, 14736, 8, 1563, 17103, 5433, 14736, 304, 339, 347, 636, 826, 721, 277, 12, 3336, 63, 533, 12, 922, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 751, 275, 922, 267, 291, 14, 4365, 63, 751, 63, 6088, 3059, 275, 440, 922, 14, 374, 63, 7018, 267, 291, 14, 2558, 63, 533, 275, 3336, 63, 533, 267, 1613, 8, 17103, 5433, 14736, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 409, 63, 2747, 63, 576, 342, 339, 347, 663, 63, 2747, 63, 576, 8, 277, 304, 267, 408, 267, 982, 922, 965, 1454, 1373, 5854, 4568, 12, 663, 314, 1642, 267, 10952, 2777, 1159, 5854, 370, 652, 14, 6855, 1133, 876, 13, 2416, 367, 12622, 4390, 465, 267, 2985, 3984, 4370, 370, 3354, 282, 3336, 1928, 282, 10952, 2777, 14, 398, 961, 365, 32005, 4224, 2410, 6358, 636, 826, 363, 465, 9476, 2536, 267, 666, 370, 636, 826, 363, 8491, 282, 1824, 367, 1924, 769, 1242, 14, 2002, 10298, 641, 267, 3775, 781, 883, 876, 13, 2416, 314, 5854, 503, 440, 12, 781, 5121, 1284, 1536, 543, 413, 503, 499, 267, 4513, 367, 376, 22334, 1824, 14, 267, 408, 267, 340, 291, 14, 4365, 63, 751, 63, 6088, 3059, 26, 288, 862, 26, 355, 922, 63, 3899, 275, 291, 14, 751, 14, 23385, 14, 362, 342, 288, 871, 334, 3924, 14, 1692, 7400, 12, 490, 4967, 14, 8433, 11188, 28239, 304, 355, 986, 288, 587, 26 ]
[ 1639, 492, 4513, 199, 504, 1639, 14, 1018, 492, 4967, 199, 504, 1639, 14, 3351, 14, 992, 492, 8308, 10724, 63, 3702, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 3123, 15283, 14, 3351, 492, 1303, 1856, 79, 318, 1025, 63, 3702, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 533, 12, 664, 63, 1238, 199, 504, 312, 22707, 14, 1018, 14, 1208, 492, 29864, 199, 504, 312, 22707, 14, 3351, 14, 8583, 492, 6047, 3205, 199, 199, 5884, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 358, 199, 5884, 2543, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 2543, 358, 199, 5884, 1646, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 1646, 358, 199, 7841, 275, 664, 63, 1238, 360, 22330, 297, 283, 7841, 358, 199, 17103, 5433, 275, 664, 63, 1238, 360, 3899, 297, 283, 17103, 5433, 358, 199, 5884, 7841, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 7841, 358, 199, 5884, 3491, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 3491, 358, 199, 5884, 497, 22105, 275, 664, 63, 1238, 360, 22330, 297, 283, 5884, 497, 22105, 358, 199, 5884, 5446, 275, 664, 63, 533, 360, 9743, 14, 22330, 14, 8583, 297, 283, 5884, 5446, 358, 199, 199, 7841, 2821, 275, 1303, 1856, 79, 318, 1025, 63, 3702, 8, 272, 13573, 12, 272, 1504, 2968, 354, 297, 283, 1802, 297, 283, 1569, 1105, 421, 199, 533, 12705, 2543, 5446, 2821, 8, 3351, 14, 2821, 304, 272, 408, 272, 8204, 1314, 365, 1202, 2544, 6425, 282, 3336, 370, 3504, 652, 1159, 3336, 1021, 272, 408, 339, 3336, 63, 533, 275, 4513, 14, 1685, 15792, 8, 267, 1768, 9384, 2499, 282, 892, 3336, 402, 730, 1288, 267, 2701, 63, 1302, 3699, 6739, 29826, 730, 1553, 1288, 267, 7594, 29, 5884, 2543, 14, 1462, 14, 452, 1012, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 982, 2337, 1159, 1454, 1373, 3336, 1021, 12, 876, 13, 2416, 652, 267, 408, 267, 1613, 8, 5884, 2543, 5446, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 6377, 275, 291, 14, 955, 459, 2558, 63, 533, 2278, 7924, 267, 340, 440, 2074, 14, 362, 360, 2747, 358, 436, 822, 8, 6177, 9, 508, 413, 26, 288, 291, 14, 955, 459, 2558, 63, 533, 2278, 2747, 275, 6377, 59, 16, 61, 421, 199, 533, 12705, 5278, 2821, 8, 3351, 14, 2821, 304, 272, 1536, 67, 275, 4513, 14, 2183, 8, 988, 63, 1267, 29, 975, 12, 1415, 29, 797, 12, 1768, 12397, 2160, 35, 1333, 272, 2538, 275, 4513, 14, 2183, 8, 267, 1390, 63, 1267, 29, 2299, 12, 1415, 29, 797, 12, 1768, 12397, 5884, 2538, 1333, 339, 347, 3633, 8, 277, 304, 267, 12364, 63, 576, 275, 1613, 8, 5884, 5278, 2821, 12, 291, 680, 3118, 342, 267, 12364, 63, 576, 459, 384, 67, 418, 275, 12364, 63, 576, 459, 384, 67, 2278, 1913, 342, 267, 12364, 63, 576, 459, 1213, 418, 275, 12364, 63, 576, 459, 1213, 2278, 1913, 342, 267, 372, 12364, 63, 576, 421, 199, 533, 28406, 5433, 2821, 8, 3351, 14, 15937, 304, 339, 347, 636, 826, 721, 277, 12, 3336, 63, 533, 12, 922, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 710, 922, 17582, 365, 440, 1202, 701, 10952, 28406, 5433, 2821, 14, 2136, 986, 652, 267, 327, 15988, 315, 1930, 1373, 13809, 397, 370, 3537, 572, 314, 5854, 7594, 267, 291, 14, 751, 275, 922, 267, 1613, 8, 17103, 5433, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 327, 982, 440, 15161, 10952, 12, 781, 13714, 314, 1504, 267, 340, 440, 3336, 63, 533, 14, 3885, 63, 6088, 26, 288, 2150, 291, 14, 955, 459, 1507, 63, 262, 63, 6088, 418, 288, 2150, 291, 14, 955, 459, 674, 63, 6088, 63, 7227, 418, 267, 587, 26, 288, 291, 14, 955, 459, 4777, 63, 476, 429, 63, 5530, 2278, 2427, 275, 715, 288, 291, 14, 955, 459, 1507, 63, 262, 63, 6088, 2278, 2427, 275, 715, 339, 1021, 6288, 26, 267, 1402, 275, 28406, 5433, 267, 1504, 275, 359, 288, 283, 3899, 297, 283, 3899, 63, 27772, 297, 288, 283, 4777, 63, 4968, 297, 283, 4777, 63, 476, 429, 63, 5530, 297, 283, 4777, 63, 264, 1521, 297, 283, 6336, 63, 4777, 297, 288, 283, 1507, 63, 262, 63, 6088, 297, 283, 674, 63, 6088, 63, 7227, 297, 267, 1622, 421, 199, 1563, 17103, 5433, 14736, 275, 8308, 10724, 63, 3702, 8, 272, 12705, 12, 28406, 5433, 12, 1824, 29, 17103, 5433, 2821, 12, 2402, 29, 17, 9, 421, 199, 533, 28406, 5433, 14736, 8, 1563, 17103, 5433, 14736, 304, 339, 347, 636, 826, 721, 277, 12, 3336, 63, 533, 12, 922, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 751, 275, 922, 267, 291, 14, 4365, 63, 751, 63, 6088, 3059, 275, 440, 922, 14, 374, 63, 7018, 267, 291, 14, 2558, 63, 533, 275, 3336, 63, 533, 267, 1613, 8, 17103, 5433, 14736, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 409, 63, 2747, 63, 576, 342, 339, 347, 663, 63, 2747, 63, 576, 8, 277, 304, 267, 408, 267, 982, 922, 965, 1454, 1373, 5854, 4568, 12, 663, 314, 1642, 267, 10952, 2777, 1159, 5854, 370, 652, 14, 6855, 1133, 876, 13, 2416, 367, 12622, 4390, 465, 267, 2985, 3984, 4370, 370, 3354, 282, 3336, 1928, 282, 10952, 2777, 14, 398, 961, 365, 32005, 4224, 2410, 6358, 636, 826, 363, 465, 9476, 2536, 267, 666, 370, 636, 826, 363, 8491, 282, 1824, 367, 1924, 769, 1242, 14, 2002, 10298, 641, 267, 3775, 781, 883, 876, 13, 2416, 314, 5854, 503, 440, 12, 781, 5121, 1284, 1536, 543, 413, 503, 499, 267, 4513, 367, 376, 22334, 1824, 14, 267, 408, 267, 340, 291, 14, 4365, 63, 751, 63, 6088, 3059, 26, 288, 862, 26, 355, 922, 63, 3899, 275, 291, 14, 751, 14, 23385, 14, 362, 342, 288, 871, 334, 3924, 14, 1692, 7400, 12, 490, 4967, 14, 8433, 11188, 28239, 304, 355, 986, 288, 587, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
aninternetof/bremen
bremenenv/lib/python3.5/site-packages/pip/_vendor/__init__.py
329
4670
""" pip._vendor is for vendoring dependencies of pip to prevent needing pip to depend on something external. Files inside of pip._vendor should be considered immutable and should only be updated to versions from upstream. """ from __future__ import absolute_import import glob import os.path import sys # Downstream redistributors which have debundled our dependencies should also # patch this value to be true. This will trigger the additional patching # to cause things like "six" to be available as pip. DEBUNDLED = False # By default, look in this directory for a bunch of .whl files which we will # add to the beginning of sys.path before attempting to import anything. This # is done to support downstream re-distributors like Debian and Fedora who # wish to create their own Wheels for our dependencies to aid in debundling. WHEEL_DIR = os.path.abspath(os.path.dirname(__file__)) # Define a small helper function to alias our vendored modules to the real ones # if the vendored ones do not exist. This idea of this was taken from # https://github.com/kennethreitz/requests/pull/2567. def vendored(modulename): vendored_name = "{0}.{1}".format(__name__, modulename) try: __import__(vendored_name, globals(), locals(), level=0) except ImportError: try: __import__(modulename, globals(), locals(), level=0) except ImportError: # We can just silently allow import failures to pass here. If we # got to this point it means that ``import pip._vendor.whatever`` # failed and so did ``import whatever``. Since we're importing this # upfront in an attempt to alias imports, not erroring here will # just mean we get a regular import error whenever pip *actually* # tries to import one of these modules to use it, which actually # gives us a better error message than we would have otherwise # gotten. pass else: sys.modules[vendored_name] = sys.modules[modulename] base, head = vendored_name.rsplit(".", 1) setattr(sys.modules[base], head, sys.modules[modulename]) # If we're operating in a debundled setup, then we want to go ahead and trigger # the aliasing of our vendored libraries as well as looking for wheels to add # to our sys.path. This will cause all of this code to be a no-op typically # however downstream redistributors can enable it in a consistent way across # all platforms. if DEBUNDLED: # Actually look inside of WHEEL_DIR to find .whl files and add them to the # front of our sys.path. sys.path[:] = glob.glob(os.path.join(WHEEL_DIR, "*.whl")) + sys.path # Actually alias all of our vendored dependencies. vendored("cachecontrol") vendored("colorama") vendored("distlib") vendored("distro") vendored("html5lib") vendored("lockfile") vendored("six") vendored("six.moves") vendored("six.moves.urllib") vendored("packaging") vendored("packaging.version") vendored("packaging.specifiers") vendored("pkg_resources") vendored("progress") vendored("retrying") vendored("requests") vendored("requests.packages") vendored("requests.packages.urllib3") vendored("requests.packages.urllib3._collections") vendored("requests.packages.urllib3.connection") vendored("requests.packages.urllib3.connectionpool") vendored("requests.packages.urllib3.contrib") vendored("requests.packages.urllib3.contrib.ntlmpool") vendored("requests.packages.urllib3.contrib.pyopenssl") vendored("requests.packages.urllib3.exceptions") vendored("requests.packages.urllib3.fields") vendored("requests.packages.urllib3.filepost") vendored("requests.packages.urllib3.packages") vendored("requests.packages.urllib3.packages.ordered_dict") vendored("requests.packages.urllib3.packages.six") vendored("requests.packages.urllib3.packages.ssl_match_hostname") vendored("requests.packages.urllib3.packages.ssl_match_hostname." "_implementation") vendored("requests.packages.urllib3.poolmanager") vendored("requests.packages.urllib3.request") vendored("requests.packages.urllib3.response") vendored("requests.packages.urllib3.util") vendored("requests.packages.urllib3.util.connection") vendored("requests.packages.urllib3.util.request") vendored("requests.packages.urllib3.util.response") vendored("requests.packages.urllib3.util.retry") vendored("requests.packages.urllib3.util.ssl_") vendored("requests.packages.urllib3.util.timeout") vendored("requests.packages.urllib3.util.url")
mit
[ 624, 199, 9983, 423, 9884, 365, 367, 373, 500, 6854, 5124, 402, 7305, 370, 7981, 1929, 316, 7305, 370, 199, 26434, 641, 6020, 5957, 14, 199, 199, 5535, 6272, 402, 7305, 423, 9884, 1077, 506, 8652, 17092, 436, 1077, 1454, 506, 199, 5334, 370, 5459, 687, 18932, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 5739, 199, 646, 747, 14, 515, 199, 646, 984, 199, 199, 3, 13392, 1745, 295, 20231, 6622, 1314, 1172, 32610, 725, 1146, 4154, 5124, 1077, 2597, 199, 3, 3371, 642, 574, 370, 506, 2549, 14, 961, 911, 6804, 314, 4722, 3371, 316, 199, 3, 370, 7675, 7645, 2839, 298, 4174, 2, 370, 506, 2808, 465, 7305, 14, 199, 1093, 32044, 5290, 275, 756, 199, 199, 3, 4885, 849, 12, 3648, 315, 642, 2082, 367, 282, 22219, 402, 1275, 2191, 76, 1584, 1314, 781, 911, 199, 3, 1050, 370, 314, 9608, 402, 984, 14, 515, 2544, 19595, 370, 492, 7003, 14, 961, 199, 3, 365, 4224, 370, 2291, 3224, 1745, 295, 13, 20231, 6622, 2839, 30445, 436, 481, 379, 11131, 3963, 199, 3, 13809, 370, 1218, 3932, 5705, 26161, 83, 367, 4154, 5124, 370, 23939, 315, 32610, 725, 2983, 14, 199, 31588, 2901, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 421, 199, 3, 13930, 282, 7425, 5922, 805, 370, 5162, 4154, 373, 500, 2908, 4621, 370, 314, 3363, 7869, 199, 3, 340, 314, 373, 500, 2908, 7869, 886, 440, 2187, 14, 961, 16819, 402, 642, 1990, 9394, 687, 199, 3, 4178, 921, 5031, 14, 957, 15, 917, 685, 273, 264, 23751, 15, 6615, 15, 9302, 15, 821, 1822, 14, 199, 318, 373, 500, 2908, 8, 22582, 304, 272, 373, 500, 2908, 63, 354, 275, 5310, 16, 26944, 17, 5469, 908, 3460, 354, 3108, 30045, 9, 339, 862, 26, 267, 636, 646, 721, 86, 500, 2908, 63, 354, 12, 7992, 1062, 9480, 1062, 2166, 29, 16, 9, 272, 871, 3545, 26, 267, 862, 26, 288, 636, 646, 721, 22582, 12, 7992, 1062, 9480, 1062, 2166, 29, 16, 9, 267, 871, 3545, 26, 288, 327, 2136, 883, 2951, 18030, 2040, 492, 9081, 370, 986, 2348, 14, 982, 781, 288, 327, 4788, 370, 642, 2376, 652, 4910, 626, 1124, 646, 7305, 423, 9884, 14, 26517, 1040, 288, 327, 3405, 436, 880, 8103, 1124, 646, 15685, 4345, 9336, 781, 3984, 16306, 642, 288, 327, 1536, 14708, 315, 376, 7427, 370, 5162, 8925, 12, 440, 1125, 316, 2348, 911, 288, 327, 2951, 4615, 781, 664, 282, 5578, 492, 1125, 18119, 7305, 627, 2442, 3163, 10, 288, 327, 11275, 370, 492, 1373, 402, 3520, 4621, 370, 675, 652, 12, 1314, 5965, 288, 327, 10557, 2739, 282, 8034, 1125, 1245, 2419, 781, 3955, 1172, 4257, 288, 327, 4788, 724, 14, 288, 986, 267, 587, 26, 288, 984, 14, 3112, 59, 86, 500, 2908, 63, 354, 61, 275, 984, 14, 3112, 59, 22582, 61, 288, 1300, 12, 4854, 275, 373, 500, 2908, 63, 354, 14, 13490, 30381, 413, 9, 288, 5371, 8, 1274, 14, 3112, 59, 1095, 467, 4854, 12, 984, 14, 3112, 59, 22582, 566, 421, 199, 3, 982, 781, 3984, 17406, 315, 282, 32610, 725, 1146, 3272, 12, 2066, 781, 2934, 370, 2621, 23417, 436, 6804, 199, 3, 314, 5162, 316, 402, 4154, 373, 500, 2908, 8363, 465, 5521, 465, 10023, 367, 28300, 370, 1050, 199, 3, 370, 4154, 984, 14, 515, 14, 961, 911, 7675, 1006, 402, 642, 1233, 370, 506, 282, 949, 13, 411, 13609, 199, 3, 13432, 3224, 1745, 295, 20231, 6622, 883, 4756, 652, 315, 282, 12137, 4340, 9371, 199, 3, 1006, 10677, 14, 199, 692, 3265, 32044, 5290, 26, 272, 327, 18982, 3163, 3648, 6272, 402, 644, 1645, 2901, 63, 3022, 370, 2342, 1275, 2191, 76, 1584, 436, 1050, 3062, 370, 314, 272, 327, 13738, 402, 4154, 984, 14, 515, 14, 272, 984, 14, 515, 5873, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 31588, 2901, 63, 3022, 12, 298, 4856, 2191, 76, 2237, 435, 984, 14, 515, 339, 327, 18982, 3163, 5162, 1006, 402, 4154, 373, 500, 2908, 5124, 14, 272, 373, 500, 2908, 480, 1637, 2785, 531, 272, 373, 500, 2908, 480, 2326, 14541, 531, 272, 373, 500, 2908, 480, 2686, 773, 531, 272, 373, 500, 2908, 480, 18371, 531, 272, 373, 500, 2908, 480, 1360, 21, 773, 531, 272, 373, 500, 2908, 480, 26204, 531, 272, 373, 500, 2908, 480, 4174, 531, 272, 373, 500, 2908, 480, 4174, 14, 4912, 531, 272, 373, 500, 2908, 480, 4174, 14, 4912, 14, 4078, 531, 272, 373, 500, 2908, 480, 27796, 531, 272, 373, 500, 2908, 480, 27796, 14, 1023, 531, 272, 373, 500, 2908, 480, 27796, 14, 31659, 531, 272, 373, 500, 2908, 480, 4600, 63, 4435, 531, 272, 373, 500, 2908, 480, 5734, 531, 272, 373, 500, 2908, 480, 7154, 316, 531, 272, 373, 500, 2908, 480, 6615, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 423, 7882, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2105, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2105, 2293, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2828, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2828, 14, 21264, 18205, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2828, 14, 647, 14837, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 3924, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 955, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 493, 1932, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 5154, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 5154, 14, 8235, 63, 807, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 5154, 14, 4174, 531, 272, 373, 500, 2908, 480, 6615, 14 ]
[ 199, 9983, 423, 9884, 365, 367, 373, 500, 6854, 5124, 402, 7305, 370, 7981, 1929, 316, 7305, 370, 199, 26434, 641, 6020, 5957, 14, 199, 199, 5535, 6272, 402, 7305, 423, 9884, 1077, 506, 8652, 17092, 436, 1077, 1454, 506, 199, 5334, 370, 5459, 687, 18932, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 5739, 199, 646, 747, 14, 515, 199, 646, 984, 199, 199, 3, 13392, 1745, 295, 20231, 6622, 1314, 1172, 32610, 725, 1146, 4154, 5124, 1077, 2597, 199, 3, 3371, 642, 574, 370, 506, 2549, 14, 961, 911, 6804, 314, 4722, 3371, 316, 199, 3, 370, 7675, 7645, 2839, 298, 4174, 2, 370, 506, 2808, 465, 7305, 14, 199, 1093, 32044, 5290, 275, 756, 199, 199, 3, 4885, 849, 12, 3648, 315, 642, 2082, 367, 282, 22219, 402, 1275, 2191, 76, 1584, 1314, 781, 911, 199, 3, 1050, 370, 314, 9608, 402, 984, 14, 515, 2544, 19595, 370, 492, 7003, 14, 961, 199, 3, 365, 4224, 370, 2291, 3224, 1745, 295, 13, 20231, 6622, 2839, 30445, 436, 481, 379, 11131, 3963, 199, 3, 13809, 370, 1218, 3932, 5705, 26161, 83, 367, 4154, 5124, 370, 23939, 315, 32610, 725, 2983, 14, 199, 31588, 2901, 63, 3022, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 421, 199, 3, 13930, 282, 7425, 5922, 805, 370, 5162, 4154, 373, 500, 2908, 4621, 370, 314, 3363, 7869, 199, 3, 340, 314, 373, 500, 2908, 7869, 886, 440, 2187, 14, 961, 16819, 402, 642, 1990, 9394, 687, 199, 3, 4178, 921, 5031, 14, 957, 15, 917, 685, 273, 264, 23751, 15, 6615, 15, 9302, 15, 821, 1822, 14, 199, 318, 373, 500, 2908, 8, 22582, 304, 272, 373, 500, 2908, 63, 354, 275, 5310, 16, 26944, 17, 5469, 908, 3460, 354, 3108, 30045, 9, 339, 862, 26, 267, 636, 646, 721, 86, 500, 2908, 63, 354, 12, 7992, 1062, 9480, 1062, 2166, 29, 16, 9, 272, 871, 3545, 26, 267, 862, 26, 288, 636, 646, 721, 22582, 12, 7992, 1062, 9480, 1062, 2166, 29, 16, 9, 267, 871, 3545, 26, 288, 327, 2136, 883, 2951, 18030, 2040, 492, 9081, 370, 986, 2348, 14, 982, 781, 288, 327, 4788, 370, 642, 2376, 652, 4910, 626, 1124, 646, 7305, 423, 9884, 14, 26517, 1040, 288, 327, 3405, 436, 880, 8103, 1124, 646, 15685, 4345, 9336, 781, 3984, 16306, 642, 288, 327, 1536, 14708, 315, 376, 7427, 370, 5162, 8925, 12, 440, 1125, 316, 2348, 911, 288, 327, 2951, 4615, 781, 664, 282, 5578, 492, 1125, 18119, 7305, 627, 2442, 3163, 10, 288, 327, 11275, 370, 492, 1373, 402, 3520, 4621, 370, 675, 652, 12, 1314, 5965, 288, 327, 10557, 2739, 282, 8034, 1125, 1245, 2419, 781, 3955, 1172, 4257, 288, 327, 4788, 724, 14, 288, 986, 267, 587, 26, 288, 984, 14, 3112, 59, 86, 500, 2908, 63, 354, 61, 275, 984, 14, 3112, 59, 22582, 61, 288, 1300, 12, 4854, 275, 373, 500, 2908, 63, 354, 14, 13490, 30381, 413, 9, 288, 5371, 8, 1274, 14, 3112, 59, 1095, 467, 4854, 12, 984, 14, 3112, 59, 22582, 566, 421, 199, 3, 982, 781, 3984, 17406, 315, 282, 32610, 725, 1146, 3272, 12, 2066, 781, 2934, 370, 2621, 23417, 436, 6804, 199, 3, 314, 5162, 316, 402, 4154, 373, 500, 2908, 8363, 465, 5521, 465, 10023, 367, 28300, 370, 1050, 199, 3, 370, 4154, 984, 14, 515, 14, 961, 911, 7675, 1006, 402, 642, 1233, 370, 506, 282, 949, 13, 411, 13609, 199, 3, 13432, 3224, 1745, 295, 20231, 6622, 883, 4756, 652, 315, 282, 12137, 4340, 9371, 199, 3, 1006, 10677, 14, 199, 692, 3265, 32044, 5290, 26, 272, 327, 18982, 3163, 3648, 6272, 402, 644, 1645, 2901, 63, 3022, 370, 2342, 1275, 2191, 76, 1584, 436, 1050, 3062, 370, 314, 272, 327, 13738, 402, 4154, 984, 14, 515, 14, 272, 984, 14, 515, 5873, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 31588, 2901, 63, 3022, 12, 298, 4856, 2191, 76, 2237, 435, 984, 14, 515, 339, 327, 18982, 3163, 5162, 1006, 402, 4154, 373, 500, 2908, 5124, 14, 272, 373, 500, 2908, 480, 1637, 2785, 531, 272, 373, 500, 2908, 480, 2326, 14541, 531, 272, 373, 500, 2908, 480, 2686, 773, 531, 272, 373, 500, 2908, 480, 18371, 531, 272, 373, 500, 2908, 480, 1360, 21, 773, 531, 272, 373, 500, 2908, 480, 26204, 531, 272, 373, 500, 2908, 480, 4174, 531, 272, 373, 500, 2908, 480, 4174, 14, 4912, 531, 272, 373, 500, 2908, 480, 4174, 14, 4912, 14, 4078, 531, 272, 373, 500, 2908, 480, 27796, 531, 272, 373, 500, 2908, 480, 27796, 14, 1023, 531, 272, 373, 500, 2908, 480, 27796, 14, 31659, 531, 272, 373, 500, 2908, 480, 4600, 63, 4435, 531, 272, 373, 500, 2908, 480, 5734, 531, 272, 373, 500, 2908, 480, 7154, 316, 531, 272, 373, 500, 2908, 480, 6615, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 423, 7882, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2105, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2105, 2293, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2828, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2828, 14, 21264, 18205, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 2828, 14, 647, 14837, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 3924, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 955, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 493, 1932, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 5154, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 5154, 14, 8235, 63, 807, 531, 272, 373, 500, 2908, 480, 6615, 14, 5154, 14, 4078, 19, 14, 5154, 14, 4174, 531, 272, 373, 500, 2908, 480, 6615, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
atodorov/dnf
dnf/yum/history.py
9
63071
# Copyright (C) 2009, 2012-2013 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # James Antill <james@fedoraproject.org> from __future__ import absolute_import from __future__ import unicode_literals from dnf.i18n import _, ucd import time import os, os.path import glob from .sqlutils import sqlite, executeSQL, sql_esc_glob from . import misc as misc import dnf.arch import dnf.exceptions import dnf.rpm.miscutils import dnf.i18n import functools # Cut over for when we should just give up and load everything. # The main problem here is not so much SQLite dying (although that happens # at large values: http://sqlite.org/limits.html#max_variable_number) but that # but SQLite going really slow when it gets medium sized values (much slower # than just loading everything and filtering it in python). PATTERNS_MAX = 8 # We have another value here because name is indexed and sqlite is _much_ # faster even at large numbers of patterns. PATTERNS_INDEXED_MAX = 128 def _setupHistorySearchSQL(patterns=None, ignore_case=False): """Setup need_full and patterns for _yieldSQLDataList, also see if we can get away with just using searchNames(). """ if patterns is None: patterns = [] fields = ['name', 'sql_nameArch', 'sql_nameVerRelArch', 'sql_nameVer', 'sql_nameVerRel', 'sql_envra', 'sql_nevra'] need_full = False for pat in patterns: if misc.re_full_search_needed(pat): need_full = True break pat_max = PATTERNS_MAX if not need_full: fields = ['name'] pat_max = PATTERNS_INDEXED_MAX if len(patterns) > pat_max: patterns = [] if ignore_case: patterns = sql_esc_glob(patterns) else: tmp = [] need_glob = False for pat in patterns: if misc.re_glob(pat): tmp.append((pat, 'glob')) need_glob = True else: tmp.append((pat, '=')) if not need_full and not need_glob and patterns: return (need_full, patterns, fields, True) patterns = tmp return (need_full, patterns, fields, False) class _YumHistPackageYumDB(object): """ Class to pretend to be yumdb_info for history packages. """ def __init__(self, pkg): self._pkg = pkg _valid_yumdb_keys = set(["command_line", "from_repo", "from_repo_revision", "from_repo_timestamp", "installed_by", "changed_by", "reason", "releasever"]) def __getattr__(self, attr): """ Load yumdb attributes from the history sqlite. """ pkg = self._pkg if attr.startswith('_'): raise AttributeError("%s has no yum attribute %s" % (pkg, attr)) if attr not in self._valid_yumdb_keys: raise AttributeError("%s has no yum attribute %s" % (pkg, attr)) val = pkg._history._load_yumdb_key(pkg, attr) if False and val is None: raise AttributeError("%s has no yum attribute %s" % (pkg, attr)) if val is None: return None val = str(val) or "" setattr(self, attr, val) return val def __contains__(self, attr): # This is faster than __iter__ and it makes things fail in a much more # obvious way in weird FS corruption cases like: BZ 593436 x = self.get(attr) return x is not None def get(self, attr, default=None): """retrieve an add'l data obj""" try: res = getattr(self, attr) except AttributeError: return default return res @functools.total_ordering class YumHistoryPackage(object): def __init__(self, name, arch, epoch, version, release, checksum=None, history=None): self.name = name self.version = version self.release = release self.epoch = epoch self.arch = arch self.pkgtup = (self.name, self.arch, self.epoch, self.version, self.release) if checksum is None: self._checksums = [] # (type, checksum, id(0,1) else: chk = checksum.split(':') self._checksums = [(chk[0], chk[1], 1)] # (type, checksum, id(0,1)) self.repoid = "<history>" self._history = history self.yumdb_info = _YumHistPackageYumDB(self) _valid_rpmdb_keys = set(["buildtime", "buildhost", "license", "packager", "size", "sourcerpm", "url", "vendor", # ? "committer", "committime"]) def __le__(self, other): """Test whether the *self* is less than or equal to the *other*.""" ret = self.verCMP(other) if ret != 0: return ret < 0 # less or grater if self.arch != other.arch: return self.arch < other.arch # less or greater try: self_repoid, other_repoid = self.repoid, other.repoid except AttributeError: return True # equal if self_repoid == other_repoid: return True # equal # We want 'installed' to appear over 'abcd' and 'xyz', so boost that if self_repoid == 'installed': return False # greater if other_repoid == 'installed': return True # less return self_repoid < other_repoid # less or grater @staticmethod def __comparePoEVR(po1, po2): """ Compare two Package or PackageEVR objects. """ (e1, v1, r1) = (po1.epoch, po1.version, po1.release) (e2, v2, r2) = (po2.epoch, po2.version, po2.release) return dnf.rpm.miscutils.compareEVR((e1, v1, r1), (e2, v2, r2)) def __eq__(self, other): """ Compare packages for yes/no equality, includes everything in the UI package comparison. """ if not other: return False if not hasattr(other, 'pkgtup') or self.pkgtup != other.pkgtup: return False if hasattr(self, 'repoid') and hasattr(other, 'repoid'): if self.repoid != other.repoid: return False return True def __getattr__(self, attr): """ Load rpmdb attributes from the history sqlite. """ if attr.startswith('_'): raise AttributeError("%s has no attribute %s" % (self, attr)) if attr not in self._valid_rpmdb_keys: raise AttributeError("%s has no attribute %s" % (self, attr)) val = self._history._load_rpmdb_key(self, attr) if False and val is None: raise AttributeError("%s has no attribute %s" % (self, attr)) if val is None: return None val = str(val) or "" setattr(self, attr, val) return val def __ne__(self, other): return not (self == other) def __repr__(self): return ("<%s : %s (%s)>" % (self.__class__.__name__, str(self), hex(id(self)))) def __str__(self): return self.ui_envra @property def envra(self): return ('%s:%s-%s-%s.%s' % (self.epoch, self.name, self.version, self.release, self.arch)) @property def nevra(self): return ('%s-%s:%s-%s.%s' % (self.name, self.epoch, self.version, self.release, self.arch)) @property def nvra(self): return ('%s-%s-%s.%s' % (self.name, self.version, self.release, self.arch)) def returnIdSum(self): for (csumtype, csum, csumid) in self._checksums: if csumid: return (csumtype, csum) @property def ui_envra(self): if self.epoch == '0': return self.nvra else: return self.envra def _ui_from_repo(self): """ This reports the repo the package is from, we integrate YUMDB info. for RPM packages so a package from "fedora" that is installed has a ui_from_repo of "@fedora". Note that, esp. with the --releasever option, "fedora" or "rawhide" isn't authoritative. So we also check against the current releasever and if it is different we also print the YUMDB releasever. This means that installing from F12 fedora, while running F12, would report as "@fedora/13". """ if 'from_repo' in self.yumdb_info: self._history.releasever end = '' if (self._history.releasever is not None and 'releasever' in self.yumdb_info and self.yumdb_info.releasever != self._history.releasever): end = '/' + self.yumdb_info.releasever return '@' + self.yumdb_info.from_repo + end return self.repoid ui_from_repo = property(fget=lambda self: self._ui_from_repo()) @property def ui_nevra(self): if self.epoch == '0': return self.nvra else: return self.nevra def verCMP(self, other): """ Compare package to another one, only rpm-version ordering. """ if not other: return 1 if self.name != other.name: return -1 if self.name < other.name else +1 return self.__comparePoEVR(self, other) class YumHistoryPackageState(YumHistoryPackage): def __init__(self, name,arch, epoch,version,release, state, checksum=None, history=None): YumHistoryPackage.__init__(self, name,arch, epoch,version,release, checksum, history) self.done = None self.state = state class YumHistoryRpmdbProblem(object): """ Class representing an rpmdb problem that existed at the time of the transaction. """ def __init__(self, history, rpid, problem, text): self._history = history self.rpid = rpid self.problem = problem self.text = text self._loaded_P = None def __lt__(self, other): if other is None: return False if self.problem == other.problem: return self.rpid < other.rpid return self.problem > other.problem def _getProbPkgs(self): if self._loaded_P is None: self._loaded_P = sorted(self._history._old_prob_pkgs(self.rpid)) return self._loaded_P packages = property(fget=lambda self: self._getProbPkgs()) class YumHistoryTransaction(object): """ Holder for a history transaction. """ def __init__(self, history, row): self._history = history self.tid = row[0] self.beg_timestamp = row[1] self.beg_rpmdbversion = row[2] self.end_timestamp = row[3] self.end_rpmdbversion = row[4] self.loginuid = row[5] self.return_code = row[6] self._loaded_TW = None self._loaded_TD = None self._loaded_TS = None self._loaded_PROB = None self._have_loaded_CMD = False # cmdline can validly be None self._loaded_CMD = None self._loaded_ER = None self._loaded_OT = None self.altered_lt_rpmdb = None self.altered_gt_rpmdb = None def __lt__(self, other): if other is None: return False if self.beg_timestamp == other.beg_timestamp: if self.end_timestamp == other.end_timestamp: return self.tid > other.tid else: return self.end_timestamp < other.end_timestamp else: return self.beg_timestamp > other.beg_timestamp def _getTransWith(self): if self._loaded_TW is None: self._loaded_TW = sorted(self._history._old_with_pkgs(self.tid)) return self._loaded_TW def _getTransData(self): if self._loaded_TD is None: self._loaded_TD = sorted(self._history._old_data_pkgs(self.tid)) return self._loaded_TD def _getTransSkip(self): if self._loaded_TS is None: self._loaded_TS = sorted(self._history._old_skip_pkgs(self.tid)) return self._loaded_TS trans_with = property(fget=lambda self: self._getTransWith()) trans_data = property(fget=lambda self: self._getTransData()) trans_skip = property(fget=lambda self: self._getTransSkip()) def _getProblems(self): if self._loaded_PROB is None: self._loaded_PROB = sorted(self._history._old_problems(self.tid)) return self._loaded_PROB rpmdb_problems = property(fget=lambda self: self._getProblems()) def _getCmdline(self): if not self._have_loaded_CMD: self._have_loaded_CMD = True self._loaded_CMD = self._history._old_cmdline(self.tid) return self._loaded_CMD cmdline = property(fget=lambda self: self._getCmdline()) def _getErrors(self): if self._loaded_ER is None: self._loaded_ER = self._history._load_errors(self.tid) return self._loaded_ER def _getOutput(self): if self._loaded_OT is None: self._loaded_OT = self._history._load_output(self.tid) return self._loaded_OT errors = property(fget=lambda self: self._getErrors()) output = property(fget=lambda self: self._getOutput()) class YumMergedHistoryTransaction(YumHistoryTransaction): def __init__(self, obj): self._merged_tids = set([obj.tid]) self._merged_objs = [obj] self.beg_timestamp = obj.beg_timestamp self.beg_rpmdbversion = obj.beg_rpmdbversion self.end_timestamp = obj.end_timestamp self.end_rpmdbversion = obj.end_rpmdbversion self._loaded_TW = None self._loaded_TD = None # Hack, this is difficult ... not sure if we want to list everything # that was skipped. Just those things which were skipped and then not # updated later ... or nothing. Nothing is much easier. self._loaded_TS = [] self._loaded_PROB = None self._have_loaded_CMD = False # cmdline can validly be None self._loaded_CMD = None self._loaded_ER = None self._loaded_OT = None self.altered_lt_rpmdb = None self.altered_gt_rpmdb = None def _getAllTids(self): return sorted(self._merged_tids) tid = property(fget=lambda self: self._getAllTids()) def _getLoginUIDs(self): ret = set((tid.loginuid for tid in self._merged_objs)) if len(ret) == 1: return list(ret)[0] return sorted(ret) loginuid = property(fget=lambda self: self._getLoginUIDs()) def _getReturnCodes(self): ret_codes = set((tid.return_code for tid in self._merged_objs)) if len(ret_codes) == 1 and 0 in ret_codes: return 0 if 0 in ret_codes: ret_codes.remove(0) return sorted(ret_codes) return_code = property(fget=lambda self: self._getReturnCodes()) def _getTransWith(self): ret = [] filt = set() for obj in self._merged_objs: for pkg in obj.trans_with: if pkg.pkgtup in filt: continue filt.add(pkg.pkgtup) ret.append(pkg) return sorted(ret) # This is the real tricky bit, we want to "merge" so that: # pkgA-1 => pkgA-2 # pkgA-2 => pkgA-3 # pkgB-1 => pkgB-2 # pkgB-2 => pkgB-1 # ...becomes: # pkgA-1 => pkgA-3 # pkgB-1 => pkgB-1 (reinstall) # ...note that we just give up if "impossible" things happen, Eg. # pkgA-1 => pkgA-2 # pkgA-4 => pkgA-5 @staticmethod def _p2sk(pkg, state=None): """ Take a pkg and return the key for it's state lookup. """ if state is None: state = pkg.state # Arch is needed so multilib. works, dito. basearch() -- (so .i586 # => .i686 moves are seen) return (pkg.name, dnf.arch.basearch(pkg.arch), state) @staticmethod def _list2dict(pkgs): pkgtup2pkg = {} pkgstate2pkg = {} for pkg in pkgs: key = YumMergedHistoryTransaction._p2sk(pkg) pkgtup2pkg[pkg.pkgtup] = pkg pkgstate2pkg[key] = pkg return pkgtup2pkg, pkgstate2pkg @staticmethod def _conv_pkg_state(pkg, state): npkg = YumHistoryPackageState(pkg.name, pkg.arch, pkg.epoch,pkg.version,pkg.release, state, history=pkg._history) npkg._checksums = pkg._checksums npkg.done = pkg.done if npkg.state in dnf.history.INSTALLING_STATES: npkg.state_installed = True if npkg.state in dnf.history.REMOVING_STATES: npkg.state_installed = False return npkg @staticmethod def _get_pkg(sk, pkgstate2pkg): if type(sk) != type((0,1)): sk = YumMergedHistoryTransaction._p2sk(sk) if sk not in pkgstate2pkg: return None return pkgstate2pkg[sk] def _move_pkg(self, sk, nstate, pkgtup2pkg, pkgstate2pkg): xpkg = self._get_pkg(sk, pkgstate2pkg) if xpkg is None: return del pkgstate2pkg[self._p2sk(xpkg)] xpkg = self._conv_pkg_state(xpkg, nstate) pkgtup2pkg[xpkg.pkgtup] = xpkg pkgstate2pkg[self._p2sk(xpkg)] = xpkg def _getTransData(self): def _get_pkg_f(sk): return self._get_pkg(sk, fpkgstate2pkg) def _get_pkg_n(sk): return self._get_pkg(sk, npkgstate2pkg) def _move_pkg_f(sk, nstate): self._move_pkg(sk, nstate, fpkgtup2pkg, fpkgstate2pkg) def _move_pkg_n(sk, nstate): self._move_pkg(sk, nstate, npkgtup2pkg, npkgstate2pkg) def _del1_n(pkg): del npkgtup2pkg[pkg.pkgtup] key = self._p2sk(pkg) if key in npkgstate2pkg: # For broken rpmdbv's and installonly del npkgstate2pkg[key] def _del1_f(pkg): del fpkgtup2pkg[pkg.pkgtup] key = self._p2sk(pkg) if key in fpkgstate2pkg: # For broken rpmdbv's and installonly del fpkgstate2pkg[key] def _del2(fpkg, npkg): assert fpkg.pkgtup == npkg.pkgtup _del1_f(fpkg) _del1_n(npkg) fpkgtup2pkg = {} fpkgstate2pkg = {} # We need to go from oldest to newest here, so we can see what happened # in the correct chronological order. for obj in self._merged_objs: npkgtup2pkg, npkgstate2pkg = self._list2dict(obj.trans_data) # Handle Erase => Install, as update/reinstall/downgrade for key in list(fpkgstate2pkg.keys()): (name, arch, state) = key if state not in ('Obsoleted', 'Erase'): continue fpkg = fpkgstate2pkg[key] for xstate in ('Install', 'True-Install', 'Dep-Install', 'Obsoleting'): npkg = _get_pkg_n(self._p2sk(fpkg, xstate)) if npkg is not None: break else: continue if False: pass elif fpkg > npkg: _move_pkg_f(fpkg, 'Downgraded') if xstate != 'Obsoleting': _move_pkg_n(npkg, 'Downgrade') elif fpkg < npkg: _move_pkg_f(fpkg, 'Updated') if xstate != 'Obsoleting': _move_pkg_n(npkg, 'Update') else: _del1_f(fpkg) if xstate != 'Obsoleting': _move_pkg_n(npkg, 'Reinstall') sametups = set(npkgtup2pkg.keys()).intersection(fpkgtup2pkg.keys()) for pkgtup in sametups: if pkgtup not in fpkgtup2pkg or pkgtup not in npkgtup2pkg: continue fpkg = fpkgtup2pkg[pkgtup] npkg = npkgtup2pkg[pkgtup] if False: pass elif fpkg.state == 'Reinstall': if npkg.state in ('Reinstall', 'Erase', 'Obsoleted', 'Downgraded', 'Updated'): _del1_f(fpkg) elif fpkg.state in ('Obsoleted', 'Erase'): # Should be covered by above loop which deals with # all goood state changes. good_states = ('Install', 'True-Install', 'Dep-Install', 'Obsoleting') assert npkg.state not in good_states elif fpkg.state in ('Install', 'True-Install', 'Dep-Install'): if False: pass elif npkg.state in ('Erase', 'Obsoleted'): _del2(fpkg, npkg) elif npkg.state == 'Updated': _del2(fpkg, npkg) # Move '*Install' state along to newer pkg. (not for # obsoletes). _move_pkg_n(self._p2sk(fpkg, 'Update'), fpkg.state) elif npkg.state == 'Downgraded': _del2(fpkg, npkg) # Move '*Install' state along to newer pkg. (not for # obsoletes). _move_pkg_n(self._p2sk(fpkg, 'Downgrade'), fpkg.state) elif fpkg.state in ('Downgrade', 'Update', 'Obsoleting'): if False: pass elif npkg.state == 'Reinstall': _del1_n(npkg) elif npkg.state in ('Erase', 'Obsoleted'): _del2(fpkg, npkg) # Move 'Erase'/'Obsoleted' state to orig. pkg. _move_pkg_f(self._p2sk(fpkg, 'Updated'), npkg.state) _move_pkg_f(self._p2sk(fpkg, 'Downgraded'), npkg.state) elif npkg.state in ('Downgraded', 'Updated'): xfpkg = _get_pkg_f(self._p2sk(fpkg, 'Updated')) if xfpkg is None: xfpkg = _get_pkg_f(self._p2sk(fpkg, 'Downgraded')) if xfpkg is None: if fpkg.state != 'Obsoleting': continue # Was an Install*/Reinstall with Obsoletes xfpkg = fpkg xnpkg = _get_pkg_n(self._p2sk(npkg, 'Update')) if xnpkg is None: xnpkg = _get_pkg_n(self._p2sk(npkg, 'Downgrade')) if xnpkg is None: xnpkg = _get_pkg_n(self._p2sk(npkg, 'Obsoleting')) if xnpkg is None: continue # Now we have 4 pkgs, f1, f2, n1, n2, and 3 pkgtups # f2.pkgtup == n1.pkgtup. So we need to find out if # f1 => n2 is an Update or a Downgrade. _del2(fpkg, npkg) if xfpkg == xnpkg: nfstate = 'Reinstall' if 'Obsoleting' in (fpkg.state, xnpkg.state): nfstate = 'Obsoleting' if xfpkg != fpkg: _move_pkg_f(xfpkg, nfstate) _del1_n(xnpkg) elif xfpkg < xnpkg: # Update... nfstate = 'Updated' nnstate = 'Update' if 'Obsoleting' in (fpkg.state, xnpkg.state): nnstate = 'Obsoleting' if xfpkg != fpkg: _move_pkg_f(xfpkg, nfstate) _move_pkg_n(xnpkg, nnstate) else: # Downgrade... nfstate = 'Downgraded' nnstate = 'Downgrade' if 'Obsoleting' in (fpkg.state, xnpkg.state): nnstate = 'Obsoleting' if xfpkg != fpkg: _move_pkg_f(xfpkg, nfstate) _move_pkg_n(xnpkg, nnstate) for x in npkgtup2pkg: fpkgtup2pkg[x] = npkgtup2pkg[x] for x in npkgstate2pkg: fpkgstate2pkg[x] = npkgstate2pkg[x] return sorted(fpkgtup2pkg.values()) def _getProblems(self): probs = set() for tid in self._merged_objs: for prob in tid.rpmdb_problems: probs.add(prob) return sorted(probs) def _getCmdline(self): cmdlines = [] for tid in self._merged_objs: if not tid.cmdline: continue if cmdlines and cmdlines[-1] == tid.cmdline: continue cmdlines.append(tid.cmdline) if not cmdlines: return None return cmdlines def _getErrors(self): ret = [] for obj in self._merged_objs: ret.extend(obj.errors) return ret def _getOutput(self): ret = [] for obj in self._merged_objs: ret.extend(obj.output) return ret def merge(self, obj): if obj.tid in self._merged_tids: return # Already done, signal an error? self._merged_tids.add(obj.tid) self._merged_objs.append(obj) # Oldest first... self._merged_objs.sort(reverse=True) if self.beg_timestamp > obj.beg_timestamp: self.beg_timestamp = obj.beg_timestamp self.beg_rpmdbversion = obj.beg_rpmdbversion if self.end_timestamp < obj.end_timestamp: self.end_timestamp = obj.end_timestamp self.end_rpmdbversion = obj.end_rpmdbversion class YumHistory(object): """ API for accessing the history sqlite data. """ def __init__(self, db_path, yumdb, root='/', releasever=None): self._conn = None self.conf = misc.GenericHolder() if not os.path.normpath(db_path).startswith(root): self.conf.db_path = os.path.normpath(root + '/' + db_path) else: self.conf.db_path = os.path.normpath('/' + db_path) self.conf.writable = False self.conf.readable = True self.yumdb = yumdb self.releasever = releasever if not os.path.exists(self.conf.db_path): try: os.makedirs(self.conf.db_path) except (IOError, OSError) as e: error = dnf.i18n.ucd(e) msg = _("Unable to initialize DNF DB history: %s") % error raise dnf.exceptions.Error(msg) else: self.conf.writable = True else: if os.access(self.conf.db_path, os.W_OK): self.conf.writable = True DBs = glob.glob('%s/history-*-*-*.sqlite' % self.conf.db_path) self._db_file = None for d in reversed(sorted(DBs)): fname = os.path.basename(d) fname = fname[len("history-"):-len(".sqlite")] pieces = fname.split('-', 4) if len(pieces) != 3: continue try: for piece in pieces: int(piece) except ValueError: continue self._db_date = '%s-%s-%s' % (pieces[0], pieces[1], pieces[2]) self._db_file = d break if self._db_file is None: self._create_db_file() # make an addon path for where we're going to stick # random additional history info - probably from plugins and what-not self.conf.addon_path = self.conf.db_path + '/' + self._db_date if not os.path.exists(self.conf.addon_path): try: os.makedirs(self.conf.addon_path) except (IOError, OSError) as e: # some sort of useful thing here? A warning? return else: if os.access(self.conf.addon_path, os.W_OK): self.conf.writable = True def __del__(self): self.close() def _get_cursor(self): if self._conn is None: if not self.conf.readable: return None try: self._conn = sqlite.connect(self._db_file) except (sqlite.OperationalError, sqlite.DatabaseError): self.conf.readable = False return None # Note that this is required due to changing the history DB in the # callback for removed txmbrs ... which happens inside the chroot, # as against all our other access which is outside the chroot. So # we need sqlite to not open the journal. # In theory this sucks, as history could be shared. In reality # it's deep yum stuff and there should only be one yum. executeSQL(self._conn.cursor(), "PRAGMA locking_mode = EXCLUSIVE") return self._conn.cursor() def _commit(self): return self._conn.commit() def _rollback(self): return self._conn.rollback() def close(self): if self._conn is not None: self._conn.close() self._conn = None def _pkgtup2pid(self, pkgtup, checksum=None, create=True): cur = self._get_cursor() executeSQL(cur, """SELECT pkgtupid, checksum FROM pkgtups WHERE name=? AND arch=? AND epoch=? AND version=? AND release=?""", pkgtup) for sql_pkgtupid, sql_checksum in cur: if checksum is None and sql_checksum is None: return sql_pkgtupid if checksum is None: continue if sql_checksum is None: continue if checksum == sql_checksum: return sql_pkgtupid if not create: return None pkgtup = map(ucd, pkgtup) (n,a,e,v,r) = pkgtup if checksum is not None: res = executeSQL(cur, """INSERT INTO pkgtups (name, arch, epoch, version, release, checksum) VALUES (?, ?, ?, ?, ?, ?)""", (n,a,e,v,r, checksum)) else: res = executeSQL(cur, """INSERT INTO pkgtups (name, arch, epoch, version, release) VALUES (?, ?, ?, ?, ?)""", (n,a,e,v,r)) return cur.lastrowid def _apkg2pid(self, po, create=True): csum = po.returnIdSum() if csum is not None: csum = "%s:%s" % (str(csum[0]), str(csum[1])) return self._pkgtup2pid(po.pkgtup, csum, create) def _ipkg2pid(self, po, create=True): csum = None yumdb = self.yumdb.get_package(po) if 'checksum_type' in yumdb and 'checksum_data' in yumdb: csum = "%s:%s" % (yumdb.checksum_type, yumdb.checksum_data) return self._pkgtup2pid(po.pkgtup, csum, create) def _hpkg2pid(self, po, create=False): return self._apkg2pid(po, create) def pkg2pid(self, po, create=True): if isinstance(po, YumHistoryPackage): return self._hpkg2pid(po, create) if po.from_system: return self._ipkg2pid(po, create) return self._apkg2pid(po, create) def trans_with_pid(self, pid): cur = self._get_cursor() if cur is None: return None res = executeSQL(cur, """INSERT INTO trans_with_pkgs (tid, pkgtupid) VALUES (?, ?)""", (self._tid, pid)) return cur.lastrowid def trans_skip_pid(self, pid): cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return None res = executeSQL(cur, """INSERT INTO trans_skip_pkgs (tid, pkgtupid) VALUES (?, ?)""", (self._tid, pid)) return cur.lastrowid def trans_data_pid_beg(self, pid, state): assert state is not None if not hasattr(self, '_tid') or state is None: return # Not configured to run cur = self._get_cursor() if cur is None: return # Should never happen, due to above res = executeSQL(cur, """INSERT INTO trans_data_pkgs (tid, pkgtupid, state) VALUES (?, ?, ?)""", (self._tid, pid, state)) return cur.lastrowid def trans_data_pid_end(self, pid, state): # State can be none here, Eg. TS_FAILED from rpmtrans if not hasattr(self, '_tid') or state is None: return # Not configured to run cur = self._get_cursor() if cur is None: return # Should never happen, due to above res = executeSQL(cur, """UPDATE trans_data_pkgs SET done = ? WHERE tid = ? AND pkgtupid = ? AND state = ? """, ('TRUE', self._tid, pid, state)) self._commit() def _trans_rpmdb_problem(self, problem): if not hasattr(self, '_tid'): return # Not configured to run cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return None # str(problem) doesn't work if problem contains unicode(), uproblem = ucd(problem) res = executeSQL(cur, """INSERT INTO trans_rpmdb_problems (tid, problem, msg) VALUES (?, ?, ?)""", (self._tid, problem.problem, uproblem)) rpid = cur.lastrowid if not rpid: return rpid pkgs = {} pkg = problem.pkg pkgs[pkg.pkgtup] = pkg if problem.problem == 'conflicts': for pkg in problem.conflicts: pkgs[pkg.pkgtup] = pkg if problem.problem == 'duplicates': pkgs[problem.duplicate.pkgtup] = problem.duplicate for pkg in pkgs.values(): pid = self.pkg2pid(pkg) if pkg.pkgtup == problem.pkg.pkgtup: main = 'TRUE' else: main = 'FALSE' res = executeSQL(cur, """INSERT INTO trans_prob_pkgs (rpid, pkgtupid, main) VALUES (?, ?, ?)""", (rpid, pid, main)) return rpid def _trans_cmdline(self, cmdline): if not hasattr(self, '_tid'): return # Not configured to run cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return None res = executeSQL(cur, """INSERT INTO trans_cmdline (tid, cmdline) VALUES (?, ?)""", (self._tid, ucd(cmdline))) return cur.lastrowid def beg(self, rpmdb_version, using_pkgs, tsis, skip_packages=[], rpmdb_problems=[], cmdline=None): cur = self._get_cursor() if cur is None: return res = executeSQL(cur, """INSERT INTO trans_beg (timestamp, rpmdb_version, loginuid) VALUES (?, ?, ?)""", (int(time.time()), str(rpmdb_version), misc.getloginuid())) self._tid = cur.lastrowid for pkg in using_pkgs: pid = self._ipkg2pid(pkg) self.trans_with_pid(pid) for tsi in tsis: for (pkg, state) in tsi.history_iterator(): pid = self.pkg2pid(pkg) self.trans_data_pid_beg(pid, state) for pkg in skip_packages: pid = self.pkg2pid(pkg) self.trans_skip_pid(pid) for problem in rpmdb_problems: self._trans_rpmdb_problem(problem) if cmdline: self._trans_cmdline(cmdline) self._commit() def _log_errors(self, errors): cur = self._get_cursor() if cur is None: return for error in errors: error = ucd(error) executeSQL(cur, """INSERT INTO trans_error (tid, msg) VALUES (?, ?)""", (self._tid, error)) self._commit() def log_scriptlet_output(self, msg): if msg is None or not hasattr(self, '_tid'): return # Not configured to run cur = self._get_cursor() if cur is None: return # Should never happen, due to above for error in msg.splitlines(): error = ucd(error) executeSQL(cur, """INSERT INTO trans_script_stdout (tid, line) VALUES (?, ?)""", (self._tid, error)) self._commit() def _load_errors(self, tid): cur = self._get_cursor() executeSQL(cur, """SELECT msg FROM trans_error WHERE tid = ? ORDER BY mid ASC""", (tid,)) ret = [] for row in cur: ret.append(row[0]) return ret def _load_output(self, tid): cur = self._get_cursor() executeSQL(cur, """SELECT line FROM trans_script_stdout WHERE tid = ? ORDER BY lid ASC""", (tid,)) ret = [] for row in cur: ret.append(row[0]) return ret def end(self, rpmdb_version, return_code, errors=None): assert return_code or not errors if not hasattr(self, '_tid'): return # Failed at beg() time cur = self._get_cursor() if cur is None: return # Should never happen, due to above res = executeSQL(cur, """INSERT INTO trans_end (tid, timestamp, rpmdb_version, return_code) VALUES (?, ?, ?, ?)""", (self._tid,int(time.time()), str(rpmdb_version), return_code)) self._commit() if not return_code: # Simple hack, if the transaction finished. Note that this # catches the erase cases (as we still don't get pkgtups for them), # Eg. Updated elements. executeSQL(cur, """UPDATE trans_data_pkgs SET done = ? WHERE tid = ?""", ('TRUE', self._tid,)) self._commit() if errors is not None: self._log_errors(errors) del self._tid def write_addon_data(self, dataname, data): """append data to an arbitrary-named file in the history addon_path/transaction id location, returns True if write succeeded, False if not""" if not hasattr(self, '_tid'): # maybe we should raise an exception or a warning here? return False if not dataname: return False if not data: return False # make sure the tid dir exists tid_dir = self.conf.addon_path + '/' + str(self._tid) if self.conf.writable and not os.path.exists(tid_dir): try: os.makedirs(tid_dir, mode=0o700) except (IOError, OSError) as e: # emit a warning/raise an exception? return False # cleanup dataname safename = dataname.replace('/', '_') data_fn = tid_dir + '/' + safename try: # open file in append fo = open(data_fn, 'wb+') # write data fo.write(data.encode('utf-8')) # flush data fo.flush() fo.close() except (IOError, OSError) as e: return False # return return True def return_addon_data(self, tid, item=None): hist_and_tid = self.conf.addon_path + '/' + str(tid) + '/' addon_info = glob.glob(hist_and_tid + '*') addon_names = [ i.replace(hist_and_tid, '') for i in addon_info ] if not item: return addon_names if item not in addon_names: # XXX history needs SOME kind of exception, or warning, I think? return None fo = open(hist_and_tid + item, 'r') data = fo.read() fo.close() return data def _old_with_pkgs(self, tid): cur = self._get_cursor() executeSQL(cur, """SELECT name, arch, epoch, version, release, checksum FROM trans_with_pkgs JOIN pkgtups USING(pkgtupid) WHERE tid = ? ORDER BY name ASC, epoch ASC""", (tid,)) ret = [] for row in cur: obj = YumHistoryPackage(row[0],row[1],row[2],row[3],row[4], row[5], history=self) ret.append(obj) return ret def _old_data_pkgs(self, tid, sort=True): cur = self._get_cursor() sql = """SELECT name, arch, epoch, version, release, checksum, done, state FROM trans_data_pkgs JOIN pkgtups USING(pkgtupid) WHERE tid = ?""" if sort: sql = " ".join((sql, "ORDER BY name ASC, epoch ASC, state DESC")) executeSQL(cur, sql, (tid,)) ret = [] for row in cur: obj = YumHistoryPackageState(row[0],row[1],row[2],row[3],row[4], row[7], row[5], history=self) obj.done = row[6] == 'TRUE' obj.state_installed = None if obj.state in dnf.history.INSTALLING_STATES: obj.state_installed = True if obj.state in dnf.history.REMOVING_STATES: obj.state_installed = False ret.append(obj) return ret def _old_skip_pkgs(self, tid): cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return [] executeSQL(cur, """SELECT name, arch, epoch, version, release, checksum FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid) WHERE tid = ? ORDER BY name ASC, epoch ASC""", (tid,)) ret = [] for row in cur: obj = YumHistoryPackage(row[0],row[1],row[2],row[3],row[4], row[5], history=self) ret.append(obj) return ret def _old_prob_pkgs(self, rpid): cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return [] executeSQL(cur, """SELECT name, arch, epoch, version, release, checksum, main FROM trans_prob_pkgs JOIN pkgtups USING(pkgtupid) WHERE rpid = ? ORDER BY name ASC, epoch ASC""", (rpid,)) ret = [] for row in cur: obj = YumHistoryPackage(row[0],row[1],row[2],row[3],row[4], row[5], history=self) obj.main = row[6] == 'TRUE' ret.append(obj) return ret def _old_problems(self, tid): cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return [] executeSQL(cur, """SELECT rpid, problem, msg FROM trans_rpmdb_problems WHERE tid = ? ORDER BY problem ASC, rpid ASC""", (tid,)) ret = [] for row in cur: obj = YumHistoryRpmdbProblem(self, row[0], row[1], row[2]) ret.append(obj) return ret def _old_cmdline(self, tid): cur = self._get_cursor() if cur is None or not self._update_db_file_2(): return None executeSQL(cur, """SELECT cmdline FROM trans_cmdline WHERE tid = ?""", (tid,)) ret = [] for row in cur: return row[0] return None def old(self, tids=[], limit=None, complete_transactions_only=False): """ Return a list of the last transactions, note that this includes partial transactions (ones without an end transaction). """ cur = self._get_cursor() if cur is None: return [] sql = """SELECT tid, trans_beg.timestamp AS beg_ts, trans_beg.rpmdb_version AS beg_rv, trans_end.timestamp AS end_ts, trans_end.rpmdb_version AS end_rv, loginuid, return_code FROM trans_beg JOIN trans_end USING(tid)""" # NOTE: sqlite doesn't do OUTER JOINs ... *sigh*. So we have to do it # ourself. if not complete_transactions_only: sql = """SELECT tid, trans_beg.timestamp AS beg_ts, trans_beg.rpmdb_version AS beg_rv, NULL, NULL, loginuid, NULL FROM trans_beg""" params = None if tids and len(tids) <= PATTERNS_INDEXED_MAX: params = tids = list(set(tids)) sql += " WHERE tid IN (%s)" % ", ".join(['?'] * len(tids)) # This relies on the fact that the PRIMARY KEY in sqlite will always # increase with each transaction. In theory we can use: # ORDER BY beg_ts DESC ... except sometimes people do installs with a # system clock that is very broken, and using that screws them forever. sql += " ORDER BY tid DESC" if limit is not None: sql += " LIMIT " + str(limit) executeSQL(cur, sql, params) ret = [] tid2obj = {} for row in cur: if tids and len(tids) > PATTERNS_INDEXED_MAX: if row[0] not in tids: continue obj = YumHistoryTransaction(self, row) tid2obj[row[0]] = obj ret.append(obj) sql = """SELECT tid, trans_end.timestamp AS end_ts, trans_end.rpmdb_version AS end_rv, return_code FROM trans_end""" params = list(tid2obj.keys()) if len(params) > PATTERNS_INDEXED_MAX: executeSQL(cur, sql) else: sql += " WHERE tid IN (%s)" % ", ".join(['?'] * len(params)) executeSQL(cur, sql, params) for row in cur: if row[0] not in tid2obj: continue tid2obj[row[0]].end_timestamp = row[1] tid2obj[row[0]].end_rpmdbversion = row[2] tid2obj[row[0]].return_code = row[3] # Go through backwards, and see if the rpmdb versions match las = None for obj in reversed(ret): cur_rv = obj.beg_rpmdbversion las_rv = None if las is not None: las_rv = las.end_rpmdbversion if las_rv is None or cur_rv is None or (las.tid + 1) != obj.tid: pass elif las_rv != cur_rv: obj.altered_lt_rpmdb = True las.altered_gt_rpmdb = True else: obj.altered_lt_rpmdb = False las.altered_gt_rpmdb = False las = obj return ret def last(self, complete_transactions_only=True): """ This is the last full transaction. So any incomplete transactions do not count, by default. """ ret = self.old([], 1, complete_transactions_only) if not ret: return None assert len(ret) == 1 return ret[0] def _load_anydb_key(self, pkg, db, attr): cur = self._get_cursor() if cur is None or not self._update_db_file_3(): return None pid = self.pkg2pid(pkg, create=False) if pid is None: return None sql = """SELECT %(db)sdb_val FROM pkg_%(db)sdb WHERE pkgtupid=? and %(db)sdb_key=? """ % {'db' : db} executeSQL(cur, sql, (pid, attr)) for row in cur: return row[0] return None def _load_rpmdb_key(self, pkg, attr): return self._load_anydb_key(pkg, "rpm", attr) def _load_yumdb_key(self, pkg, attr): return self._load_anydb_key(pkg, "yum", attr) def _save_anydb_key(self, pkg, db, attr, val): cur = self._get_cursor() if cur is None or not self._update_db_file_3(): return None pid = self.pkg2pid(pkg, create=False) if pid is None: return None sql = """INSERT INTO pkg_%(db)sdb (pkgtupid, %(db)sdb_key, %(db)sdb_val) VALUES (?, ?, ?)""" % {'db' : db} executeSQL(cur, sql, (pid, attr, ucd(val))) return cur.lastrowid def _save_rpmdb(self, ipkg): """ Save all the data for rpmdb for this installed pkg, assumes there is no data currently. """ for attr in YumHistoryPackage._valid_rpmdb_keys: val = getattr(ipkg, attr, None) if val is None: continue if not self._save_anydb_key(ipkg, "rpm", attr, val): return False return True def _save_yumdb(self, ipkg): """ Save all the data for yumdb for this installed pkg, assumes there is no data currently. """ yumdb_info = self.yumdb.get_package(ipkg) for attr in _YumHistPackageYumDB._valid_yumdb_keys: val = yumdb_info.get(attr) if val is None: continue if not self._save_anydb_key(ipkg, "yum", attr, val): return False return True def _wipe_anydb(self, pkg, db): """ Delete all the data for rpmdb/yumdb for this installed pkg. """ cur = self._get_cursor() if cur is None or not self._update_db_file_3(): return False pid = self.pkg2pid(pkg, create=False) if pid is None: return False sql = """DELETE FROM pkg_%(db)sdb WHERE pkgtupid=?""" % {'db' : db} executeSQL(cur, sql, (pid,)) return True def sync_alldb(self, ipkg): """ Sync. all the data for rpmdb/yumdb for this installed pkg. """ if not self._wipe_anydb(ipkg, "rpm"): return False if not (self._wipe_anydb(ipkg, "yum") and self._save_rpmdb(ipkg) and self._save_yumdb(ipkg)): self._rollback() return False self._commit() return True def _pkg_stats(self): """ Some stats about packages in the DB. """ ret = {'nevrac' : 0, 'nevra' : 0, 'nevr' : 0, 'na' : 0, 'rpmdb' : 0, 'yumdb' : 0, } cur = self._get_cursor() if cur is None or not self._update_db_file_3(): return False data = (('nevrac', "COUNT(*)", "pkgtups"), ('na', "COUNT(DISTINCT(name || arch))", "pkgtups"), ('nevra',"COUNT(DISTINCT(name||version||epoch||release||arch))", "pkgtups"), ('nevr', "COUNT(DISTINCT(name||version||epoch||release))", "pkgtups"), ('rpmdb', "COUNT(DISTINCT(pkgtupid))", "pkg_rpmdb"), ('yumdb', "COUNT(DISTINCT(pkgtupid))", "pkg_yumdb")) for key, bsql, esql in data: executeSQL(cur, "SELECT %s FROM %s" % (bsql, esql)) for row in cur: ret[key] = row[0] return ret def _yieldSQLDataList(self, patterns, fields, ignore_case): """Yields all the package data for the given params. """ cur = self._get_cursor() qsql = _FULL_PARSE_QUERY_BEG pat_sqls = [] pat_data = [] for (pattern, rest) in patterns: for field in fields: if ignore_case: pat_sqls.append("%s LIKE ?%s" % (field, rest)) else: pat_sqls.append("%s %s ?" % (field, rest)) pat_data.append(pattern) assert pat_sqls qsql += " OR ".join(pat_sqls) executeSQL(cur, qsql, pat_data) for x in cur: yield x def search(self, patterns, ignore_case=True): """ Search for history transactions which contain specified packages al. la. "yum list". Returns transaction ids. """ # Search packages ... kind of sucks that it's search not list, pkglist? cur = self._get_cursor() if cur is None: return set() data = _setupHistorySearchSQL(patterns, ignore_case) (need_full, npatterns, fields, names) = data ret = [] pkgtupids = set() if npatterns: for row in self._yieldSQLDataList(npatterns, fields, ignore_case): pkgtupids.add(row[0]) else: # Too many patterns, *sigh* pat_max = PATTERNS_MAX if not need_full: pat_max = PATTERNS_INDEXED_MAX for npatterns in misc.seq_max_split(patterns, pat_max): data = _setupHistorySearchSQL(npatterns, ignore_case) (need_full, nps, fields, names) = data assert nps for row in self._yieldSQLDataList(nps, fields, ignore_case): pkgtupids.add(row[0]) sql = """SELECT tid FROM trans_data_pkgs WHERE pkgtupid IN """ sql += "(%s)" % ",".join(['?'] * len(pkgtupids)) params = list(pkgtupids) tids = set() if len(params) > PATTERNS_INDEXED_MAX: executeSQL(cur, """SELECT tid FROM trans_data_pkgs""") for row in cur: if row[0] in params: tids.add(row[0]) return tids if not params: return tids executeSQL(cur, sql, params) for row in cur: tids.add(row[0]) return tids _update_ops_3 = ['''\ \ CREATE TABLE pkg_rpmdb ( pkgtupid INTEGER NOT NULL REFERENCES pkgtups, rpmdb_key TEXT NOT NULL, rpmdb_val TEXT NOT NULL); ''', '''\ CREATE INDEX i_pkgkey_rpmdb ON pkg_rpmdb (pkgtupid, rpmdb_key); ''', '''\ CREATE TABLE pkg_yumdb ( pkgtupid INTEGER NOT NULL REFERENCES pkgtups, yumdb_key TEXT NOT NULL, yumdb_val TEXT NOT NULL); ''', '''\ CREATE INDEX i_pkgkey_yumdb ON pkg_yumdb (pkgtupid, yumdb_key); '''] # pylint: disable-msg=E0203 def _update_db_file_3(self): """ Update to version 3 of history, rpmdb/yumdb data. """ if not self._update_db_file_2(): return False if hasattr(self, '_cached_updated_3'): return self._cached_updated_3 cur = self._get_cursor() if cur is None: return False executeSQL(cur, "PRAGMA table_info(pkg_yumdb)") # If we get anything, we're fine. There might be a better way of # saying "anything" but this works. for ob in cur: break else: for op in self._update_ops_3: cur.execute(op) self._commit() self._cached_updated_3 = True return True _update_ops_2 = ['''\ \ CREATE TABLE trans_skip_pkgs ( tid INTEGER NOT NULL REFERENCES trans_beg, pkgtupid INTEGER NOT NULL REFERENCES pkgtups); ''', '''\ \ CREATE TABLE trans_cmdline ( tid INTEGER NOT NULL REFERENCES trans_beg, cmdline TEXT NOT NULL); ''', '''\ \ CREATE TABLE trans_rpmdb_problems ( rpid INTEGER PRIMARY KEY, tid INTEGER NOT NULL REFERENCES trans_beg, problem TEXT NOT NULL, msg TEXT NOT NULL); ''', '''\ \ CREATE TABLE trans_prob_pkgs ( rpid INTEGER NOT NULL REFERENCES trans_rpmdb_problems, pkgtupid INTEGER NOT NULL REFERENCES pkgtups, main BOOL NOT NULL DEFAULT FALSE); ''', '''\ \ CREATE VIEW vtrans_data_pkgs AS SELECT tid,name,epoch,version,release,arch,pkgtupid, state,done, name || '-' || epoch || ':' || version || '-' || release || '.' || arch AS nevra FROM trans_data_pkgs JOIN pkgtups USING(pkgtupid) ORDER BY name; ''', '''\ \ CREATE VIEW vtrans_with_pkgs AS SELECT tid,name,epoch,version,release,arch,pkgtupid, name || '-' || epoch || ':' || version || '-' || release || '.' || arch AS nevra FROM trans_with_pkgs JOIN pkgtups USING(pkgtupid) ORDER BY name; ''', '''\ \ CREATE VIEW vtrans_skip_pkgs AS SELECT tid,name,epoch,version,release,arch,pkgtupid, name || '-' || epoch || ':' || version || '-' || release || '.' || arch AS nevra FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid) ORDER BY name; ''', # NOTE: Old versions of sqlite don't like the normal way to do the next # view. So we do it with the select. It's for debugging only, so # no big deal. '''\ \ CREATE VIEW vtrans_prob_pkgs2 AS SELECT tid,rpid,name,epoch,version,release,arch,pkgtups.pkgtupid, main,problem,msg, name || '-' || epoch || ':' || version || '-' || release || '.' || arch AS nevra FROM (SELECT * FROM trans_prob_pkgs,trans_rpmdb_problems WHERE trans_prob_pkgs.rpid=trans_rpmdb_problems.rpid) JOIN pkgtups USING(pkgtupid) ORDER BY name; '''] def _update_db_file_2(self): """ Update to version 2 of history, includes trans_skip_pkgs. """ if not self.conf.writable: return False if hasattr(self, '_cached_updated_2'): return self._cached_updated_2 cur = self._get_cursor() if cur is None: return False executeSQL(cur, "PRAGMA table_info(trans_skip_pkgs)") # If we get anything, we're fine. There might be a better way of # saying "anything" but this works. for ob in cur: break else: for op in self._update_ops_2: cur.execute(op) self._commit() self._cached_updated_2 = True return True # pylint: enable-msg=E0203 def _create_db_file(self): """ Create a new history DB file, populating tables etc. """ self._db_date = time.strftime('%Y-%m-%d') _db_file = '%s/%s-%s.%s' % (self.conf.db_path, 'history', self._db_date, 'sqlite') if self._db_file == _db_file: os.rename(_db_file, _db_file + '.old') # Just in case ... move the journal file too. if os.path.exists(_db_file + '-journal'): os.rename(_db_file + '-journal', _db_file + '-journal.old') self._db_file = _db_file if self.conf.writable and not os.path.exists(self._db_file): # make them default to 0600 - sysadmin can change it later # if they want fo = os.open(self._db_file, os.O_CREAT, 0o600) os.close(fo) cur = self._get_cursor() if cur is None: raise IOError(_("Can not create history database at '%s'.") % \ self._db_file) ops = ['''\ CREATE TABLE trans_beg ( tid INTEGER PRIMARY KEY, timestamp INTEGER NOT NULL, rpmdb_version TEXT NOT NULL, loginuid INTEGER); ''', '''\ CREATE TABLE trans_end ( tid INTEGER PRIMARY KEY REFERENCES trans_beg, timestamp INTEGER NOT NULL, rpmdb_version TEXT NOT NULL, return_code INTEGER NOT NULL); ''', '''\ \ CREATE TABLE trans_with_pkgs ( tid INTEGER NOT NULL REFERENCES trans_beg, pkgtupid INTEGER NOT NULL REFERENCES pkgtups); ''', '''\ \ CREATE TABLE trans_error ( mid INTEGER PRIMARY KEY, tid INTEGER NOT NULL REFERENCES trans_beg, msg TEXT NOT NULL); ''', '''\ CREATE TABLE trans_script_stdout ( lid INTEGER PRIMARY KEY, tid INTEGER NOT NULL REFERENCES trans_beg, line TEXT NOT NULL); ''', '''\ \ CREATE TABLE trans_data_pkgs ( tid INTEGER NOT NULL REFERENCES trans_beg, pkgtupid INTEGER NOT NULL REFERENCES pkgtups, done BOOL NOT NULL DEFAULT FALSE, state TEXT NOT NULL); ''', '''\ \ CREATE TABLE pkgtups ( pkgtupid INTEGER PRIMARY KEY, name TEXT NOT NULL, arch TEXT NOT NULL, epoch TEXT NOT NULL, version TEXT NOT NULL, release TEXT NOT NULL, checksum TEXT); ''', '''\ CREATE INDEX i_pkgtup_naevr ON pkgtups (name, arch, epoch, version, release); '''] for op in ops: cur.execute(op) for op in self._update_ops_2: cur.execute(op) for op in self._update_ops_3: cur.execute(op) self._commit() _FULL_PARSE_QUERY_BEG = """ SELECT pkgtupid,name,epoch,version,release,arch, name || "." || arch AS sql_nameArch, name || "-" || version || "-" || release || "." || arch AS sql_nameVerRelArch, name || "-" || version AS sql_nameVer, name || "-" || version || "-" || release AS sql_nameVerRel, epoch || ":" || name || "-" || version || "-" || release || "." || arch AS sql_envra, name || "-" || epoch || ":" || version || "-" || release || "." || arch AS sql_nevra FROM pkgtups WHERE """
gpl-2.0
[ 3, 1898, 334, 35, 9, 8937, 12, 6029, 13, 6965, 221, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1603, 14015, 1626, 12587, 665, 74, 14015, 32, 15800, 269, 30204, 963, 14, 1308, 30, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 28215, 14, 73, 1085, 78, 492, 5501, 399, 2866, 199, 646, 900, 199, 646, 747, 12, 747, 14, 515, 199, 646, 5739, 199, 199, 504, 1275, 3009, 1208, 492, 11723, 12, 5341, 4657, 12, 3875, 63, 19303, 63, 6463, 199, 504, 1275, 492, 18576, 465, 18576, 199, 646, 28215, 14, 1047, 199, 646, 28215, 14, 3924, 199, 646, 28215, 14, 14191, 14, 9923, 1208, 199, 646, 28215, 14, 73, 1085, 78, 199, 646, 9143, 421, 199, 3, 221, 445, 337, 1806, 367, 1380, 781, 1077, 2951, 8120, 1536, 436, 2248, 8137, 14, 199, 3, 221, 710, 2446, 5160, 2348, 365, 440, 880, 8298, 19245, 13119, 316, 334, 6130, 4937, 626, 10986, 199, 3, 737, 7031, 1338, 26, 1455, 921, 10659, 14, 1308, 15, 9368, 14, 1360, 3, 988, 63, 1975, 63, 1955, 9, 1325, 626, 199, 3, 1325, 19245, 9995, 7710, 11999, 1380, 652, 7545, 21576, 308, 1759, 1338, 334, 77, 2133, 26200, 199, 3, 2419, 2951, 8697, 8137, 436, 14545, 652, 315, 2366, 680, 199, 2805, 1157, 2709, 63, 4283, 275, 1695, 199, 3, 221, 2136, 1172, 4573, 574, 2348, 2952, 536, 365, 15235, 436, 11723, 365, 485, 77, 2133, 63, 199, 3, 12930, 2755, 737, 7031, 5579, 402, 7970, 14, 199, 2805, 1157, 2709, 63, 10215, 1149, 63, 4283, 275, 7960, 199, 199, 318, 485, 2758, 12114, 5278, 4657, 8, 7435, 29, 403, 12, 3686, 63, 2546, 29, 797, 304, 272, 408, 8555, 1929, 63, 2861, 436, 7970, 367, 485, 11481, 4657, 1451, 1296, 12, 2597, 1937, 340, 2126, 781, 883, 664, 13437, 543, 2951, 1808, 2754, 5866, 1252, 408, 339, 340, 7970, 365, 488, 26, 267, 7970, 275, 942, 339, 1504, 275, 788, 354, 297, 283, 3009, 63, 354, 8438, 297, 283, 3009, 63, 354, 3673, 5640, 8438, 297, 1598, 283, 3009, 63, 354, 3673, 297, 283, 3009, 63, 354, 3673, 5640, 297, 1598, 283, 3009, 63, 1813, 345, 297, 283, 3009, 63, 685, 86, 345, 418, 272, 1929, 63, 2861, 275, 756, 272, 367, 12713, 315, 7970, 26, 267, 340, 18576, 14, 264, 63, 2861, 63, 1733, 63, 11368, 8, 10853, 304, 288, 1929, 63, 2861, 275, 715, 288, 2059, 339, 12713, 63, 988, 275, 31467, 1157, 2709, 63, 4283, 272, 340, 440, 1929, 63, 2861, 26, 267, 1504, 275, 788, 354, 418, 267, 12713, 63, 988, 275, 31467, 1157, 2709, 63, 10215, 1149, 63, 4283, 272, 340, 822, 8, 7435, 9, 690, 12713, 63, 988, 26, 267, 7970, 275, 942, 272, 340, 3686, 63, 2546, 26, 267, 7970, 275, 3875, 63, 19303, 63, 6463, 8, 7435, 9, 272, 587, 26, 267, 3529, 275, 942, 267, 1929, 63, 6463, 275, 756, 267, 367, 12713, 315, 7970, 26, 288, 340, 18576, 14, 264, 63, 6463, 8, 10853, 304, 355, 3529, 14, 740, 1332, 10853, 12, 283, 6463, 1333, 355, 1929, 63, 6463, 275, 715, 288, 587, 26, 355, 3529, 14, 740, 1332, 10853, 12, 26143, 1333, 267, 340, 440, 1929, 63, 2861, 436, 440, 1929, 63, 6463, 436, 7970, 26, 288, 372, 334, 9321, 63, 2861, 12, 7970, 12, 1504, 12, 715, 9, 267, 7970, 275, 3529, 272, 372, 334, 9321, 63, 2861, 12, 7970, 12, 1504, 12, 756, 9, 199, 199, 533, 485, 57, 453, 27785, 8599, 57, 453, 2846, 8, 785, 304, 272, 408, 8089, 370, 27830, 370, 506, 24717, 697, 63, 815, 367, 7994, 6117, 14, 408, 339, 347, 636, 826, 721, 277, 12, 5496, 304, 267, 291, 423, 4600, 275, 5496, 339, 485, 1078, 63, 22108, 697, 63, 1612, 275, 663, 5234, 1531, 63, 604, 401, 2490, 298, 504, 63, 3417, 401, 298, 504, 63, 3417, 63, 5792, 401, 2490, 298, 504, 63, 3417, 63, 3954, 401, 2490, 298, 7657, 63, 991, 401, 298, 2489, 63, 991, 401, 2490, 298, 5764, 401, 298, 3221, 422, 3135, 272, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 408, 7190, 24717, 697, 3004, 687, 314, 7994, 11723, 14, 408, 267, 5496, 275, 291, 423, 4600, 267, 340, 1921, 14, 2460, 30018, 288, 746, 4281, 3647, 83, 965, 949, 24717, 2225, 450, 83, 2, 450, 334, 4600, 12, 1921, 430, 398, 340, 1921, 440, 315, 291, 423, 1078, 63, 22108, 697, 63, 1612, 26, 288, 746, 4281, 3647, 83, 965, 949, 24717, 2225, 450, 83, 2, 450, 334, 4600, 12, 1921, 430, 398, 1139, 275, 5496, 423, 5570, 423, 912, 63, 22108, 697, 63, 498, 8, 4600, 12, 1921, 9, 267, 340, 756, 436, 1139, 365, 488, 26, 288, 746, 4281, 3647, 83, 965, 949, 24717, 2225, 450, 83, 2, 450, 334, 4600, 12, 1921, 430, 398, 340, 1139, 365, 488, 26, 288, 372, 488, 398, 1139, 275, 620, 8, 637, 9, 503, 3087, 267, 5371, 8, 277, 12, 1921, 12, 1139, 9, 398, 372, 1139, 339, 347, 636, 6134, 721, 277, 12, 1921, 304, 267, 327, 221, 961, 365, 12930, 2419, 636, 1661, 363, 436, 652, 7704, 7645 ]
[ 1898, 334, 35, 9, 8937, 12, 6029, 13, 6965, 221, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1603, 14015, 1626, 12587, 665, 74, 14015, 32, 15800, 269, 30204, 963, 14, 1308, 30, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 28215, 14, 73, 1085, 78, 492, 5501, 399, 2866, 199, 646, 900, 199, 646, 747, 12, 747, 14, 515, 199, 646, 5739, 199, 199, 504, 1275, 3009, 1208, 492, 11723, 12, 5341, 4657, 12, 3875, 63, 19303, 63, 6463, 199, 504, 1275, 492, 18576, 465, 18576, 199, 646, 28215, 14, 1047, 199, 646, 28215, 14, 3924, 199, 646, 28215, 14, 14191, 14, 9923, 1208, 199, 646, 28215, 14, 73, 1085, 78, 199, 646, 9143, 421, 199, 3, 221, 445, 337, 1806, 367, 1380, 781, 1077, 2951, 8120, 1536, 436, 2248, 8137, 14, 199, 3, 221, 710, 2446, 5160, 2348, 365, 440, 880, 8298, 19245, 13119, 316, 334, 6130, 4937, 626, 10986, 199, 3, 737, 7031, 1338, 26, 1455, 921, 10659, 14, 1308, 15, 9368, 14, 1360, 3, 988, 63, 1975, 63, 1955, 9, 1325, 626, 199, 3, 1325, 19245, 9995, 7710, 11999, 1380, 652, 7545, 21576, 308, 1759, 1338, 334, 77, 2133, 26200, 199, 3, 2419, 2951, 8697, 8137, 436, 14545, 652, 315, 2366, 680, 199, 2805, 1157, 2709, 63, 4283, 275, 1695, 199, 3, 221, 2136, 1172, 4573, 574, 2348, 2952, 536, 365, 15235, 436, 11723, 365, 485, 77, 2133, 63, 199, 3, 12930, 2755, 737, 7031, 5579, 402, 7970, 14, 199, 2805, 1157, 2709, 63, 10215, 1149, 63, 4283, 275, 7960, 199, 199, 318, 485, 2758, 12114, 5278, 4657, 8, 7435, 29, 403, 12, 3686, 63, 2546, 29, 797, 304, 272, 408, 8555, 1929, 63, 2861, 436, 7970, 367, 485, 11481, 4657, 1451, 1296, 12, 2597, 1937, 340, 2126, 781, 883, 664, 13437, 543, 2951, 1808, 2754, 5866, 1252, 408, 339, 340, 7970, 365, 488, 26, 267, 7970, 275, 942, 339, 1504, 275, 788, 354, 297, 283, 3009, 63, 354, 8438, 297, 283, 3009, 63, 354, 3673, 5640, 8438, 297, 1598, 283, 3009, 63, 354, 3673, 297, 283, 3009, 63, 354, 3673, 5640, 297, 1598, 283, 3009, 63, 1813, 345, 297, 283, 3009, 63, 685, 86, 345, 418, 272, 1929, 63, 2861, 275, 756, 272, 367, 12713, 315, 7970, 26, 267, 340, 18576, 14, 264, 63, 2861, 63, 1733, 63, 11368, 8, 10853, 304, 288, 1929, 63, 2861, 275, 715, 288, 2059, 339, 12713, 63, 988, 275, 31467, 1157, 2709, 63, 4283, 272, 340, 440, 1929, 63, 2861, 26, 267, 1504, 275, 788, 354, 418, 267, 12713, 63, 988, 275, 31467, 1157, 2709, 63, 10215, 1149, 63, 4283, 272, 340, 822, 8, 7435, 9, 690, 12713, 63, 988, 26, 267, 7970, 275, 942, 272, 340, 3686, 63, 2546, 26, 267, 7970, 275, 3875, 63, 19303, 63, 6463, 8, 7435, 9, 272, 587, 26, 267, 3529, 275, 942, 267, 1929, 63, 6463, 275, 756, 267, 367, 12713, 315, 7970, 26, 288, 340, 18576, 14, 264, 63, 6463, 8, 10853, 304, 355, 3529, 14, 740, 1332, 10853, 12, 283, 6463, 1333, 355, 1929, 63, 6463, 275, 715, 288, 587, 26, 355, 3529, 14, 740, 1332, 10853, 12, 26143, 1333, 267, 340, 440, 1929, 63, 2861, 436, 440, 1929, 63, 6463, 436, 7970, 26, 288, 372, 334, 9321, 63, 2861, 12, 7970, 12, 1504, 12, 715, 9, 267, 7970, 275, 3529, 272, 372, 334, 9321, 63, 2861, 12, 7970, 12, 1504, 12, 756, 9, 199, 199, 533, 485, 57, 453, 27785, 8599, 57, 453, 2846, 8, 785, 304, 272, 408, 8089, 370, 27830, 370, 506, 24717, 697, 63, 815, 367, 7994, 6117, 14, 408, 339, 347, 636, 826, 721, 277, 12, 5496, 304, 267, 291, 423, 4600, 275, 5496, 339, 485, 1078, 63, 22108, 697, 63, 1612, 275, 663, 5234, 1531, 63, 604, 401, 2490, 298, 504, 63, 3417, 401, 298, 504, 63, 3417, 63, 5792, 401, 2490, 298, 504, 63, 3417, 63, 3954, 401, 2490, 298, 7657, 63, 991, 401, 298, 2489, 63, 991, 401, 2490, 298, 5764, 401, 298, 3221, 422, 3135, 272, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 408, 7190, 24717, 697, 3004, 687, 314, 7994, 11723, 14, 408, 267, 5496, 275, 291, 423, 4600, 267, 340, 1921, 14, 2460, 30018, 288, 746, 4281, 3647, 83, 965, 949, 24717, 2225, 450, 83, 2, 450, 334, 4600, 12, 1921, 430, 398, 340, 1921, 440, 315, 291, 423, 1078, 63, 22108, 697, 63, 1612, 26, 288, 746, 4281, 3647, 83, 965, 949, 24717, 2225, 450, 83, 2, 450, 334, 4600, 12, 1921, 430, 398, 1139, 275, 5496, 423, 5570, 423, 912, 63, 22108, 697, 63, 498, 8, 4600, 12, 1921, 9, 267, 340, 756, 436, 1139, 365, 488, 26, 288, 746, 4281, 3647, 83, 965, 949, 24717, 2225, 450, 83, 2, 450, 334, 4600, 12, 1921, 430, 398, 340, 1139, 365, 488, 26, 288, 372, 488, 398, 1139, 275, 620, 8, 637, 9, 503, 3087, 267, 5371, 8, 277, 12, 1921, 12, 1139, 9, 398, 372, 1139, 339, 347, 636, 6134, 721, 277, 12, 1921, 304, 267, 327, 221, 961, 365, 12930, 2419, 636, 1661, 363, 436, 652, 7704, 7645, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hip-odoo/odoo
addons/bus/models/bus_presence.py
38
2676
# -*- coding: utf-8 -*- import datetime import time from odoo import api, fields, models from odoo import tools from odoo.addons.bus.models.bus import TIMEOUT from odoo.tools.misc import DEFAULT_SERVER_DATETIME_FORMAT DISCONNECTION_TIMER = TIMEOUT + 5 AWAY_TIMER = 1800 # 30 minutes class BusPresence(models.Model): """ User Presence Its status is 'online', 'away' or 'offline'. This model should be a one2one, but is not attached to res_users to avoid database concurrence errors. Since the 'update' method is executed at each poll, if the user have multiple opened tabs, concurrence errors can happend, but are 'muted-logged'. """ _name = 'bus.presence' _description = 'User Presence' _log_access = False _sql_constraints = [('bus_user_presence_unique', 'unique(user_id)', 'A user can only have one IM status.')] user_id = fields.Many2one('res.users', 'Users', required=True, index=True, ondelete='cascade') last_poll = fields.Datetime('Last Poll', default=lambda self: fields.Datetime.now()) last_presence = fields.Datetime('Last Presence', default=lambda self: fields.Datetime.now()) status = fields.Selection([('online', 'Online'), ('away', 'Away'), ('offline', 'Offline')], 'IM Status', default='offline') @api.model def update(self, inactivity_period): """ Updates the last_poll and last_presence of the current user :param inactivity_period: duration in milliseconds """ presence = self.search([('user_id', '=', self._uid)], limit=1) # compute last_presence timestamp last_presence = datetime.datetime.now() - datetime.timedelta(milliseconds=inactivity_period) values = { 'last_poll': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT), } # update the presence or a create a new one if not presence: # create a new presence for the user values['user_id'] = self._uid values['last_presence'] = last_presence.strftime(DEFAULT_SERVER_DATETIME_FORMAT) self.create(values) else: # update the last_presence if necessary, and write values if datetime.datetime.strptime(presence.last_presence, DEFAULT_SERVER_DATETIME_FORMAT) < last_presence: values['last_presence'] = last_presence.strftime(DEFAULT_SERVER_DATETIME_FORMAT) # Hide transaction serialization errors, which can be ignored, the presence update is not essential with tools.mute_logger('odoo.sql_db'): presence.write(values) # avoid TransactionRollbackError self.env.cr.commit() # TODO : check if still necessary
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 646, 900, 199, 199, 504, 28811, 492, 2986, 12, 1504, 12, 1709, 199, 504, 28811, 492, 7249, 199, 504, 28811, 14, 10788, 14, 5610, 14, 992, 14, 5610, 492, 29998, 199, 504, 28811, 14, 2537, 14, 9923, 492, 6186, 63, 6613, 63, 12488, 63, 4807, 199, 199, 6178, 18389, 63, 29108, 275, 29998, 435, 959, 199, 15088, 3448, 63, 29108, 275, 6155, 383, 221, 327, 4233, 9395, 421, 199, 533, 18573, 2398, 14073, 8, 992, 14, 1685, 304, 272, 408, 2876, 5543, 14073, 267, 22940, 2004, 365, 283, 15178, 297, 283, 22703, 7, 503, 283, 18430, 1370, 961, 1402, 1077, 506, 282, 1373, 18, 368, 12, 1325, 365, 440, 267, 10102, 370, 522, 63, 3707, 370, 5126, 3050, 406, 895, 4646, 2552, 14, 9336, 314, 283, 873, 7, 1083, 365, 7934, 267, 737, 1924, 11271, 12, 340, 314, 922, 1172, 3663, 12123, 12187, 12, 406, 895, 4646, 2552, 883, 394, 740, 12, 1325, 787, 283, 77, 4241, 13, 12419, 1370, 272, 408, 339, 485, 354, 275, 283, 5610, 14, 21566, 7, 272, 485, 1802, 275, 283, 1899, 5543, 14073, 7, 272, 485, 793, 63, 2732, 275, 756, 339, 485, 3009, 63, 9882, 275, 4274, 5610, 63, 751, 63, 21566, 63, 3235, 297, 283, 3235, 8, 751, 63, 344, 3196, 283, 33, 922, 883, 1454, 1172, 1373, 18211, 2004, 2659, 61, 339, 922, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 3707, 297, 283, 12117, 297, 1415, 29, 549, 12, 1478, 29, 549, 12, 16549, 534, 15377, 358, 272, 2061, 63, 6843, 275, 1504, 14, 19636, 360, 6090, 25306, 297, 849, 29, 2734, 291, 26, 1504, 14, 19636, 14, 2131, 1012, 272, 2061, 63, 21566, 275, 1504, 14, 19636, 360, 6090, 5543, 14073, 297, 849, 29, 2734, 291, 26, 1504, 14, 19636, 14, 2131, 1012, 272, 2004, 275, 1504, 14, 7713, 8318, 15178, 297, 283, 28587, 659, 661, 22703, 297, 283, 33, 3316, 659, 661, 18430, 297, 283, 5195, 604, 2665, 283, 1469, 9795, 297, 849, 534, 18430, 358, 339, 768, 1246, 14, 1238, 272, 347, 1678, 8, 277, 12, 315, 8240, 63, 5191, 304, 267, 408, 24663, 314, 2061, 63, 6843, 436, 2061, 63, 21566, 402, 314, 1453, 922, 288, 520, 635, 315, 8240, 63, 5191, 26, 7373, 315, 21131, 267, 408, 267, 20024, 275, 291, 14, 1733, 8318, 751, 63, 344, 297, 6291, 291, 423, 1535, 4360, 2304, 29, 17, 9, 267, 327, 4526, 2061, 63, 21566, 4913, 267, 2061, 63, 21566, 275, 2197, 14, 2083, 14, 2131, 342, 446, 2197, 14, 7473, 8, 19579, 4515, 29, 262, 8240, 63, 5191, 9, 267, 1338, 275, 469, 288, 283, 2019, 63, 6843, 356, 900, 14, 6205, 8, 3472, 63, 6613, 63, 12488, 63, 4807, 395, 267, 789, 267, 327, 1678, 314, 20024, 503, 282, 1218, 282, 892, 1373, 267, 340, 440, 20024, 26, 221, 327, 1218, 282, 892, 20024, 367, 314, 922, 288, 1338, 459, 751, 63, 344, 418, 275, 291, 423, 1535, 288, 1338, 459, 2019, 63, 21566, 418, 275, 2061, 63, 21566, 14, 6205, 8, 3472, 63, 6613, 63, 12488, 63, 4807, 9, 288, 291, 14, 981, 8, 1459, 9, 267, 587, 26, 221, 327, 1678, 314, 2061, 63, 21566, 340, 5784, 12, 436, 2218, 1338, 288, 340, 2197, 14, 2083, 14, 9866, 8, 21566, 14, 2019, 63, 21566, 12, 6186, 63, 6613, 63, 12488, 63, 4807, 9, 665, 2061, 63, 21566, 26, 355, 1338, 459, 2019, 63, 21566, 418, 275, 2061, 63, 21566, 14, 6205, 8, 3472, 63, 6613, 63, 12488, 63, 4807, 9, 288, 327, 869, 2655, 6008, 16953, 2552, 12, 1314, 883, 506, 5525, 12, 314, 20024, 1678, 365, 440, 22829, 1009, 288, 543, 7249, 14, 12423, 63, 2921, 360, 22058, 14, 3009, 63, 697, 735, 355, 20024, 14, 952, 8, 1459, 9, 267, 327, 5126, 18244, 24363, 894, 547, 267, 291, 14, 1813, 14, 1556, 14, 3543, 342, 327, 3254, 520, 1104, 340, 5139, 5784, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 646, 900, 199, 199, 504, 28811, 492, 2986, 12, 1504, 12, 1709, 199, 504, 28811, 492, 7249, 199, 504, 28811, 14, 10788, 14, 5610, 14, 992, 14, 5610, 492, 29998, 199, 504, 28811, 14, 2537, 14, 9923, 492, 6186, 63, 6613, 63, 12488, 63, 4807, 199, 199, 6178, 18389, 63, 29108, 275, 29998, 435, 959, 199, 15088, 3448, 63, 29108, 275, 6155, 383, 221, 327, 4233, 9395, 421, 199, 533, 18573, 2398, 14073, 8, 992, 14, 1685, 304, 272, 408, 2876, 5543, 14073, 267, 22940, 2004, 365, 283, 15178, 297, 283, 22703, 7, 503, 283, 18430, 1370, 961, 1402, 1077, 506, 282, 1373, 18, 368, 12, 1325, 365, 440, 267, 10102, 370, 522, 63, 3707, 370, 5126, 3050, 406, 895, 4646, 2552, 14, 9336, 314, 283, 873, 7, 1083, 365, 7934, 267, 737, 1924, 11271, 12, 340, 314, 922, 1172, 3663, 12123, 12187, 12, 406, 895, 4646, 2552, 883, 394, 740, 12, 1325, 787, 283, 77, 4241, 13, 12419, 1370, 272, 408, 339, 485, 354, 275, 283, 5610, 14, 21566, 7, 272, 485, 1802, 275, 283, 1899, 5543, 14073, 7, 272, 485, 793, 63, 2732, 275, 756, 339, 485, 3009, 63, 9882, 275, 4274, 5610, 63, 751, 63, 21566, 63, 3235, 297, 283, 3235, 8, 751, 63, 344, 3196, 283, 33, 922, 883, 1454, 1172, 1373, 18211, 2004, 2659, 61, 339, 922, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 3707, 297, 283, 12117, 297, 1415, 29, 549, 12, 1478, 29, 549, 12, 16549, 534, 15377, 358, 272, 2061, 63, 6843, 275, 1504, 14, 19636, 360, 6090, 25306, 297, 849, 29, 2734, 291, 26, 1504, 14, 19636, 14, 2131, 1012, 272, 2061, 63, 21566, 275, 1504, 14, 19636, 360, 6090, 5543, 14073, 297, 849, 29, 2734, 291, 26, 1504, 14, 19636, 14, 2131, 1012, 272, 2004, 275, 1504, 14, 7713, 8318, 15178, 297, 283, 28587, 659, 661, 22703, 297, 283, 33, 3316, 659, 661, 18430, 297, 283, 5195, 604, 2665, 283, 1469, 9795, 297, 849, 534, 18430, 358, 339, 768, 1246, 14, 1238, 272, 347, 1678, 8, 277, 12, 315, 8240, 63, 5191, 304, 267, 408, 24663, 314, 2061, 63, 6843, 436, 2061, 63, 21566, 402, 314, 1453, 922, 288, 520, 635, 315, 8240, 63, 5191, 26, 7373, 315, 21131, 267, 408, 267, 20024, 275, 291, 14, 1733, 8318, 751, 63, 344, 297, 6291, 291, 423, 1535, 4360, 2304, 29, 17, 9, 267, 327, 4526, 2061, 63, 21566, 4913, 267, 2061, 63, 21566, 275, 2197, 14, 2083, 14, 2131, 342, 446, 2197, 14, 7473, 8, 19579, 4515, 29, 262, 8240, 63, 5191, 9, 267, 1338, 275, 469, 288, 283, 2019, 63, 6843, 356, 900, 14, 6205, 8, 3472, 63, 6613, 63, 12488, 63, 4807, 395, 267, 789, 267, 327, 1678, 314, 20024, 503, 282, 1218, 282, 892, 1373, 267, 340, 440, 20024, 26, 221, 327, 1218, 282, 892, 20024, 367, 314, 922, 288, 1338, 459, 751, 63, 344, 418, 275, 291, 423, 1535, 288, 1338, 459, 2019, 63, 21566, 418, 275, 2061, 63, 21566, 14, 6205, 8, 3472, 63, 6613, 63, 12488, 63, 4807, 9, 288, 291, 14, 981, 8, 1459, 9, 267, 587, 26, 221, 327, 1678, 314, 2061, 63, 21566, 340, 5784, 12, 436, 2218, 1338, 288, 340, 2197, 14, 2083, 14, 9866, 8, 21566, 14, 2019, 63, 21566, 12, 6186, 63, 6613, 63, 12488, 63, 4807, 9, 665, 2061, 63, 21566, 26, 355, 1338, 459, 2019, 63, 21566, 418, 275, 2061, 63, 21566, 14, 6205, 8, 3472, 63, 6613, 63, 12488, 63, 4807, 9, 288, 327, 869, 2655, 6008, 16953, 2552, 12, 1314, 883, 506, 5525, 12, 314, 20024, 1678, 365, 440, 22829, 1009, 288, 543, 7249, 14, 12423, 63, 2921, 360, 22058, 14, 3009, 63, 697, 735, 355, 20024, 14, 952, 8, 1459, 9, 267, 327, 5126, 18244, 24363, 894, 547, 267, 291, 14, 1813, 14, 1556, 14, 3543, 342, 327, 3254, 520, 1104, 340, 5139, 5784, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
stackforge/watcher
watcher/notifications/audit.py
2
12071
# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE <vincent.francoise@b-com.com> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from oslo_config import cfg from watcher.common import exception from watcher.notifications import base as notificationbase from watcher.notifications import exception as exception_notifications from watcher.notifications import goal as goal_notifications from watcher.notifications import strategy as strategy_notifications from watcher.objects import base from watcher.objects import fields as wfields CONF = cfg.CONF @base.WatcherObjectRegistry.register_notification class TerseAuditPayload(notificationbase.NotificationPayloadBase): SCHEMA = { 'uuid': ('audit', 'uuid'), 'name': ('audit', 'name'), 'audit_type': ('audit', 'audit_type'), 'state': ('audit', 'state'), 'parameters': ('audit', 'parameters'), 'interval': ('audit', 'interval'), 'scope': ('audit', 'scope'), 'auto_trigger': ('audit', 'auto_trigger'), 'next_run_time': ('audit', 'next_run_time'), 'created_at': ('audit', 'created_at'), 'updated_at': ('audit', 'updated_at'), 'deleted_at': ('audit', 'deleted_at'), } # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' boolean field, # Added 'next_run_time' DateTime field, # 'interval' type has been changed from Integer to String # Version 1.2: Added 'name' string field VERSION = '1.2' fields = { 'uuid': wfields.UUIDField(), 'name': wfields.StringField(), 'audit_type': wfields.StringField(), 'state': wfields.StringField(), 'parameters': wfields.FlexibleDictField(nullable=True), 'interval': wfields.StringField(nullable=True), 'scope': wfields.FlexibleListOfDictField(nullable=True), 'goal_uuid': wfields.UUIDField(), 'strategy_uuid': wfields.UUIDField(nullable=True), 'auto_trigger': wfields.BooleanField(), 'next_run_time': wfields.DateTimeField(nullable=True), 'created_at': wfields.DateTimeField(nullable=True), 'updated_at': wfields.DateTimeField(nullable=True), 'deleted_at': wfields.DateTimeField(nullable=True), } def __init__(self, audit, goal_uuid, strategy_uuid=None, **kwargs): super(TerseAuditPayload, self).__init__( goal_uuid=goal_uuid, strategy_uuid=strategy_uuid, **kwargs) self.populate_schema(audit=audit) @base.WatcherObjectRegistry.register_notification class AuditPayload(TerseAuditPayload): SCHEMA = { 'uuid': ('audit', 'uuid'), 'name': ('audit', 'name'), 'audit_type': ('audit', 'audit_type'), 'state': ('audit', 'state'), 'parameters': ('audit', 'parameters'), 'interval': ('audit', 'interval'), 'scope': ('audit', 'scope'), 'auto_trigger': ('audit', 'auto_trigger'), 'next_run_time': ('audit', 'next_run_time'), 'created_at': ('audit', 'created_at'), 'updated_at': ('audit', 'updated_at'), 'deleted_at': ('audit', 'deleted_at'), } # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' field, # Added 'next_run_time' field # Version 1.2: Added 'name' string field VERSION = '1.2' fields = { 'goal': wfields.ObjectField('GoalPayload'), 'strategy': wfields.ObjectField('StrategyPayload', nullable=True), } def __init__(self, audit, goal, strategy=None, **kwargs): if not kwargs.get('goal_uuid'): kwargs['goal_uuid'] = goal.uuid if strategy and not kwargs.get('strategy_uuid'): kwargs['strategy_uuid'] = strategy.uuid super(AuditPayload, self).__init__( audit=audit, goal=goal, strategy=strategy, **kwargs) @base.WatcherObjectRegistry.register_notification class AuditStateUpdatePayload(notificationbase.NotificationPayloadBase): # Version 1.0: Initial version VERSION = '1.0' fields = { 'old_state': wfields.StringField(nullable=True), 'state': wfields.StringField(nullable=True), } @base.WatcherObjectRegistry.register_notification class AuditCreatePayload(AuditPayload): # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' field, # Added 'next_run_time' field VERSION = '1.1' fields = {} def __init__(self, audit, goal, strategy): super(AuditCreatePayload, self).__init__( audit=audit, goal=goal, goal_uuid=goal.uuid, strategy=strategy) @base.WatcherObjectRegistry.register_notification class AuditUpdatePayload(AuditPayload): # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' field, # Added 'next_run_time' field VERSION = '1.1' fields = { 'state_update': wfields.ObjectField('AuditStateUpdatePayload'), } def __init__(self, audit, state_update, goal, strategy): super(AuditUpdatePayload, self).__init__( audit=audit, state_update=state_update, goal=goal, goal_uuid=goal.uuid, strategy=strategy) @base.WatcherObjectRegistry.register_notification class AuditActionPayload(AuditPayload): # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' field, # Added 'next_run_time' field VERSION = '1.1' fields = { 'fault': wfields.ObjectField('ExceptionPayload', nullable=True), } def __init__(self, audit, goal, strategy, **kwargs): super(AuditActionPayload, self).__init__( audit=audit, goal=goal, goal_uuid=goal.uuid, strategy=strategy, **kwargs) @base.WatcherObjectRegistry.register_notification class AuditDeletePayload(AuditPayload): # Version 1.0: Initial version # Version 1.1: Added 'auto_trigger' field, # Added 'next_run_time' field VERSION = '1.1' fields = {} def __init__(self, audit, goal, strategy): super(AuditDeletePayload, self).__init__( audit=audit, goal=goal, goal_uuid=goal.uuid, strategy=strategy) @notificationbase.notification_sample('audit-strategy-error.json') @notificationbase.notification_sample('audit-strategy-end.json') @notificationbase.notification_sample('audit-strategy-start.json') @base.WatcherObjectRegistry.register_notification class AuditActionNotification(notificationbase.NotificationBase): # Version 1.0: Initial version VERSION = '1.0' fields = { 'payload': wfields.ObjectField('AuditActionPayload') } @notificationbase.notification_sample('audit-create.json') @base.WatcherObjectRegistry.register_notification class AuditCreateNotification(notificationbase.NotificationBase): # Version 1.0: Initial version VERSION = '1.0' fields = { 'payload': wfields.ObjectField('AuditCreatePayload') } @notificationbase.notification_sample('audit-update.json') @base.WatcherObjectRegistry.register_notification class AuditUpdateNotification(notificationbase.NotificationBase): # Version 1.0: Initial version VERSION = '1.0' fields = { 'payload': wfields.ObjectField('AuditUpdatePayload') } @notificationbase.notification_sample('audit-delete.json') @base.WatcherObjectRegistry.register_notification class AuditDeleteNotification(notificationbase.NotificationBase): # Version 1.0: Initial version VERSION = '1.0' fields = { 'payload': wfields.ObjectField('AuditDeletePayload') } def _get_common_payload(audit): goal = None strategy = None try: goal = audit.goal if audit.strategy_id: strategy = audit.strategy except NotImplementedError: raise exception.EagerlyLoadedAuditRequired(audit=audit.uuid) goal_payload = goal_notifications.GoalPayload(goal=goal) strategy_payload = None if strategy: strategy_payload = strategy_notifications.StrategyPayload( strategy=strategy) return goal_payload, strategy_payload def send_create(context, audit, service='infra-optim', host=None): """Emit an audit.create notification.""" goal_payload, strategy_payload = _get_common_payload(audit) versioned_payload = AuditCreatePayload( audit=audit, goal=goal_payload, strategy=strategy_payload, ) notification = AuditCreateNotification( priority=wfields.NotificationPriority.INFO, event_type=notificationbase.EventType( object='audit', action=wfields.NotificationAction.CREATE), publisher=notificationbase.NotificationPublisher( host=host or CONF.host, binary=service), payload=versioned_payload) notification.emit(context) def send_update(context, audit, service='infra-optim', host=None, old_state=None): """Emit an audit.update notification.""" goal_payload, strategy_payload = _get_common_payload(audit) state_update = AuditStateUpdatePayload( old_state=old_state, state=audit.state if old_state else None) versioned_payload = AuditUpdatePayload( audit=audit, state_update=state_update, goal=goal_payload, strategy=strategy_payload, ) notification = AuditUpdateNotification( priority=wfields.NotificationPriority.INFO, event_type=notificationbase.EventType( object='audit', action=wfields.NotificationAction.UPDATE), publisher=notificationbase.NotificationPublisher( host=host or CONF.host, binary=service), payload=versioned_payload) notification.emit(context) def send_delete(context, audit, service='infra-optim', host=None): goal_payload, strategy_payload = _get_common_payload(audit) versioned_payload = AuditDeletePayload( audit=audit, goal=goal_payload, strategy=strategy_payload, ) notification = AuditDeleteNotification( priority=wfields.NotificationPriority.INFO, event_type=notificationbase.EventType( object='audit', action=wfields.NotificationAction.DELETE), publisher=notificationbase.NotificationPublisher( host=host or CONF.host, binary=service), payload=versioned_payload) notification.emit(context) def send_action_notification(context, audit, action, phase=None, priority=wfields.NotificationPriority.INFO, service='infra-optim', host=None): """Emit an audit action notification.""" goal_payload, strategy_payload = _get_common_payload(audit) fault = None if phase == wfields.NotificationPhase.ERROR: fault = exception_notifications.ExceptionPayload.from_exception() versioned_payload = AuditActionPayload( audit=audit, goal=goal_payload, strategy=strategy_payload, fault=fault, ) notification = AuditActionNotification( priority=priority, event_type=notificationbase.EventType( object='audit', action=action, phase=phase), publisher=notificationbase.NotificationPublisher( host=host or CONF.host, binary=service), payload=versioned_payload) notification.emit(context)
apache-2.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 7800, 330, 16137, 957, 199, 3, 199, 3, 6642, 26, 28882, 2946, 481, 27644, 1439, 4971, 665, 11908, 2946, 14, 70, 1312, 331, 572, 32, 66, 13, 957, 14, 957, 30, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 199, 504, 9626, 281, 14, 2330, 492, 1919, 199, 504, 9626, 281, 14, 12782, 492, 1300, 465, 6955, 1095, 199, 504, 9626, 281, 14, 12782, 492, 1919, 465, 1919, 63, 12782, 199, 504, 9626, 281, 14, 12782, 492, 14850, 465, 14850, 63, 12782, 199, 504, 9626, 281, 14, 12782, 492, 10054, 465, 10054, 63, 12782, 199, 504, 9626, 281, 14, 1462, 492, 1300, 199, 504, 9626, 281, 14, 1462, 492, 1504, 465, 336, 955, 199, 199, 3103, 275, 4810, 14, 3103, 421, 199, 32, 1095, 14, 13978, 281, 1692, 10899, 14, 2683, 63, 6761, 199, 533, 13861, 261, 23601, 17215, 8, 6761, 1095, 14, 11598, 17215, 1563, 304, 272, 428, 10364, 275, 469, 267, 283, 2580, 356, 661, 14274, 297, 283, 2580, 659, 267, 283, 354, 356, 661, 14274, 297, 283, 354, 659, 267, 283, 14274, 63, 466, 356, 661, 14274, 297, 283, 14274, 63, 466, 659, 267, 283, 929, 356, 661, 14274, 297, 283, 929, 659, 267, 283, 3214, 356, 661, 14274, 297, 283, 3214, 659, 267, 283, 4284, 356, 661, 14274, 297, 283, 4284, 659, 267, 283, 2645, 356, 661, 14274, 297, 283, 2645, 659, 267, 283, 2495, 63, 7631, 356, 661, 14274, 297, 283, 2495, 63, 7631, 659, 267, 283, 2184, 63, 1065, 63, 521, 356, 661, 14274, 297, 283, 2184, 63, 1065, 63, 521, 659, 398, 283, 3966, 63, 292, 356, 661, 14274, 297, 283, 3966, 63, 292, 659, 267, 283, 5334, 63, 292, 356, 661, 14274, 297, 283, 5334, 63, 292, 659, 267, 283, 6062, 63, 292, 356, 661, 14274, 297, 283, 6062, 63, 292, 659, 272, 789, 339, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 327, 3394, 413, 14, 17, 26, 16230, 283, 2495, 63, 7631, 7, 5046, 901, 12, 272, 327, 4519, 16230, 283, 2184, 63, 1065, 63, 521, 7, 13686, 901, 12, 272, 327, 4519, 283, 4284, 7, 730, 965, 2757, 2896, 687, 7225, 370, 2624, 272, 327, 3394, 413, 14, 18, 26, 16230, 283, 354, 7, 1059, 901, 272, 15945, 275, 283, 17, 14, 18, 7, 339, 1504, 275, 469, 267, 283, 2580, 356, 336, 955, 14, 8757, 792, 1062, 267, 283, 354, 356, 336, 955, 14, 14912, 1062, 267, 283, 14274, 63, 466, 356, 336, 955, 14, 14912, 1062, 267, 283, 929, 356, 336, 955, 14, 14912, 1062, 267, 283, 3214, 356, 336, 955, 14, 9389, 2141, 792, 8, 16375, 29, 549, 395, 267, 283, 4284, 356, 336, 955, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 2645, 356, 336, 955, 14, 9389, 30210, 2141, 792, 8, 16375, 29, 549, 395, 267, 283, 16117, 63, 2580, 356, 336, 955, 14, 8757, 792, 1062, 267, 283, 8590, 63, 2580, 356, 336, 955, 14, 8757, 792, 8, 16375, 29, 549, 395, 267, 283, 2495, 63, 7631, 356, 336, 955, 14, 5036, 1062, 267, 283, 2184, 63, 1065, 63, 521, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 398, 283, 3966, 63, 292, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 267, 283, 5334, 63, 292, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 267, 283, 6062, 63, 292, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 272, 789, 339, 347, 636, 826, 721, 277, 12, 13968, 12, 14850, 63, 2580, 12, 10054, 63, 2580, 29, 403, 12, 1011, 958, 304, 267, 1613, 8, 8600, 261, 23601, 17215, 12, 291, 2843, 826, 721, 288, 14850, 63, 2580, 29, 16117, 63, 2580, 12, 10054, 63, 2580, 29, 8590, 63, 2580, 12, 1011, 958, 9, 267, 291, 14, 13817, 63, 3629, 8, 14274, 29, 14274, 9, 421, 199, 32, 1095, 14, 13978, 281, 1692, 10899, 14, 2683, 63, 6761, 199, 533, 31853, 1741, 17215, 8, 8600, 261, 23601, 17215, 304, 272, 428, 10364, 275, 469, 267, 283, 2580, 356, 661, 14274, 297, 283, 2580, 659, 267, 283, 354, 356, 661, 14274, 297, 283, 354, 659, 267, 283, 14274, 63, 466, 356, 661, 14274, 297, 283, 14274, 63, 466, 659, 267, 283, 929, 356, 661, 14274, 297, 283, 929, 659, 267, 283, 3214, 356, 661, 14274, 297, 283, 3214, 659, 267, 283, 4284, 356, 661, 14274, 297, 283, 4284, 659, 267, 283, 2645, 356, 661, 14274, 297, 283, 2645, 659, 267, 283, 2495, 63, 7631, 356, 661, 14274, 297, 283, 2495, 63, 7631, 659, 267, 283, 2184, 63, 1065, 63, 521, 356, 661, 14274, 297, 283, 2184, 63, 1065, 63, 521, 659, 398, 283, 3966, 63, 292, 356, 661, 14274, 297, 283, 3966, 63, 292, 659, 267, 283, 5334, 63, 292, 356, 661, 14274, 297, 283, 5334, 63, 292, 659, 267, 283, 6062, 63, 292, 356, 661, 14274, 297, 283, 6062, 63, 292, 659, 272, 789, 339, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 327, 3394, 413, 14, 17, 26, 16230, 283, 2495, 63, 7631, 7, 901, 12, 272, 327, 4519, 16230, 283, 2184, 63, 1065, 63, 521, 7, 901, 272, 327, 3394, 413, 14, 18, 26, 16230, 283, 354, 7, 1059, 901, 272, 15945, 275, 283, 17, 14, 18, 7, 339, 1504, 275, 469, 267, 283, 16117, 356, 336, 955 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 7800, 330, 16137, 957, 199, 3, 199, 3, 6642, 26, 28882, 2946, 481, 27644, 1439, 4971, 665, 11908, 2946, 14, 70, 1312, 331, 572, 32, 66, 13, 957, 14, 957, 30, 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, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 199, 504, 9626, 281, 14, 2330, 492, 1919, 199, 504, 9626, 281, 14, 12782, 492, 1300, 465, 6955, 1095, 199, 504, 9626, 281, 14, 12782, 492, 1919, 465, 1919, 63, 12782, 199, 504, 9626, 281, 14, 12782, 492, 14850, 465, 14850, 63, 12782, 199, 504, 9626, 281, 14, 12782, 492, 10054, 465, 10054, 63, 12782, 199, 504, 9626, 281, 14, 1462, 492, 1300, 199, 504, 9626, 281, 14, 1462, 492, 1504, 465, 336, 955, 199, 199, 3103, 275, 4810, 14, 3103, 421, 199, 32, 1095, 14, 13978, 281, 1692, 10899, 14, 2683, 63, 6761, 199, 533, 13861, 261, 23601, 17215, 8, 6761, 1095, 14, 11598, 17215, 1563, 304, 272, 428, 10364, 275, 469, 267, 283, 2580, 356, 661, 14274, 297, 283, 2580, 659, 267, 283, 354, 356, 661, 14274, 297, 283, 354, 659, 267, 283, 14274, 63, 466, 356, 661, 14274, 297, 283, 14274, 63, 466, 659, 267, 283, 929, 356, 661, 14274, 297, 283, 929, 659, 267, 283, 3214, 356, 661, 14274, 297, 283, 3214, 659, 267, 283, 4284, 356, 661, 14274, 297, 283, 4284, 659, 267, 283, 2645, 356, 661, 14274, 297, 283, 2645, 659, 267, 283, 2495, 63, 7631, 356, 661, 14274, 297, 283, 2495, 63, 7631, 659, 267, 283, 2184, 63, 1065, 63, 521, 356, 661, 14274, 297, 283, 2184, 63, 1065, 63, 521, 659, 398, 283, 3966, 63, 292, 356, 661, 14274, 297, 283, 3966, 63, 292, 659, 267, 283, 5334, 63, 292, 356, 661, 14274, 297, 283, 5334, 63, 292, 659, 267, 283, 6062, 63, 292, 356, 661, 14274, 297, 283, 6062, 63, 292, 659, 272, 789, 339, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 327, 3394, 413, 14, 17, 26, 16230, 283, 2495, 63, 7631, 7, 5046, 901, 12, 272, 327, 4519, 16230, 283, 2184, 63, 1065, 63, 521, 7, 13686, 901, 12, 272, 327, 4519, 283, 4284, 7, 730, 965, 2757, 2896, 687, 7225, 370, 2624, 272, 327, 3394, 413, 14, 18, 26, 16230, 283, 354, 7, 1059, 901, 272, 15945, 275, 283, 17, 14, 18, 7, 339, 1504, 275, 469, 267, 283, 2580, 356, 336, 955, 14, 8757, 792, 1062, 267, 283, 354, 356, 336, 955, 14, 14912, 1062, 267, 283, 14274, 63, 466, 356, 336, 955, 14, 14912, 1062, 267, 283, 929, 356, 336, 955, 14, 14912, 1062, 267, 283, 3214, 356, 336, 955, 14, 9389, 2141, 792, 8, 16375, 29, 549, 395, 267, 283, 4284, 356, 336, 955, 14, 14912, 8, 16375, 29, 549, 395, 267, 283, 2645, 356, 336, 955, 14, 9389, 30210, 2141, 792, 8, 16375, 29, 549, 395, 267, 283, 16117, 63, 2580, 356, 336, 955, 14, 8757, 792, 1062, 267, 283, 8590, 63, 2580, 356, 336, 955, 14, 8757, 792, 8, 16375, 29, 549, 395, 267, 283, 2495, 63, 7631, 356, 336, 955, 14, 5036, 1062, 267, 283, 2184, 63, 1065, 63, 521, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 398, 283, 3966, 63, 292, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 267, 283, 5334, 63, 292, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 267, 283, 6062, 63, 292, 356, 336, 955, 14, 4626, 8, 16375, 29, 549, 395, 272, 789, 339, 347, 636, 826, 721, 277, 12, 13968, 12, 14850, 63, 2580, 12, 10054, 63, 2580, 29, 403, 12, 1011, 958, 304, 267, 1613, 8, 8600, 261, 23601, 17215, 12, 291, 2843, 826, 721, 288, 14850, 63, 2580, 29, 16117, 63, 2580, 12, 10054, 63, 2580, 29, 8590, 63, 2580, 12, 1011, 958, 9, 267, 291, 14, 13817, 63, 3629, 8, 14274, 29, 14274, 9, 421, 199, 32, 1095, 14, 13978, 281, 1692, 10899, 14, 2683, 63, 6761, 199, 533, 31853, 1741, 17215, 8, 8600, 261, 23601, 17215, 304, 272, 428, 10364, 275, 469, 267, 283, 2580, 356, 661, 14274, 297, 283, 2580, 659, 267, 283, 354, 356, 661, 14274, 297, 283, 354, 659, 267, 283, 14274, 63, 466, 356, 661, 14274, 297, 283, 14274, 63, 466, 659, 267, 283, 929, 356, 661, 14274, 297, 283, 929, 659, 267, 283, 3214, 356, 661, 14274, 297, 283, 3214, 659, 267, 283, 4284, 356, 661, 14274, 297, 283, 4284, 659, 267, 283, 2645, 356, 661, 14274, 297, 283, 2645, 659, 267, 283, 2495, 63, 7631, 356, 661, 14274, 297, 283, 2495, 63, 7631, 659, 267, 283, 2184, 63, 1065, 63, 521, 356, 661, 14274, 297, 283, 2184, 63, 1065, 63, 521, 659, 398, 283, 3966, 63, 292, 356, 661, 14274, 297, 283, 3966, 63, 292, 659, 267, 283, 5334, 63, 292, 356, 661, 14274, 297, 283, 5334, 63, 292, 659, 267, 283, 6062, 63, 292, 356, 661, 14274, 297, 283, 6062, 63, 292, 659, 272, 789, 339, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 327, 3394, 413, 14, 17, 26, 16230, 283, 2495, 63, 7631, 7, 901, 12, 272, 327, 4519, 16230, 283, 2184, 63, 1065, 63, 521, 7, 901, 272, 327, 3394, 413, 14, 18, 26, 16230, 283, 354, 7, 1059, 901, 272, 15945, 275, 283, 17, 14, 18, 7, 339, 1504, 275, 469, 267, 283, 16117, 356, 336, 955, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rallylee/gem5
src/cpu/minor/MinorCPU.py
12
11679
# Copyright (c) 2012-2014 ARM Limited # All rights reserved. # # The license below extends only to copyright in the software and shall # not be construed as granting a license to any other intellectual # property including but not limited to intellectual property relating # to a hardware implementation of the functionality of the software # licensed hereunder. You may use the software subject to the license # terms below provided that you ensure that this notice is replicated # unmodified and in its entirety in all distributions of the software, # modified or unmodified, in source code or in binary form. # # Copyright (c) 2007 The Regents of The University of Michigan # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer; # redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution; # neither the name of the copyright holders 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. # # Authors: Gabe Black # Nathan Binkert # Andrew Bardsley from m5.defines import buildEnv from m5.params import * from m5.proxy import * from m5.SimObject import SimObject from BaseCPU import BaseCPU from DummyChecker import DummyChecker from BranchPredictor import * from TimingExpr import TimingExpr from FuncUnit import OpClass class MinorOpClass(SimObject): """Boxing of OpClass to get around build problems and provide a hook for future additions to OpClass checks""" type = 'MinorOpClass' cxx_header = "cpu/minor/func_unit.hh" opClass = Param.OpClass("op class to match") class MinorOpClassSet(SimObject): """A set of matchable op classes""" type = 'MinorOpClassSet' cxx_header = "cpu/minor/func_unit.hh" opClasses = VectorParam.MinorOpClass([], "op classes to be matched." " An empty list means any class") class MinorFUTiming(SimObject): type = 'MinorFUTiming' cxx_header = "cpu/minor/func_unit.hh" mask = Param.UInt64(0, "mask for testing ExtMachInst") match = Param.UInt64(0, "match value for testing ExtMachInst:" " (ext_mach_inst & mask) == match") suppress = Param.Bool(False, "if true, this inst. is not executed by" " this FU") extraCommitLat = Param.Cycles(0, "extra cycles to stall commit for" " this inst.") extraCommitLatExpr = Param.TimingExpr(NULL, "extra cycles as a" " run-time evaluated expression") extraAssumedLat = Param.Cycles(0, "extra cycles to add to scoreboard" " retire time for this insts dest registers once it leaves the" " functional unit. For mem refs, if this is 0, the result's time" " is marked as unpredictable and no forwarding can take place.") srcRegsRelativeLats = VectorParam.Cycles("the maximum number of cycles" " after inst. issue that each src reg can be available for this" " inst. to issue") opClasses = Param.MinorOpClassSet(MinorOpClassSet(), "op classes to be considered for this decode. An empty set means any" " class") description = Param.String('', "description string of the decoding/inst." " class") def minorMakeOpClassSet(op_classes): """Make a MinorOpClassSet from a list of OpClass enum value strings""" def boxOpClass(op_class): return MinorOpClass(opClass=op_class) return MinorOpClassSet(opClasses=map(boxOpClass, op_classes)) class MinorFU(SimObject): type = 'MinorFU' cxx_header = "cpu/minor/func_unit.hh" opClasses = Param.MinorOpClassSet(MinorOpClassSet(), "type of operations" " allowed on this functional unit") opLat = Param.Cycles(1, "latency in cycles") issueLat = Param.Cycles(1, "cycles until another instruction can be" " issued") timings = VectorParam.MinorFUTiming([], "extra decoding rules") cantForwardFromFUIndices = VectorParam.Unsigned([], "list of FU indices from which this FU can't receive and early" " (forwarded) result") class MinorFUPool(SimObject): type = 'MinorFUPool' cxx_header = "cpu/minor/func_unit.hh" funcUnits = VectorParam.MinorFU("functional units") class MinorDefaultIntFU(MinorFU): opClasses = minorMakeOpClassSet(['IntAlu']) timings = [MinorFUTiming(description="Int", srcRegsRelativeLats=[2])] opLat = 3 class MinorDefaultIntMulFU(MinorFU): opClasses = minorMakeOpClassSet(['IntMult']) timings = [MinorFUTiming(description='Mul', srcRegsRelativeLats=[0])] opLat = 3 class MinorDefaultIntDivFU(MinorFU): opClasses = minorMakeOpClassSet(['IntDiv']) issueLat = 9 opLat = 9 class MinorDefaultFloatSimdFU(MinorFU): opClasses = minorMakeOpClassSet([ 'FloatAdd', 'FloatCmp', 'FloatCvt', 'FloatMisc', 'FloatMult', 'FloatMultAcc', 'FloatDiv', 'FloatSqrt', 'SimdAdd', 'SimdAddAcc', 'SimdAlu', 'SimdCmp', 'SimdCvt', 'SimdMisc', 'SimdMult', 'SimdMultAcc', 'SimdShift', 'SimdShiftAcc', 'SimdSqrt', 'SimdFloatAdd', 'SimdFloatAlu', 'SimdFloatCmp', 'SimdFloatCvt', 'SimdFloatDiv', 'SimdFloatMisc', 'SimdFloatMult', 'SimdFloatMultAcc', 'SimdFloatSqrt']) timings = [MinorFUTiming(description='FloatSimd', srcRegsRelativeLats=[2])] opLat = 6 class MinorDefaultMemFU(MinorFU): opClasses = minorMakeOpClassSet(['MemRead', 'MemWrite', 'FloatMemRead', 'FloatMemWrite']) timings = [MinorFUTiming(description='Mem', srcRegsRelativeLats=[1], extraAssumedLat=2)] opLat = 1 class MinorDefaultMiscFU(MinorFU): opClasses = minorMakeOpClassSet(['IprAccess', 'InstPrefetch']) opLat = 1 class MinorDefaultFUPool(MinorFUPool): funcUnits = [MinorDefaultIntFU(), MinorDefaultIntFU(), MinorDefaultIntMulFU(), MinorDefaultIntDivFU(), MinorDefaultFloatSimdFU(), MinorDefaultMemFU(), MinorDefaultMiscFU()] class ThreadPolicy(Enum): vals = ['SingleThreaded', 'RoundRobin', 'Random'] class MinorCPU(BaseCPU): type = 'MinorCPU' cxx_header = "cpu/minor/cpu.hh" @classmethod def memory_mode(cls): return 'timing' @classmethod def require_caches(cls): return True @classmethod def support_take_over(cls): return True threadPolicy = Param.ThreadPolicy('RoundRobin', "Thread scheduling policy") fetch1FetchLimit = Param.Unsigned(1, "Number of line fetches allowable in flight at once") fetch1LineSnapWidth = Param.Unsigned(0, "Fetch1 'line' fetch snap size in bytes" " (0 means use system cache line size)") fetch1LineWidth = Param.Unsigned(0, "Fetch1 maximum fetch size in bytes (0 means use system cache" " line size)") fetch1ToFetch2ForwardDelay = Param.Cycles(1, "Forward cycle delay from Fetch1 to Fetch2 (1 means next cycle)") fetch1ToFetch2BackwardDelay = Param.Cycles(1, "Backward cycle delay from Fetch2 to Fetch1 for branch prediction" " signalling (0 means in the same cycle, 1 mean the next cycle)") fetch2InputBufferSize = Param.Unsigned(2, "Size of input buffer to Fetch2 in cycles-worth of insts.") fetch2ToDecodeForwardDelay = Param.Cycles(1, "Forward cycle delay from Fetch2 to Decode (1 means next cycle)") fetch2CycleInput = Param.Bool(True, "Allow Fetch2 to cross input lines to generate full output each" " cycle") decodeInputBufferSize = Param.Unsigned(3, "Size of input buffer to Decode in cycles-worth of insts.") decodeToExecuteForwardDelay = Param.Cycles(1, "Forward cycle delay from Decode to Execute (1 means next cycle)") decodeInputWidth = Param.Unsigned(2, "Width (in instructions) of input to Decode (and implicitly" " Decode's own width)") decodeCycleInput = Param.Bool(True, "Allow Decode to pack instructions from more than one input cycle" " to fill its output each cycle") executeInputWidth = Param.Unsigned(2, "Width (in instructions) of input to Execute") executeCycleInput = Param.Bool(True, "Allow Execute to use instructions from more than one input cycle" " each cycle") executeIssueLimit = Param.Unsigned(2, "Number of issuable instructions in Execute each cycle") executeMemoryIssueLimit = Param.Unsigned(1, "Number of issuable memory instructions in Execute each cycle") executeCommitLimit = Param.Unsigned(2, "Number of committable instructions in Execute each cycle") executeMemoryCommitLimit = Param.Unsigned(1, "Number of committable memory references in Execute each cycle") executeInputBufferSize = Param.Unsigned(7, "Size of input buffer to Execute in cycles-worth of insts.") executeMemoryWidth = Param.Unsigned(0, "Width (and snap) in bytes of the data memory interface. (0 mean use" " the system cacheLineSize)") executeMaxAccessesInMemory = Param.Unsigned(2, "Maximum number of concurrent accesses allowed to the memory system" " from the dcache port") executeLSQMaxStoreBufferStoresPerCycle = Param.Unsigned(2, "Maximum number of stores that the store buffer can issue per cycle") executeLSQRequestsQueueSize = Param.Unsigned(1, "Size of LSQ requests queue (address translation queue)") executeLSQTransfersQueueSize = Param.Unsigned(2, "Size of LSQ transfers queue (memory transaction queue)") executeLSQStoreBufferSize = Param.Unsigned(5, "Size of LSQ store buffer") executeBranchDelay = Param.Cycles(1, "Delay from Execute deciding to branch and Fetch1 reacting" " (1 means next cycle)") executeFuncUnits = Param.MinorFUPool(MinorDefaultFUPool(), "FUlines for this processor") executeSetTraceTimeOnCommit = Param.Bool(True, "Set inst. trace times to be commit times") executeSetTraceTimeOnIssue = Param.Bool(False, "Set inst. trace times to be issue times") executeAllowEarlyMemoryIssue = Param.Bool(True, "Allow mem refs to be issued to the LSQ before reaching the head of" " the in flight insts queue") enableIdling = Param.Bool(True, "Enable cycle skipping when the processor is idle\n"); branchPred = Param.BranchPredictor(TournamentBP( numThreads = Parent.numThreads), "Branch Predictor") def addCheckerCpu(self): print "Checker not yet supported by MinorCPU" exit(1)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 13, 7280, 27155, 23954, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4190, 5084, 16879, 1454, 370, 4248, 315, 314, 2032, 436, 10989, 199, 3, 440, 506, 950, 431, 68, 465, 16085, 316, 282, 4190, 370, 1263, 1163, 27925, 1264, 1061, 199, 3, 3324, 5893, 1325, 440, 13988, 370, 27925, 1264, 1061, 3324, 4668, 1958, 199, 3, 370, 282, 14991, 4514, 402, 314, 9330, 402, 314, 2032, 199, 3, 18233, 2348, 7138, 14, 221, 2047, 1443, 675, 314, 2032, 5420, 370, 314, 4190, 199, 3, 2895, 5084, 2741, 626, 1265, 4868, 626, 642, 4245, 365, 32436, 199, 3, 24214, 436, 315, 2399, 8039, 369, 315, 1006, 10208, 402, 314, 2032, 12, 199, 3, 6042, 503, 24214, 12, 315, 1350, 1233, 503, 315, 3366, 1824, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 10219, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 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, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 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, 3, 199, 3, 6642, 26, 598, 7570, 30593, 199, 3, 3515, 653, 1619, 290, 699, 2292, 15299, 199, 3, 3515, 6061, 5257, 699, 5596, 15515, 199, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1162, 492, 627, 199, 504, 333, 21, 14, 3280, 492, 627, 199, 504, 333, 21, 14, 7467, 1692, 492, 10751, 1692, 199, 504, 3523, 11011, 492, 3523, 11011, 199, 504, 9762, 3048, 492, 9762, 3048, 199, 504, 699, 2965, 14730, 630, 492, 627, 199, 504, 26244, 316, 8561, 492, 26244, 316, 8561, 199, 199, 504, 28794, 5072, 492, 9319, 2543, 199, 199, 533, 10195, 269, 4619, 2543, 8, 7467, 1692, 304, 272, 408, 3532, 316, 402, 9319, 2543, 370, 664, 6818, 1900, 8826, 436, 5647, 282, 5759, 367, 272, 6466, 32113, 370, 9319, 2543, 5920, 624, 339, 730, 275, 283, 23094, 4619, 2543, 7, 272, 17327, 63, 1291, 275, 298, 3541, 15, 11067, 15, 1532, 63, 3248, 14, 12156, 2, 339, 1687, 2543, 275, 12608, 14, 4619, 2543, 480, 411, 1021, 370, 1336, 531, 199, 199, 533, 10195, 269, 4619, 2543, 1084, 8, 7467, 1692, 304, 272, 408, 33, 663, 402, 1336, 461, 1687, 3992, 624, 339, 730, 275, 283, 23094, 4619, 2543, 1084, 7, 272, 17327, 63, 1291, 275, 298, 3541, 15, 11067, 15, 1532, 63, 3248, 14, 12156, 2, 339, 1687, 15711, 275, 11388, 4098, 14, 23094, 4619, 2543, 8798, 298, 411, 3992, 370, 506, 7838, 2122, 267, 298, 221, 1626, 2701, 769, 4910, 1263, 1021, 531, 199, 199, 533, 10195, 269, 20254, 1017, 316, 8, 7467, 1692, 304, 272, 730, 275, 283, 23094, 20254, 1017, 316, 7, 272, 17327, 63, 1291, 275, 298, 3541, 15, 11067, 15, 1532, 63, 3248, 14, 12156, 2, 339, 3656, 275, 12608, 14, 13304, 772, 8, 16, 12, 298, 2629, 367, 5343, 7255, 45, 1225, 10083, 531, 272, 1336, 275, 12608, 14, 13304, 772, 8, 16, 12, 298, 1431, 574, 367, 5343, 7255, 45, 1225, 10083, 5424, 267, 298, 334, 832, 63, 14121, 63, 3615, 1253, 3656, 9, 508, 1336, 531, 272, 15678, 275, 12608, 14, 10349, 8, 797, 12, 298, 692, 2549, 12, 642, 2727, 14, 365, 440, 7934, 701, 2, 267, 298, 642, 481, 53, 531, 272, 2402, 11421, 22510, 275, 12608, 14, 28016, 8, 16, 12, 298, 2911, 19001, 370, 410, 452, 5532, 367, 2, 267, 298, 642, 2727, 2685, 272, 2402, 11421, 22510, 8561, 275, 12608, 14, 30101, 8561, 8, 8084, 12, 298, 2911, 19001, 465, 282, 2, 267, 298, 1255, 13, 521, 13006, 3965, 531, 272, 2402, 9824, 940, 68, 22510, 275, 12608, 14, 28016, 8, 16, 12, 298, 2911, 19001, 370, 1050, 370, 5396, 3576, 2, 267, 298, 295, 7261, 900, 367, 642, 2727, 83, 2053, 24493, 5403, 652, 16733, 314, 2, 267, 298, 22380, 4137, 14, 221, 2104, 7573, 15749, 12, 340, 642, 365, 378, 12, 314, 754, 1159, 900, 2, 267, 298, 365, 11584, 465, 625, 6892, 461, 436, 949, 24119, 883, 5452, 4192, 2685, 272, 2928, 497, 458, 15277, 44, 1956, 275, 11388, 4098, 14, 28016, 480, 1589, 5696, 1329, 402, 19001, 2, 267, 298, 2410, 2727, 14, 4976, 626, 1924, 2928, 1295, 883, 506, 2808, 367, 642, 2, 267, 298, 2727, 14, 370, 4976, 531, 272, 1687, 15711, 275, 12608, 14, 23094, 4619, 2543, 1084, 8, 23094, 4619, 2543, 1084, 1062, 267, 298, 411, 3992, 370, 506, 8652, 367, 642, 4849, 14, 221, 1626, 2701, 663, 4910, 1263, 2, 267 ]
[ 1898, 334, 67, 9, 6029, 13, 7280, 27155, 23954, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 710, 4190, 5084, 16879, 1454, 370, 4248, 315, 314, 2032, 436, 10989, 199, 3, 440, 506, 950, 431, 68, 465, 16085, 316, 282, 4190, 370, 1263, 1163, 27925, 1264, 1061, 199, 3, 3324, 5893, 1325, 440, 13988, 370, 27925, 1264, 1061, 3324, 4668, 1958, 199, 3, 370, 282, 14991, 4514, 402, 314, 9330, 402, 314, 2032, 199, 3, 18233, 2348, 7138, 14, 221, 2047, 1443, 675, 314, 2032, 5420, 370, 314, 4190, 199, 3, 2895, 5084, 2741, 626, 1265, 4868, 626, 642, 4245, 365, 32436, 199, 3, 24214, 436, 315, 2399, 8039, 369, 315, 1006, 10208, 402, 314, 2032, 12, 199, 3, 6042, 503, 24214, 12, 315, 1350, 1233, 503, 315, 3366, 1824, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 10219, 710, 5044, 24871, 402, 710, 15904, 402, 603, 1158, 528, 290, 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, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 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, 3, 199, 3, 6642, 26, 598, 7570, 30593, 199, 3, 3515, 653, 1619, 290, 699, 2292, 15299, 199, 3, 3515, 6061, 5257, 699, 5596, 15515, 199, 199, 504, 333, 21, 14, 14334, 492, 1900, 7744, 199, 504, 333, 21, 14, 1162, 492, 627, 199, 504, 333, 21, 14, 3280, 492, 627, 199, 504, 333, 21, 14, 7467, 1692, 492, 10751, 1692, 199, 504, 3523, 11011, 492, 3523, 11011, 199, 504, 9762, 3048, 492, 9762, 3048, 199, 504, 699, 2965, 14730, 630, 492, 627, 199, 504, 26244, 316, 8561, 492, 26244, 316, 8561, 199, 199, 504, 28794, 5072, 492, 9319, 2543, 199, 199, 533, 10195, 269, 4619, 2543, 8, 7467, 1692, 304, 272, 408, 3532, 316, 402, 9319, 2543, 370, 664, 6818, 1900, 8826, 436, 5647, 282, 5759, 367, 272, 6466, 32113, 370, 9319, 2543, 5920, 624, 339, 730, 275, 283, 23094, 4619, 2543, 7, 272, 17327, 63, 1291, 275, 298, 3541, 15, 11067, 15, 1532, 63, 3248, 14, 12156, 2, 339, 1687, 2543, 275, 12608, 14, 4619, 2543, 480, 411, 1021, 370, 1336, 531, 199, 199, 533, 10195, 269, 4619, 2543, 1084, 8, 7467, 1692, 304, 272, 408, 33, 663, 402, 1336, 461, 1687, 3992, 624, 339, 730, 275, 283, 23094, 4619, 2543, 1084, 7, 272, 17327, 63, 1291, 275, 298, 3541, 15, 11067, 15, 1532, 63, 3248, 14, 12156, 2, 339, 1687, 15711, 275, 11388, 4098, 14, 23094, 4619, 2543, 8798, 298, 411, 3992, 370, 506, 7838, 2122, 267, 298, 221, 1626, 2701, 769, 4910, 1263, 1021, 531, 199, 199, 533, 10195, 269, 20254, 1017, 316, 8, 7467, 1692, 304, 272, 730, 275, 283, 23094, 20254, 1017, 316, 7, 272, 17327, 63, 1291, 275, 298, 3541, 15, 11067, 15, 1532, 63, 3248, 14, 12156, 2, 339, 3656, 275, 12608, 14, 13304, 772, 8, 16, 12, 298, 2629, 367, 5343, 7255, 45, 1225, 10083, 531, 272, 1336, 275, 12608, 14, 13304, 772, 8, 16, 12, 298, 1431, 574, 367, 5343, 7255, 45, 1225, 10083, 5424, 267, 298, 334, 832, 63, 14121, 63, 3615, 1253, 3656, 9, 508, 1336, 531, 272, 15678, 275, 12608, 14, 10349, 8, 797, 12, 298, 692, 2549, 12, 642, 2727, 14, 365, 440, 7934, 701, 2, 267, 298, 642, 481, 53, 531, 272, 2402, 11421, 22510, 275, 12608, 14, 28016, 8, 16, 12, 298, 2911, 19001, 370, 410, 452, 5532, 367, 2, 267, 298, 642, 2727, 2685, 272, 2402, 11421, 22510, 8561, 275, 12608, 14, 30101, 8561, 8, 8084, 12, 298, 2911, 19001, 465, 282, 2, 267, 298, 1255, 13, 521, 13006, 3965, 531, 272, 2402, 9824, 940, 68, 22510, 275, 12608, 14, 28016, 8, 16, 12, 298, 2911, 19001, 370, 1050, 370, 5396, 3576, 2, 267, 298, 295, 7261, 900, 367, 642, 2727, 83, 2053, 24493, 5403, 652, 16733, 314, 2, 267, 298, 22380, 4137, 14, 221, 2104, 7573, 15749, 12, 340, 642, 365, 378, 12, 314, 754, 1159, 900, 2, 267, 298, 365, 11584, 465, 625, 6892, 461, 436, 949, 24119, 883, 5452, 4192, 2685, 272, 2928, 497, 458, 15277, 44, 1956, 275, 11388, 4098, 14, 28016, 480, 1589, 5696, 1329, 402, 19001, 2, 267, 298, 2410, 2727, 14, 4976, 626, 1924, 2928, 1295, 883, 506, 2808, 367, 642, 2, 267, 298, 2727, 14, 370, 4976, 531, 272, 1687, 15711, 275, 12608, 14, 23094, 4619, 2543, 1084, 8, 23094, 4619, 2543, 1084, 1062, 267, 298, 411, 3992, 370, 506, 8652, 367, 642, 4849, 14, 221, 1626, 2701, 663, 4910, 1263, 2, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
SylvainCecchetto/plugin.video.catchuptvandmore
plugin.video.catchuptvandmore/resources/lib/channels/jp/ntvnews24.py
1
2396
# -*- coding: utf-8 -*- """ Catch-up TV & More Copyright (C) 2018 SylvainCecchetto This file is part of Catch-up TV & More. Catch-up TV & More is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Catch-up TV & More 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 Catch-up TV & More; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ # The unicode_literals import only has # an effect on Python 2. # It makes string literals as unicode like in Python 3 from __future__ import unicode_literals from codequick import Route, Resolver, Listitem, utils, Script from resources.lib import web_utils from resources.lib import resolver_proxy from resources.lib.menu_utils import item_post_treatment import re import urlquick # TO DO # Add Videos, Replays ? URL_ROOT = 'http://www.news24.jp' URL_LIVE = URL_ROOT + '/livestream/' @Resolver.register def get_live_url(plugin, item_id, **kwargs): resp = urlquick.get(URL_LIVE, headers={'User-Agent': web_utils.get_random_ua()}, max_age=-1) data_account = '' data_player = '' data_video_id = '' if len(re.compile(r'data-account="(.*?)"').findall(resp.text)) > 0: data_account = re.compile(r'data-account="(.*?)"').findall( resp.text)[0] data_player = re.compile(r'data-player="(.*?)"').findall(resp.text)[0] data_video_id = re.compile(r'data-video-id="(.*?)"').findall( resp.text)[0] else: data_account = re.compile(r'accountId\: "(.*?)"').findall(resp.text)[0] data_player = re.compile(r'player\: "(.*?)"').findall(resp.text)[0] data_video_id = re.compile(r'videoId\: "(.*?)"').findall(resp.text)[0] return resolver_proxy.get_brightcove_video_json(plugin, data_account, data_player, data_video_id)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 32754, 13, 384, 26990, 1253, 16917, 272, 1898, 334, 35, 9, 14894, 221, 5515, 6371, 1581, 35, 825, 335, 386, 475, 339, 961, 570, 365, 1777, 402, 32754, 13, 384, 26990, 1253, 16917, 14, 339, 32754, 13, 384, 26990, 1253, 16917, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 32754, 13, 384, 26990, 1253, 16917, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 272, 543, 32754, 13, 384, 26990, 1253, 16917, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 272, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 624, 199, 199, 3, 710, 2649, 63, 5955, 492, 1454, 965, 199, 3, 376, 7763, 641, 2018, 499, 14, 199, 3, 2779, 7704, 1059, 18041, 465, 2649, 2839, 315, 2018, 650, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1233, 13239, 492, 24244, 12, 26046, 12, 3820, 1053, 12, 3778, 12, 14914, 421, 199, 504, 5944, 14, 773, 492, 3330, 63, 1208, 199, 504, 5944, 14, 773, 492, 15611, 63, 3280, 199, 504, 5944, 14, 773, 14, 4470, 63, 1208, 492, 1242, 63, 1932, 63, 84, 8319, 434, 199, 199, 646, 295, 199, 646, 1166, 13239, 199, 199, 3, 2296, 3506, 199, 3, 2654, 812, 2655, 736, 12, 16000, 9316, 5805, 199, 199, 2632, 63, 5441, 275, 283, 1014, 921, 1544, 14, 13224, 1194, 14, 11538, 7, 199, 199, 2632, 63, 31541, 275, 2851, 63, 5441, 435, 1994, 6442, 1745, 4805, 421, 199, 32, 12407, 14, 2683, 199, 318, 664, 63, 6442, 63, 633, 8, 2718, 12, 1242, 63, 344, 12, 1011, 958, 304, 339, 3085, 275, 1166, 13239, 14, 362, 8, 2632, 63, 31541, 12, 717, 2323, 3713, 1899, 13, 7788, 356, 3330, 63, 1208, 14, 362, 63, 2355, 63, 1458, 342, 1386, 717, 1390, 63, 474, 4022, 17, 9, 272, 666, 63, 2048, 275, 2125, 272, 666, 63, 6147, 275, 2125, 272, 666, 63, 3722, 63, 344, 275, 2125, 272, 340, 822, 8, 264, 14, 2014, 8, 82, 5121, 419, 13, 2048, 628, 17140, 2924, 1959, 6452, 8, 4518, 14, 505, 430, 690, 378, 26, 267, 666, 63, 2048, 275, 295, 14, 2014, 8, 82, 5121, 419, 13, 2048, 628, 17140, 2924, 1959, 6452, 8, 288, 3085, 14, 505, 2788, 16, 61, 267, 666, 63, 6147, 275, 295, 14, 2014, 8, 82, 5121, 419, 13, 6147, 628, 17140, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 267, 666, 63, 3722, 63, 344, 275, 295, 14, 2014, 8, 82, 5121, 419, 13, 3722, 13, 344, 628, 17140, 2924, 1959, 6452, 8, 288, 3085, 14, 505, 2788, 16, 61, 272, 587, 26, 267, 666, 63, 2048, 275, 295, 14, 2014, 8, 82, 7, 2048, 1304, 60, 26, 7340, 6697, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 267, 666, 63, 6147, 275, 295, 14, 2014, 8, 82, 7, 6147, 60, 26, 7340, 6697, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 267, 666, 63, 3722, 63, 344, 275, 295, 14, 2014, 8, 82, 7, 3722, 1304, 60, 26, 7340, 6697, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 272, 372, 15611, 63, 3280, 14, 362, 63, 27454, 24617, 63, 3722, 63, 1001, 8, 2718, 12, 666, 63, 2048, 12, 8105, 666, 63, 6147, 12, 666, 63, 3722, 63, 344, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 32754, 13, 384, 26990, 1253, 16917, 272, 1898, 334, 35, 9, 14894, 221, 5515, 6371, 1581, 35, 825, 335, 386, 475, 339, 961, 570, 365, 1777, 402, 32754, 13, 384, 26990, 1253, 16917, 14, 339, 32754, 13, 384, 26990, 1253, 16917, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 32754, 13, 384, 26990, 1253, 16917, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 272, 543, 32754, 13, 384, 26990, 1253, 16917, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 272, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 624, 199, 199, 3, 710, 2649, 63, 5955, 492, 1454, 965, 199, 3, 376, 7763, 641, 2018, 499, 14, 199, 3, 2779, 7704, 1059, 18041, 465, 2649, 2839, 315, 2018, 650, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1233, 13239, 492, 24244, 12, 26046, 12, 3820, 1053, 12, 3778, 12, 14914, 421, 199, 504, 5944, 14, 773, 492, 3330, 63, 1208, 199, 504, 5944, 14, 773, 492, 15611, 63, 3280, 199, 504, 5944, 14, 773, 14, 4470, 63, 1208, 492, 1242, 63, 1932, 63, 84, 8319, 434, 199, 199, 646, 295, 199, 646, 1166, 13239, 199, 199, 3, 2296, 3506, 199, 3, 2654, 812, 2655, 736, 12, 16000, 9316, 5805, 199, 199, 2632, 63, 5441, 275, 283, 1014, 921, 1544, 14, 13224, 1194, 14, 11538, 7, 199, 199, 2632, 63, 31541, 275, 2851, 63, 5441, 435, 1994, 6442, 1745, 4805, 421, 199, 32, 12407, 14, 2683, 199, 318, 664, 63, 6442, 63, 633, 8, 2718, 12, 1242, 63, 344, 12, 1011, 958, 304, 339, 3085, 275, 1166, 13239, 14, 362, 8, 2632, 63, 31541, 12, 717, 2323, 3713, 1899, 13, 7788, 356, 3330, 63, 1208, 14, 362, 63, 2355, 63, 1458, 342, 1386, 717, 1390, 63, 474, 4022, 17, 9, 272, 666, 63, 2048, 275, 2125, 272, 666, 63, 6147, 275, 2125, 272, 666, 63, 3722, 63, 344, 275, 2125, 272, 340, 822, 8, 264, 14, 2014, 8, 82, 5121, 419, 13, 2048, 628, 17140, 2924, 1959, 6452, 8, 4518, 14, 505, 430, 690, 378, 26, 267, 666, 63, 2048, 275, 295, 14, 2014, 8, 82, 5121, 419, 13, 2048, 628, 17140, 2924, 1959, 6452, 8, 288, 3085, 14, 505, 2788, 16, 61, 267, 666, 63, 6147, 275, 295, 14, 2014, 8, 82, 5121, 419, 13, 6147, 628, 17140, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 267, 666, 63, 3722, 63, 344, 275, 295, 14, 2014, 8, 82, 5121, 419, 13, 3722, 13, 344, 628, 17140, 2924, 1959, 6452, 8, 288, 3085, 14, 505, 2788, 16, 61, 272, 587, 26, 267, 666, 63, 2048, 275, 295, 14, 2014, 8, 82, 7, 2048, 1304, 60, 26, 7340, 6697, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 267, 666, 63, 6147, 275, 295, 14, 2014, 8, 82, 7, 6147, 60, 26, 7340, 6697, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 267, 666, 63, 3722, 63, 344, 275, 295, 14, 2014, 8, 82, 7, 3722, 1304, 60, 26, 7340, 6697, 2924, 1959, 6452, 8, 4518, 14, 505, 2788, 16, 61, 272, 372, 15611, 63, 3280, 14, 362, 63, 27454, 24617, 63, 3722, 63, 1001, 8, 2718, 12, 666, 63, 2048, 12, 8105, 666, 63, 6147, 12, 666, 63, 3722, 63, 344, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mrjaydee82/SinLessKernel-4.4.4
toolchains/a8483/share/gdb/python/gdb/__init__.py
110
3408
# Copyright (C) 2010-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import traceback import os import sys import _gdb if sys.version_info[0] > 2: # Python 3 moved "reload" from imp import reload from _gdb import * class _GdbFile (object): # These two are needed in Python 3 encoding = "UTF-8" errors = "strict" def close(self): # Do nothing. return None def isatty(self): return False def writelines(self, iterable): for line in iterable: self.write(line) def flush(self): flush() class GdbOutputFile (_GdbFile): def write(self, s): write(s, stream=STDOUT) sys.stdout = GdbOutputFile() class GdbOutputErrorFile (_GdbFile): def write(self, s): write(s, stream=STDERR) sys.stderr = GdbOutputErrorFile() # Default prompt hook does nothing. prompt_hook = None # Ensure that sys.argv is set to something. # We do not use PySys_SetArgvEx because it did not appear until 2.6.6. sys.argv = [''] # Initial pretty printers. pretty_printers = [] # Initial type printers. type_printers = [] # Convenience variable to GDB's python directory PYTHONDIR = os.path.dirname(os.path.dirname(__file__)) # Auto-load all functions/commands. # Packages to auto-load. packages = [ 'function', 'command' ] # pkgutil.iter_modules is not available prior to Python 2.6. Instead, # manually iterate the list, collating the Python files in each module # path. Construct the module name, and import. def auto_load_packages(): for package in packages: location = os.path.join(os.path.dirname(__file__), package) if os.path.exists(location): py_files = filter(lambda x: x.endswith('.py') and x != '__init__.py', os.listdir(location)) for py_file in py_files: # Construct from foo.py, gdb.module.foo modname = "%s.%s.%s" % ( __name__, package, py_file[:-3] ) try: if modname in sys.modules: # reload modules with duplicate names reload(__import__(modname)) else: __import__(modname) except: sys.stderr.write (traceback.format_exc() + "\n") auto_load_packages() def GdbSetPythonDirectory(dir): """Update sys.path, reload gdb and auto-load packages.""" global PYTHONDIR try: sys.path.remove(PYTHONDIR) except ValueError: pass sys.path.insert(0, dir) PYTHONDIR = dir # note that reload overwrites the gdb module without deleting existing # attributes reload(__import__(__name__)) auto_load_packages()
gpl-2.0
[ 3, 1898, 334, 35, 9, 7129, 13, 6965, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 5190, 199, 646, 747, 199, 646, 984, 199, 646, 485, 17119, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 690, 499, 26, 272, 327, 2018, 650, 12155, 298, 9233, 2, 272, 687, 1742, 492, 13101, 199, 199, 504, 485, 17119, 492, 627, 199, 199, 533, 485, 39, 697, 1173, 334, 785, 304, 272, 327, 5723, 2877, 787, 4346, 315, 2018, 650, 272, 2644, 275, 298, 6610, 13, 24, 2, 272, 2552, 275, 298, 4768, 2, 2286, 347, 4002, 8, 277, 304, 267, 327, 4226, 6548, 14, 267, 372, 488, 339, 347, 365, 16623, 8, 277, 304, 267, 372, 756, 339, 347, 2218, 1278, 8, 277, 12, 6076, 304, 267, 367, 1004, 315, 6076, 26, 288, 291, 14, 952, 8, 604, 9, 339, 347, 8976, 8, 277, 304, 267, 8976, 342, 199, 199, 533, 598, 697, 23847, 6110, 39, 697, 1173, 304, 272, 347, 2218, 8, 277, 12, 308, 304, 267, 2218, 8, 83, 12, 2547, 29, 13850, 9, 199, 199, 1274, 14, 2703, 275, 598, 697, 23847, 342, 199, 199, 533, 598, 697, 2959, 547, 1173, 6110, 39, 697, 1173, 304, 272, 347, 2218, 8, 277, 12, 308, 304, 267, 2218, 8, 83, 12, 2547, 29, 18472, 2666, 9, 199, 199, 1274, 14, 3083, 275, 598, 697, 2959, 547, 1173, 342, 199, 199, 3, 3758, 8457, 5759, 1630, 6548, 14, 199, 7650, 63, 3664, 275, 488, 199, 199, 3, 7523, 626, 984, 14, 3020, 365, 663, 370, 6020, 14, 199, 3, 2136, 886, 440, 675, 1611, 11319, 63, 1084, 6373, 86, 920, 2952, 652, 8103, 440, 7468, 5133, 499, 14, 22, 14, 22, 14, 199, 1274, 14, 3020, 275, 24506, 199, 199, 3, 6026, 7268, 5448, 11005, 14, 199, 9118, 63, 24858, 275, 942, 199, 199, 3, 6026, 730, 5448, 11005, 14, 199, 466, 63, 24858, 275, 942, 199, 199, 3, 1448, 23329, 1750, 370, 598, 2846, 1159, 2366, 2082, 199, 11720, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 199, 199, 3, 9195, 13, 912, 1006, 3423, 15, 4405, 14, 199, 199, 3, 9954, 7441, 370, 2599, 13, 912, 14, 199, 199, 5154, 275, 359, 272, 283, 1593, 297, 272, 283, 1531, 7, 199, 61, 199, 199, 3, 28728, 14, 1661, 63, 3112, 365, 440, 2808, 6791, 370, 2018, 499, 14, 22, 14, 221, 15345, 12, 199, 3, 10250, 13974, 314, 769, 12, 23721, 1958, 314, 2018, 1584, 315, 1924, 859, 199, 3, 931, 14, 221, 9215, 314, 859, 536, 12, 436, 492, 14, 199, 199, 318, 2599, 63, 912, 63, 5154, 837, 272, 367, 2559, 315, 6117, 26, 267, 2909, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 2559, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 1985, 304, 288, 1134, 63, 1725, 275, 2457, 8, 2734, 671, 26, 671, 14, 4130, 5175, 647, 358, 3147, 436, 671, 1137, 2560, 826, 4343, 647, 297, 2892, 747, 14, 7374, 8, 1985, 430, 953, 367, 1134, 63, 493, 315, 1134, 63, 1725, 26, 355, 327, 9215, 687, 3925, 14, 647, 12, 12124, 14, 578, 14, 1421, 355, 13526, 275, 2071, 83, 4111, 83, 4111, 83, 2, 450, 334, 636, 354, 3108, 2559, 12, 1134, 63, 493, 4439, 19, 61, 776, 355, 862, 26, 490, 340, 13526, 315, 984, 14, 3112, 26, 717, 327, 13101, 4621, 543, 9250, 1561, 717, 13101, 3460, 646, 721, 14789, 430, 490, 587, 26, 717, 636, 646, 721, 14789, 9, 355, 871, 26, 490, 984, 14, 3083, 14, 952, 334, 6894, 14, 908, 63, 2804, 342, 435, 1867, 78, 531, 199, 199, 2495, 63, 912, 63, 5154, 342, 199, 199, 318, 598, 697, 1084, 4718, 6231, 8, 694, 304, 272, 408, 4152, 984, 14, 515, 12, 13101, 12124, 436, 2599, 13, 912, 6117, 1041, 272, 2288, 18280, 3022, 339, 862, 26, 267, 984, 14, 515, 14, 2168, 8, 11720, 3022, 9, 272, 871, 1722, 26, 267, 986, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 2935, 9, 339, 18280, 3022, 275, 2935, 339, 327, 5317, 626, 13101, 1806, 16334, 314, 12124, 859, 1928, 13794, 3411, 272, 327, 3004, 272, 13101, 3460, 646, 721, 363, 354, 8964, 272, 2599, 63, 912, 63, 5154, 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 ]
[ 1898, 334, 35, 9, 7129, 13, 6965, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 5190, 199, 646, 747, 199, 646, 984, 199, 646, 485, 17119, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 690, 499, 26, 272, 327, 2018, 650, 12155, 298, 9233, 2, 272, 687, 1742, 492, 13101, 199, 199, 504, 485, 17119, 492, 627, 199, 199, 533, 485, 39, 697, 1173, 334, 785, 304, 272, 327, 5723, 2877, 787, 4346, 315, 2018, 650, 272, 2644, 275, 298, 6610, 13, 24, 2, 272, 2552, 275, 298, 4768, 2, 2286, 347, 4002, 8, 277, 304, 267, 327, 4226, 6548, 14, 267, 372, 488, 339, 347, 365, 16623, 8, 277, 304, 267, 372, 756, 339, 347, 2218, 1278, 8, 277, 12, 6076, 304, 267, 367, 1004, 315, 6076, 26, 288, 291, 14, 952, 8, 604, 9, 339, 347, 8976, 8, 277, 304, 267, 8976, 342, 199, 199, 533, 598, 697, 23847, 6110, 39, 697, 1173, 304, 272, 347, 2218, 8, 277, 12, 308, 304, 267, 2218, 8, 83, 12, 2547, 29, 13850, 9, 199, 199, 1274, 14, 2703, 275, 598, 697, 23847, 342, 199, 199, 533, 598, 697, 2959, 547, 1173, 6110, 39, 697, 1173, 304, 272, 347, 2218, 8, 277, 12, 308, 304, 267, 2218, 8, 83, 12, 2547, 29, 18472, 2666, 9, 199, 199, 1274, 14, 3083, 275, 598, 697, 2959, 547, 1173, 342, 199, 199, 3, 3758, 8457, 5759, 1630, 6548, 14, 199, 7650, 63, 3664, 275, 488, 199, 199, 3, 7523, 626, 984, 14, 3020, 365, 663, 370, 6020, 14, 199, 3, 2136, 886, 440, 675, 1611, 11319, 63, 1084, 6373, 86, 920, 2952, 652, 8103, 440, 7468, 5133, 499, 14, 22, 14, 22, 14, 199, 1274, 14, 3020, 275, 24506, 199, 199, 3, 6026, 7268, 5448, 11005, 14, 199, 9118, 63, 24858, 275, 942, 199, 199, 3, 6026, 730, 5448, 11005, 14, 199, 466, 63, 24858, 275, 942, 199, 199, 3, 1448, 23329, 1750, 370, 598, 2846, 1159, 2366, 2082, 199, 11720, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 199, 199, 3, 9195, 13, 912, 1006, 3423, 15, 4405, 14, 199, 199, 3, 9954, 7441, 370, 2599, 13, 912, 14, 199, 199, 5154, 275, 359, 272, 283, 1593, 297, 272, 283, 1531, 7, 199, 61, 199, 199, 3, 28728, 14, 1661, 63, 3112, 365, 440, 2808, 6791, 370, 2018, 499, 14, 22, 14, 221, 15345, 12, 199, 3, 10250, 13974, 314, 769, 12, 23721, 1958, 314, 2018, 1584, 315, 1924, 859, 199, 3, 931, 14, 221, 9215, 314, 859, 536, 12, 436, 492, 14, 199, 199, 318, 2599, 63, 912, 63, 5154, 837, 272, 367, 2559, 315, 6117, 26, 267, 2909, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 2559, 9, 267, 340, 747, 14, 515, 14, 2444, 8, 1985, 304, 288, 1134, 63, 1725, 275, 2457, 8, 2734, 671, 26, 671, 14, 4130, 5175, 647, 358, 3147, 436, 671, 1137, 2560, 826, 4343, 647, 297, 2892, 747, 14, 7374, 8, 1985, 430, 953, 367, 1134, 63, 493, 315, 1134, 63, 1725, 26, 355, 327, 9215, 687, 3925, 14, 647, 12, 12124, 14, 578, 14, 1421, 355, 13526, 275, 2071, 83, 4111, 83, 4111, 83, 2, 450, 334, 636, 354, 3108, 2559, 12, 1134, 63, 493, 4439, 19, 61, 776, 355, 862, 26, 490, 340, 13526, 315, 984, 14, 3112, 26, 717, 327, 13101, 4621, 543, 9250, 1561, 717, 13101, 3460, 646, 721, 14789, 430, 490, 587, 26, 717, 636, 646, 721, 14789, 9, 355, 871, 26, 490, 984, 14, 3083, 14, 952, 334, 6894, 14, 908, 63, 2804, 342, 435, 1867, 78, 531, 199, 199, 2495, 63, 912, 63, 5154, 342, 199, 199, 318, 598, 697, 1084, 4718, 6231, 8, 694, 304, 272, 408, 4152, 984, 14, 515, 12, 13101, 12124, 436, 2599, 13, 912, 6117, 1041, 272, 2288, 18280, 3022, 339, 862, 26, 267, 984, 14, 515, 14, 2168, 8, 11720, 3022, 9, 272, 871, 1722, 26, 267, 986, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 2935, 9, 339, 18280, 3022, 275, 2935, 339, 327, 5317, 626, 13101, 1806, 16334, 314, 12124, 859, 1928, 13794, 3411, 272, 327, 3004, 272, 13101, 3460, 646, 721, 363, 354, 8964, 272, 2599, 63, 912, 63, 5154, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xuru/restler
lib/usr/sqlalchemy/dialects/mssql/pyodbc.py
2
9228
# mssql/pyodbc.py # Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """ Support for MS-SQL via pyodbc. pyodbc is available at: http://pypi.python.org/pypi/pyodbc/ Connecting ^^^^^^^^^^ Examples of pyodbc connection string URLs: * ``mssql+pyodbc://mydsn`` - connects using the specified DSN named ``mydsn``. The connection string that is created will appear like:: dsn=mydsn;Trusted_Connection=Yes * ``mssql+pyodbc://user:pass@mydsn`` - connects using the DSN named ``mydsn`` passing in the ``UID`` and ``PWD`` information. The connection string that is created will appear like:: dsn=mydsn;UID=user;PWD=pass * ``mssql+pyodbc://user:pass@mydsn/?LANGUAGE=us_english`` - connects using the DSN named ``mydsn`` passing in the ``UID`` and ``PWD`` information, plus the additional connection configuration option ``LANGUAGE``. The connection string that is created will appear like:: dsn=mydsn;UID=user;PWD=pass;LANGUAGE=us_english * ``mssql+pyodbc://user:pass@host/db`` - connects using a connection that would appear like:: DRIVER={SQL Server};Server=host;Database=db;UID=user;PWD=pass * ``mssql+pyodbc://user:pass@host:123/db`` - connects using a connection string which includes the port information using the comma syntax. This will create the following connection string:: DRIVER={SQL Server};Server=host,123;Database=db;UID=user;PWD=pass * ``mssql+pyodbc://user:pass@host/db?port=123`` - connects using a connection string that includes the port information as a separate ``port`` keyword. This will create the following connection string:: DRIVER={SQL Server};Server=host;Database=db;UID=user;PWD=pass;port=123 * ``mssql+pyodbc://user:pass@host/db?driver=MyDriver`` - connects using a connection string that includes a custom ODBC driver name. This will create the following connection string:: DRIVER={MyDriver};Server=host;Database=db;UID=user;PWD=pass If you require a connection string that is outside the options presented above, use the ``odbc_connect`` keyword to pass in a urlencoded connection string. What gets passed in will be urldecoded and passed directly. For example:: mssql+pyodbc:///?odbc_connect=dsn%3Dmydsn%3BDatabase%3Ddb would create the following connection string:: dsn=mydsn;Database=db Encoding your connection string can be easily accomplished through the python shell. For example:: >>> import urllib >>> urllib.quote_plus('dsn=mydsn;Database=db') 'dsn%3Dmydsn%3BDatabase%3Ddb' Unicode Binds ^^^^^^^^^^^^^ The current state of PyODBC on a unix backend with FreeTDS and/or EasySoft is poor regarding unicode; different OS platforms and versions of UnixODBC versus IODBC versus FreeTDS/EasySoft versus PyODBC itself dramatically alter how strings are received. The PyODBC dialect attempts to use all the information it knows to determine whether or not a Python unicode literal can be passed directly to the PyODBC driver or not; while SQLAlchemy can encode these to bytestrings first, some users have reported that PyODBC mis-handles bytestrings for certain encodings and requires a Python unicode object, while the author has observed widespread cases where a Python unicode is completely misinterpreted by PyODBC, particularly when dealing with the information schema tables used in table reflection, and the value must first be encoded to a bytestring. It is for this reason that whether or not unicode literals for bound parameters be sent to PyODBC can be controlled using the ``supports_unicode_binds`` parameter to ``create_engine()``. When left at its default of ``None``, the PyODBC dialect will use its best guess as to whether or not the driver deals with unicode literals well. When ``False``, unicode literals will be encoded first, and when ``True`` unicode literals will be passed straight through. This is an interim flag that hopefully should not be needed when the unicode situation stabilizes for unix + PyODBC. .. versionadded:: 0.7.7 ``supports_unicode_binds`` parameter to ``create_engine()``\ . """ from sqlalchemy.dialects.mssql.base import MSExecutionContext, MSDialect from sqlalchemy.connectors.pyodbc import PyODBCConnector from sqlalchemy import types as sqltypes, util import decimal class _MSNumeric_pyodbc(sqltypes.Numeric): """Turns Decimals with adjusted() < 0 or > 7 into strings. This is the only method that is proven to work with Pyodbc+MSSQL without crashing (floats can be used but seem to cause sporadic crashes). """ def bind_processor(self, dialect): super_process = super(_MSNumeric_pyodbc, self).\ bind_processor(dialect) if not dialect._need_decimal_fix: return super_process def process(value): if self.asdecimal and \ isinstance(value, decimal.Decimal): adjusted = value.adjusted() if adjusted < 0: return self._small_dec_to_string(value) elif adjusted > 7: return self._large_dec_to_string(value) if super_process: return super_process(value) else: return value return process # these routines needed for older versions of pyodbc. # as of 2.1.8 this logic is integrated. def _small_dec_to_string(self, value): return "%s0.%s%s" % ( (value < 0 and '-' or ''), '0' * (abs(value.adjusted()) - 1), "".join([str(nint) for nint in value.as_tuple()[1]])) def _large_dec_to_string(self, value): _int = value.as_tuple()[1] if 'E' in str(value): result = "%s%s%s" % ( (value < 0 and '-' or ''), "".join([str(s) for s in _int]), "0" * (value.adjusted() - (len(_int)-1))) else: if (len(_int) - 1) > value.adjusted(): result = "%s%s.%s" % ( (value < 0 and '-' or ''), "".join( [str(s) for s in _int][0:value.adjusted() + 1]), "".join( [str(s) for s in _int][value.adjusted() + 1:])) else: result = "%s%s" % ( (value < 0 and '-' or ''), "".join( [str(s) for s in _int][0:value.adjusted() + 1])) return result class MSExecutionContext_pyodbc(MSExecutionContext): _embedded_scope_identity = False def pre_exec(self): """where appropriate, issue "select scope_identity()" in the same statement. Background on why "scope_identity()" is preferable to "@@identity": http://msdn.microsoft.com/en-us/library/ms190315.aspx Background on why we attempt to embed "scope_identity()" into the same statement as the INSERT: http://code.google.com/p/pyodbc/wiki/FAQs#How_do_I_retrieve_autogenerated/identity_values? """ super(MSExecutionContext_pyodbc, self).pre_exec() # don't embed the scope_identity select into an # "INSERT .. DEFAULT VALUES" if self._select_lastrowid and \ self.dialect.use_scope_identity and \ len(self.parameters[0]): self._embedded_scope_identity = True self.statement += "; select scope_identity()" def post_exec(self): if self._embedded_scope_identity: # Fetch the last inserted id from the manipulated statement # We may have to skip over a number of result sets with # no data (due to triggers, etc.) while True: try: # fetchall() ensures the cursor is consumed # without closing it (FreeTDS particularly) row = self.cursor.fetchall()[0] break except self.dialect.dbapi.Error, e: # no way around this - nextset() consumes the previous set # so we need to just keep flipping self.cursor.nextset() self._lastrowid = int(row[0]) else: super(MSExecutionContext_pyodbc, self).post_exec() class MSDialect_pyodbc(PyODBCConnector, MSDialect): execution_ctx_cls = MSExecutionContext_pyodbc pyodbc_driver_name = 'SQL Server' colspecs = util.update_copy( MSDialect.colspecs, { sqltypes.Numeric:_MSNumeric_pyodbc } ) def __init__(self, description_encoding='latin-1', **params): super(MSDialect_pyodbc, self).__init__(**params) self.description_encoding = description_encoding self.use_scope_identity = self.use_scope_identity and \ self.dbapi and \ hasattr(self.dbapi.Cursor, 'nextset') self._need_decimal_fix = self.dbapi and \ self._dbapi_version() < (2, 1, 8) dialect = MSDialect_pyodbc
mit
[ 3, 333, 385, 1710, 15, 647, 19887, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7409, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 199, 11532, 367, 14282, 13, 4657, 4799, 1134, 19887, 14, 199, 199, 647, 19887, 365, 2808, 737, 26, 339, 1455, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 15, 647, 19887, 15, 199, 199, 32000, 199, 19628, 19628, 11871, 199, 199, 22787, 402, 1134, 19887, 1950, 1059, 10867, 26, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 1662, 32510, 1040, 446, 4907, 83, 1808, 314, 2013, 577, 8199, 4310, 1124, 1662, 32510, 4345, 523, 710, 1950, 1059, 626, 365, 2737, 911, 7468, 2839, 447, 339, 366, 5167, 29, 1662, 32510, 27, 14064, 7274, 63, 3225, 29, 12555, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1662, 32510, 1040, 446, 4907, 83, 1808, 314, 577, 8199, 4310, 523, 1124, 1662, 32510, 1040, 9476, 315, 314, 1124, 6685, 1040, 436, 1124, 10780, 36, 1040, 2556, 14, 710, 523, 1950, 1059, 626, 365, 2737, 911, 7468, 2839, 447, 339, 366, 5167, 29, 1662, 32510, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1662, 32510, 10197, 13947, 29, 527, 63, 17872, 1040, 446, 4907, 83, 523, 1808, 314, 577, 8199, 4310, 1124, 1662, 32510, 1040, 9476, 315, 314, 1124, 6685, 1040, 436, 1124, 10780, 36, 1040, 523, 2556, 12, 12254, 314, 4722, 1950, 2897, 945, 523, 1124, 13947, 4345, 710, 1950, 1059, 626, 365, 2737, 911, 7468, 523, 2839, 447, 339, 366, 5167, 29, 1662, 32510, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 27, 13947, 29, 527, 63, 17872, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 15, 697, 1040, 446, 4907, 83, 1808, 282, 1950, 16421, 626, 3955, 7468, 2839, 447, 339, 577, 6129, 2111, 3126, 4657, 7146, 12084, 3120, 29, 1102, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 26, 4288, 15, 697, 1040, 446, 4907, 83, 1808, 282, 1950, 523, 1059, 1314, 6952, 314, 1844, 523, 2556, 1808, 314, 10029, 6302, 14, 961, 911, 1218, 314, 2569, 16421, 1950, 1059, 447, 339, 577, 6129, 2111, 3126, 4657, 7146, 12084, 3120, 29, 1102, 12, 4288, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 15, 697, 31, 719, 29, 4288, 1040, 446, 4907, 83, 1808, 282, 1950, 523, 1059, 626, 6952, 314, 1844, 523, 2556, 465, 282, 7396, 1124, 719, 1040, 4252, 14, 961, 911, 1218, 314, 523, 2569, 1950, 1059, 447, 339, 577, 6129, 2111, 3126, 4657, 7146, 12084, 3120, 29, 1102, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 27, 719, 29, 4288, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 15, 697, 31, 3090, 29, 5713, 6158, 1040, 446, 4907, 83, 1808, 282, 1950, 523, 1059, 626, 6952, 282, 3537, 523, 593, 23317, 5253, 536, 14, 221, 961, 911, 1218, 314, 2569, 1950, 1059, 447, 339, 577, 6129, 2111, 3126, 5713, 6158, 12084, 3120, 29, 1102, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 3917, 1265, 4409, 282, 1950, 1059, 626, 365, 9682, 314, 1511, 199, 10317, 3432, 12, 675, 314, 1124, 19887, 63, 2242, 1040, 4252, 370, 986, 315, 282, 199, 21886, 1950, 1059, 14, 14791, 7545, 3032, 315, 911, 506, 1166, 16167, 199, 460, 3032, 5370, 14, 199, 199, 1858, 2893, 447, 339, 333, 385, 1710, 11, 647, 19887, 921, 10197, 19887, 63, 2242, 29, 32510, 5, 19, 36, 1662, 32510, 5, 19, 34, 7243, 5, 19, 36, 697, 199, 199, 2027, 854, 1218, 314, 2569, 1950, 1059, 447, 339, 366, 5167, 29, 1662, 32510, 27, 7243, 29, 697, 199, 199, 7630, 2195, 1950, 1059, 883, 506, 16174, 1066, 863, 1891, 379, 4012, 199, 1589, 2366, 5218, 14, 2104, 2893, 447, 339, 1306, 492, 4011, 272, 1306, 4011, 14, 3513, 63, 6666, 360, 32510, 29, 1662, 32510, 27, 7243, 29, 697, 358, 272, 283, 32510, 5, 19, 36, 1662, 32510, 5, 19, 34, 7243, 5, 19, 36, 697, 7, 199, 199, 7087, 699, 18212, 199, 19628, 19628, 19628, 62, 199, 199, 1918, 1453, 1174, 402, 1611, 47, 23317, 641, 282, 16572, 4865, 543, 2868, 52, 3177, 436, 15, 269, 221, 199, 28326, 19302, 365, 1115, 269, 12602, 2649, 27, 3365, 4403, 10677, 436, 5459, 402, 13074, 47, 23317, 199, 14895, 527, 5004, 23317, 809, 25253, 2868, 52, 3177, 15, 28326, 19302, 809, 25253, 1611, 47, 23317, 6337, 366, 345, 17174, 221, 199, 11858, 4212, 3326, 787, 3086, 14, 221, 710, 1611, 47, 23317, 10982, 12454, 370, 675, 1006, 314, 2556, 199, 390, 19428, 370, 6705, 3775, 503, 440, 282, 2018, 2649, 8785, 883, 506, 199, 12070, 5370, 370, 314, 1611, 47, 23317, 5253, 503, 440, 27, 1830, 14303, 883, 3752, 199, 29032, 370, 18792, 25182, 1642, 12, 2005, 4390, 1172, 14581, 626, 1611, 47, 23317, 3201, 13, 16947, 199, 991, 396, 25182, 367, 9842, 14134, 436, 5074, 282, 2018, 2649, 909, 12, 199, 6710, 314, 4132, 965, 20802, 20239, 29889, 5560, 2382, 282, 2018, 2649, 199, 374, 14793, 3201, 12108, 471, 701, 1611, 47, 23317, 12, 6770, 590, 1380, 23654, 543, 199, 1589, 2556, 4177, 6716, 1202, 315, 1817, 25572, 12, 436, 314, 574, 221, 199, 7790, 1642, 506, 5737, 370, 282, 23888, 14, 199, 199, 7940, 365, 367, 642, 4499, 626, 3775, 503, 440, 2649, 18041, 367, 3914, 199, 3214, 506, 4847, 370, 1611, 47, 23317, 883, 506, 22284, 1808, 314, 221, 199, 1040, 9823, 63, 2975, 63, 27080, 1040, 2725, 370, 1124, 981, 63, 3908, 28566, 221, 3979, 221, 199, 3039, 737, 2399, 849, 402, 1124, 403, 4542, 314, 1611 ]
[ 333, 385, 1710, 15, 647, 19887, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7409, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 199, 11532, 367, 14282, 13, 4657, 4799, 1134, 19887, 14, 199, 199, 647, 19887, 365, 2808, 737, 26, 339, 1455, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 15, 647, 19887, 15, 199, 199, 32000, 199, 19628, 19628, 11871, 199, 199, 22787, 402, 1134, 19887, 1950, 1059, 10867, 26, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 1662, 32510, 1040, 446, 4907, 83, 1808, 314, 2013, 577, 8199, 4310, 1124, 1662, 32510, 4345, 523, 710, 1950, 1059, 626, 365, 2737, 911, 7468, 2839, 447, 339, 366, 5167, 29, 1662, 32510, 27, 14064, 7274, 63, 3225, 29, 12555, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1662, 32510, 1040, 446, 4907, 83, 1808, 314, 577, 8199, 4310, 523, 1124, 1662, 32510, 1040, 9476, 315, 314, 1124, 6685, 1040, 436, 1124, 10780, 36, 1040, 2556, 14, 710, 523, 1950, 1059, 626, 365, 2737, 911, 7468, 2839, 447, 339, 366, 5167, 29, 1662, 32510, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1662, 32510, 10197, 13947, 29, 527, 63, 17872, 1040, 446, 4907, 83, 523, 1808, 314, 577, 8199, 4310, 1124, 1662, 32510, 1040, 9476, 315, 314, 1124, 6685, 1040, 436, 1124, 10780, 36, 1040, 523, 2556, 12, 12254, 314, 4722, 1950, 2897, 945, 523, 1124, 13947, 4345, 710, 1950, 1059, 626, 365, 2737, 911, 7468, 523, 2839, 447, 339, 366, 5167, 29, 1662, 32510, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 27, 13947, 29, 527, 63, 17872, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 15, 697, 1040, 446, 4907, 83, 1808, 282, 1950, 16421, 626, 3955, 7468, 2839, 447, 339, 577, 6129, 2111, 3126, 4657, 7146, 12084, 3120, 29, 1102, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 26, 4288, 15, 697, 1040, 446, 4907, 83, 1808, 282, 1950, 523, 1059, 1314, 6952, 314, 1844, 523, 2556, 1808, 314, 10029, 6302, 14, 961, 911, 1218, 314, 2569, 16421, 1950, 1059, 447, 339, 577, 6129, 2111, 3126, 4657, 7146, 12084, 3120, 29, 1102, 12, 4288, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 15, 697, 31, 719, 29, 4288, 1040, 446, 4907, 83, 1808, 282, 1950, 523, 1059, 626, 6952, 314, 1844, 523, 2556, 465, 282, 7396, 1124, 719, 1040, 4252, 14, 961, 911, 1218, 314, 523, 2569, 1950, 1059, 447, 339, 577, 6129, 2111, 3126, 4657, 7146, 12084, 3120, 29, 1102, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 27, 719, 29, 4288, 199, 199, 10, 1124, 30230, 11, 647, 19887, 921, 751, 26, 1529, 32, 1102, 15, 697, 31, 3090, 29, 5713, 6158, 1040, 446, 4907, 83, 1808, 282, 1950, 523, 1059, 626, 6952, 282, 3537, 523, 593, 23317, 5253, 536, 14, 221, 961, 911, 1218, 314, 2569, 1950, 1059, 447, 339, 577, 6129, 2111, 3126, 5713, 6158, 12084, 3120, 29, 1102, 27, 7243, 29, 697, 27, 6685, 29, 751, 27, 10780, 36, 29, 1529, 199, 199, 3917, 1265, 4409, 282, 1950, 1059, 626, 365, 9682, 314, 1511, 199, 10317, 3432, 12, 675, 314, 1124, 19887, 63, 2242, 1040, 4252, 370, 986, 315, 282, 199, 21886, 1950, 1059, 14, 14791, 7545, 3032, 315, 911, 506, 1166, 16167, 199, 460, 3032, 5370, 14, 199, 199, 1858, 2893, 447, 339, 333, 385, 1710, 11, 647, 19887, 921, 10197, 19887, 63, 2242, 29, 32510, 5, 19, 36, 1662, 32510, 5, 19, 34, 7243, 5, 19, 36, 697, 199, 199, 2027, 854, 1218, 314, 2569, 1950, 1059, 447, 339, 366, 5167, 29, 1662, 32510, 27, 7243, 29, 697, 199, 199, 7630, 2195, 1950, 1059, 883, 506, 16174, 1066, 863, 1891, 379, 4012, 199, 1589, 2366, 5218, 14, 2104, 2893, 447, 339, 1306, 492, 4011, 272, 1306, 4011, 14, 3513, 63, 6666, 360, 32510, 29, 1662, 32510, 27, 7243, 29, 697, 358, 272, 283, 32510, 5, 19, 36, 1662, 32510, 5, 19, 34, 7243, 5, 19, 36, 697, 7, 199, 199, 7087, 699, 18212, 199, 19628, 19628, 19628, 62, 199, 199, 1918, 1453, 1174, 402, 1611, 47, 23317, 641, 282, 16572, 4865, 543, 2868, 52, 3177, 436, 15, 269, 221, 199, 28326, 19302, 365, 1115, 269, 12602, 2649, 27, 3365, 4403, 10677, 436, 5459, 402, 13074, 47, 23317, 199, 14895, 527, 5004, 23317, 809, 25253, 2868, 52, 3177, 15, 28326, 19302, 809, 25253, 1611, 47, 23317, 6337, 366, 345, 17174, 221, 199, 11858, 4212, 3326, 787, 3086, 14, 221, 710, 1611, 47, 23317, 10982, 12454, 370, 675, 1006, 314, 2556, 199, 390, 19428, 370, 6705, 3775, 503, 440, 282, 2018, 2649, 8785, 883, 506, 199, 12070, 5370, 370, 314, 1611, 47, 23317, 5253, 503, 440, 27, 1830, 14303, 883, 3752, 199, 29032, 370, 18792, 25182, 1642, 12, 2005, 4390, 1172, 14581, 626, 1611, 47, 23317, 3201, 13, 16947, 199, 991, 396, 25182, 367, 9842, 14134, 436, 5074, 282, 2018, 2649, 909, 12, 199, 6710, 314, 4132, 965, 20802, 20239, 29889, 5560, 2382, 282, 2018, 2649, 199, 374, 14793, 3201, 12108, 471, 701, 1611, 47, 23317, 12, 6770, 590, 1380, 23654, 543, 199, 1589, 2556, 4177, 6716, 1202, 315, 1817, 25572, 12, 436, 314, 574, 221, 199, 7790, 1642, 506, 5737, 370, 282, 23888, 14, 199, 199, 7940, 365, 367, 642, 4499, 626, 3775, 503, 440, 2649, 18041, 367, 3914, 199, 3214, 506, 4847, 370, 1611, 47, 23317, 883, 506, 22284, 1808, 314, 221, 199, 1040, 9823, 63, 2975, 63, 27080, 1040, 2725, 370, 1124, 981, 63, 3908, 28566, 221, 3979, 221, 199, 3039, 737, 2399, 849, 402, 1124, 403, 4542, 314, 1611, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
seem-sky/kbengine
kbe/src/lib/python/Lib/test/test_generators.py
72
50910
import gc import sys import unittest import weakref from test import support class FinalizationTest(unittest.TestCase): def test_frame_resurrect(self): # A generator frame can be resurrected by a generator's finalization. def gen(): nonlocal frame try: yield finally: frame = sys._getframe() g = gen() wr = weakref.ref(g) next(g) del g support.gc_collect() self.assertIs(wr(), None) self.assertTrue(frame) del frame support.gc_collect() def test_refcycle(self): # A generator caught in a refcycle gets finalized anyway. old_garbage = gc.garbage[:] finalized = False def gen(): nonlocal finalized try: g = yield yield 1 finally: finalized = True g = gen() next(g) g.send(g) self.assertGreater(sys.getrefcount(g), 2) self.assertFalse(finalized) del g support.gc_collect() self.assertTrue(finalized) self.assertEqual(gc.garbage, old_garbage) tutorial_tests = """ Let's try a simple generator: >>> def f(): ... yield 1 ... yield 2 >>> for i in f(): ... print(i) 1 2 >>> g = f() >>> next(g) 1 >>> next(g) 2 "Falling off the end" stops the generator: >>> next(g) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in g StopIteration "return" also stops the generator: >>> def f(): ... yield 1 ... return ... yield 2 # never reached ... >>> g = f() >>> next(g) 1 >>> next(g) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 3, in f StopIteration >>> next(g) # once stopped, can't be resumed Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration "raise StopIteration" stops the generator too: >>> def f(): ... yield 1 ... raise StopIteration ... yield 2 # never reached ... >>> g = f() >>> next(g) 1 >>> next(g) Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration >>> next(g) Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration However, they are not exactly equivalent: >>> def g1(): ... try: ... return ... except: ... yield 1 ... >>> list(g1()) [] >>> def g2(): ... try: ... raise StopIteration ... except: ... yield 42 >>> print(list(g2())) [42] This may be surprising at first: >>> def g3(): ... try: ... return ... finally: ... yield 1 ... >>> list(g3()) [1] Let's create an alternate range() function implemented as a generator: >>> def yrange(n): ... for i in range(n): ... yield i ... >>> list(yrange(5)) [0, 1, 2, 3, 4] Generators always return to the most recent caller: >>> def creator(): ... r = yrange(5) ... print("creator", next(r)) ... return r ... >>> def caller(): ... r = creator() ... for i in r: ... print("caller", i) ... >>> caller() creator 0 caller 1 caller 2 caller 3 caller 4 Generators can call other generators: >>> def zrange(n): ... for i in yrange(n): ... yield i ... >>> list(zrange(5)) [0, 1, 2, 3, 4] """ # The examples from PEP 255. pep_tests = """ Specification: Yield Restriction: A generator cannot be resumed while it is actively running: >>> def g(): ... i = next(me) ... yield i >>> me = g() >>> next(me) Traceback (most recent call last): ... File "<string>", line 2, in g ValueError: generator already executing Specification: Return Note that return isn't always equivalent to raising StopIteration: the difference lies in how enclosing try/except constructs are treated. For example, >>> def f1(): ... try: ... return ... except: ... yield 1 >>> print(list(f1())) [] because, as in any function, return simply exits, but >>> def f2(): ... try: ... raise StopIteration ... except: ... yield 42 >>> print(list(f2())) [42] because StopIteration is captured by a bare "except", as is any exception. Specification: Generators and Exception Propagation >>> def f(): ... return 1//0 >>> def g(): ... yield f() # the zero division exception propagates ... yield 42 # and we'll never get here >>> k = g() >>> next(k) Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in g File "<stdin>", line 2, in f ZeroDivisionError: integer division or modulo by zero >>> next(k) # and the generator cannot be resumed Traceback (most recent call last): File "<stdin>", line 1, in ? StopIteration >>> Specification: Try/Except/Finally >>> def f(): ... try: ... yield 1 ... try: ... yield 2 ... 1//0 ... yield 3 # never get here ... except ZeroDivisionError: ... yield 4 ... yield 5 ... raise ... except: ... yield 6 ... yield 7 # the "raise" above stops this ... except: ... yield 8 ... yield 9 ... try: ... x = 12 ... finally: ... yield 10 ... yield 11 >>> print(list(f())) [1, 2, 4, 5, 8, 9, 10, 11] >>> Guido's binary tree example. >>> # A binary tree class. >>> class Tree: ... ... def __init__(self, label, left=None, right=None): ... self.label = label ... self.left = left ... self.right = right ... ... def __repr__(self, level=0, indent=" "): ... s = level*indent + repr(self.label) ... if self.left: ... s = s + "\\n" + self.left.__repr__(level+1, indent) ... if self.right: ... s = s + "\\n" + self.right.__repr__(level+1, indent) ... return s ... ... def __iter__(self): ... return inorder(self) >>> # Create a Tree from a list. >>> def tree(list): ... n = len(list) ... if n == 0: ... return [] ... i = n // 2 ... return Tree(list[i], tree(list[:i]), tree(list[i+1:])) >>> # Show it off: create a tree. >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") >>> # A recursive generator that generates Tree labels in in-order. >>> def inorder(t): ... if t: ... for x in inorder(t.left): ... yield x ... yield t.label ... for x in inorder(t.right): ... yield x >>> # Show it off: create a tree. >>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") >>> # Print the nodes of the tree in in-order. >>> for x in t: ... print(' '+x, end='') A B C D E F G H I J K L M N O P Q R S T U V W X Y Z >>> # A non-recursive generator. >>> def inorder(node): ... stack = [] ... while node: ... while node.left: ... stack.append(node) ... node = node.left ... yield node.label ... while not node.right: ... try: ... node = stack.pop() ... except IndexError: ... return ... yield node.label ... node = node.right >>> # Exercise the non-recursive generator. >>> for x in t: ... print(' '+x, end='') A B C D E F G H I J K L M N O P Q R S T U V W X Y Z """ # Examples from Iterator-List and Python-Dev and c.l.py. email_tests = """ The difference between yielding None and returning it. >>> def g(): ... for i in range(3): ... yield None ... yield None ... return >>> list(g()) [None, None, None, None] Ensure that explicitly raising StopIteration acts like any other exception in try/except, not like a return. >>> def g(): ... yield 1 ... try: ... raise StopIteration ... except: ... yield 2 ... yield 3 >>> list(g()) [1, 2, 3] Next one was posted to c.l.py. >>> def gcomb(x, k): ... "Generate all combinations of k elements from list x." ... ... if k > len(x): ... return ... if k == 0: ... yield [] ... else: ... first, rest = x[0], x[1:] ... # A combination does or doesn't contain first. ... # If it does, the remainder is a k-1 comb of rest. ... for c in gcomb(rest, k-1): ... c.insert(0, first) ... yield c ... # If it doesn't contain first, it's a k comb of rest. ... for c in gcomb(rest, k): ... yield c >>> seq = list(range(1, 5)) >>> for k in range(len(seq) + 2): ... print("%d-combs of %s:" % (k, seq)) ... for c in gcomb(seq, k): ... print(" ", c) 0-combs of [1, 2, 3, 4]: [] 1-combs of [1, 2, 3, 4]: [1] [2] [3] [4] 2-combs of [1, 2, 3, 4]: [1, 2] [1, 3] [1, 4] [2, 3] [2, 4] [3, 4] 3-combs of [1, 2, 3, 4]: [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] 4-combs of [1, 2, 3, 4]: [1, 2, 3, 4] 5-combs of [1, 2, 3, 4]: From the Iterators list, about the types of these things. >>> def g(): ... yield 1 ... >>> type(g) <class 'function'> >>> i = g() >>> type(i) <class 'generator'> >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_code', 'gi_frame', 'gi_running', 'send', 'throw'] >>> from test.support import HAVE_DOCSTRINGS >>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).') Implement next(self). >>> iter(i) is i True >>> import types >>> isinstance(i, types.GeneratorType) True And more, added later. >>> i.gi_running 0 >>> type(i.gi_frame) <class 'frame'> >>> i.gi_running = 42 Traceback (most recent call last): ... AttributeError: readonly attribute >>> def g(): ... yield me.gi_running >>> me = g() >>> me.gi_running 0 >>> next(me) 1 >>> me.gi_running 0 A clever union-find implementation from c.l.py, due to David Eppstein. Sent: Friday, June 29, 2001 12:16 PM To: python-list@python.org Subject: Re: PEP 255: Simple Generators >>> class disjointSet: ... def __init__(self, name): ... self.name = name ... self.parent = None ... self.generator = self.generate() ... ... def generate(self): ... while not self.parent: ... yield self ... for x in self.parent.generator: ... yield x ... ... def find(self): ... return next(self.generator) ... ... def union(self, parent): ... if self.parent: ... raise ValueError("Sorry, I'm not a root!") ... self.parent = parent ... ... def __str__(self): ... return self.name >>> names = "ABCDEFGHIJKLM" >>> sets = [disjointSet(name) for name in names] >>> roots = sets[:] >>> import random >>> gen = random.Random(42) >>> while 1: ... for s in sets: ... print(" %s->%s" % (s, s.find()), end='') ... print() ... if len(roots) > 1: ... s1 = gen.choice(roots) ... roots.remove(s1) ... s2 = gen.choice(roots) ... s1.union(s2) ... print("merged", s1, "into", s2) ... else: ... break A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M merged K into B A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M merged A into F A->F B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M merged E into F A->F B->B C->C D->D E->F F->F G->G H->H I->I J->J K->B L->L M->M merged D into C A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->M merged M into C A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->C merged J into B A->F B->B C->C D->C E->F F->F G->G H->H I->I J->B K->B L->L M->C merged B into C A->F B->C C->C D->C E->F F->F G->G H->H I->I J->C K->C L->L M->C merged F into G A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->L M->C merged L into C A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->C M->C merged G into I A->I B->C C->C D->C E->I F->I G->I H->H I->I J->C K->C L->C M->C merged I into H A->H B->C C->C D->C E->H F->H G->H H->H I->H J->C K->C L->C M->C merged C into H A->H B->H C->H D->H E->H F->H G->H H->H I->H J->H K->H L->H M->H """ # Emacs turd ' # Fun tests (for sufficiently warped notions of "fun"). fun_tests = """ Build up to a recursive Sieve of Eratosthenes generator. >>> def firstn(g, n): ... return [next(g) for i in range(n)] >>> def intsfrom(i): ... while 1: ... yield i ... i += 1 >>> firstn(intsfrom(5), 7) [5, 6, 7, 8, 9, 10, 11] >>> def exclude_multiples(n, ints): ... for i in ints: ... if i % n: ... yield i >>> firstn(exclude_multiples(3, intsfrom(1)), 6) [1, 2, 4, 5, 7, 8] >>> def sieve(ints): ... prime = next(ints) ... yield prime ... not_divisible_by_prime = exclude_multiples(prime, ints) ... for p in sieve(not_divisible_by_prime): ... yield p >>> primes = sieve(intsfrom(2)) >>> firstn(primes, 20) [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71] Another famous problem: generate all integers of the form 2**i * 3**j * 5**k in increasing order, where i,j,k >= 0. Trickier than it may look at first! Try writing it without generators, and correctly, and without generating 3 internal results for each result output. >>> def times(n, g): ... for i in g: ... yield n * i >>> firstn(times(10, intsfrom(1)), 10) [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] >>> def merge(g, h): ... ng = next(g) ... nh = next(h) ... while 1: ... if ng < nh: ... yield ng ... ng = next(g) ... elif ng > nh: ... yield nh ... nh = next(h) ... else: ... yield ng ... ng = next(g) ... nh = next(h) The following works, but is doing a whale of a lot of redundant work -- it's not clear how to get the internal uses of m235 to share a single generator. Note that me_times2 (etc) each need to see every element in the result sequence. So this is an example where lazy lists are more natural (you can look at the head of a lazy list any number of times). >>> def m235(): ... yield 1 ... me_times2 = times(2, m235()) ... me_times3 = times(3, m235()) ... me_times5 = times(5, m235()) ... for i in merge(merge(me_times2, ... me_times3), ... me_times5): ... yield i Don't print "too many" of these -- the implementation above is extremely inefficient: each call of m235() leads to 3 recursive calls, and in turn each of those 3 more, and so on, and so on, until we've descended enough levels to satisfy the print stmts. Very odd: when I printed 5 lines of results below, this managed to screw up Win98's malloc in "the usual" way, i.e. the heap grew over 4Mb so Win98 started fragmenting address space, and it *looked* like a very slow leak. >>> result = m235() >>> for i in range(3): ... print(firstn(result, 15)) [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] Heh. Here's one way to get a shared list, complete with an excruciating namespace renaming trick. The *pretty* part is that the times() and merge() functions can be reused as-is, because they only assume their stream arguments are iterable -- a LazyList is the same as a generator to times(). >>> class LazyList: ... def __init__(self, g): ... self.sofar = [] ... self.fetch = g.__next__ ... ... def __getitem__(self, i): ... sofar, fetch = self.sofar, self.fetch ... while i >= len(sofar): ... sofar.append(fetch()) ... return sofar[i] >>> def m235(): ... yield 1 ... # Gack: m235 below actually refers to a LazyList. ... me_times2 = times(2, m235) ... me_times3 = times(3, m235) ... me_times5 = times(5, m235) ... for i in merge(merge(me_times2, ... me_times3), ... me_times5): ... yield i Print as many of these as you like -- *this* implementation is memory- efficient. >>> m235 = LazyList(m235()) >>> for i in range(5): ... print([m235[j] for j in range(15*i, 15*(i+1))]) [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384] [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675] Ye olde Fibonacci generator, LazyList style. >>> def fibgen(a, b): ... ... def sum(g, h): ... while 1: ... yield next(g) + next(h) ... ... def tail(g): ... next(g) # throw first away ... for x in g: ... yield x ... ... yield a ... yield b ... for s in sum(iter(fib), ... tail(iter(fib))): ... yield s >>> fib = LazyList(fibgen(1, 2)) >>> firstn(iter(fib), 17) [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] Running after your tail with itertools.tee (new in version 2.4) The algorithms "m235" (Hamming) and Fibonacci presented above are both examples of a whole family of FP (functional programming) algorithms where a function produces and returns a list while the production algorithm suppose the list as already produced by recursively calling itself. For these algorithms to work, they must: - produce at least a first element without presupposing the existence of the rest of the list - produce their elements in a lazy manner To work efficiently, the beginning of the list must not be recomputed over and over again. This is ensured in most FP languages as a built-in feature. In python, we have to explicitly maintain a list of already computed results and abandon genuine recursivity. This is what had been attempted above with the LazyList class. One problem with that class is that it keeps a list of all of the generated results and therefore continually grows. This partially defeats the goal of the generator concept, viz. produce the results only as needed instead of producing them all and thereby wasting memory. Thanks to itertools.tee, it is now clear "how to get the internal uses of m235 to share a single generator". >>> from itertools import tee >>> def m235(): ... def _m235(): ... yield 1 ... for n in merge(times(2, m2), ... merge(times(3, m3), ... times(5, m5))): ... yield n ... m1 = _m235() ... m2, m3, m5, mRes = tee(m1, 4) ... return mRes >>> it = m235() >>> for i in range(5): ... print(firstn(it, 15)) [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24] [25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80] [81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192] [200, 216, 225, 240, 243, 250, 256, 270, 288, 300, 320, 324, 360, 375, 384] [400, 405, 432, 450, 480, 486, 500, 512, 540, 576, 600, 625, 640, 648, 675] The "tee" function does just what we want. It internally keeps a generated result for as long as it has not been "consumed" from all of the duplicated iterators, whereupon it is deleted. You can therefore print the hamming sequence during hours without increasing memory usage, or very little. The beauty of it is that recursive running-after-their-tail FP algorithms are quite straightforwardly expressed with this Python idiom. Ye olde Fibonacci generator, tee style. >>> def fib(): ... ... def _isum(g, h): ... while 1: ... yield next(g) + next(h) ... ... def _fib(): ... yield 1 ... yield 2 ... next(fibTail) # throw first away ... for res in _isum(fibHead, fibTail): ... yield res ... ... realfib = _fib() ... fibHead, fibTail, fibRes = tee(realfib, 3) ... return fibRes >>> firstn(fib(), 17) [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] """ # syntax_tests mostly provokes SyntaxErrors. Also fiddling with #if 0 # hackery. syntax_tests = """ These are fine: >>> def f(): ... yield 1 ... return >>> def f(): ... try: ... yield 1 ... finally: ... pass >>> def f(): ... try: ... try: ... 1//0 ... except ZeroDivisionError: ... yield 666 ... except: ... pass ... finally: ... pass >>> def f(): ... try: ... try: ... yield 12 ... 1//0 ... except ZeroDivisionError: ... yield 666 ... except: ... try: ... x = 12 ... finally: ... yield 12 ... except: ... return >>> list(f()) [12, 666] >>> def f(): ... yield >>> type(f()) <class 'generator'> >>> def f(): ... if 0: ... yield >>> type(f()) <class 'generator'> >>> def f(): ... if 0: ... yield 1 >>> type(f()) <class 'generator'> >>> def f(): ... if "": ... yield None >>> type(f()) <class 'generator'> >>> def f(): ... return ... try: ... if x==4: ... pass ... elif 0: ... try: ... 1//0 ... except SyntaxError: ... pass ... else: ... if 0: ... while 12: ... x += 1 ... yield 2 # don't blink ... f(a, b, c, d, e) ... else: ... pass ... except: ... x = 1 ... return >>> type(f()) <class 'generator'> >>> def f(): ... if 0: ... def g(): ... yield 1 ... >>> type(f()) <class 'NoneType'> >>> def f(): ... if 0: ... class C: ... def __init__(self): ... yield 1 ... def f(self): ... yield 2 >>> type(f()) <class 'NoneType'> >>> def f(): ... if 0: ... return ... if 0: ... yield 2 >>> type(f()) <class 'generator'> This one caused a crash (see SF bug 567538): >>> def f(): ... for i in range(3): ... try: ... continue ... finally: ... yield i ... >>> g = f() >>> print(next(g)) 0 >>> print(next(g)) 1 >>> print(next(g)) 2 >>> print(next(g)) Traceback (most recent call last): StopIteration Test the gi_code attribute >>> def f(): ... yield 5 ... >>> g = f() >>> g.gi_code is f.__code__ True >>> next(g) 5 >>> next(g) Traceback (most recent call last): StopIteration >>> g.gi_code is f.__code__ True Test the __name__ attribute and the repr() >>> def f(): ... yield 5 ... >>> g = f() >>> g.__name__ 'f' >>> repr(g) # doctest: +ELLIPSIS '<generator object f at ...>' Lambdas shouldn't have their usual return behavior. >>> x = lambda: (yield 1) >>> list(x()) [1] >>> x = lambda: ((yield 1), (yield 2)) >>> list(x()) [1, 2] """ # conjoin is a simple backtracking generator, named in honor of Icon's # "conjunction" control structure. Pass a list of no-argument functions # that return iterable objects. Easiest to explain by example: assume the # function list [x, y, z] is passed. Then conjoin acts like: # # def g(): # values = [None] * 3 # for values[0] in x(): # for values[1] in y(): # for values[2] in z(): # yield values # # So some 3-lists of values *may* be generated, each time we successfully # get into the innermost loop. If an iterator fails (is exhausted) before # then, it "backtracks" to get the next value from the nearest enclosing # iterator (the one "to the left"), and starts all over again at the next # slot (pumps a fresh iterator). Of course this is most useful when the # iterators have side-effects, so that which values *can* be generated at # each slot depend on the values iterated at previous slots. def simple_conjoin(gs): values = [None] * len(gs) def gen(i): if i >= len(gs): yield values else: for values[i] in gs[i](): for x in gen(i+1): yield x for x in gen(0): yield x # That works fine, but recursing a level and checking i against len(gs) for # each item produced is inefficient. By doing manual loop unrolling across # generator boundaries, it's possible to eliminate most of that overhead. # This isn't worth the bother *in general* for generators, but conjoin() is # a core building block for some CPU-intensive generator applications. def conjoin(gs): n = len(gs) values = [None] * n # Do one loop nest at time recursively, until the # of loop nests # remaining is divisible by 3. def gen(i): if i >= n: yield values elif (n-i) % 3: ip1 = i+1 for values[i] in gs[i](): for x in gen(ip1): yield x else: for x in _gen3(i): yield x # Do three loop nests at a time, recursing only if at least three more # remain. Don't call directly: this is an internal optimization for # gen's use. def _gen3(i): assert i < n and (n-i) % 3 == 0 ip1, ip2, ip3 = i+1, i+2, i+3 g, g1, g2 = gs[i : ip3] if ip3 >= n: # These are the last three, so we can yield values directly. for values[i] in g(): for values[ip1] in g1(): for values[ip2] in g2(): yield values else: # At least 6 loop nests remain; peel off 3 and recurse for the # rest. for values[i] in g(): for values[ip1] in g1(): for values[ip2] in g2(): for x in _gen3(ip3): yield x for x in gen(0): yield x # And one more approach: For backtracking apps like the Knight's Tour # solver below, the number of backtracking levels can be enormous (one # level per square, for the Knight's Tour, so that e.g. a 100x100 board # needs 10,000 levels). In such cases Python is likely to run out of # stack space due to recursion. So here's a recursion-free version of # conjoin too. # NOTE WELL: This allows large problems to be solved with only trivial # demands on stack space. Without explicitly resumable generators, this is # much harder to achieve. OTOH, this is much slower (up to a factor of 2) # than the fancy unrolled recursive conjoin. def flat_conjoin(gs): # rename to conjoin to run tests with this instead n = len(gs) values = [None] * n iters = [None] * n _StopIteration = StopIteration # make local because caught a *lot* i = 0 while 1: # Descend. try: while i < n: it = iters[i] = gs[i]().__next__ values[i] = it() i += 1 except _StopIteration: pass else: assert i == n yield values # Backtrack until an older iterator can be resumed. i -= 1 while i >= 0: try: values[i] = iters[i]() # Success! Start fresh at next level. i += 1 break except _StopIteration: # Continue backtracking. i -= 1 else: assert i < 0 break # A conjoin-based N-Queens solver. class Queens: def __init__(self, n): self.n = n rangen = range(n) # Assign a unique int to each column and diagonal. # columns: n of those, range(n). # NW-SE diagonals: 2n-1 of these, i-j unique and invariant along # each, smallest i-j is 0-(n-1) = 1-n, so add n-1 to shift to 0- # based. # NE-SW diagonals: 2n-1 of these, i+j unique and invariant along # each, smallest i+j is 0, largest is 2n-2. # For each square, compute a bit vector of the columns and # diagonals it covers, and for each row compute a function that # generates the possiblities for the columns in that row. self.rowgenerators = [] for i in rangen: rowuses = [(1 << j) | # column ordinal (1 << (n + i-j + n-1)) | # NW-SE ordinal (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal for j in rangen] def rowgen(rowuses=rowuses): for j in rangen: uses = rowuses[j] if uses & self.used == 0: self.used |= uses yield j self.used &= ~uses self.rowgenerators.append(rowgen) # Generate solutions. def solve(self): self.used = 0 for row2col in conjoin(self.rowgenerators): yield row2col def printsolution(self, row2col): n = self.n assert n == len(row2col) sep = "+" + "-+" * n print(sep) for i in range(n): squares = [" " for j in range(n)] squares[row2col[i]] = "Q" print("|" + "|".join(squares) + "|") print(sep) # A conjoin-based Knight's Tour solver. This is pretty sophisticated # (e.g., when used with flat_conjoin above, and passing hard=1 to the # constructor, a 200x200 Knight's Tour was found quickly -- note that we're # creating 10s of thousands of generators then!), and is lengthy. class Knights: def __init__(self, m, n, hard=0): self.m, self.n = m, n # solve() will set up succs[i] to be a list of square #i's # successors. succs = self.succs = [] # Remove i0 from each of its successor's successor lists, i.e. # successors can't go back to i0 again. Return 0 if we can # detect this makes a solution impossible, else return 1. def remove_from_successors(i0, len=len): # If we remove all exits from a free square, we're dead: # even if we move to it next, we can't leave it again. # If we create a square with one exit, we must visit it next; # else somebody else will have to visit it, and since there's # only one adjacent, there won't be a way to leave it again. # Finelly, if we create more than one free square with a # single exit, we can only move to one of them next, leaving # the other one a dead end. ne0 = ne1 = 0 for i in succs[i0]: s = succs[i] s.remove(i0) e = len(s) if e == 0: ne0 += 1 elif e == 1: ne1 += 1 return ne0 == 0 and ne1 < 2 # Put i0 back in each of its successor's successor lists. def add_to_successors(i0): for i in succs[i0]: succs[i].append(i0) # Generate the first move. def first(): if m < 1 or n < 1: return # Since we're looking for a cycle, it doesn't matter where we # start. Starting in a corner makes the 2nd move easy. corner = self.coords2index(0, 0) remove_from_successors(corner) self.lastij = corner yield corner add_to_successors(corner) # Generate the second moves. def second(): corner = self.coords2index(0, 0) assert self.lastij == corner # i.e., we started in the corner if m < 3 or n < 3: return assert len(succs[corner]) == 2 assert self.coords2index(1, 2) in succs[corner] assert self.coords2index(2, 1) in succs[corner] # Only two choices. Whichever we pick, the other must be the # square picked on move m*n, as it's the only way to get back # to (0, 0). Save its index in self.final so that moves before # the last know it must be kept free. for i, j in (1, 2), (2, 1): this = self.coords2index(i, j) final = self.coords2index(3-i, 3-j) self.final = final remove_from_successors(this) succs[final].append(corner) self.lastij = this yield this succs[final].remove(corner) add_to_successors(this) # Generate moves 3 thru m*n-1. def advance(len=len): # If some successor has only one exit, must take it. # Else favor successors with fewer exits. candidates = [] for i in succs[self.lastij]: e = len(succs[i]) assert e > 0, "else remove_from_successors() pruning flawed" if e == 1: candidates = [(e, i)] break candidates.append((e, i)) else: candidates.sort() for e, i in candidates: if i != self.final: if remove_from_successors(i): self.lastij = i yield i add_to_successors(i) # Generate moves 3 thru m*n-1. Alternative version using a # stronger (but more expensive) heuristic to order successors. # Since the # of backtracking levels is m*n, a poor move early on # can take eons to undo. Smallest square board for which this # matters a lot is 52x52. def advance_hard(vmid=(m-1)/2.0, hmid=(n-1)/2.0, len=len): # If some successor has only one exit, must take it. # Else favor successors with fewer exits. # Break ties via max distance from board centerpoint (favor # corners and edges whenever possible). candidates = [] for i in succs[self.lastij]: e = len(succs[i]) assert e > 0, "else remove_from_successors() pruning flawed" if e == 1: candidates = [(e, 0, i)] break i1, j1 = self.index2coords(i) d = (i1 - vmid)**2 + (j1 - hmid)**2 candidates.append((e, -d, i)) else: candidates.sort() for e, d, i in candidates: if i != self.final: if remove_from_successors(i): self.lastij = i yield i add_to_successors(i) # Generate the last move. def last(): assert self.final in succs[self.lastij] yield self.final if m*n < 4: self.squaregenerators = [first] else: self.squaregenerators = [first, second] + \ [hard and advance_hard or advance] * (m*n - 3) + \ [last] def coords2index(self, i, j): assert 0 <= i < self.m assert 0 <= j < self.n return i * self.n + j def index2coords(self, index): assert 0 <= index < self.m * self.n return divmod(index, self.n) def _init_board(self): succs = self.succs del succs[:] m, n = self.m, self.n c2i = self.coords2index offsets = [( 1, 2), ( 2, 1), ( 2, -1), ( 1, -2), (-1, -2), (-2, -1), (-2, 1), (-1, 2)] rangen = range(n) for i in range(m): for j in rangen: s = [c2i(i+io, j+jo) for io, jo in offsets if 0 <= i+io < m and 0 <= j+jo < n] succs.append(s) # Generate solutions. def solve(self): self._init_board() for x in conjoin(self.squaregenerators): yield x def printsolution(self, x): m, n = self.m, self.n assert len(x) == m*n w = len(str(m*n)) format = "%" + str(w) + "d" squares = [[None] * n for i in range(m)] k = 1 for i in x: i1, j1 = self.index2coords(i) squares[i1][j1] = format % k k += 1 sep = "+" + ("-" * w + "+") * n print(sep) for i in range(m): row = squares[i] print("|" + "|".join(row) + "|") print(sep) conjoin_tests = """ Generate the 3-bit binary numbers in order. This illustrates dumbest- possible use of conjoin, just to generate the full cross-product. >>> for c in conjoin([lambda: iter((0, 1))] * 3): ... print(c) [0, 0, 0] [0, 0, 1] [0, 1, 0] [0, 1, 1] [1, 0, 0] [1, 0, 1] [1, 1, 0] [1, 1, 1] For efficiency in typical backtracking apps, conjoin() yields the same list object each time. So if you want to save away a full account of its generated sequence, you need to copy its results. >>> def gencopy(iterator): ... for x in iterator: ... yield x[:] >>> for n in range(10): ... all = list(gencopy(conjoin([lambda: iter((0, 1))] * n))) ... print(n, len(all), all[0] == [0] * n, all[-1] == [1] * n) 0 1 True True 1 2 True True 2 4 True True 3 8 True True 4 16 True True 5 32 True True 6 64 True True 7 128 True True 8 256 True True 9 512 True True And run an 8-queens solver. >>> q = Queens(8) >>> LIMIT = 2 >>> count = 0 >>> for row2col in q.solve(): ... count += 1 ... if count <= LIMIT: ... print("Solution", count) ... q.printsolution(row2col) Solution 1 +-+-+-+-+-+-+-+-+ |Q| | | | | | | | +-+-+-+-+-+-+-+-+ | | | | |Q| | | | +-+-+-+-+-+-+-+-+ | | | | | | | |Q| +-+-+-+-+-+-+-+-+ | | | | | |Q| | | +-+-+-+-+-+-+-+-+ | | |Q| | | | | | +-+-+-+-+-+-+-+-+ | | | | | | |Q| | +-+-+-+-+-+-+-+-+ | |Q| | | | | | | +-+-+-+-+-+-+-+-+ | | | |Q| | | | | +-+-+-+-+-+-+-+-+ Solution 2 +-+-+-+-+-+-+-+-+ |Q| | | | | | | | +-+-+-+-+-+-+-+-+ | | | | | |Q| | | +-+-+-+-+-+-+-+-+ | | | | | | | |Q| +-+-+-+-+-+-+-+-+ | | |Q| | | | | | +-+-+-+-+-+-+-+-+ | | | | | | |Q| | +-+-+-+-+-+-+-+-+ | | | |Q| | | | | +-+-+-+-+-+-+-+-+ | |Q| | | | | | | +-+-+-+-+-+-+-+-+ | | | | |Q| | | | +-+-+-+-+-+-+-+-+ >>> print(count, "solutions in all.") 92 solutions in all. And run a Knight's Tour on a 10x10 board. Note that there are about 20,000 solutions even on a 6x6 board, so don't dare run this to exhaustion. >>> k = Knights(10, 10) >>> LIMIT = 2 >>> count = 0 >>> for x in k.solve(): ... count += 1 ... if count <= LIMIT: ... print("Solution", count) ... k.printsolution(x) ... else: ... break Solution 1 +---+---+---+---+---+---+---+---+---+---+ | 1| 58| 27| 34| 3| 40| 29| 10| 5| 8| +---+---+---+---+---+---+---+---+---+---+ | 26| 35| 2| 57| 28| 33| 4| 7| 30| 11| +---+---+---+---+---+---+---+---+---+---+ | 59|100| 73| 36| 41| 56| 39| 32| 9| 6| +---+---+---+---+---+---+---+---+---+---+ | 74| 25| 60| 55| 72| 37| 42| 49| 12| 31| +---+---+---+---+---+---+---+---+---+---+ | 61| 86| 99| 76| 63| 52| 47| 38| 43| 50| +---+---+---+---+---+---+---+---+---+---+ | 24| 75| 62| 85| 54| 71| 64| 51| 48| 13| +---+---+---+---+---+---+---+---+---+---+ | 87| 98| 91| 80| 77| 84| 53| 46| 65| 44| +---+---+---+---+---+---+---+---+---+---+ | 90| 23| 88| 95| 70| 79| 68| 83| 14| 17| +---+---+---+---+---+---+---+---+---+---+ | 97| 92| 21| 78| 81| 94| 19| 16| 45| 66| +---+---+---+---+---+---+---+---+---+---+ | 22| 89| 96| 93| 20| 69| 82| 67| 18| 15| +---+---+---+---+---+---+---+---+---+---+ Solution 2 +---+---+---+---+---+---+---+---+---+---+ | 1| 58| 27| 34| 3| 40| 29| 10| 5| 8| +---+---+---+---+---+---+---+---+---+---+ | 26| 35| 2| 57| 28| 33| 4| 7| 30| 11| +---+---+---+---+---+---+---+---+---+---+ | 59|100| 73| 36| 41| 56| 39| 32| 9| 6| +---+---+---+---+---+---+---+---+---+---+ | 74| 25| 60| 55| 72| 37| 42| 49| 12| 31| +---+---+---+---+---+---+---+---+---+---+ | 61| 86| 99| 76| 63| 52| 47| 38| 43| 50| +---+---+---+---+---+---+---+---+---+---+ | 24| 75| 62| 85| 54| 71| 64| 51| 48| 13| +---+---+---+---+---+---+---+---+---+---+ | 87| 98| 89| 80| 77| 84| 53| 46| 65| 44| +---+---+---+---+---+---+---+---+---+---+ | 90| 23| 92| 95| 70| 79| 68| 83| 14| 17| +---+---+---+---+---+---+---+---+---+---+ | 97| 88| 21| 78| 81| 94| 19| 16| 45| 66| +---+---+---+---+---+---+---+---+---+---+ | 22| 91| 96| 93| 20| 69| 82| 67| 18| 15| +---+---+---+---+---+---+---+---+---+---+ """ weakref_tests = """\ Generators are weakly referencable: >>> import weakref >>> def gen(): ... yield 'foo!' ... >>> wr = weakref.ref(gen) >>> wr() is gen True >>> p = weakref.proxy(gen) Generator-iterators are weakly referencable as well: >>> gi = gen() >>> wr = weakref.ref(gi) >>> wr() is gi True >>> p = weakref.proxy(gi) >>> list(p) ['foo!'] """ coroutine_tests = """\ Sending a value into a started generator: >>> def f(): ... print((yield 1)) ... yield 2 >>> g = f() >>> next(g) 1 >>> g.send(42) 42 2 Sending a value into a new generator produces a TypeError: >>> f().send("foo") Traceback (most recent call last): ... TypeError: can't send non-None value to a just-started generator Yield by itself yields None: >>> def f(): yield >>> list(f()) [None] An obscene abuse of a yield expression within a generator expression: >>> list((yield 21) for i in range(4)) [21, None, 21, None, 21, None, 21, None] And a more sane, but still weird usage: >>> def f(): list(i for i in [(yield 26)]) >>> type(f()) <class 'generator'> A yield expression with augmented assignment. >>> def coroutine(seq): ... count = 0 ... while count < 200: ... count += yield ... seq.append(count) >>> seq = [] >>> c = coroutine(seq) >>> next(c) >>> print(seq) [] >>> c.send(10) >>> print(seq) [10] >>> c.send(10) >>> print(seq) [10, 20] >>> c.send(10) >>> print(seq) [10, 20, 30] Check some syntax errors for yield expressions: >>> f=lambda: (yield 1),(yield 2) Traceback (most recent call last): ... SyntaxError: 'yield' outside function >>> def f(): x = yield = y Traceback (most recent call last): ... SyntaxError: assignment to yield expression not possible >>> def f(): (yield bar) = y Traceback (most recent call last): ... SyntaxError: can't assign to yield expression >>> def f(): (yield bar) += y Traceback (most recent call last): ... SyntaxError: can't assign to yield expression Now check some throw() conditions: >>> def f(): ... while True: ... try: ... print((yield)) ... except ValueError as v: ... print("caught ValueError (%s)" % (v)) >>> import sys >>> g = f() >>> next(g) >>> g.throw(ValueError) # type only caught ValueError () >>> g.throw(ValueError("xyz")) # value only caught ValueError (xyz) >>> g.throw(ValueError, ValueError(1)) # value+matching type caught ValueError (1) >>> g.throw(ValueError, TypeError(1)) # mismatched type, rewrapped caught ValueError (1) >>> g.throw(ValueError, ValueError(1), None) # explicit None traceback caught ValueError (1) >>> g.throw(ValueError(1), "foo") # bad args Traceback (most recent call last): ... TypeError: instance exception may not have a separate value >>> g.throw(ValueError, "foo", 23) # bad args Traceback (most recent call last): ... TypeError: throw() third argument must be a traceback object >>> g.throw("abc") Traceback (most recent call last): ... TypeError: exceptions must be classes or instances deriving from BaseException, not str >>> g.throw(0) Traceback (most recent call last): ... TypeError: exceptions must be classes or instances deriving from BaseException, not int >>> g.throw(list) Traceback (most recent call last): ... TypeError: exceptions must be classes or instances deriving from BaseException, not type >>> def throw(g,exc): ... try: ... raise exc ... except: ... g.throw(*sys.exc_info()) >>> throw(g,ValueError) # do it with traceback included caught ValueError () >>> g.send(1) 1 >>> throw(g,TypeError) # terminate the generator Traceback (most recent call last): ... TypeError >>> print(g.gi_frame) None >>> g.send(2) Traceback (most recent call last): ... StopIteration >>> g.throw(ValueError,6) # throw on closed generator Traceback (most recent call last): ... ValueError: 6 >>> f().throw(ValueError,7) # throw on just-opened generator Traceback (most recent call last): ... ValueError: 7 Plain "raise" inside a generator should preserve the traceback (#13188). The traceback should have 3 levels: - g.throw() - f() - 1/0 >>> def f(): ... try: ... yield ... except: ... raise >>> g = f() >>> try: ... 1/0 ... except ZeroDivisionError as v: ... try: ... g.throw(v) ... except Exception as w: ... tb = w.__traceback__ >>> levels = 0 >>> while tb: ... levels += 1 ... tb = tb.tb_next >>> levels 3 Now let's try closing a generator: >>> def f(): ... try: yield ... except GeneratorExit: ... print("exiting") >>> g = f() >>> next(g) >>> g.close() exiting >>> g.close() # should be no-op now >>> f().close() # close on just-opened generator should be fine >>> def f(): yield # an even simpler generator >>> f().close() # close before opening >>> g = f() >>> next(g) >>> g.close() # close normally And finalization: >>> def f(): ... try: yield ... finally: ... print("exiting") >>> g = f() >>> next(g) >>> del g exiting GeneratorExit is not caught by except Exception: >>> def f(): ... try: yield ... except Exception: ... print('except') ... finally: ... print('finally') >>> g = f() >>> next(g) >>> del g finally Now let's try some ill-behaved generators: >>> def f(): ... try: yield ... except GeneratorExit: ... yield "foo!" >>> g = f() >>> next(g) >>> g.close() Traceback (most recent call last): ... RuntimeError: generator ignored GeneratorExit >>> g.close() Our ill-behaved code should be invoked during GC: >>> import sys, io >>> old, sys.stderr = sys.stderr, io.StringIO() >>> g = f() >>> next(g) >>> del g >>> "RuntimeError: generator ignored GeneratorExit" in sys.stderr.getvalue() True >>> sys.stderr = old And errors thrown during closing should propagate: >>> def f(): ... try: yield ... except GeneratorExit: ... raise TypeError("fie!") >>> g = f() >>> next(g) >>> g.close() Traceback (most recent call last): ... TypeError: fie! Ensure that various yield expression constructs make their enclosing function a generator: >>> def f(): x += yield >>> type(f()) <class 'generator'> >>> def f(): x = yield >>> type(f()) <class 'generator'> >>> def f(): lambda x=(yield): 1 >>> type(f()) <class 'generator'> >>> def f(): x=(i for i in (yield) if (yield)) >>> type(f()) <class 'generator'> >>> def f(d): d[(yield "a")] = d[(yield "b")] = 27 >>> data = [1,2] >>> g = f(data) >>> type(g) <class 'generator'> >>> g.send(None) 'a' >>> data [1, 2] >>> g.send(0) 'b' >>> data [27, 2] >>> try: g.send(1) ... except StopIteration: pass >>> data [27, 27] """ refleaks_tests = """ Prior to adding cycle-GC support to itertools.tee, this code would leak references. We add it to the standard suite so the routine refleak-tests would trigger if it starts being uncleanable again. >>> import itertools >>> def leak(): ... class gen: ... def __iter__(self): ... return self ... def __next__(self): ... return self.item ... g = gen() ... head, tail = itertools.tee(g) ... g.item = head ... return head >>> it = leak() Make sure to also test the involvement of the tee-internal teedataobject, which stores returned items. >>> item = next(it) This test leaked at one point due to generator finalization/destruction. It was copied from Lib/test/leakers/test_generator_cycle.py before the file was removed. >>> def leak(): ... def gen(): ... while True: ... yield g ... g = gen() >>> leak() This test isn't really generator related, but rather exception-in-cleanup related. The coroutine tests (above) just happen to cause an exception in the generator's __del__ (tp_del) method. We can also test for this explicitly, without generators. We do have to redirect stderr to avoid printing warnings and to doublecheck that we actually tested what we wanted to test. >>> import sys, io >>> old = sys.stderr >>> try: ... sys.stderr = io.StringIO() ... class Leaker: ... def __del__(self): ... def invoke(message): ... raise RuntimeError(message) ... invoke("test") ... ... l = Leaker() ... del l ... err = sys.stderr.getvalue().strip() ... "Exception ignored in" in err ... "RuntimeError: test" in err ... "Traceback" in err ... "in invoke" in err ... finally: ... sys.stderr = old True True True True These refleak tests should perhaps be in a testfile of their own, test_generators just happened to be the test that drew these out. """ __test__ = {"tut": tutorial_tests, "pep": pep_tests, "email": email_tests, "fun": fun_tests, "syntax": syntax_tests, "conjoin": conjoin_tests, "weakref": weakref_tests, "coroutine": coroutine_tests, "refleaks": refleaks_tests, } # Magic test name that regrtest.py invokes *after* importing this module. # This worms around a bootstrap problem. # Note that doctest and regrtest both look in sys.argv for a "-v" argument, # so this works as expected in both ways of running regrtest. def test_main(verbose=None): from test import support, test_generators support.run_unittest(__name__) support.run_doctest(test_generators, verbose) # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": test_main(1)
lgpl-3.0
[ 646, 9486, 199, 646, 984, 199, 646, 2882, 199, 646, 13852, 199, 199, 504, 511, 492, 2291, 421, 199, 533, 21789, 2072, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1943, 63, 470, 300, 1201, 8, 277, 304, 267, 327, 437, 4306, 2787, 883, 506, 522, 300, 7983, 701, 282, 4306, 1159, 4242, 2072, 14, 267, 347, 3805, 837, 288, 2222, 1832, 2787, 288, 862, 26, 355, 1995, 288, 3753, 26, 355, 2787, 275, 984, 423, 20912, 342, 398, 486, 275, 3805, 342, 267, 19865, 275, 13852, 14, 1121, 8, 71, 9, 267, 2163, 8, 71, 9, 267, 2150, 486, 267, 2291, 14, 9493, 63, 7112, 342, 267, 291, 14, 3436, 8, 17097, 1062, 488, 9, 267, 291, 14, 1815, 8, 1943, 9, 267, 2150, 2787, 267, 2291, 14, 9493, 63, 7112, 342, 339, 347, 511, 63, 1121, 7612, 8, 277, 304, 267, 327, 437, 4306, 15604, 315, 282, 2984, 7612, 7545, 4242, 1759, 15988, 14, 267, 2269, 63, 28737, 275, 9486, 14, 28737, 5873, 267, 4242, 1759, 275, 756, 267, 347, 3805, 837, 288, 2222, 1832, 4242, 1759, 288, 862, 26, 355, 486, 275, 1995, 355, 1995, 413, 288, 3753, 26, 355, 4242, 1759, 275, 715, 398, 486, 275, 3805, 342, 267, 2163, 8, 71, 9, 267, 486, 14, 2254, 8, 71, 9, 267, 291, 14, 15070, 8, 1274, 14, 32371, 8, 71, 395, 499, 9, 267, 291, 14, 3334, 8, 19231, 9, 267, 2150, 486, 267, 2291, 14, 9493, 63, 7112, 342, 267, 291, 14, 1815, 8, 19231, 9, 267, 291, 14, 629, 8, 9493, 14, 28737, 12, 2269, 63, 28737, 9, 421, 199, 23561, 63, 2219, 275, 408, 199, 15314, 1159, 862, 282, 3486, 4306, 26, 339, 1306, 347, 289, 837, 272, 2263, 259, 1995, 413, 272, 2263, 259, 1995, 499, 339, 1306, 367, 284, 315, 289, 837, 272, 2263, 258, 870, 8, 73, 9, 272, 413, 272, 499, 272, 1306, 486, 275, 289, 342, 272, 1306, 2163, 8, 71, 9, 272, 413, 272, 1306, 2163, 8, 71, 9, 272, 499, 199, 199, 2, 38, 26039, 2331, 314, 1284, 2, 20922, 314, 4306, 26, 339, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 489, 3814, 3886, 6626, 7166, 1004, 499, 12, 315, 486, 272, 10852, 199, 199, 2, 1107, 2, 2597, 20922, 314, 4306, 26, 339, 1306, 347, 289, 837, 272, 2263, 258, 1995, 413, 272, 2263, 258, 372, 272, 2263, 258, 1995, 499, 327, 7078, 13075, 272, 2263, 272, 1306, 486, 275, 289, 342, 272, 1306, 2163, 8, 71, 9, 272, 413, 272, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 489, 3814, 3886, 6626, 7166, 1004, 650, 12, 315, 289, 272, 10852, 272, 1306, 2163, 8, 71, 9, 327, 5403, 15248, 12, 883, 1133, 506, 14604, 68, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 272, 10852, 199, 199, 2, 3730, 10852, 2, 20922, 314, 4306, 4634, 26, 339, 1306, 347, 289, 837, 272, 2263, 258, 1995, 413, 272, 2263, 258, 746, 10852, 272, 2263, 258, 1995, 499, 327, 7078, 13075, 272, 2263, 272, 1306, 486, 275, 289, 342, 272, 1306, 2163, 8, 71, 9, 272, 413, 272, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 272, 10852, 272, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 272, 10852, 199, 199, 18335, 5907, 12, 2985, 787, 440, 8840, 7353, 26, 339, 1306, 347, 486, 17, 837, 272, 2263, 258, 862, 26, 272, 2263, 260, 372, 272, 2263, 258, 871, 26, 272, 2263, 260, 1995, 413, 272, 2263, 272, 1306, 769, 8, 71, 17, 1012, 272, 942, 339, 1306, 347, 486, 18, 837, 272, 2263, 258, 862, 26, 272, 2263, 260, 746, 10852, 272, 2263, 258, 871, 26, 272, 2263, 260, 1995, 5685, 272, 1306, 870, 8, 513, 8, 71, 18, 4059, 272, 359, 2260, 61, 199, 199, 2765, 1443, 506, 6296, 1359, 1044, 737, 1642, 26, 339, 1306, 347, 486, 19, 837, 272, 2263, 258, 862, 26, 272, 2263, 260, 372, 272, 2263, 258, 3753, 26, 272, 2263, 260, 1995, 413, 272, 2263, 272, 1306, 769, 8, 71, 19, 1012, 272, 359, 17, 61, 199, 199, 15314, 1159, 1218, 376, 18034, 1425, 342, 805, 6366, 465, 282, 4306, 26, 339, 1306, 347, 612, 1842, 8, 78, 304, 272, 2263, 258, 367, 284, 315, 1425, 8, 78, 304, 272, 2263, 260, 1995, 284, 272, 2263, 272, 1306, 769, 8, 89, 1842, 8, 21, 430, 272, 359, 16, 12, 413, 12, 499, 12, 650, 12, 841, 61, 199, 199, 3139, 2750, 3544, 372, 370, 314, 4750, 8058, 8025, 26, 339, 1306, 347, 14875, 837, 272, 2263, 258, 519, 275, 612, 1842, 8, 21, 9, 272, 2263, 258, 870, 480, 9986, 401, 2163, 8, 82, 430, 272, 2263, 258, 372, 519, 272, 2263, 272, 1306, 347, 8025, 837, 272, 2263, 258, 519, 275, 14875, 342, 272, 2263, 258, 367, 284, 315, 519, 26, 272, 2263, 3777, 870, 480, 11219, 401, 284, 9, 272, 2263, 272, 1306, 8025, 342, 272, 14875, 378, 272, 8025, 413, 272, 8025, 499, 272, 8025, 650, 272, 8025, 841, 199, 199, 3139, 2750, 883, 1240, 1163, 16952, 26, 339, 1306, 347, 1315, 1842, 8, 78, 304, 272, 2263, 258, 367, 284, 315, 612, 1842, 8, 78, 304, 272, 2263, 260, 1995, 284, 272, 2263, 272, 1306, 769, 8, 90, 1842, 8, 21, 430, 272, 359, 16, 12, 413, 12, 499, 12, 650, 12, 841, 61, 199, 199, 624, 199, 199, 3, 710, 7251, 687, 13663, 5450, 14, 199, 199, 12636, 63, 2219, 275, 408, 199, 199, 26235, 26, 221, 23771, 339, 32491, 414, 26, 221, 437, 4306, 3913, 506, 14604, 68, 1830, 652, 365, 6633, 5636, 272, 3879, 26, 339, 1306, 347, 486, 837, 272, 2263, 258, 284, 275, 2163, 8, 278, 9, 272, 2263, 258, 1995, 284, 272, 1306, 562, 275, 486, 342, 272, 1306 ]
[ 9486, 199, 646, 984, 199, 646, 2882, 199, 646, 13852, 199, 199, 504, 511, 492, 2291, 421, 199, 533, 21789, 2072, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 1943, 63, 470, 300, 1201, 8, 277, 304, 267, 327, 437, 4306, 2787, 883, 506, 522, 300, 7983, 701, 282, 4306, 1159, 4242, 2072, 14, 267, 347, 3805, 837, 288, 2222, 1832, 2787, 288, 862, 26, 355, 1995, 288, 3753, 26, 355, 2787, 275, 984, 423, 20912, 342, 398, 486, 275, 3805, 342, 267, 19865, 275, 13852, 14, 1121, 8, 71, 9, 267, 2163, 8, 71, 9, 267, 2150, 486, 267, 2291, 14, 9493, 63, 7112, 342, 267, 291, 14, 3436, 8, 17097, 1062, 488, 9, 267, 291, 14, 1815, 8, 1943, 9, 267, 2150, 2787, 267, 2291, 14, 9493, 63, 7112, 342, 339, 347, 511, 63, 1121, 7612, 8, 277, 304, 267, 327, 437, 4306, 15604, 315, 282, 2984, 7612, 7545, 4242, 1759, 15988, 14, 267, 2269, 63, 28737, 275, 9486, 14, 28737, 5873, 267, 4242, 1759, 275, 756, 267, 347, 3805, 837, 288, 2222, 1832, 4242, 1759, 288, 862, 26, 355, 486, 275, 1995, 355, 1995, 413, 288, 3753, 26, 355, 4242, 1759, 275, 715, 398, 486, 275, 3805, 342, 267, 2163, 8, 71, 9, 267, 486, 14, 2254, 8, 71, 9, 267, 291, 14, 15070, 8, 1274, 14, 32371, 8, 71, 395, 499, 9, 267, 291, 14, 3334, 8, 19231, 9, 267, 2150, 486, 267, 2291, 14, 9493, 63, 7112, 342, 267, 291, 14, 1815, 8, 19231, 9, 267, 291, 14, 629, 8, 9493, 14, 28737, 12, 2269, 63, 28737, 9, 421, 199, 23561, 63, 2219, 275, 408, 199, 15314, 1159, 862, 282, 3486, 4306, 26, 339, 1306, 347, 289, 837, 272, 2263, 259, 1995, 413, 272, 2263, 259, 1995, 499, 339, 1306, 367, 284, 315, 289, 837, 272, 2263, 258, 870, 8, 73, 9, 272, 413, 272, 499, 272, 1306, 486, 275, 289, 342, 272, 1306, 2163, 8, 71, 9, 272, 413, 272, 1306, 2163, 8, 71, 9, 272, 499, 199, 199, 2, 38, 26039, 2331, 314, 1284, 2, 20922, 314, 4306, 26, 339, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 489, 3814, 3886, 6626, 7166, 1004, 499, 12, 315, 486, 272, 10852, 199, 199, 2, 1107, 2, 2597, 20922, 314, 4306, 26, 339, 1306, 347, 289, 837, 272, 2263, 258, 1995, 413, 272, 2263, 258, 372, 272, 2263, 258, 1995, 499, 327, 7078, 13075, 272, 2263, 272, 1306, 486, 275, 289, 342, 272, 1306, 2163, 8, 71, 9, 272, 413, 272, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 489, 3814, 3886, 6626, 7166, 1004, 650, 12, 315, 289, 272, 10852, 272, 1306, 2163, 8, 71, 9, 327, 5403, 15248, 12, 883, 1133, 506, 14604, 68, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 272, 10852, 199, 199, 2, 3730, 10852, 2, 20922, 314, 4306, 4634, 26, 339, 1306, 347, 289, 837, 272, 2263, 258, 1995, 413, 272, 2263, 258, 746, 10852, 272, 2263, 258, 1995, 499, 327, 7078, 13075, 272, 2263, 272, 1306, 486, 275, 289, 342, 272, 1306, 2163, 8, 71, 9, 272, 413, 272, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 272, 10852, 272, 1306, 2163, 8, 71, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 489, 3814, 3886, 6626, 7166, 1004, 413, 12, 315, 5805, 272, 10852, 199, 199, 18335, 5907, 12, 2985, 787, 440, 8840, 7353, 26, 339, 1306, 347, 486, 17, 837, 272, 2263, 258, 862, 26, 272, 2263, 260, 372, 272, 2263, 258, 871, 26, 272, 2263, 260, 1995, 413, 272, 2263, 272, 1306, 769, 8, 71, 17, 1012, 272, 942, 339, 1306, 347, 486, 18, 837, 272, 2263, 258, 862, 26, 272, 2263, 260, 746, 10852, 272, 2263, 258, 871, 26, 272, 2263, 260, 1995, 5685, 272, 1306, 870, 8, 513, 8, 71, 18, 4059, 272, 359, 2260, 61, 199, 199, 2765, 1443, 506, 6296, 1359, 1044, 737, 1642, 26, 339, 1306, 347, 486, 19, 837, 272, 2263, 258, 862, 26, 272, 2263, 260, 372, 272, 2263, 258, 3753, 26, 272, 2263, 260, 1995, 413, 272, 2263, 272, 1306, 769, 8, 71, 19, 1012, 272, 359, 17, 61, 199, 199, 15314, 1159, 1218, 376, 18034, 1425, 342, 805, 6366, 465, 282, 4306, 26, 339, 1306, 347, 612, 1842, 8, 78, 304, 272, 2263, 258, 367, 284, 315, 1425, 8, 78, 304, 272, 2263, 260, 1995, 284, 272, 2263, 272, 1306, 769, 8, 89, 1842, 8, 21, 430, 272, 359, 16, 12, 413, 12, 499, 12, 650, 12, 841, 61, 199, 199, 3139, 2750, 3544, 372, 370, 314, 4750, 8058, 8025, 26, 339, 1306, 347, 14875, 837, 272, 2263, 258, 519, 275, 612, 1842, 8, 21, 9, 272, 2263, 258, 870, 480, 9986, 401, 2163, 8, 82, 430, 272, 2263, 258, 372, 519, 272, 2263, 272, 1306, 347, 8025, 837, 272, 2263, 258, 519, 275, 14875, 342, 272, 2263, 258, 367, 284, 315, 519, 26, 272, 2263, 3777, 870, 480, 11219, 401, 284, 9, 272, 2263, 272, 1306, 8025, 342, 272, 14875, 378, 272, 8025, 413, 272, 8025, 499, 272, 8025, 650, 272, 8025, 841, 199, 199, 3139, 2750, 883, 1240, 1163, 16952, 26, 339, 1306, 347, 1315, 1842, 8, 78, 304, 272, 2263, 258, 367, 284, 315, 612, 1842, 8, 78, 304, 272, 2263, 260, 1995, 284, 272, 2263, 272, 1306, 769, 8, 90, 1842, 8, 21, 430, 272, 359, 16, 12, 413, 12, 499, 12, 650, 12, 841, 61, 199, 199, 624, 199, 199, 3, 710, 7251, 687, 13663, 5450, 14, 199, 199, 12636, 63, 2219, 275, 408, 199, 199, 26235, 26, 221, 23771, 339, 32491, 414, 26, 221, 437, 4306, 3913, 506, 14604, 68, 1830, 652, 365, 6633, 5636, 272, 3879, 26, 339, 1306, 347, 486, 837, 272, 2263, 258, 284, 275, 2163, 8, 278, 9, 272, 2263, 258, 1995, 284, 272, 1306, 562, 275, 486, 342, 272, 1306, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
genedna/containerops
component/python/analysis/memory_profiler/memory_profiler.py
5
42427
"""Profile the memory usage of a Python program""" # .. we'll use this to pass it to the child script .. _CLEAN_GLOBALS = globals().copy() __version__ = '0.47' _CMD_USAGE = "python -m memory_profiler script_file.py" import time import sys import os import pdb import warnings import linecache import inspect import subprocess import logging import traceback from signal import SIGKILL import json import yaml # TODO: provide alternative when multiprocessing is not available try: from multiprocessing import Process, Pipe except ImportError: from multiprocessing.dummy import Process, Pipe try: from IPython.core.magic import Magics, line_cell_magic, magics_class except ImportError: # ipython_version < '0.13' Magics = object line_cell_magic = lambda func: func magics_class = lambda cls: cls PY2 = sys.version_info[0] == 2 _TWO_20 = float(2 ** 20) if PY2: import __builtin__ as builtins else: import builtins def unicode(x, *args): return str(x) # .. get available packages .. try: import psutil has_psutil = True except ImportError: has_psutil = False try: import tracemalloc has_tracemalloc = True except ImportError: has_tracemalloc = False class MemitResult(object): """memit magic run details. Object based on IPython's TimeitResult """ def __init__(self, mem_usage, baseline, repeat, timeout, interval, include_children): self.mem_usage = mem_usage self.baseline = baseline self.repeat = repeat self.timeout = timeout self.interval = interval self.include_children = include_children def __str__(self): max_mem = max(self.mem_usage) inc = max_mem - self.baseline return 'peak memory: %.02f MiB, increment: %.02f MiB' % (max_mem, inc) def _repr_pretty_(self, p, cycle): msg = str(self) p.text(u'<MemitResult : ' + msg + u'>') def _get_child_memory(process, meminfo_attr=None): """ Returns a generator that yields memory for all child processes. """ if not has_psutil: raise NotImplementedError(( "The psutil module is required to monitor the " "memory usage of child processes." )) # Convert a pid to a process if isinstance(process, int): if process == -1: process = os.getpid() process = psutil.Process(process) if not meminfo_attr: # Use the psutil 2.0 attr if the older version isn't passed in. meminfo_attr = 'memory_info' if hasattr(process, 'memory_info') else 'get_memory_info' # Select the psutil function get the children similar to how we selected # the memory_info attr (a change from excepting the AttributeError). children_attr = 'children' if hasattr(process, 'children') else 'get_children' # Loop over the child processes and yield their memory try: for child in getattr(process, children_attr)(recursive=True): yield getattr(child, meminfo_attr)()[0] / _TWO_20 except psutil.NoSuchProcess: # https://github.com/fabianp/memory_profiler/issues/71 yield 0.0 def _get_memory(pid, backend, timestamps=False, include_children=False, filename=None): # .. low function to get memory consumption .. if pid == -1: pid = os.getpid() def tracemalloc_tool(): # .. cross-platform but but requires Python 3.4 or higher .. stat = next(filter(lambda item: str(item).startswith(filename), tracemalloc.take_snapshot().statistics('filename'))) mem = stat.size / _TWO_20 if timestamps: return mem, time.time() else: return mem def ps_util_tool(): # .. cross-platform but but requires psutil .. process = psutil.Process(pid) try: # avoid useing get_memory_info since it does not exists # in psutil > 2.0 and accessing it will cause exception. meminfo_attr = 'memory_info' if hasattr(process, 'memory_info') \ else 'get_memory_info' mem = getattr(process, meminfo_attr)()[0] / _TWO_20 if include_children: mem += sum(_get_child_memory(process, meminfo_attr)) if timestamps: return mem, time.time() else: return mem except psutil.AccessDenied: pass # continue and try to get this from ps def posix_tool(): # .. scary stuff .. if include_children: raise NotImplementedError(( "The psutil module is required to monitor the " "memory usage of child processes." )) warnings.warn("psutil module not found. memory_profiler will be slow") # .. # .. memory usage in MiB .. # .. this should work on both Mac and Linux .. # .. subprocess.check_output appeared in 2.7, using Popen .. # .. for backwards compatibility .. out = subprocess.Popen(['ps', 'v', '-p', str(pid)], stdout=subprocess.PIPE ).communicate()[0].split(b'\n') try: vsz_index = out[0].split().index(b'RSS') mem = float(out[1].split()[vsz_index]) / 1024 if timestamps: return mem, time.time() else: return mem except: if timestamps: return -1, time.time() else: return -1 if backend == 'tracemalloc' and \ (filename is None or filename == '<unknown>'): raise RuntimeError( 'There is no access to source file of the profiled function' ) tools = {'tracemalloc': tracemalloc_tool, 'psutil': ps_util_tool, 'posix': posix_tool} return tools[backend]() class MemTimer(Process): """ Fetch memory consumption from over a time interval """ def __init__(self, monitor_pid, interval, pipe, backend, max_usage=False, *args, **kw): self.monitor_pid = monitor_pid self.interval = interval self.pipe = pipe self.cont = True self.backend = backend self.max_usage = max_usage self.n_measurements = 1 self.timestamps = kw.pop("timestamps", False) self.include_children = kw.pop("include_children", False) # get baseline memory usage self.mem_usage = [ _get_memory(self.monitor_pid, self.backend, timestamps=self.timestamps, include_children=self.include_children)] super(MemTimer, self).__init__(*args, **kw) def run(self): self.pipe.send(0) # we're ready stop = False while True: cur_mem = _get_memory( self.monitor_pid, self.backend, timestamps=self.timestamps, include_children=self.include_children,) if not self.max_usage: self.mem_usage.append(cur_mem) else: self.mem_usage[0] = max(cur_mem, self.mem_usage[0]) self.n_measurements += 1 if stop: break stop = self.pipe.poll(self.interval) # do one more iteration self.pipe.send(self.mem_usage) self.pipe.send(self.n_measurements) def memory_usage(proc=-1, interval=.1, timeout=None, timestamps=False, include_children=False, multiprocess=False, max_usage=False, retval=False, stream=None, backend=None): """ Return the memory usage of a process or piece of code Parameters ---------- proc : {int, string, tuple, subprocess.Popen}, optional The process to monitor. Can be given by an integer/string representing a PID, by a Popen object or by a tuple representing a Python function. The tuple contains three values (f, args, kw) and specifies to run the function f(*args, **kw). Set to -1 (default) for current process. interval : float, optional Interval at which measurements are collected. timeout : float, optional Maximum amount of time (in seconds) to wait before returning. max_usage : bool, optional Only return the maximum memory usage (default False) retval : bool, optional For profiling python functions. Save the return value of the profiled function. Return value of memory_usage becomes a tuple: (mem_usage, retval) timestamps : bool, optional if True, timestamps of memory usage measurement are collected as well. include_children : bool, optional if True, sum the memory of all forked processes as well multiprocess : bool, optional if True, track the memory usage of all forked processes. stream : File if stream is a File opened with write access, then results are written to this file instead of stored in memory and returned at the end of the subprocess. Useful for long-running processes. Implies timestamps=True. Returns ------- mem_usage : list of floating-point values memory usage, in MiB. It's length is always < timeout / interval if max_usage is given, returns the two elements maximum memory and number of measurements effectuated ret : return value of the profiled function Only returned if retval is set to True """ backend = choose_backend(backend) if stream is not None: timestamps = True if not max_usage: ret = [] else: ret = -1 if timeout is not None: max_iter = int(timeout / interval) elif isinstance(proc, int): # external process and no timeout max_iter = 1 else: # for a Python function wait until it finishes max_iter = float('inf') if callable(proc): proc = (proc, (), {}) if isinstance(proc, (list, tuple)): if len(proc) == 1: f, args, kw = (proc[0], (), {}) elif len(proc) == 2: f, args, kw = (proc[0], proc[1], {}) elif len(proc) == 3: f, args, kw = (proc[0], proc[1], proc[2]) else: raise ValueError while True: child_conn, parent_conn = Pipe() # this will store MemTimer's results p = MemTimer(os.getpid(), interval, child_conn, backend, timestamps=timestamps, max_usage=max_usage, include_children=include_children) p.start() parent_conn.recv() # wait until we start getting memory # When there is an exception in the "proc" - the (spawned) monitoring processes don't get killed. # Therefore, the whole process hangs indefinitely. Here, we are ensuring that the process gets killed! try: returned = f(*args, **kw) parent_conn.send(0) # finish timing ret = parent_conn.recv() n_measurements = parent_conn.recv() if retval: ret = ret, returned except Exception: if has_psutil: parent = psutil.Process(os.getpid()) for child in parent.children(recursive=True): os.kill(child.pid, SIGKILL) p.join(0) raise p.join(5 * interval) if n_measurements > 4 or interval < 1e-6: break interval /= 10. elif isinstance(proc, subprocess.Popen): # external process, launched from Python line_count = 0 while True: if not max_usage: mem_usage = _get_memory( proc.pid, backend, timestamps=timestamps, include_children=include_children) if stream is not None: stream.write("MEM {0:.6f} {1:.4f}\n".format(*mem_usage)) # Write children to the stream file if multiprocess: for idx, chldmem in enumerate(_get_child_memory(proc.pid)): stream.write("CHLD {0} {1:.6f} {2:.4f}\n".format(idx, chldmem, time.time())) else: # Create a nested list with the child memory if multiprocess: mem_usage = [mem_usage] for chldmem in _get_child_memory(proc.pid): mem_usage.append(chldmem) # Append the memory usage to the return value ret.append(mem_usage) else: ret = max(ret, _get_memory( proc.pid, backend, include_children=include_children)) time.sleep(interval) line_count += 1 # flush every 50 lines. Make 'tail -f' usable on profile file if line_count > 50: line_count = 0 if stream is not None: stream.flush() if timeout is not None: max_iter -= 1 if max_iter == 0: break if proc.poll() is not None: break else: # external process if max_iter == -1: max_iter = 1 counter = 0 while counter < max_iter: counter += 1 if not max_usage: mem_usage = _get_memory( proc, backend, timestamps=timestamps, include_children=include_children) if stream is not None: stream.write("MEM {0:.6f} {1:.4f}\n".format(*mem_usage)) # Write children to the stream file if multiprocess: for idx, chldmem in enumerate(_get_child_memory(proc.pid)): stream.write("CHLD {0} {1:.6f} {2:.4f}\n".format(idx, chldmem, time.time())) else: # Create a nested list with the child memory if multiprocess: mem_usage = [mem_usage] for chldmem in _get_child_memory(proc.pid): mem_usage.append(chldmem) # Append the memory usage to the return value ret.append(mem_usage) else: ret = max([ret, _get_memory(proc, backend, include_children=include_children) ]) time.sleep(interval) # Flush every 50 lines. if counter % 50 == 0 and stream is not None: stream.flush() if stream: return None return ret # .. # .. utility functions for line-by-line .. def _find_script(script_name): """ Find the script. If the input is not a file, then $PATH will be searched. """ if os.path.isfile(script_name): return script_name path = os.getenv('PATH', os.defpath).split(os.pathsep) for folder in path: if not folder: continue fn = os.path.join(folder, script_name) if os.path.isfile(fn): return fn sys.stderr.write('Could not find script {0}\n'.format(script_name)) raise SystemExit(1) class _TimeStamperCM(object): """Time-stamping context manager.""" def __init__(self, timestamps, filename, backend): self.timestamps = timestamps self.filename = filename self.backend = backend def __enter__(self): self.timestamps.append( _get_memory(os.getpid(), self.backend, timestamps=True, filename=self.filename)) def __exit__(self, *args): self.timestamps.append( _get_memory(os.getpid(), self.backend, timestamps=True, filename=self.filename)) class TimeStamper: """ A profiler that just records start and end execution times for any decorated function. """ def __init__(self, backend): self.functions = {} self.backend = backend def __call__(self, func=None, precision=None): if func is not None: if not callable(func): raise ValueError("Value must be callable") self.add_function(func) f = self.wrap_function(func) f.__module__ = func.__module__ f.__name__ = func.__name__ f.__doc__ = func.__doc__ f.__dict__.update(getattr(func, '__dict__', {})) return f else: def inner_partial(f): return self.__call__(f, precision=precision) return inner_partial def timestamp(self, name="<block>"): """Returns a context manager for timestamping a block of code.""" # Make a fake function func = lambda x: x func.__module__ = "" func.__name__ = name self.add_function(func) timestamps = [] self.functions[func].append(timestamps) # A new object is required each time, since there can be several # nested context managers. try: filename = inspect.getsourcefile(func) except TypeError: filename = '<unknown>' return _TimeStamperCM(timestamps, filename, self.backend) def add_function(self, func): if func not in self.functions: self.functions[func] = [] def wrap_function(self, func): """ Wrap a function to timestamp it. """ def f(*args, **kwds): # Start time try: filename = inspect.getsourcefile(func) except TypeError: filename = '<unknown>' timestamps = [ _get_memory(os.getpid(), self.backend, timestamps=True, filename=filename)] self.functions[func].append(timestamps) try: return func(*args, **kwds) finally: # end time timestamps.append(_get_memory(os.getpid(), self.backend, timestamps=True, filename=filename)) return f def show_results(self, stream=None): if stream is None: stream = sys.stdout for func, timestamps in self.functions.items(): function_name = "%s.%s" % (func.__module__, func.__name__) for ts in timestamps: stream.write("FUNC %s %.4f %.4f %.4f %.4f\n" % ( (function_name,) + ts[0] + ts[1])) class CodeMap(dict): def __init__(self, include_children, backend): self.include_children = include_children self._toplevel = [] self.backend = backend def add(self, code, toplevel_code=None): if code in self: return if toplevel_code is None: filename = code.co_filename if filename.endswith((".pyc", ".pyo")): filename = filename[:-1] if not os.path.exists(filename): print('ERROR: Could not find file ' + filename) if filename.startswith(("ipython-input", "<ipython-input")): print( "NOTE: %mprun can only be used on functions defined in" " physical files, and not in the IPython environment.") return toplevel_code = code (sub_lines, start_line) = inspect.getsourcelines(code) linenos = range(start_line, start_line + len(sub_lines)) self._toplevel.append((filename, code, linenos)) self[code] = {} else: self[code] = self[toplevel_code] for subcode in filter(inspect.iscode, code.co_consts): self.add(subcode, toplevel_code=toplevel_code) def trace(self, code, lineno): memory = _get_memory(-1, self.backend, include_children=self.include_children, filename=code.co_filename) # if there is already a measurement for that line get the max previous_memory = self[code].get(lineno, 0) self[code][lineno] = max(memory, previous_memory) def items(self): """Iterate on the toplevel code blocks.""" for (filename, code, linenos) in self._toplevel: measures = self[code] if not measures: continue # skip if no measurement line_iterator = ((line, measures.get(line)) for line in linenos) yield (filename, line_iterator) class LineProfiler(object): """ A profiler that records the amount of memory for each line """ def __init__(self, **kw): include_children = kw.get('include_children', False) backend = kw.get('backend', 'psutil') self.code_map = CodeMap( include_children=include_children, backend=backend) self.enable_count = 0 self.max_mem = kw.get('max_mem', None) self.prevlines = [] self.backend = choose_backend(kw.get('backend', None)) def __call__(self, func=None, precision=1): if func is not None: self.add_function(func) f = self.wrap_function(func) f.__module__ = func.__module__ f.__name__ = func.__name__ f.__doc__ = func.__doc__ f.__dict__.update(getattr(func, '__dict__', {})) return f else: def inner_partial(f): return self.__call__(f, precision=precision) return inner_partial def add_function(self, func): """ Record line profiling information for the given Python function. """ try: # func_code does not exist in Python3 code = func.__code__ except AttributeError: warnings.warn("Could not extract a code object for the object %r" % func) else: self.code_map.add(code) def wrap_function(self, func): """ Wrap a function to profile it. """ def f(*args, **kwds): self.enable_by_count() try: return func(*args, **kwds) finally: self.disable_by_count() return f def runctx(self, cmd, globals, locals): """ Profile a single executable statement in the given namespaces. """ self.enable_by_count() try: exec(cmd, globals, locals) finally: self.disable_by_count() return self def enable_by_count(self): """ Enable the profiler if it hasn't been enabled before. """ if self.enable_count == 0: self.enable() self.enable_count += 1 def disable_by_count(self): """ Disable the profiler if the number of disable requests matches the number of enable requests. """ if self.enable_count > 0: self.enable_count -= 1 if self.enable_count == 0: self.disable() def trace_memory_usage(self, frame, event, arg): """Callback for sys.settrace""" if frame.f_code in self.code_map: if event == 'call': # "call" event just saves the lineno but not the memory self.prevlines.append(frame.f_lineno) elif event == 'line': self.code_map.trace(frame.f_code, self.prevlines[-1]) self.prevlines[-1] = frame.f_lineno elif event == 'return': self.code_map.trace(frame.f_code, self.prevlines.pop()) if self._original_trace_function is not None: self._original_trace_function(frame, event, arg) return self.trace_memory_usage def trace_max_mem(self, frame, event, arg): # run into PDB as soon as memory is higher than MAX_MEM if event in ('line', 'return') and frame.f_code in self.code_map: c = _get_memory(-1, self.backend, filename=frame.f_code.co_filename) if c >= self.max_mem: t = ('Current memory {0:.2f} MiB exceeded the ' 'maximum of {1:.2f} MiB\n'.format(c, self.max_mem)) sys.stdout.write(t) sys.stdout.write('Stepping into the debugger \n') frame.f_lineno -= 2 p = pdb.Pdb() p.quitting = False p.stopframe = frame p.returnframe = None p.stoplineno = frame.f_lineno - 3 p.botframe = None return p.trace_dispatch if self._original_trace_function is not None: (self._original_trace_function)(frame, event, arg) return self.trace_max_mem def __enter__(self): self.enable_by_count() def __exit__(self, exc_type, exc_val, exc_tb): self.disable_by_count() def enable(self): self._original_trace_function = sys.gettrace() if self.max_mem is not None: sys.settrace(self.trace_max_mem) else: sys.settrace(self.trace_memory_usage) def disable(self): sys.settrace(self._original_trace_function) def json_results(prof, precision=1): ret = [] for (filename, lines) in prof.code_map.items(): st = {'filename': filename, 'lines': []} all_lines = linecache.getlines(filename) mem_old = None float_format = u'{0}.{1}f'.format(precision + 4, precision) template_mem = u'{0:' + float_format + '} MiB' for (lineno, mem) in lines: if mem: inc = (mem - mem_old) if mem_old else 0 mem_old = mem mem = template_mem.format(mem) inc = template_mem.format(inc) else: mem = u'' inc = u'' st['lines'].append({ 'Line #': lineno, 'Mem usage': mem, 'Increment': inc, 'Line Contents': all_lines[lineno - 1] }) ret.append(st) return ret def _func_exec(stmt, ns): # helper for magic_memit, just a function proxy for the exec # statement exec(stmt, ns) @magics_class class MemoryProfilerMagics(Magics): # A lprun-style %mprun magic for IPython. @line_cell_magic def mprun(self, parameter_s='', cell=None): """ Execute a statement under the line-by-line memory profiler from the memory_profiler module. Usage, in line mode: %mprun -f func1 -f func2 <statement> Usage, in cell mode: %%mprun -f func1 -f func2 [statement] code... code... In cell mode, the additional code lines are appended to the (possibly empty) statement in the first line. Cell mode allows you to easily profile multiline blocks without having to put them in a separate function. The given statement (which doesn't require quote marks) is run via the LineProfiler. Profiling is enabled for the functions specified by the -f options. The statistics will be shown side-by-side with the code through the pager once the statement has completed. Options: -f <function>: LineProfiler only profiles functions and methods it is told to profile. This option tells the profiler about these functions. Multiple -f options may be used. The argument may be any expression that gives a Python function or method object. However, one must be careful to avoid spaces that may confuse the option parser. Additionally, functions defined in the interpreter at the In[] prompt or via %run currently cannot be displayed. Write these functions out to a separate file and import them. One or more -f options are required to get any useful results. -T <filename>: dump the text-formatted statistics with the code side-by-side out to a text file. -r: return the LineProfiler object after it has completed profiling. -c: If present, add the memory usage of any children process to the report. """ from io import StringIO from memory_profiler import show_results, LineProfiler # Local imports to avoid hard dependency. from distutils.version import LooseVersion import IPython ipython_version = LooseVersion(IPython.__version__) if ipython_version < '0.11': from IPython.genutils import page from IPython.ipstruct import Struct from IPython.ipapi import UsageError else: from IPython.core.page import page from IPython.utils.ipstruct import Struct from IPython.core.error import UsageError # Escape quote markers. opts_def = Struct(T=[''], f=[]) parameter_s = parameter_s.replace('"', r'\"').replace("'", r"\'") opts, arg_str = self.parse_options(parameter_s, 'rf:T:c', list_all=True) opts.merge(opts_def) global_ns = self.shell.user_global_ns local_ns = self.shell.user_ns if cell is not None: arg_str += '\n' + cell # Get the requested functions. funcs = [] for name in opts.f: try: funcs.append(eval(name, global_ns, local_ns)) except Exception as e: raise UsageError('Could not find function %r.\n%s: %s' % (name, e.__class__.__name__, e)) include_children = 'c' in opts profile = LineProfiler(include_children=include_children) for func in funcs: profile(func) # Add the profiler to the builtins for @profile. if 'profile' in builtins.__dict__: had_profile = True old_profile = builtins.__dict__['profile'] else: had_profile = False old_profile = None builtins.__dict__['profile'] = profile try: profile.runctx(arg_str, global_ns, local_ns) message = '' except SystemExit: message = "*** SystemExit exception caught in code being profiled." except KeyboardInterrupt: message = ("*** KeyboardInterrupt exception caught in code being " "profiled.") finally: if had_profile: builtins.__dict__['profile'] = old_profile # Trap text output. stdout_trap = StringIO() show_results(profile, stdout_trap) output = stdout_trap.getvalue() output = output.rstrip() if ipython_version < '0.11': page(output, screen_lines=self.shell.rc.screen_length) else: page(output) print(message, ) text_file = opts.T[0] if text_file: with open(text_file, 'w') as pfile: pfile.write(output) print('\n*** Profile printout saved to text file %s. %s' % ( text_file, message)) return_value = None if 'r' in opts: return_value = profile return return_value # a timeit-style %memit magic for IPython @line_cell_magic def memit(self, line='', cell=None): """Measure memory usage of a Python statement Usage, in line mode: %memit [-r<R>t<T>i<I>] statement Usage, in cell mode: %%memit [-r<R>t<T>i<I>] setup_code code... code... This function can be used both as a line and cell magic: - In line mode you can measure a single-line statement (though multiple ones can be chained with using semicolons). - In cell mode, the statement in the first line is used as setup code (executed but not measured) and the body of the cell is measured. The cell body has access to any variables created in the setup code. Options: -r<R>: repeat the loop iteration <R> times and take the best result. Default: 1 -t<T>: timeout after <T> seconds. Default: None -i<I>: Get time information at an interval of I times per second. Defaults to 0.1 so that there is ten measurements per second. -c: If present, add the memory usage of any children process to the report. -o: If present, return a object containing memit run details -q: If present, be quiet and do not output a result. Examples -------- :: In [1]: %memit range(10000) peak memory: 21.42 MiB, increment: 0.41 MiB In [2]: %memit range(1000000) peak memory: 52.10 MiB, increment: 31.08 MiB In [3]: %%memit l=range(1000000) ...: len(l) ...: peak memory: 52.14 MiB, increment: 0.08 MiB """ from memory_profiler import memory_usage, _func_exec opts, stmt = self.parse_options(line, 'r:t:i:coq', posix=False, strict=False) if cell is None: setup = 'pass' else: setup = stmt stmt = cell repeat = int(getattr(opts, 'r', 1)) if repeat < 1: repeat == 1 timeout = int(getattr(opts, 't', 0)) if timeout <= 0: timeout = None interval = float(getattr(opts, 'i', 0.1)) include_children = 'c' in opts return_result = 'o' in opts quiet = 'q' in opts # I've noticed we get less noisier measurements if we run # a garbage collection first import gc gc.collect() _func_exec(setup, self.shell.user_ns) mem_usage = [] counter = 0 baseline = memory_usage()[0] while counter < repeat: counter += 1 tmp = memory_usage((_func_exec, (stmt, self.shell.user_ns)), timeout=timeout, interval=interval, max_usage=True, include_children=include_children) mem_usage.append(tmp[0]) result = MemitResult(mem_usage, baseline, repeat, timeout, interval, include_children) if not quiet: if mem_usage: print(result) else: print('ERROR: could not read memory usage, try with a ' 'lower interval or more iterations') if return_result: return result @classmethod def register_magics(cls, ip): from distutils.version import LooseVersion import IPython ipython_version = LooseVersion(IPython.__version__) if ipython_version < '0.13': try: _register_magic = ip.define_magic except AttributeError: # ipython 0.10 _register_magic = ip.expose_magic _register_magic('mprun', cls.mprun.__func__) _register_magic('memit', cls.memit.__func__) else: ip.register_magics(cls) # commenting out due to failures with some versions of IPython # see https://github.com/fabianp/memory_profiler/issues/106 # # Ensuring old interface of magics expose for IPython 0.10 # magic_mprun = MemoryProfilerMagics().mprun.__func__ # magic_memit = MemoryProfilerMagics().memit.__func__ def load_ipython_extension(ip): """This is called to load the module as an IPython extension.""" MemoryProfilerMagics.register_magics(ip) def profile(func=None, stream=None, precision=1, backend='psutil'): """ Decorator that will run the function and print a line-by-line profile """ backend = choose_backend(backend) if backend == 'tracemalloc' and has_tracemalloc: if not tracemalloc.is_tracing(): tracemalloc.start() if func is not None: def wrapper(*args, **kwargs): prof = LineProfiler(backend=backend) val = prof(func)(*args, **kwargs) show_results(prof, stream=stream, precision=precision) return val return wrapper else: def inner_wrapper(f): return profile(f, stream=stream, precision=precision, backend=backend) return inner_wrapper def choose_backend(new_backend=None): """ Function that tries to setup backend, chosen by user, and if failed, setup one of the allowable backends """ _backend = 'no_backend' all_backends = [ ('psutil', has_psutil), ('posix', os.name == 'posix'), ('tracemalloc', has_tracemalloc), ('no_backend', True) ] backends_indices = dict((b[0], i) for i, b in enumerate(all_backends)) if new_backend is not None: all_backends.insert(0, all_backends.pop(backends_indices[new_backend])) for n_backend, is_available in all_backends: if is_available: _backend = n_backend break if _backend == 'no_backend': raise NotImplementedError( 'Tracemalloc or psutil module is required for non-unix ' 'platforms') if _backend != new_backend and new_backend is not None: warnings.warn('{0} can not be used, {1} used instead'.format( new_backend, _backend)) return _backend # Insert in the built-ins to have profile # globally defined (global variables is not enough # for all cases, e.g. a script that imports another # script where @profile is used) if PY2: def exec_with_profiler(filename, profiler, backend): builtins.__dict__['profile'] = profiler ns = dict(_CLEAN_GLOBALS, profile=profiler) choose_backend(backend) execfile(filename, ns, ns) else: def exec_with_profiler(filename, profiler, backend): _backend = choose_backend(backend) if _backend == 'tracemalloc' and has_tracemalloc: tracemalloc.start() builtins.__dict__['profile'] = profiler # shadow the profile decorator defined above ns = dict(_CLEAN_GLOBALS, profile=profiler) try: with open(filename) as f: exec(compile(f.read(), filename, 'exec'), ns, ns) finally: if has_tracemalloc and tracemalloc.is_tracing(): tracemalloc.stop() class LogFile(object): """File-like object to log text using the `logging` module and the log report can be customised.""" def __init__(self, name=None, reportIncrementFlag=False): """ :param name: name of the logger module reportIncrementFlag: This must be set to True if only the steps with memory increments are to be reported :type self: object name: string reportIncrementFlag: bool """ self.logger = logging.getLogger(name) self.reportIncrementFlag = reportIncrementFlag def write(self, msg, level=logging.INFO): if self.reportIncrementFlag: if "MiB" in msg and float(msg.split("MiB")[1].strip()) > 0: self.logger.log(level, msg) elif msg.__contains__("Filename:") or msg.__contains__( "Line Contents"): self.logger.log(level, msg) else: self.logger.log(level, msg) def flush(self): for handler in self.logger.handlers: handler.flush() if __name__ == '__main__': from optparse import OptionParser parser = OptionParser(usage=_CMD_USAGE, version=__version__) parser.disable_interspersed_args() parser.add_option( '--pdb-mmem', dest='max_mem', metavar='MAXMEM', type='float', action='store', help='step into the debugger when memory exceeds MAXMEM') parser.add_option( '--precision', dest='precision', type='int', action='store', default=3, help='precision of memory output in number of significant digits') parser.add_option( '--yaml', dest='yaml', type='str', action='store', default='False', help='use yaml') parser.add_option('-o', dest='out_filename', type='str', action='store', default=None, help='path to a file where results will be written') parser.add_option('--timestamp', dest='timestamp', default=False, action='store_true', help='''print timestamp instead of memory measurement for decorated functions''') parser.add_option('--backend', dest='backend', type='choice', action='store', choices=['tracemalloc', 'psutil', 'posix'], default='psutil', help='backend using for getting memory info ' '(one of the {tracemalloc, psutil, posix})') if not sys.argv[1:]: parser.print_help() sys.exit(2) (options, args) = parser.parse_args() sys.argv[:] = args # Remove every memory_profiler arguments script_filename = _find_script(args[0]) _backend = choose_backend(options.backend) if options.timestamp: prof = TimeStamper(_backend) else: prof = LineProfiler(max_mem=options.max_mem, backend=_backend) try: exec_with_profiler(script_filename, prof, options.backend) finally: if options.out_filename is not None: out_file = open(options.out_filename, "a") else: out_file = sys.stdout if options.timestamp: prof.show_results(stream=out_file) else: ret = json_results(prof, precision=options.precision) if options.yaml == 'True': out = bytes(yaml.safe_dump(ret), 'utf-8') print('[COUT] CO_YAML_CONTENT {}'.format(str(out)[1:])) else: print('[COUT] CO_JSON_CONTENT {}'.format(json.dumps(ret)))
apache-2.0
[ 624, 5736, 314, 4402, 4503, 402, 282, 2018, 2240, 624, 199, 199, 3, 2508, 781, 7171, 675, 642, 370, 986, 652, 370, 314, 1982, 2884, 2508, 199, 63, 28663, 63, 13808, 51, 275, 7992, 1252, 1574, 342, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 2417, 7, 199, 199, 63, 9744, 63, 20274, 275, 298, 1548, 446, 77, 4402, 63, 20132, 2884, 63, 493, 14, 647, 2, 199, 199, 646, 900, 199, 646, 984, 199, 646, 747, 199, 646, 10543, 199, 646, 3598, 199, 646, 26026, 199, 646, 6485, 199, 646, 3873, 199, 646, 2050, 199, 646, 5190, 199, 504, 4673, 492, 15522, 30691, 199, 646, 2022, 199, 646, 8864, 421, 199, 3, 3254, 26, 5647, 13943, 1380, 12866, 365, 440, 2808, 199, 893, 26, 272, 687, 12866, 492, 7132, 12, 16850, 199, 2590, 3545, 26, 272, 687, 12866, 14, 5869, 492, 7132, 12, 16850, 199, 199, 893, 26, 272, 687, 16243, 14, 1018, 14, 11523, 492, 603, 643, 2932, 12, 1004, 63, 3890, 63, 11523, 12, 8127, 2932, 63, 533, 199, 2590, 3545, 26, 272, 327, 284, 1548, 63, 1023, 665, 283, 16, 14, 969, 7, 272, 603, 643, 2932, 275, 909, 272, 1004, 63, 3890, 63, 11523, 275, 2400, 2562, 26, 2562, 272, 8127, 2932, 63, 533, 275, 2400, 843, 26, 843, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 199, 63, 52, 11325, 63, 1165, 275, 2069, 8, 18, 1011, 3388, 9, 199, 199, 692, 7843, 18, 26, 272, 492, 636, 5351, 363, 465, 12963, 199, 2836, 26, 272, 492, 12963, 2378, 347, 2649, 8, 88, 12, 627, 589, 304, 267, 372, 620, 8, 88, 9, 199, 199, 3, 2508, 664, 2808, 6117, 2508, 199, 893, 26, 272, 492, 22214, 339, 965, 63, 31903, 275, 715, 199, 2590, 3545, 26, 272, 965, 63, 31903, 275, 756, 199, 199, 893, 26, 272, 492, 3307, 23981, 339, 965, 63, 3446, 23981, 275, 715, 199, 2590, 3545, 26, 272, 965, 63, 3446, 23981, 275, 756, 421, 199, 533, 3194, 1147, 2889, 8, 785, 304, 272, 408, 278, 1147, 10628, 1255, 2436, 14, 339, 6935, 4079, 641, 16243, 1159, 4703, 390, 2889, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7573, 63, 3807, 12, 18828, 12, 11982, 12, 2653, 12, 6252, 12, 326, 2387, 63, 3223, 304, 267, 291, 14, 5286, 63, 3807, 275, 7573, 63, 3807, 267, 291, 14, 14232, 275, 18828, 267, 291, 14, 8755, 275, 11982, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 4284, 275, 6252, 267, 291, 14, 2613, 63, 3223, 275, 2387, 63, 3223, 339, 347, 636, 495, 721, 277, 304, 267, 1390, 63, 5286, 275, 1390, 8, 277, 14, 5286, 63, 3807, 9, 267, 12864, 275, 1390, 63, 5286, 446, 291, 14, 14232, 267, 372, 283, 8556, 4402, 26, 10536, 996, 70, 603, 17587, 12, 11609, 26, 10536, 996, 70, 603, 17587, 7, 450, 334, 988, 63, 5286, 12, 12864, 9, 339, 347, 485, 2722, 63, 9118, 2531, 277, 12, 299, 12, 8643, 304, 267, 1499, 275, 620, 8, 277, 9, 267, 299, 14, 505, 8, 85, 7601, 1352, 1147, 2889, 520, 283, 435, 1499, 435, 399, 7, 5971, 421, 199, 318, 485, 362, 63, 1739, 63, 4844, 8, 1412, 12, 7573, 815, 63, 962, 29, 403, 304, 272, 408, 272, 1803, 282, 4306, 626, 14801, 4402, 367, 1006, 1982, 10358, 14, 272, 408, 272, 340, 440, 965, 63, 31903, 26, 267, 746, 4279, 1332, 288, 298, 1918, 22214, 859, 365, 1415, 370, 8372, 314, 298, 288, 298, 4844, 4503, 402, 1982, 10358, 2122, 267, 5082, 339, 327, 7905, 282, 4422, 370, 282, 2112, 272, 340, 1228, 8, 1412, 12, 1109, 304, 267, 340, 2112, 508, 446, 17, 26, 2112, 275, 747, 14, 17829, 342, 267, 2112, 275, 22214, 14, 3498, 8, 1412, 9, 339, 340, 440, 7573, 815, 63, 962, 26, 267, 327, 3645, 314, 22214, 499, 14, 16, 1921, 340, 314, 12731, 1015, 5712, 1133, 3032, 315, 14, 267, 7573, 815, 63, 962, 275, 283, 4844, 63, 815, 7, 340, 2688, 8, 1412, 12, 283, 4844, 63, 815, 358, 587, 283, 362, 63, 4844, 63, 815, 7, 339, 327, 9496, 314, 22214, 805, 664, 314, 4978, 8545, 370, 4212, 781, 4895, 272, 327, 314, 4402, 63, 815, 1921, 334, 65, 1570, 687, 871, 316, 314, 4281, 680, 272, 4978, 63, 962, 275, 283, 3223, 7, 340, 2688, 8, 1412, 12, 283, 3223, 358, 587, 283, 362, 63, 3223, 7, 339, 327, 18175, 1806, 314, 1982, 10358, 436, 1995, 3932, 4402, 272, 862, 26, 267, 367, 1982, 315, 2519, 8, 1412, 12, 4978, 63, 962, 5130, 9931, 29, 549, 304, 288, 1995, 2519, 8, 1739, 12, 7573, 815, 63, 962, 9, 3430, 16, 61, 1182, 485, 52, 11325, 63, 1165, 272, 871, 22214, 14, 30049, 3498, 26, 267, 327, 4178, 921, 5031, 14, 957, 15, 21159, 5653, 80, 15, 4844, 63, 20132, 15, 10115, 15, 3172, 267, 1995, 378, 14, 16, 421, 199, 318, 485, 362, 63, 4844, 8, 3150, 12, 4865, 12, 22496, 29, 797, 12, 2387, 63, 3223, 29, 797, 12, 1788, 29, 403, 304, 272, 327, 2508, 6465, 805, 370, 664, 4402, 13447, 15052, 2508, 272, 340, 4422, 508, 446, 17, 26, 267, 4422, 275, 747, 14, 17829, 342, 339, 347, 3307, 23981, 63, 3557, 837, 267, 327, 2508, 8059, 13, 3246, 1325, 1325, 5074, 2018, 650, 14, 20, 503, 10948, 2508, 267, 5672, 275, 2163, 8, 1541, 8, 2734, 1242, 26, 620, 8, 1053, 680, 2460, 8, 1501, 395, 2574, 3307, 23981, 14, 11066, 63, 4753, 1252, 13724, 360, 1501, 7058, 267, 7573, 275, 5672, 14, 890, 1182, 485, 52, 11325, 63, 1165, 267, 340, 22496, 26, 288, 372, 7573, 12, 900, 14, 521, 342, 267, 587, 26, 288, 372, 7573, 339, 347, 7347, 63, 1974, 63, 3557, 837, 267, 327, 2508, 8059, 13, 3246, 1325, 1325, 5074, 22214, 2508, 267, 2112, 275, 22214, 14, 3498, 8, 3150, 9, 267, 862, 26, 288, 327, 5126, 675, 316, 664, 63, 4844, 63, 815, 3967, 652, 1630, 440, 3495, 288, 327, 315, 22214, 690, 499, 14, 16, 436, 18549, 652, 911, 7675, 1919, 14, 288, 7573, 815, 63, 962, 275, 283, 4844, 63, 815 ]
[ 5736, 314, 4402, 4503, 402, 282, 2018, 2240, 624, 199, 199, 3, 2508, 781, 7171, 675, 642, 370, 986, 652, 370, 314, 1982, 2884, 2508, 199, 63, 28663, 63, 13808, 51, 275, 7992, 1252, 1574, 342, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 2417, 7, 199, 199, 63, 9744, 63, 20274, 275, 298, 1548, 446, 77, 4402, 63, 20132, 2884, 63, 493, 14, 647, 2, 199, 199, 646, 900, 199, 646, 984, 199, 646, 747, 199, 646, 10543, 199, 646, 3598, 199, 646, 26026, 199, 646, 6485, 199, 646, 3873, 199, 646, 2050, 199, 646, 5190, 199, 504, 4673, 492, 15522, 30691, 199, 646, 2022, 199, 646, 8864, 421, 199, 3, 3254, 26, 5647, 13943, 1380, 12866, 365, 440, 2808, 199, 893, 26, 272, 687, 12866, 492, 7132, 12, 16850, 199, 2590, 3545, 26, 272, 687, 12866, 14, 5869, 492, 7132, 12, 16850, 199, 199, 893, 26, 272, 687, 16243, 14, 1018, 14, 11523, 492, 603, 643, 2932, 12, 1004, 63, 3890, 63, 11523, 12, 8127, 2932, 63, 533, 199, 2590, 3545, 26, 272, 327, 284, 1548, 63, 1023, 665, 283, 16, 14, 969, 7, 272, 603, 643, 2932, 275, 909, 272, 1004, 63, 3890, 63, 11523, 275, 2400, 2562, 26, 2562, 272, 8127, 2932, 63, 533, 275, 2400, 843, 26, 843, 199, 199, 4521, 18, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 199, 199, 63, 52, 11325, 63, 1165, 275, 2069, 8, 18, 1011, 3388, 9, 199, 199, 692, 7843, 18, 26, 272, 492, 636, 5351, 363, 465, 12963, 199, 2836, 26, 272, 492, 12963, 2378, 347, 2649, 8, 88, 12, 627, 589, 304, 267, 372, 620, 8, 88, 9, 199, 199, 3, 2508, 664, 2808, 6117, 2508, 199, 893, 26, 272, 492, 22214, 339, 965, 63, 31903, 275, 715, 199, 2590, 3545, 26, 272, 965, 63, 31903, 275, 756, 199, 199, 893, 26, 272, 492, 3307, 23981, 339, 965, 63, 3446, 23981, 275, 715, 199, 2590, 3545, 26, 272, 965, 63, 3446, 23981, 275, 756, 421, 199, 533, 3194, 1147, 2889, 8, 785, 304, 272, 408, 278, 1147, 10628, 1255, 2436, 14, 339, 6935, 4079, 641, 16243, 1159, 4703, 390, 2889, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7573, 63, 3807, 12, 18828, 12, 11982, 12, 2653, 12, 6252, 12, 326, 2387, 63, 3223, 304, 267, 291, 14, 5286, 63, 3807, 275, 7573, 63, 3807, 267, 291, 14, 14232, 275, 18828, 267, 291, 14, 8755, 275, 11982, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 4284, 275, 6252, 267, 291, 14, 2613, 63, 3223, 275, 2387, 63, 3223, 339, 347, 636, 495, 721, 277, 304, 267, 1390, 63, 5286, 275, 1390, 8, 277, 14, 5286, 63, 3807, 9, 267, 12864, 275, 1390, 63, 5286, 446, 291, 14, 14232, 267, 372, 283, 8556, 4402, 26, 10536, 996, 70, 603, 17587, 12, 11609, 26, 10536, 996, 70, 603, 17587, 7, 450, 334, 988, 63, 5286, 12, 12864, 9, 339, 347, 485, 2722, 63, 9118, 2531, 277, 12, 299, 12, 8643, 304, 267, 1499, 275, 620, 8, 277, 9, 267, 299, 14, 505, 8, 85, 7601, 1352, 1147, 2889, 520, 283, 435, 1499, 435, 399, 7, 5971, 421, 199, 318, 485, 362, 63, 1739, 63, 4844, 8, 1412, 12, 7573, 815, 63, 962, 29, 403, 304, 272, 408, 272, 1803, 282, 4306, 626, 14801, 4402, 367, 1006, 1982, 10358, 14, 272, 408, 272, 340, 440, 965, 63, 31903, 26, 267, 746, 4279, 1332, 288, 298, 1918, 22214, 859, 365, 1415, 370, 8372, 314, 298, 288, 298, 4844, 4503, 402, 1982, 10358, 2122, 267, 5082, 339, 327, 7905, 282, 4422, 370, 282, 2112, 272, 340, 1228, 8, 1412, 12, 1109, 304, 267, 340, 2112, 508, 446, 17, 26, 2112, 275, 747, 14, 17829, 342, 267, 2112, 275, 22214, 14, 3498, 8, 1412, 9, 339, 340, 440, 7573, 815, 63, 962, 26, 267, 327, 3645, 314, 22214, 499, 14, 16, 1921, 340, 314, 12731, 1015, 5712, 1133, 3032, 315, 14, 267, 7573, 815, 63, 962, 275, 283, 4844, 63, 815, 7, 340, 2688, 8, 1412, 12, 283, 4844, 63, 815, 358, 587, 283, 362, 63, 4844, 63, 815, 7, 339, 327, 9496, 314, 22214, 805, 664, 314, 4978, 8545, 370, 4212, 781, 4895, 272, 327, 314, 4402, 63, 815, 1921, 334, 65, 1570, 687, 871, 316, 314, 4281, 680, 272, 4978, 63, 962, 275, 283, 3223, 7, 340, 2688, 8, 1412, 12, 283, 3223, 358, 587, 283, 362, 63, 3223, 7, 339, 327, 18175, 1806, 314, 1982, 10358, 436, 1995, 3932, 4402, 272, 862, 26, 267, 367, 1982, 315, 2519, 8, 1412, 12, 4978, 63, 962, 5130, 9931, 29, 549, 304, 288, 1995, 2519, 8, 1739, 12, 7573, 815, 63, 962, 9, 3430, 16, 61, 1182, 485, 52, 11325, 63, 1165, 272, 871, 22214, 14, 30049, 3498, 26, 267, 327, 4178, 921, 5031, 14, 957, 15, 21159, 5653, 80, 15, 4844, 63, 20132, 15, 10115, 15, 3172, 267, 1995, 378, 14, 16, 421, 199, 318, 485, 362, 63, 4844, 8, 3150, 12, 4865, 12, 22496, 29, 797, 12, 2387, 63, 3223, 29, 797, 12, 1788, 29, 403, 304, 272, 327, 2508, 6465, 805, 370, 664, 4402, 13447, 15052, 2508, 272, 340, 4422, 508, 446, 17, 26, 267, 4422, 275, 747, 14, 17829, 342, 339, 347, 3307, 23981, 63, 3557, 837, 267, 327, 2508, 8059, 13, 3246, 1325, 1325, 5074, 2018, 650, 14, 20, 503, 10948, 2508, 267, 5672, 275, 2163, 8, 1541, 8, 2734, 1242, 26, 620, 8, 1053, 680, 2460, 8, 1501, 395, 2574, 3307, 23981, 14, 11066, 63, 4753, 1252, 13724, 360, 1501, 7058, 267, 7573, 275, 5672, 14, 890, 1182, 485, 52, 11325, 63, 1165, 267, 340, 22496, 26, 288, 372, 7573, 12, 900, 14, 521, 342, 267, 587, 26, 288, 372, 7573, 339, 347, 7347, 63, 1974, 63, 3557, 837, 267, 327, 2508, 8059, 13, 3246, 1325, 1325, 5074, 22214, 2508, 267, 2112, 275, 22214, 14, 3498, 8, 3150, 9, 267, 862, 26, 288, 327, 5126, 675, 316, 664, 63, 4844, 63, 815, 3967, 652, 1630, 440, 3495, 288, 327, 315, 22214, 690, 499, 14, 16, 436, 18549, 652, 911, 7675, 1919, 14, 288, 7573, 815, 63, 962, 275, 283, 4844, 63, 815, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sdague/home-assistant
homeassistant/components/alarm_control_panel/device_condition.py
9
5397
"""Provide the device automations for Alarm control panel.""" from typing import Dict, List import voluptuous as vol from homeassistant.components.alarm_control_panel.const import ( SUPPORT_ALARM_ARM_AWAY, SUPPORT_ALARM_ARM_CUSTOM_BYPASS, SUPPORT_ALARM_ARM_HOME, SUPPORT_ALARM_ARM_NIGHT, ) from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, CONF_CONDITION, CONF_DEVICE_ID, CONF_DOMAIN, CONF_ENTITY_ID, CONF_TYPE, STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_CUSTOM_BYPASS, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED, ) from homeassistant.core import HomeAssistant from homeassistant.helpers import condition, config_validation as cv, entity_registry from homeassistant.helpers.config_validation import DEVICE_CONDITION_BASE_SCHEMA from homeassistant.helpers.typing import ConfigType, TemplateVarsType from . import DOMAIN from .const import ( CONDITION_ARMED_AWAY, CONDITION_ARMED_CUSTOM_BYPASS, CONDITION_ARMED_HOME, CONDITION_ARMED_NIGHT, CONDITION_DISARMED, CONDITION_TRIGGERED, ) CONDITION_TYPES = { CONDITION_TRIGGERED, CONDITION_DISARMED, CONDITION_ARMED_HOME, CONDITION_ARMED_AWAY, CONDITION_ARMED_NIGHT, CONDITION_ARMED_CUSTOM_BYPASS, } CONDITION_SCHEMA = DEVICE_CONDITION_BASE_SCHEMA.extend( { vol.Required(CONF_ENTITY_ID): cv.entity_id, vol.Required(CONF_TYPE): vol.In(CONDITION_TYPES), } ) async def async_get_conditions( hass: HomeAssistant, device_id: str ) -> List[Dict[str, str]]: """List device conditions for Alarm control panel devices.""" registry = await entity_registry.async_get_registry(hass) conditions = [] # Get all the integrations entities for this device for entry in entity_registry.async_entries_for_device(registry, device_id): if entry.domain != DOMAIN: continue state = hass.states.get(entry.entity_id) # We need a state or else we can't populate the different armed conditions if state is None: continue supported_features = state.attributes[ATTR_SUPPORTED_FEATURES] # Add conditions for each entity that belongs to this integration conditions += [ { CONF_CONDITION: "device", CONF_DEVICE_ID: device_id, CONF_DOMAIN: DOMAIN, CONF_ENTITY_ID: entry.entity_id, CONF_TYPE: CONDITION_DISARMED, }, { CONF_CONDITION: "device", CONF_DEVICE_ID: device_id, CONF_DOMAIN: DOMAIN, CONF_ENTITY_ID: entry.entity_id, CONF_TYPE: CONDITION_TRIGGERED, }, ] if supported_features & SUPPORT_ALARM_ARM_HOME: conditions.append( { CONF_CONDITION: "device", CONF_DEVICE_ID: device_id, CONF_DOMAIN: DOMAIN, CONF_ENTITY_ID: entry.entity_id, CONF_TYPE: CONDITION_ARMED_HOME, } ) if supported_features & SUPPORT_ALARM_ARM_AWAY: conditions.append( { CONF_CONDITION: "device", CONF_DEVICE_ID: device_id, CONF_DOMAIN: DOMAIN, CONF_ENTITY_ID: entry.entity_id, CONF_TYPE: CONDITION_ARMED_AWAY, } ) if supported_features & SUPPORT_ALARM_ARM_NIGHT: conditions.append( { CONF_CONDITION: "device", CONF_DEVICE_ID: device_id, CONF_DOMAIN: DOMAIN, CONF_ENTITY_ID: entry.entity_id, CONF_TYPE: CONDITION_ARMED_NIGHT, } ) if supported_features & SUPPORT_ALARM_ARM_CUSTOM_BYPASS: conditions.append( { CONF_CONDITION: "device", CONF_DEVICE_ID: device_id, CONF_DOMAIN: DOMAIN, CONF_ENTITY_ID: entry.entity_id, CONF_TYPE: CONDITION_ARMED_CUSTOM_BYPASS, } ) return conditions def async_condition_from_config( config: ConfigType, config_validation: bool ) -> condition.ConditionCheckerType: """Create a function to test a device condition.""" if config_validation: config = CONDITION_SCHEMA(config) if config[CONF_TYPE] == CONDITION_TRIGGERED: state = STATE_ALARM_TRIGGERED elif config[CONF_TYPE] == CONDITION_DISARMED: state = STATE_ALARM_DISARMED elif config[CONF_TYPE] == CONDITION_ARMED_HOME: state = STATE_ALARM_ARMED_HOME elif config[CONF_TYPE] == CONDITION_ARMED_AWAY: state = STATE_ALARM_ARMED_AWAY elif config[CONF_TYPE] == CONDITION_ARMED_NIGHT: state = STATE_ALARM_ARMED_NIGHT elif config[CONF_TYPE] == CONDITION_ARMED_CUSTOM_BYPASS: state = STATE_ALARM_ARMED_CUSTOM_BYPASS def test_is_state(hass: HomeAssistant, variables: TemplateVarsType) -> bool: """Test if an entity is a certain state.""" return condition.state(hass, config[ATTR_ENTITY_ID], state) return test_is_state
apache-2.0
[ 624, 25107, 314, 2243, 2599, 21953, 367, 4580, 5362, 3304, 12748, 1041, 199, 504, 14090, 492, 7448, 12, 3820, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 14160, 63, 2785, 63, 7885, 14, 1297, 492, 334, 272, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 20519, 63, 8285, 6909, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 10762, 63, 13630, 63, 998, 12, 272, 10762, 63, 15925, 63, 13313, 12, 272, 6392, 63, 1864, 31247, 12, 272, 6392, 63, 10555, 63, 998, 12, 272, 6392, 63, 7378, 12, 272, 6392, 63, 13630, 63, 998, 12, 272, 6392, 63, 2711, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 20519, 63, 8285, 6909, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 9524, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 46, 2830, 12, 272, 11377, 63, 748, 12482, 63, 6178, 12482, 1149, 12, 272, 11377, 63, 748, 12482, 63, 30073, 1149, 12, 199, 9, 199, 504, 8846, 14, 1018, 492, 29913, 199, 504, 8846, 14, 7546, 492, 5558, 12, 1101, 63, 6136, 465, 6277, 12, 4642, 63, 5189, 199, 504, 8846, 14, 7546, 14, 888, 63, 6136, 492, 11643, 63, 1864, 31247, 63, 5825, 63, 10926, 199, 504, 8846, 14, 7546, 14, 29747, 492, 4094, 804, 12, 5458, 16270, 804, 199, 199, 504, 1275, 492, 15265, 199, 504, 1275, 1297, 492, 334, 272, 1868, 31247, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 20519, 63, 8285, 6909, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 9524, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 46, 2830, 12, 272, 1868, 31247, 63, 6178, 12482, 1149, 12, 272, 1868, 31247, 63, 30073, 1149, 12, 199, 9, 199, 199, 1864, 31247, 63, 7893, 275, 469, 272, 1868, 31247, 63, 30073, 1149, 12, 272, 1868, 31247, 63, 6178, 12482, 1149, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 9524, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 46, 2830, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 20519, 63, 8285, 6909, 12, 199, 93, 199, 199, 1864, 31247, 63, 10926, 275, 11643, 63, 1864, 31247, 63, 5825, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 13630, 63, 998, 304, 6277, 14, 4502, 63, 344, 12, 267, 5236, 14, 8030, 8, 3103, 63, 2711, 304, 5236, 14, 607, 8, 1864, 31247, 63, 7893, 395, 272, 789, 199, 9, 421, 199, 4146, 347, 5316, 63, 362, 63, 9855, 8, 272, 6298, 26, 29913, 12, 2243, 63, 344, 26, 620, 199, 9, 1035, 3820, 59, 2141, 59, 495, 12, 620, 27589, 272, 408, 1296, 2243, 3704, 367, 4580, 5362, 3304, 12748, 7256, 1041, 272, 7086, 275, 5517, 4642, 63, 5189, 14, 4146, 63, 362, 63, 5189, 8, 5387, 9, 272, 3704, 275, 942, 339, 327, 2372, 1006, 314, 4661, 926, 852, 9045, 367, 642, 2243, 272, 367, 2397, 315, 4642, 63, 5189, 14, 4146, 63, 3189, 63, 509, 63, 1782, 8, 5189, 12, 2243, 63, 344, 304, 267, 340, 2397, 14, 2261, 1137, 15265, 26, 288, 1980, 398, 1174, 275, 6298, 14, 4981, 14, 362, 8, 2373, 14, 4502, 63, 344, 9, 398, 327, 2136, 1929, 282, 1174, 503, 587, 781, 883, 1133, 13904, 314, 3365, 601, 3594, 3704, 267, 340, 1174, 365, 488, 26, 288, 1980, 398, 3748, 63, 3179, 275, 1174, 14, 2987, 59, 5280, 63, 15925, 63, 13313, 61, 398, 327, 2654, 3704, 367, 1924, 4642, 626, 15006, 370, 642, 13150, 267, 3704, 847, 359, 288, 469, 355, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 355, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 355, 6392, 63, 7378, 26, 15265, 12, 355, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 355, 6392, 63, 2711, 26, 1868, 31247, 63, 6178, 12482, 1149, 12, 288, 1660, 288, 469, 355, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 355, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 355, 6392, 63, 7378, 26, 15265, 12, 355, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 355, 6392, 63, 2711, 26, 1868, 31247, 63, 30073, 1149, 12, 288, 1660, 267, 1622, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 490, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 490, 6392, 63, 7378, 26, 15265, 12, 490, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 490, 6392, 63, 2711, 26, 1868, 31247, 63, 12482, 1149, 63, 9524, 12, 355, 789, 288, 776, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 490, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 490, 6392, 63, 7378, 26, 15265, 12, 490, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 490, 6392, 63, 2711, 26, 1868, 31247, 63, 12482, 1149, 63, 15088, 3448, 12, 355, 789, 288, 776, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 490, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 490, 6392, 63, 7378, 26, 15265, 12, 490, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 490, 6392, 63, 2711, 26, 1868, 31247, 63, 12482, 1149, 63, 46, 2830, 12, 355, 789, 288, 776, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 20519, 63, 8285, 6909, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298 ]
[ 25107, 314, 2243, 2599, 21953, 367, 4580, 5362, 3304, 12748, 1041, 199, 504, 14090, 492, 7448, 12, 3820, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 14160, 63, 2785, 63, 7885, 14, 1297, 492, 334, 272, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 20519, 63, 8285, 6909, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 12, 272, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 12, 199, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 10762, 63, 13630, 63, 998, 12, 272, 10762, 63, 15925, 63, 13313, 12, 272, 6392, 63, 1864, 31247, 12, 272, 6392, 63, 10555, 63, 998, 12, 272, 6392, 63, 7378, 12, 272, 6392, 63, 13630, 63, 998, 12, 272, 6392, 63, 2711, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 20519, 63, 8285, 6909, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 9524, 12, 272, 11377, 63, 748, 12482, 63, 12482, 1149, 63, 46, 2830, 12, 272, 11377, 63, 748, 12482, 63, 6178, 12482, 1149, 12, 272, 11377, 63, 748, 12482, 63, 30073, 1149, 12, 199, 9, 199, 504, 8846, 14, 1018, 492, 29913, 199, 504, 8846, 14, 7546, 492, 5558, 12, 1101, 63, 6136, 465, 6277, 12, 4642, 63, 5189, 199, 504, 8846, 14, 7546, 14, 888, 63, 6136, 492, 11643, 63, 1864, 31247, 63, 5825, 63, 10926, 199, 504, 8846, 14, 7546, 14, 29747, 492, 4094, 804, 12, 5458, 16270, 804, 199, 199, 504, 1275, 492, 15265, 199, 504, 1275, 1297, 492, 334, 272, 1868, 31247, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 20519, 63, 8285, 6909, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 9524, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 46, 2830, 12, 272, 1868, 31247, 63, 6178, 12482, 1149, 12, 272, 1868, 31247, 63, 30073, 1149, 12, 199, 9, 199, 199, 1864, 31247, 63, 7893, 275, 469, 272, 1868, 31247, 63, 30073, 1149, 12, 272, 1868, 31247, 63, 6178, 12482, 1149, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 9524, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 15088, 3448, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 46, 2830, 12, 272, 1868, 31247, 63, 12482, 1149, 63, 20519, 63, 8285, 6909, 12, 199, 93, 199, 199, 1864, 31247, 63, 10926, 275, 11643, 63, 1864, 31247, 63, 5825, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 13630, 63, 998, 304, 6277, 14, 4502, 63, 344, 12, 267, 5236, 14, 8030, 8, 3103, 63, 2711, 304, 5236, 14, 607, 8, 1864, 31247, 63, 7893, 395, 272, 789, 199, 9, 421, 199, 4146, 347, 5316, 63, 362, 63, 9855, 8, 272, 6298, 26, 29913, 12, 2243, 63, 344, 26, 620, 199, 9, 1035, 3820, 59, 2141, 59, 495, 12, 620, 27589, 272, 408, 1296, 2243, 3704, 367, 4580, 5362, 3304, 12748, 7256, 1041, 272, 7086, 275, 5517, 4642, 63, 5189, 14, 4146, 63, 362, 63, 5189, 8, 5387, 9, 272, 3704, 275, 942, 339, 327, 2372, 1006, 314, 4661, 926, 852, 9045, 367, 642, 2243, 272, 367, 2397, 315, 4642, 63, 5189, 14, 4146, 63, 3189, 63, 509, 63, 1782, 8, 5189, 12, 2243, 63, 344, 304, 267, 340, 2397, 14, 2261, 1137, 15265, 26, 288, 1980, 398, 1174, 275, 6298, 14, 4981, 14, 362, 8, 2373, 14, 4502, 63, 344, 9, 398, 327, 2136, 1929, 282, 1174, 503, 587, 781, 883, 1133, 13904, 314, 3365, 601, 3594, 3704, 267, 340, 1174, 365, 488, 26, 288, 1980, 398, 3748, 63, 3179, 275, 1174, 14, 2987, 59, 5280, 63, 15925, 63, 13313, 61, 398, 327, 2654, 3704, 367, 1924, 4642, 626, 15006, 370, 642, 13150, 267, 3704, 847, 359, 288, 469, 355, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 355, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 355, 6392, 63, 7378, 26, 15265, 12, 355, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 355, 6392, 63, 2711, 26, 1868, 31247, 63, 6178, 12482, 1149, 12, 288, 1660, 288, 469, 355, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 355, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 355, 6392, 63, 7378, 26, 15265, 12, 355, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 355, 6392, 63, 2711, 26, 1868, 31247, 63, 30073, 1149, 12, 288, 1660, 267, 1622, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 9524, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 490, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 490, 6392, 63, 7378, 26, 15265, 12, 490, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 490, 6392, 63, 2711, 26, 1868, 31247, 63, 12482, 1149, 63, 9524, 12, 355, 789, 288, 776, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 15088, 3448, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 490, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 490, 6392, 63, 7378, 26, 15265, 12, 490, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 490, 6392, 63, 2711, 26, 1868, 31247, 63, 12482, 1149, 63, 15088, 3448, 12, 355, 789, 288, 776, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 46, 2830, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 1782, 401, 490, 6392, 63, 10555, 63, 998, 26, 2243, 63, 344, 12, 490, 6392, 63, 7378, 26, 15265, 12, 490, 6392, 63, 13630, 63, 998, 26, 2397, 14, 4502, 63, 344, 12, 490, 6392, 63, 2711, 26, 1868, 31247, 63, 12482, 1149, 63, 46, 2830, 12, 355, 789, 288, 776, 267, 340, 3748, 63, 3179, 1253, 13756, 63, 748, 12482, 63, 12482, 63, 20519, 63, 8285, 6909, 26, 288, 3704, 14, 740, 8, 355, 469, 490, 6392, 63, 1864, 31247, 26, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shenqicang/openmc
tests/test_cmfd_jfnk/test_cmfd_jfnk.py
8
2112
#!/usr/bin/env python import os from subprocess import Popen, STDOUT, PIPE, call import filecmp import glob from optparse import OptionParser parser = OptionParser() parser.add_option('--mpi_exec', dest='mpi_exec', default='') parser.add_option('--mpi_np', dest='mpi_np', default='3') parser.add_option('--exe', dest='exe') (opts, args) = parser.parse_args() cwd = os.getcwd() def test_run(): if opts.mpi_exec != '': proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd], stderr=STDOUT, stdout=PIPE) else: proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE) print(proc.communicate()[0]) returncode = proc.returncode assert returncode == 0, 'OpenMC did not exit successfully.' def test_created_statepoint(): statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*')) assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.' assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\ 'Statepoint file is not a binary or hdf5 file.' def test_output_exists(): assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.' def test_results(): statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*')) call(['python', 'results.py', statepoint[0]]) compare = filecmp.cmp('results_test.dat', 'results_true.dat') if not compare: os.rename('results_test.dat', 'results_error.dat') assert compare, 'Results do not agree.' def teardown(): output = glob.glob(os.path.join(cwd, 'statepoint.20.*')) output.append(os.path.join(cwd, 'tallies.out')) output.append(os.path.join(cwd, 'results_test.dat')) for f in output: if os.path.exists(f): os.remove(f) if __name__ == '__main__': # test for openmc executable if opts.exe is None: raise Exception('Must specify OpenMC executable from command line with --exe.') # run tests try: test_run() test_created_statepoint() test_output_exists() test_results() finally: teardown()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 504, 3873, 492, 13995, 12, 4384, 12619, 12, 22773, 12, 1240, 199, 646, 570, 5730, 199, 646, 5739, 199, 504, 8691, 492, 13491, 199, 199, 2087, 275, 13491, 342, 199, 2087, 14, 525, 63, 1422, 4517, 13213, 63, 1628, 297, 2053, 534, 13213, 63, 1628, 297, 849, 13275, 199, 2087, 14, 525, 63, 1422, 4517, 13213, 63, 1590, 297, 2053, 534, 13213, 63, 1590, 297, 849, 534, 19, 358, 199, 2087, 14, 525, 63, 1422, 4517, 5803, 297, 2053, 534, 5803, 358, 199, 8, 3291, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 6525, 275, 747, 14, 9458, 342, 199, 199, 318, 511, 63, 1065, 837, 272, 340, 3999, 14, 13213, 63, 1628, 1137, 8061, 267, 6499, 275, 13995, 779, 3291, 14, 13213, 63, 1628, 12, 2475, 1590, 297, 3999, 14, 13213, 63, 1590, 12, 3999, 14, 5803, 12, 8288, 467, 2049, 4635, 29, 13850, 12, 3839, 29, 6089, 9, 272, 587, 26, 267, 6499, 275, 13995, 779, 3291, 14, 5803, 12, 8288, 467, 4635, 29, 13850, 12, 3839, 29, 6089, 9, 272, 870, 8, 4687, 14, 10664, 3430, 16, 566, 272, 17630, 275, 6499, 14, 9913, 272, 702, 17630, 508, 378, 12, 283, 4299, 7608, 8103, 440, 4458, 8792, 3530, 421, 199, 318, 511, 63, 3966, 63, 929, 1403, 837, 272, 1174, 1403, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 929, 1403, 14, 1165, 2795, 1333, 272, 702, 822, 8, 929, 1403, 9, 508, 413, 12, 283, 37, 1711, 3663, 503, 949, 1174, 1403, 1584, 2187, 3530, 272, 702, 1174, 1403, 59, 16, 1055, 4130, 360, 3008, 358, 503, 1174, 1403, 59, 16, 1055, 4130, 360, 72, 21, 659, 60, 267, 283, 2223, 1403, 570, 365, 440, 282, 3366, 503, 394, 1587, 21, 570, 3530, 421, 199, 318, 511, 63, 1199, 63, 2444, 837, 272, 702, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 31466, 6528, 14, 548, 3855, 283, 52, 1183, 1072, 570, 1630, 440, 2187, 3530, 421, 199, 318, 511, 63, 2604, 837, 272, 1174, 1403, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 929, 1403, 14, 1165, 2795, 1333, 272, 1240, 2941, 1548, 297, 283, 2604, 14, 647, 297, 1174, 1403, 59, 16, 3934, 272, 6540, 275, 570, 5730, 14, 5730, 360, 2604, 63, 396, 14, 4616, 297, 283, 2604, 63, 2052, 14, 4616, 358, 272, 340, 440, 6540, 26, 267, 747, 14, 8165, 360, 2604, 63, 396, 14, 4616, 297, 283, 2604, 63, 705, 14, 4616, 358, 272, 702, 6540, 12, 283, 6579, 886, 440, 10601, 3530, 421, 199, 318, 17558, 837, 272, 1072, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 929, 1403, 14, 1165, 2795, 1333, 272, 1072, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 31466, 6528, 14, 548, 1333, 272, 1072, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 2604, 63, 396, 14, 4616, 1333, 272, 367, 289, 315, 1072, 26, 267, 340, 747, 14, 515, 14, 2444, 8, 70, 304, 288, 747, 14, 2168, 8, 70, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 327, 511, 367, 1551, 5466, 7286, 272, 340, 3999, 14, 5803, 365, 488, 26, 267, 746, 2186, 360, 13757, 4165, 3232, 7608, 7286, 687, 1414, 1004, 543, 1553, 5803, 2659, 339, 327, 1255, 2295, 272, 862, 26, 267, 511, 63, 1065, 342, 267, 511, 63, 3966, 63, 929, 1403, 342, 267, 511, 63, 1199, 63, 2444, 342, 267, 511, 63, 2604, 342, 272, 3753, 26, 267, 17558, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 504, 3873, 492, 13995, 12, 4384, 12619, 12, 22773, 12, 1240, 199, 646, 570, 5730, 199, 646, 5739, 199, 504, 8691, 492, 13491, 199, 199, 2087, 275, 13491, 342, 199, 2087, 14, 525, 63, 1422, 4517, 13213, 63, 1628, 297, 2053, 534, 13213, 63, 1628, 297, 849, 13275, 199, 2087, 14, 525, 63, 1422, 4517, 13213, 63, 1590, 297, 2053, 534, 13213, 63, 1590, 297, 849, 534, 19, 358, 199, 2087, 14, 525, 63, 1422, 4517, 5803, 297, 2053, 534, 5803, 358, 199, 8, 3291, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 199, 6525, 275, 747, 14, 9458, 342, 199, 199, 318, 511, 63, 1065, 837, 272, 340, 3999, 14, 13213, 63, 1628, 1137, 8061, 267, 6499, 275, 13995, 779, 3291, 14, 13213, 63, 1628, 12, 2475, 1590, 297, 3999, 14, 13213, 63, 1590, 12, 3999, 14, 5803, 12, 8288, 467, 2049, 4635, 29, 13850, 12, 3839, 29, 6089, 9, 272, 587, 26, 267, 6499, 275, 13995, 779, 3291, 14, 5803, 12, 8288, 467, 4635, 29, 13850, 12, 3839, 29, 6089, 9, 272, 870, 8, 4687, 14, 10664, 3430, 16, 566, 272, 17630, 275, 6499, 14, 9913, 272, 702, 17630, 508, 378, 12, 283, 4299, 7608, 8103, 440, 4458, 8792, 3530, 421, 199, 318, 511, 63, 3966, 63, 929, 1403, 837, 272, 1174, 1403, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 929, 1403, 14, 1165, 2795, 1333, 272, 702, 822, 8, 929, 1403, 9, 508, 413, 12, 283, 37, 1711, 3663, 503, 949, 1174, 1403, 1584, 2187, 3530, 272, 702, 1174, 1403, 59, 16, 1055, 4130, 360, 3008, 358, 503, 1174, 1403, 59, 16, 1055, 4130, 360, 72, 21, 659, 60, 267, 283, 2223, 1403, 570, 365, 440, 282, 3366, 503, 394, 1587, 21, 570, 3530, 421, 199, 318, 511, 63, 1199, 63, 2444, 837, 272, 702, 747, 14, 515, 14, 2444, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 31466, 6528, 14, 548, 3855, 283, 52, 1183, 1072, 570, 1630, 440, 2187, 3530, 421, 199, 318, 511, 63, 2604, 837, 272, 1174, 1403, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 929, 1403, 14, 1165, 2795, 1333, 272, 1240, 2941, 1548, 297, 283, 2604, 14, 647, 297, 1174, 1403, 59, 16, 3934, 272, 6540, 275, 570, 5730, 14, 5730, 360, 2604, 63, 396, 14, 4616, 297, 283, 2604, 63, 2052, 14, 4616, 358, 272, 340, 440, 6540, 26, 267, 747, 14, 8165, 360, 2604, 63, 396, 14, 4616, 297, 283, 2604, 63, 705, 14, 4616, 358, 272, 702, 6540, 12, 283, 6579, 886, 440, 10601, 3530, 421, 199, 318, 17558, 837, 272, 1072, 275, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 929, 1403, 14, 1165, 2795, 1333, 272, 1072, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 31466, 6528, 14, 548, 1333, 272, 1072, 14, 740, 8, 736, 14, 515, 14, 904, 8, 6525, 12, 283, 2604, 63, 396, 14, 4616, 1333, 272, 367, 289, 315, 1072, 26, 267, 340, 747, 14, 515, 14, 2444, 8, 70, 304, 288, 747, 14, 2168, 8, 70, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 327, 511, 367, 1551, 5466, 7286, 272, 340, 3999, 14, 5803, 365, 488, 26, 267, 746, 2186, 360, 13757, 4165, 3232, 7608, 7286, 687, 1414, 1004, 543, 1553, 5803, 2659, 339, 327, 1255, 2295, 272, 862, 26, 267, 511, 63, 1065, 342, 267, 511, 63, 3966, 63, 929, 1403, 342, 267, 511, 63, 1199, 63, 2444, 342, 267, 511, 63, 2604, 342, 272, 3753, 26, 267, 17558, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
askhl/ase
ase/visualize/vtk/volume.py
14
2387
import numpy as np from vtk import vtkContourFilter, vtkDepthSortPolyData from ase.visualize.vtk.grid import vtkVolumeGrid from ase.visualize.vtk.module import vtkPolyDataModule from ase.visualize.vtk.pipeline import vtkSurfaceSmootherPipeline, \ vtkDepthSortPipeline # ------------------------------------------------------------------- class vtkIsoSurfaceModule(vtkVolumeGrid, vtkPolyDataModule): def __init__(self, data, cell, vtk_renderer, contours=1, depthsort=True): #TODO don't require vtk_renderer... implement vtkScene #TODO contour values from list or autocontours if int # Make sure data argument is a valid array if not isinstance(data, np.ndarray): data = np.array(data) vtkVolumeGrid.__init__(self, data.shape, cell) self.vtk_iso = vtkContourFilter() #vtkMarchingContourFilter? self.vtk_iso.SetInput(self.get_structured_points()) #TODO non-orthogonal self.vtk_iso.SetValue(0, 0.25) self.vtk_iso.SetValue(1, -0.25) self.smoothpipe = vtkSurfaceSmootherPipeline(self, vtk_iso) #TODO use vtkDepthSortPipeline - but vtkPolyDataModule isn't a pipeline self.depthsort = depthsort if self.depthsort: # The depht sort object is set up to generate scalars representing # the sort depth. A camera is assigned for the sorting. The camera # defines the sort vector (position and focal point). self.vtk_ds = vtkDepthSortPolyData() self.vtk_ds.SetCamera(vtk_renderer.GetActiveCamera()) self.vtk_ds.SetInputConnection(self.vtk_iso.GetOutputPort()) self.vtk_ds.SetDirectionToBackToFront() #vtk_ds.SetVector(1, 1, 1) #vtk_ds.SortScalarsOn() #vtk_ds.Update() vtk_renderer.ResetCamera() vtkPolyDataModule.__init__(self, self.vtk_ds) else: vtkPolyDataModule.__init__(self, self.vtk_iso) #TODO add color function """ vtk_dmap = vtk.vtkPolyDataMapper() vtk_dmap.ScalarVisibilityOn() vtk_dmap.SetScalarRange(0, vtk_sda_x.GetMaxNorm()) #TODO GetMinNorm non-existing! vtk_dmap.SetScalarModeToUsePointFieldData() vtk_dmap.SelectColorArray("x") #vtk_dmap.ColorByArrayComponent("x", 0) """
gpl-2.0
[ 199, 646, 2680, 465, 980, 199, 199, 504, 11144, 492, 11144, 714, 10808, 4131, 12, 11144, 14125, 14376, 12747, 1451, 199, 504, 282, 261, 14, 16948, 794, 14, 11919, 14, 3825, 492, 11144, 6464, 7900, 199, 504, 282, 261, 14, 16948, 794, 14, 11919, 14, 578, 492, 11144, 12747, 1451, 2377, 199, 504, 282, 261, 14, 16948, 794, 14, 11919, 14, 7379, 492, 11144, 16923, 51, 573, 1848, 17562, 12, 971, 4318, 11144, 14125, 14376, 17562, 199, 199, 3, 5620, 2595, 199, 199, 533, 11144, 41, 1152, 16923, 2377, 8, 11919, 6464, 7900, 12, 11144, 12747, 1451, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 666, 12, 4917, 12, 11144, 63, 12471, 12, 23176, 83, 29, 17, 12, 5818, 3191, 29, 549, 304, 267, 327, 11768, 2793, 1133, 4409, 11144, 63, 12471, 1396, 5669, 11144, 14216, 267, 327, 11768, 23176, 1338, 687, 769, 503, 2599, 17798, 83, 340, 1109, 398, 327, 4155, 3238, 666, 1423, 365, 282, 1686, 1625, 267, 340, 440, 1228, 8, 576, 12, 980, 14, 8237, 304, 288, 666, 275, 980, 14, 1144, 8, 576, 9, 398, 11144, 6464, 7900, 855, 826, 721, 277, 12, 666, 14, 1392, 12, 4917, 9, 398, 291, 14, 11919, 63, 4595, 275, 11144, 714, 10808, 4131, 342, 327, 11919, 45, 1047, 316, 714, 10808, 4131, 31, 267, 291, 14, 11919, 63, 4595, 14, 24029, 8, 277, 14, 362, 63, 15774, 63, 3438, 1012, 327, 11768, 2222, 13, 11297, 19133, 398, 291, 14, 11919, 63, 4595, 14, 21322, 8, 16, 12, 378, 14, 821, 9, 4960, 291, 14, 11919, 63, 4595, 14, 21322, 8, 17, 12, 446, 16, 14, 821, 9, 398, 291, 14, 19169, 4990, 275, 11144, 16923, 51, 573, 1848, 17562, 8, 277, 12, 11144, 63, 4595, 9, 398, 327, 11768, 675, 11144, 14125, 14376, 17562, 446, 1325, 11144, 12747, 1451, 2377, 5712, 1133, 282, 7679, 398, 291, 14, 4631, 3191, 275, 5818, 3191, 398, 340, 291, 14, 4631, 3191, 26, 288, 327, 710, 2657, 517, 4069, 909, 365, 663, 1536, 370, 3550, 19945, 6144, 288, 327, 314, 4069, 5818, 14, 437, 15177, 365, 7943, 367, 314, 13351, 14, 710, 15177, 288, 327, 7890, 314, 4069, 5477, 334, 3124, 436, 289, 24560, 2376, 680, 288, 291, 14, 11919, 63, 795, 275, 11144, 14125, 14376, 12747, 1451, 342, 288, 291, 14, 11919, 63, 795, 14, 1084, 18425, 8, 11919, 63, 12471, 14, 1002, 7472, 18425, 1012, 288, 291, 14, 11919, 63, 795, 14, 32195, 8, 277, 14, 11919, 63, 4595, 14, 30810, 1012, 288, 291, 14, 11919, 63, 795, 14, 1084, 17015, 1378, 4540, 1378, 17607, 342, 288, 327, 11919, 63, 795, 14, 1084, 3646, 8, 17, 12, 413, 12, 413, 9, 288, 327, 11919, 63, 795, 14, 14376, 10249, 4291, 3314, 342, 288, 327, 11919, 63, 795, 14, 4152, 342, 953, 11144, 63, 12471, 14, 9637, 18425, 342, 953, 11144, 12747, 1451, 2377, 855, 826, 721, 277, 12, 291, 14, 11919, 63, 795, 9, 267, 587, 26, 288, 11144, 12747, 1451, 2377, 855, 826, 721, 277, 12, 291, 14, 11919, 63, 4595, 9, 398, 327, 11768, 1050, 3164, 805, 267, 408, 267, 11144, 63, 68, 1130, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 267, 11144, 63, 68, 1130, 14, 13090, 24735, 3314, 342, 267, 11144, 63, 68, 1130, 14, 1084, 13090, 4709, 8, 16, 12, 11144, 63, 19387, 63, 88, 14, 28198, 15548, 1012, 327, 11768, 2372, 4649, 15548, 2222, 13, 5952, 1, 267, 11144, 63, 68, 1130, 14, 1084, 13090, 1385, 1378, 6119, 3428, 792, 1451, 342, 267, 11144, 63, 68, 1130, 14, 5446, 4117, 3836, 480, 88, 531, 267, 327, 11919, 63, 68, 1130, 14, 4117, 2175, 3836, 7004, 480, 88, 401, 378, 9, 267, 408, 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 ]
[ 646, 2680, 465, 980, 199, 199, 504, 11144, 492, 11144, 714, 10808, 4131, 12, 11144, 14125, 14376, 12747, 1451, 199, 504, 282, 261, 14, 16948, 794, 14, 11919, 14, 3825, 492, 11144, 6464, 7900, 199, 504, 282, 261, 14, 16948, 794, 14, 11919, 14, 578, 492, 11144, 12747, 1451, 2377, 199, 504, 282, 261, 14, 16948, 794, 14, 11919, 14, 7379, 492, 11144, 16923, 51, 573, 1848, 17562, 12, 971, 4318, 11144, 14125, 14376, 17562, 199, 199, 3, 5620, 2595, 199, 199, 533, 11144, 41, 1152, 16923, 2377, 8, 11919, 6464, 7900, 12, 11144, 12747, 1451, 2377, 304, 272, 347, 636, 826, 721, 277, 12, 666, 12, 4917, 12, 11144, 63, 12471, 12, 23176, 83, 29, 17, 12, 5818, 3191, 29, 549, 304, 267, 327, 11768, 2793, 1133, 4409, 11144, 63, 12471, 1396, 5669, 11144, 14216, 267, 327, 11768, 23176, 1338, 687, 769, 503, 2599, 17798, 83, 340, 1109, 398, 327, 4155, 3238, 666, 1423, 365, 282, 1686, 1625, 267, 340, 440, 1228, 8, 576, 12, 980, 14, 8237, 304, 288, 666, 275, 980, 14, 1144, 8, 576, 9, 398, 11144, 6464, 7900, 855, 826, 721, 277, 12, 666, 14, 1392, 12, 4917, 9, 398, 291, 14, 11919, 63, 4595, 275, 11144, 714, 10808, 4131, 342, 327, 11919, 45, 1047, 316, 714, 10808, 4131, 31, 267, 291, 14, 11919, 63, 4595, 14, 24029, 8, 277, 14, 362, 63, 15774, 63, 3438, 1012, 327, 11768, 2222, 13, 11297, 19133, 398, 291, 14, 11919, 63, 4595, 14, 21322, 8, 16, 12, 378, 14, 821, 9, 4960, 291, 14, 11919, 63, 4595, 14, 21322, 8, 17, 12, 446, 16, 14, 821, 9, 398, 291, 14, 19169, 4990, 275, 11144, 16923, 51, 573, 1848, 17562, 8, 277, 12, 11144, 63, 4595, 9, 398, 327, 11768, 675, 11144, 14125, 14376, 17562, 446, 1325, 11144, 12747, 1451, 2377, 5712, 1133, 282, 7679, 398, 291, 14, 4631, 3191, 275, 5818, 3191, 398, 340, 291, 14, 4631, 3191, 26, 288, 327, 710, 2657, 517, 4069, 909, 365, 663, 1536, 370, 3550, 19945, 6144, 288, 327, 314, 4069, 5818, 14, 437, 15177, 365, 7943, 367, 314, 13351, 14, 710, 15177, 288, 327, 7890, 314, 4069, 5477, 334, 3124, 436, 289, 24560, 2376, 680, 288, 291, 14, 11919, 63, 795, 275, 11144, 14125, 14376, 12747, 1451, 342, 288, 291, 14, 11919, 63, 795, 14, 1084, 18425, 8, 11919, 63, 12471, 14, 1002, 7472, 18425, 1012, 288, 291, 14, 11919, 63, 795, 14, 32195, 8, 277, 14, 11919, 63, 4595, 14, 30810, 1012, 288, 291, 14, 11919, 63, 795, 14, 1084, 17015, 1378, 4540, 1378, 17607, 342, 288, 327, 11919, 63, 795, 14, 1084, 3646, 8, 17, 12, 413, 12, 413, 9, 288, 327, 11919, 63, 795, 14, 14376, 10249, 4291, 3314, 342, 288, 327, 11919, 63, 795, 14, 4152, 342, 953, 11144, 63, 12471, 14, 9637, 18425, 342, 953, 11144, 12747, 1451, 2377, 855, 826, 721, 277, 12, 291, 14, 11919, 63, 795, 9, 267, 587, 26, 288, 11144, 12747, 1451, 2377, 855, 826, 721, 277, 12, 291, 14, 11919, 63, 4595, 9, 398, 327, 11768, 1050, 3164, 805, 267, 408, 267, 11144, 63, 68, 1130, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 267, 11144, 63, 68, 1130, 14, 13090, 24735, 3314, 342, 267, 11144, 63, 68, 1130, 14, 1084, 13090, 4709, 8, 16, 12, 11144, 63, 19387, 63, 88, 14, 28198, 15548, 1012, 327, 11768, 2372, 4649, 15548, 2222, 13, 5952, 1, 267, 11144, 63, 68, 1130, 14, 1084, 13090, 1385, 1378, 6119, 3428, 792, 1451, 342, 267, 11144, 63, 68, 1130, 14, 5446, 4117, 3836, 480, 88, 531, 267, 327, 11919, 63, 68, 1130, 14, 4117, 2175, 3836, 7004, 480, 88, 401, 378, 9, 267, 408, 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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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 ]
keflavich/pyspeckit-obsolete
pyspeckit/spectrum/models/ammonia.py
1
28836
""" ======================================== Ammonia inversion transition TKIN fitter ======================================== Ammonia inversion transition TKIN fitter translated from Erik Rosolowsky's http://svn.ok.ubc.ca/svn/signals/nh3fit/ .. moduleauthor:: Adam Ginsburg <adam.g.ginsburg@gmail.com> Module API ^^^^^^^^^^ """ import numpy as np from pyspeckit.mpfit import mpfit from pyspeckit.spectrum.parinfo import ParinfoList,Parinfo import fitter import matplotlib.cbook as mpcb import copy import model line_names = ['oneone','twotwo','threethree','fourfour'] freq_dict = { 'oneone': 23.694506e9, 'twotwo': 23.722633335e9, 'threethree': 23.8701296e9, 'fourfour': 24.1394169e9, } aval_dict = { 'oneone': 1.712e-7, #64*!pi**4/(3*h*c**3)*nu11**3*mu0**2*(1/2.) 'twotwo': 2.291e-7, #64*!pi**4/(3*h*c**3)*nu22**3*mu0**2*(2/3.) 'threethree': 2.625e-7, #64*!pi**4/(3*h*c**3)*nu33**3*mu0**2*(3/4.) 'fourfour': 3.167e-7, #64*!pi**4/(3*h*c**3)*nu44**3*mu0**2*(4/5.) } ortho_dict = { 'oneone': False, 'twotwo': False, 'threethree': True, 'fourfour': False, } n_ortho = np.arange(0,28,3) # 0..3..27 n_para = np.array([x for x in range(28) if x % 3 != 0]) voff_lines_dict = { 'oneone': [19.8513, 19.3159, 7.88669, 7.46967, 7.35132, 0.460409, 0.322042, -0.0751680, -0.213003, 0.311034, 0.192266, -0.132382, -0.250923, -7.23349, -7.37280, -7.81526, -19.4117, -19.5500], 'twotwo':[26.5263, 26.0111, 25.9505, 16.3917, 16.3793, 15.8642, 0.562503, 0.528408, 0.523745, 0.0132820, -0.00379100, -0.0132820, -0.501831, -0.531340, -0.589080, -15.8547, -16.3698, -16.3822, -25.9505, -26.0111, -26.5263], 'threethree':[29.195098, 29.044147, 28.941877, 28.911408, 21.234827, 21.214619, 21.136387, 21.087456, 1.005122, 0.806082, 0.778062, 0.628569, 0.016754, -0.005589, -0.013401, -0.639734, -0.744554, -1.031924, -21.125222, -21.203441, -21.223649, -21.076291, -28.908067, -28.938523, -29.040794, -29.191744], 'fourfour':[ 0. , -30.49783692, 30.49783692, 0., 24.25907811, -24.25907811, 0. ] } tau_wts_dict = { 'oneone': [0.0740740, 0.148148, 0.0925930, 0.166667, 0.0185190, 0.0370370, 0.0185190, 0.0185190, 0.0925930, 0.0333330, 0.300000, 0.466667, 0.0333330, 0.0925930, 0.0185190, 0.166667, 0.0740740, 0.148148], 'twotwo': [0.00418600, 0.0376740, 0.0209300, 0.0372090, 0.0260470, 0.00186000, 0.0209300, 0.0116280, 0.0106310, 0.267442, 0.499668, 0.146512, 0.0116280, 0.0106310, 0.0209300, 0.00186000, 0.0260470, 0.0372090, 0.0209300, 0.0376740, 0.00418600], 'threethree': [0.012263, 0.008409, 0.003434, 0.005494, 0.006652, 0.008852, 0.004967, 0.011589, 0.019228, 0.010387, 0.010820, 0.009482, 0.293302, 0.459109, 0.177372, 0.009482, 0.010820, 0.019228, 0.004967, 0.008852, 0.006652, 0.011589, 0.005494, 0.003434, 0.008409, 0.012263], 'fourfour': [0.2431, 0.0162, 0.0162, 0.3008, 0.0163, 0.0163, 0.3911]} def ammonia(xarr, tkin=20, tex=None, ntot=1e14, width=1, xoff_v=0.0, fortho=0.0, tau=None, fillingfraction=None, return_tau=False, thin=False, verbose=False, return_components=False, debug=False ): """ Generate a model Ammonia spectrum based on input temperatures, column, and gaussian parameters ntot can be specified as a column density (e.g., 10^15) or a log-column-density (e.g., 15) tex can be specified or can be assumed LTE if unspecified, if tex>tkin, or if "thin" is specified "thin" uses a different parametetrization and requires only the optical depth, width, offset, and tkin to be specified. In the 'thin' approximation, tex is not used in computation of the partition function - LTE is implicitly assumed If tau is specified, ntot is NOT fit but is set to a fixed value fillingfraction is an arbitrary scaling factor to apply to the model fortho is the ortho/(ortho+para) fraction. The default is to assume all ortho. xoff_v is the velocity offset in km/s tau refers to the optical depth of the 1-1 line. The optical depths of the other lines are fixed relative to tau_oneone (not implemented) if tau is specified, ntot is ignored """ # Convert X-units to frequency in GHz xarr = xarr.as_unit('GHz') if tex is not None: if tex > tkin: # cannot have Tex > Tkin tex = tkin elif thin: # tex is not used in this case tex = tkin else: tex = tkin if thin: ntot = 1e15 elif 5 < ntot < 25: # allow ntot to be specified as a logarithm. This is # safe because ntot < 1e10 gives a spectrum of all zeros, and the # plausible range of columns is not outside the specified range ntot = 10**ntot elif (25 < ntot < 1e5) or (ntot < 5): # these are totally invalid for log/non-log return 0 # fillingfraction is an arbitrary scaling for the data # The model will be (normal model) * fillingfraction if fillingfraction is None: fillingfraction = 1.0 ckms = 2.99792458e5 ccms = ckms*1e5 g1 = 1 g2 = 1 h = 6.6260693e-27 kb = 1.3806505e-16 mu0 = 1.476e-18 # Dipole Moment in cgs (1.476 Debeye) # Generate Partition Functions nlevs = 51 jv=np.arange(nlevs) ortho = jv % 3 == 0 para = True-ortho Jpara = jv[para] Jortho = jv[ortho] Brot = 298117.06e6 Crot = 186726.36e6 runspec = np.zeros(len(xarr)) tau_dict = {} para_count = 0 ortho_count = 1 # ignore 0-0 if tau is not None and thin: """ Use optical depth in the 1-1 line as a free parameter The optical depths of the other lines are then set by the kinetic temperature Tex is still a free parameter in the final spectrum calculation at the bottom (technically, I think this process assumes LTE; Tex should come into play in these equations, not just the final one) """ dT0 = 41.5 # Energy diff between (2,2) and (1,1) in K trot = tkin/(1+tkin/dT0*np.log(1+0.6*np.exp(-15.7/tkin))) tau_dict['oneone'] = tau tau_dict['twotwo'] = tau*(23.722/23.694)**2*4/3.*5/3.*np.exp(-41.5/trot) tau_dict['threethree'] = tau*(23.8701279/23.694)**2*3/2.*14./3.*np.exp(-101.1/trot) tau_dict['fourfour'] = tau*(24.1394169/23.694)**2*8/5.*9/3.*np.exp(-177.34/trot) else: """ Column density is the free parameter. It is used in conjunction with the full partition function to compute the optical depth in each band Given the complexity of these equations, it would be worth my while to comment each step carefully. """ Zpara = (2*Jpara+1)*np.exp(-h*(Brot*Jpara*(Jpara+1)+ (Crot-Brot)*Jpara**2)/(kb*tkin)) Zortho = 2*(2*Jortho+1)*np.exp(-h*(Brot*Jortho*(Jortho+1)+ (Crot-Brot)*Jortho**2)/(kb*tkin)) for linename in line_names: if ortho_dict[linename]: orthoparafrac = fortho Z = Zortho count = ortho_count ortho_count += 1 else: orthoparafrac = 1.0-fortho Z = Zpara count = para_count # need to treat partition function separately para_count += 1 tau_dict[linename] = (ntot * orthoparafrac * Z[count]/(Z.sum()) / ( 1 + np.exp(-h*freq_dict[linename]/(kb*tkin) )) * ccms**2 / (8*np.pi*freq_dict[linename]**2) * aval_dict[linename]* (1-np.exp(-h*freq_dict[linename]/(kb*tex))) / (width/ckms*freq_dict[linename]*np.sqrt(2*np.pi)) ) # allow tau(11) to be specified instead of ntot # in the thin case, this is not needed: ntot plays no role # this process allows you to specify tau without using the approximate equations specified # above. It should remove ntot from the calculations anyway... if tau is not None and not thin: tau11_temp = tau_dict['oneone'] # re-scale all optical depths so that tau is as specified, but the relative taus # are sest by the kinetic temperature and partition functions for linename,t in tau_dict.iteritems(): tau_dict[linename] = t * tau/tau11_temp components =[] for linename in line_names: voff_lines = np.array(voff_lines_dict[linename]) tau_wts = np.array(tau_wts_dict[linename]) lines = (1-voff_lines/ckms)*freq_dict[linename]/1e9 tau_wts = tau_wts / (tau_wts).sum() nuwidth = np.abs(width/ckms*lines) nuoff = xoff_v/ckms*lines # tau array tauprof = np.zeros(len(xarr)) for kk,no in enumerate(nuoff): tauprof += (tau_dict[linename] * tau_wts[kk] * np.exp(-(xarr+no-lines[kk])**2 / (2.0*nuwidth[kk]**2)) * fillingfraction) components.append( tauprof ) T0 = (h*xarr*1e9/kb) # "temperature" of wavelength if tau is not None and thin: #runspec = tauprof+runspec # is there ever a case where you want to ignore the optical depth function? I think no runspec = (T0/(np.exp(T0/tex)-1)-T0/(np.exp(T0/2.73)-1))*(1-np.exp(-tauprof))+runspec else: runspec = (T0/(np.exp(T0/tex)-1)-T0/(np.exp(T0/2.73)-1))*(1-np.exp(-tauprof))+runspec if runspec.min() < 0: raise ValueError("Model dropped below zero. That is not possible normally. Here are the input values: "+ ("tex: %f " % tex) + ("tkin: %f " % tkin) + ("ntot: %f " % ntot) + ("width: %f " % width) + ("xoff_v: %f " % xoff_v) + ("fortho: %f " % fortho) ) if verbose or debug: print "tkin: %g tex: %g ntot: %g width: %g xoff_v: %g fortho: %g fillingfraction: %g" % (tkin,tex,ntot,width,xoff_v,fortho,fillingfraction) if return_components: return (T0/(np.exp(T0/tex)-1)-T0/(np.exp(T0/2.73)-1))*(1-np.exp(-1*np.array(components))) if return_tau: return tau_dict return runspec class ammonia_model(model.SpectralModel): def __init__(self,npeaks=1,npars=6,multisingle='multi',**kwargs): self.npeaks = npeaks self.npars = npars self._default_parnames = ['tkin','tex','ntot','width','xoff_v','fortho'] self.parnames = copy.copy(self._default_parnames) # all fitters must have declared modelfuncs, which should take the fitted pars... self.modelfunc = ammonia self.n_modelfunc = self.n_ammonia # for fitting ammonia simultaneously with a flat background self.onepeakammonia = fitter.vheightmodel(ammonia) #self.onepeakammoniafit = self._fourparfitter(self.onepeakammonia) if multisingle in ('multi','single'): self.multisingle = multisingle else: raise Exception("multisingle must be multi or single") self.default_parinfo = None self.default_parinfo, kwargs = self._make_parinfo(**kwargs) # enforce ammonia-specific parameter limits for par in self.default_parinfo: if 'tex' in par.parname.lower(): par.limited = (True,par.limited[1]) par.limits = (max(par.limits[0],2.73), par.limits[1]) if 'tkin' in par.parname.lower(): par.limited = (True,par.limited[1]) par.limits = (max(par.limits[0],2.73), par.limits[1]) if 'width' in par.parname.lower(): par.limited = (True,par.limited[1]) par.limits = (max(par.limits[0],0), par.limits[1]) if 'fortho' in par.parname.lower(): par.limited = (True,True) if par.limits[1] != 0: par.limits = (max(par.limits[0],0), min(par.limits[1],1)) else: par.limits = (max(par.limits[0],0), 1) if 'ntot' in par.parname.lower(): par.limited = (True,par.limited[1]) par.limits = (max(par.limits[0],0), par.limits[1]) self.parinfo = copy.copy(self.default_parinfo) self.modelfunc_kwargs = kwargs # lower case? self.modelfunc_kwargs.update({'parnames':self.parinfo.parnames}) def __call__(self,*args,**kwargs): #if 'use_lmfit' in kwargs: kwargs.pop('use_lmfit') use_lmfit = kwargs.pop('use_lmfit') if 'use_lmfit' in kwargs else self.use_lmfit if use_lmfit: return self.lmfitter(*args,**kwargs) if self.multisingle == 'single': return self.onepeakammoniafit(*args,**kwargs) elif self.multisingle == 'multi': return self.multinh3fit(*args,**kwargs) def n_ammonia(self, pars=None, parnames=None, **kwargs): """ Returns a function that sums over N ammonia line profiles, where N is the length of tkin,tex,ntot,width,xoff_v,fortho *OR* N = len(pars) / 6 The background "height" is assumed to be zero (you must "baseline" your spectrum before fitting) *pars* [ list ] a list with len(pars) = (6-nfixed)n, assuming tkin,tex,ntot,width,xoff_v,fortho repeated *parnames* [ list ] len(parnames) must = len(pars). parnames determine how the ammonia function parses the arguments """ if hasattr(pars,'values'): # important to treat as Dictionary, since lmfit params & parinfo both have .items parnames,parvals = zip(*pars.items()) parnames = [p.lower() for p in parnames] parvals = [p.value for p in parvals] elif parnames is None: parvals = pars parnames = self.parnames else: parvals = pars if len(pars) != len(parnames): # this should only be needed when other codes are changing the number of peaks # during a copy, as opposed to letting them be set by a __call__ # (n_modelfuncs = n_ammonia can be called directly) # n_modelfuncs doesn't care how many peaks there are if len(pars) % len(parnames) == 0: parnames = [p for ii in range(len(pars)/len(parnames)) for p in parnames] npars = len(parvals) / self.npeaks else: raise ValueError("Wrong array lengths passed to n_ammonia!") else: npars = len(parvals) / self.npeaks self._components = [] def L(x): v = np.zeros(len(x)) for jj in xrange(self.npeaks): modelkwargs = kwargs.copy() for ii in xrange(npars): name = parnames[ii+jj*npars].strip('0123456789').lower() modelkwargs.update({name:parvals[ii+jj*npars]}) v += ammonia(x,**modelkwargs) return v return L def components(self, xarr, pars, hyperfine=False): """ Ammonia components don't follow the default, since in Galactic astronomy the hyperfine components should be well-separated. If you want to see the individual components overlaid, you'll need to pass hyperfine to the plot_fit call """ comps=[] for ii in xrange(self.npeaks): if hyperfine: modelkwargs = dict(zip(self.parnames[ii*self.npars:(ii+1)*self.npars],pars[ii*self.npars:(ii+1)*self.npars])) comps.append( ammonia(xarr,return_components=True,**modelkwargs) ) else: modelkwargs = dict(zip(self.parnames[ii*self.npars:(ii+1)*self.npars],pars[ii*self.npars:(ii+1)*self.npars])) comps.append( [ammonia(xarr,return_components=False,**modelkwargs)] ) modelcomponents = np.concatenate(comps) return modelcomponents def multinh3fit(self, xax, data, npeaks=1, err=None, params=(20,20,14,1.0,0.0,0.5), parnames=None, fixed=(False,False,False,False,False,False), limitedmin=(True,True,True,True,False,True), limitedmax=(False,False,False,False,False,True), minpars=(2.73,2.73,0,0,0,0), parinfo=None, maxpars=(0,0,0,0,0,1), quiet=True, shh=True, veryverbose=False, **kwargs): """ Fit multiple nh3 profiles (multiple can be 1) Inputs: xax - x axis data - y axis npeaks - How many nh3 profiles to fit? Default 1 (this could supersede onedgaussfit) err - error corresponding to data These parameters need to have length = 6*npeaks. If npeaks > 1 and length = 6, they will be replicated npeaks times, otherwise they will be reset to defaults: params - Fit parameters: [tkin, tex, ntot (or tau), width, offset, ortho fraction] * npeaks If len(params) % 6 == 0, npeaks will be set to len(params) / 6 fixed - Is parameter fixed? limitedmin/minpars - set lower limits on each parameter (default: width>0, Tex and Tkin > Tcmb) limitedmax/maxpars - set upper limits on each parameter parnames - default parameter names, important for setting kwargs in model ['tkin','tex','ntot','width','xoff_v','fortho'] quiet - should MPFIT output each iteration? shh - output final parameters? Returns: Fit parameters Model Fit errors chi2 """ if parinfo is None: self.npars = len(params) / npeaks if len(params) != npeaks and (len(params) / self.npars) > npeaks: npeaks = len(params) / self.npars self.npeaks = npeaks if isinstance(params,np.ndarray): params=params.tolist() # this is actually a hack, even though it's decently elegant # somehow, parnames was being changed WITHOUT being passed as a variable # this doesn't make sense - at all - but it happened. # (it is possible for self.parnames to have npars*npeaks elements where # npeaks > 1 coming into this function even though only 6 pars are specified; # _default_parnames is the workaround) if parnames is None: parnames = copy.copy(self._default_parnames) partype_dict = dict(zip(['params','parnames','fixed','limitedmin','limitedmax','minpars','maxpars'], [params,parnames,fixed,limitedmin,limitedmax,minpars,maxpars])) # make sure all various things are the right length; if they're not, fix them using the defaults for partype,parlist in partype_dict.iteritems(): if len(parlist) != self.npars*self.npeaks: # if you leave the defaults, or enter something that can be multiplied by npars to get to the # right number of gaussians, it will just replicate if len(parlist) == self.npars: partype_dict[partype] *= npeaks elif len(parlist) > self.npars: # DANGER: THIS SHOULD NOT HAPPEN! print "WARNING! Input parameters were longer than allowed for variable ",parlist partype_dict[partype] = partype_dict[partype][:self.npars] elif parlist==params: # this instance shouldn't really be possible partype_dict[partype] = [20,20,1e10,1.0,0.0,0.5] * npeaks elif parlist==fixed: partype_dict[partype] = [False] * len(params) elif parlist==limitedmax: # only fortho, fillingfraction have upper limits partype_dict[partype] = (np.array(parnames) == 'fortho') + (np.array(parnames) == 'fillingfraction') elif parlist==limitedmin: # no physical values can be negative except velocity partype_dict[partype] = (np.array(parnames) != 'xoff_v') elif parlist==minpars: # all have minima of zero except kinetic temperature, which can't be below CMB. Excitation temperature technically can be, but not in this model partype_dict[partype] = ((np.array(parnames) == 'tkin') + (np.array(parnames) == 'tex')) * 2.73 elif parlist==maxpars: # fractions have upper limits of 1.0 partype_dict[partype] = ((np.array(parnames) == 'fortho') + (np.array(parnames) == 'fillingfraction')).astype('float') elif parlist==parnames: # assumes the right number of parnames (essential) partype_dict[partype] = list(parnames) * self.npeaks if len(parnames) != len(partype_dict['params']): raise ValueError("Wrong array lengths AFTER fixing them") # used in components. Is this just a hack? self.parnames = partype_dict['parnames'] parinfo = [ {'n':ii, 'value':partype_dict['params'][ii], 'limits':[partype_dict['minpars'][ii],partype_dict['maxpars'][ii]], 'limited':[partype_dict['limitedmin'][ii],partype_dict['limitedmax'][ii]], 'fixed':partype_dict['fixed'][ii], 'parname':partype_dict['parnames'][ii]+str(ii/self.npars), 'mpmaxstep':float(partype_dict['parnames'][ii] in ('tex','tkin')), # must force small steps in temperature (True = 1.0) 'error': 0} for ii in xrange(len(partype_dict['params'])) ] # hack: remove 'fixed' pars parinfo_with_fixed = parinfo parinfo = [p for p in parinfo_with_fixed if not p['fixed']] fixed_kwargs = dict((p['parname'].strip("0123456789").lower(),p['value']) for p in parinfo_with_fixed if p['fixed']) # don't do this - it breaks the NEXT call because npars != len(parnames) self.parnames = [p['parname'] for p in parinfo] # this is OK - not a permanent change parnames = [p['parname'] for p in parinfo] # not OK self.npars = len(parinfo)/self.npeaks parinfo = ParinfoList([Parinfo(p) for p in parinfo], preserve_order=True) #import pdb; pdb.set_trace() else: self.parinfo = ParinfoList([Parinfo(p) for p in parinfo], preserve_order=True) parinfo_with_fixed = None fixed_kwargs = {} fitfun_kwargs = dict(kwargs.items()+fixed_kwargs.items()) npars = len(parinfo)/self.npeaks # (fortho0 is not fortho) # this doesn't work if parinfo_with_fixed is not None: # this doesn't work for p in parinfo_with_fixed: # this doesn't work # users can change the defaults while holding them fixed # this doesn't work if p['fixed']: # this doesn't work kwargs.update({p['parname']:p['value']}) def mpfitfun(x,y,err): if err is None: def f(p,fjac=None): return [0,(y-self.n_ammonia(pars=p, parnames=parinfo.parnames, **fitfun_kwargs)(x))] else: def f(p,fjac=None): return [0,(y-self.n_ammonia(pars=p, parnames=parinfo.parnames, **fitfun_kwargs)(x))/err] return f if veryverbose: print "GUESSES: " print "\n".join(["%s: %s" % (p['parname'],p['value']) for p in parinfo]) mp = mpfit(mpfitfun(xax,data,err),parinfo=parinfo,quiet=quiet) mpp = mp.params if mp.perror is not None: mpperr = mp.perror else: mpperr = mpp*0 chi2 = mp.fnorm if mp.status == 0: raise Exception(mp.errmsg) for i,p in enumerate(mpp): parinfo[i]['value'] = p parinfo[i]['error'] = mpperr[i] if not shh: print "Fit status: ",mp.status print "Fit message: ",mp.errmsg print "Final fit values: " for i,p in enumerate(mpp): print parinfo[i]['parname'],p," +/- ",mpperr[i] print "Chi2: ",mp.fnorm," Reduced Chi2: ",mp.fnorm/len(data)," DOF:",len(data)-len(mpp) if any(['tex' in s for s in parnames]) and any(['tkin' in s for s in parnames]): texnum = (i for i,s in enumerate(parnames) if 'tex' in s) tkinnum = (i for i,s in enumerate(parnames) if 'tkin' in s) for txn,tkn in zip(texnum,tkinnum): if mpp[txn] > mpp[tkn]: mpp[txn] = mpp[tkn] # force Tex>Tkin to Tex=Tkin (already done in n_ammonia) self.mp = mp if parinfo_with_fixed is not None: # self self.parinfo preserving the 'fixed' parameters # ORDER MATTERS! for p in parinfo: parinfo_with_fixed[p['n']] = p self.parinfo = ParinfoList([Parinfo(p) for p in parinfo_with_fixed], preserve_order=True) else: self.parinfo = parinfo self.parinfo = ParinfoList([Parinfo(p) for p in parinfo], preserve_order=True) # I don't THINK these are necessary? #self.parinfo = parinfo #self.parinfo = ParinfoList([Parinfo(p) for p in self.parinfo]) # need to restore the fixed parameters.... # though the above commented out section indicates that I've done and undone this dozens of times now # (a test has been added to test_nh3.py) # this was NEVER included or tested because it breaks the order #for par in parinfo_with_fixed: # if par.parname not in self.parinfo.keys(): # self.parinfo.append(par) self.mpp = self.parinfo.values self.mpperr = self.parinfo.errors self.mppnames = self.parinfo.names self.model = self.n_ammonia(pars=self.mpp, parnames=self.mppnames, **kwargs)(xax) #if self.model.sum() == 0: # print "DON'T FORGET TO REMOVE THIS ERROR!" # raise ValueError("Model is zeros.") indiv_parinfo = [self.parinfo[jj*self.npars:(jj+1)*self.npars] for jj in xrange(len(self.parinfo)/self.npars)] modelkwargs = [ dict([(p['parname'].strip("0123456789").lower(),p['value']) for p in pi]) for pi in indiv_parinfo] self.tau_list = [ammonia(xax,return_tau=True,**mk) for mk in modelkwargs] return self.mpp,self.model,self.mpperr,chi2 def moments(self, Xax, data, negamp=None, veryverbose=False, **kwargs): """ Returns a very simple and likely incorrect guess """ # TKIN, TEX, ntot, width, center, ortho fraction return [20,10, 1e15, 1.0, 0.0, 1.0] def annotations(self): from decimal import Decimal # for formatting tex_key = {'tkin':'T_K','tex':'T_{ex}','ntot':'N','fortho':'F_o','width':'\\sigma','xoff_v':'v','fillingfraction':'FF','tau':'\\tau_{1-1}'} # small hack below: don't quantize if error > value. We want to see the values. label_list = [] for pinfo in self.parinfo: parname = tex_key[pinfo['parname'].strip("0123456789").lower()] parnum = int(pinfo['parname'][-1]) if pinfo['fixed']: formatted_value = "%s" % pinfo['value'] pm = "" formatted_error="" else: formatted_value = Decimal("%g" % pinfo['value']).quantize(Decimal("%0.2g" % (min(pinfo['error'],pinfo['value'])))) pm = "$\\pm$" formatted_error = Decimal("%g" % pinfo['error']).quantize(Decimal("%0.2g" % pinfo['error'])) label = "$%s(%i)$=%8s %s %8s" % (parname, parnum, formatted_value, pm, formatted_error) label_list.append(label) labels = tuple(mpcb.flatten(label_list)) return labels class ammonia_model_vtau(ammonia_model): def __init__(self,**kwargs): super(ammonia_model_vtau,self).__init__() self.parnames = ['tkin','tex','tau','width','xoff_v','fortho'] def moments(self, Xax, data, negamp=None, veryverbose=False, **kwargs): """ Returns a very simple and likely incorrect guess """ # TKIN, TEX, ntot, width, center, ortho fraction return [20,10, 1, 1.0, 0.0, 1.0] def __call__(self,*args,**kwargs): if self.multisingle == 'single': return self.onepeakammoniafit(*args,**kwargs) elif self.multisingle == 'multi': return self.multinh3fit(*args,**kwargs)
mit
[ 624, 199, 2486, 763, 199, 33, 596, 265, 4674, 315, 1023, 14116, 377, 43, 568, 5542, 351, 199, 2486, 763, 199, 199, 33, 596, 265, 4674, 315, 1023, 14116, 377, 43, 568, 5542, 351, 14598, 687, 662, 25844, 820, 736, 79, 674, 12267, 1159, 199, 1014, 921, 6836, 14, 745, 14, 9870, 14, 696, 15, 6836, 15, 10458, 15, 29199, 19, 3269, 15, 199, 199, 703, 28966, 447, 4431, 455, 598, 3617, 29291, 665, 27679, 14, 71, 14, 903, 9264, 17629, 32, 6799, 14, 957, 30, 199, 199, 2377, 3261, 199, 19628, 19628, 11871, 199, 199, 624, 199, 646, 2680, 465, 980, 199, 504, 10382, 321, 346, 390, 14, 311, 3269, 492, 6118, 3269, 199, 504, 10382, 321, 346, 390, 14, 18142, 14, 462, 815, 492, 2235, 815, 1296, 12, 1262, 815, 199, 646, 5542, 351, 199, 646, 8027, 14, 67, 2706, 465, 6118, 2894, 199, 646, 1331, 199, 646, 1402, 421, 199, 604, 63, 1247, 275, 788, 368, 368, 1673, 8122, 357, 2027, 1673, 10480, 10480, 1673, 13672, 13672, 418, 199, 199, 5646, 63, 807, 275, 469, 5591, 283, 368, 368, 356, 258, 6546, 14, 19421, 13725, 69, 25, 12, 272, 283, 8122, 357, 2027, 356, 258, 6546, 14, 23, 11085, 6772, 21, 69, 25, 12, 272, 283, 10480, 10480, 356, 6546, 14, 1555, 614, 11700, 69, 25, 12, 272, 283, 13672, 13672, 356, 257, 5504, 14, 26980, 10143, 69, 25, 12, 272, 789, 199, 65, 637, 63, 807, 275, 469, 272, 283, 368, 368, 356, 258, 413, 14, 29527, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 845, 538, 19, 10, 6553, 16, 538, 18, 5830, 17, 15, 18, 4959, 272, 283, 8122, 357, 2027, 356, 258, 499, 14, 16319, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 1081, 538, 19, 10, 6553, 16, 538, 18, 5830, 18, 15, 19, 4959, 272, 283, 10480, 10480, 356, 499, 14, 22475, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 1153, 538, 19, 10, 6553, 16, 538, 18, 5830, 19, 15, 20, 4959, 272, 283, 13672, 13672, 356, 257, 650, 14, 10806, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 1602, 538, 19, 10, 6553, 16, 538, 18, 5830, 20, 15, 21, 4959, 272, 789, 199, 11297, 79, 63, 807, 275, 469, 272, 283, 368, 368, 356, 258, 756, 12, 272, 283, 8122, 357, 2027, 356, 258, 756, 12, 272, 283, 10480, 10480, 356, 715, 12, 272, 283, 13672, 13672, 356, 257, 756, 12, 272, 789, 199, 78, 63, 11297, 79, 275, 980, 14, 5605, 8, 16, 12, 1651, 12, 19, 9, 327, 378, 703, 19, 703, 1465, 199, 78, 63, 12227, 275, 980, 14, 1144, 779, 88, 367, 671, 315, 1425, 8, 1651, 9, 340, 671, 450, 650, 1137, 378, 566, 199, 199, 86, 1997, 63, 1278, 63, 807, 275, 469, 272, 283, 368, 368, 356, 359, 1167, 14, 2426, 969, 12, 5851, 14, 19, 9327, 12, 1520, 14, 31830, 1876, 12, 1520, 14, 16112, 1822, 12, 1520, 14, 1276, 6557, 12, 378, 14, 2466, 966, 1643, 12, 378, 14, 708, 6686, 18, 12, 267, 446, 16, 14, 19339, 975, 1257, 12, 446, 16, 14, 14271, 8262, 12, 378, 14, 2192, 709, 1082, 12, 378, 14, 1167, 1081, 1272, 12, 446, 16, 14, 6557, 16244, 12, 446, 16, 14, 821, 1643, 1789, 12, 446, 23, 14, 1789, 11991, 12, 267, 446, 23, 14, 15541, 1257, 12, 446, 23, 14, 28250, 1479, 12, 446, 1167, 14, 20, 7362, 12, 446, 1167, 14, 1229, 383, 467, 272, 283, 8122, 357, 2027, 15211, 1479, 14, 21, 14622, 12, 7875, 14, 28107, 12, 5661, 14, 25, 13938, 12, 3193, 14, 1355, 1196, 12, 3193, 14, 1401, 3129, 12, 4114, 14, 24, 15463, 12, 378, 14, 1367, 821, 1644, 12, 267, 378, 14, 2528, 1349, 2036, 12, 378, 14, 30730, 17007, 12, 378, 14, 614, 12870, 1165, 12, 446, 16, 14, 383, 12015, 1960, 12, 446, 16, 14, 614, 12870, 1165, 12, 446, 16, 14, 8216, 24, 2192, 12, 267, 446, 16, 14, 2481, 969, 2167, 12, 446, 16, 14, 21, 13173, 1257, 12, 446, 1046, 14, 24, 16710, 12, 446, 975, 14, 1344, 2905, 12, 446, 975, 14, 1703, 1081, 12, 446, 821, 14, 25, 13938, 12, 446, 1479, 14, 28107, 12, 267, 446, 1479, 14, 21, 14622, 467, 272, 283, 10480, 10480, 15211, 1398, 14, 1167, 1400, 2905, 12, 7349, 14, 9111, 11160, 12, 7294, 14, 2635, 1085, 1138, 12, 7294, 14, 25, 7636, 2036, 12, 7829, 14, 5533, 32096, 12, 267, 7829, 14, 6886, 30270, 12, 7829, 14, 969, 2766, 1555, 12, 7829, 14, 2036, 1342, 1367, 12, 413, 14, 7972, 7507, 12, 378, 14, 11901, 19171, 12, 378, 14, 1138, 1257, 2789, 12, 267, 378, 14, 22, 1651, 15143, 12, 378, 14, 614, 1822, 1477, 12, 446, 16, 14, 30760, 1407, 12, 446, 16, 14, 614, 1082, 614, 12, 446, 16, 14, 22, 13145, 1082, 12, 446, 16, 14, 1342, 13267, 20, 12, 267, 446, 17, 14, 1644, 1167, 1194, 12, 446, 2025, 14, 6889, 9485, 12, 446, 2025, 14, 1165, 1082, 2953, 12, 446, 2025, 14, 11583, 11228, 12, 446, 2025, 14, 21439, 16319, 12, 446, 1651, 14, 2710, 1257, 1822, 12, 267, 446, 1651, 14, 25, 13846, 1789, 12, 446, 1398, 14, 966, 1780, 2635, 12, 446, 1398, 14, 1167, 1196, 1602, 467, 272, 283, 13672, 13672, 15211, 221, 378, 14, 263, 2360, 446, 1216, 14, 1887, 2277, 1344, 2942, 12, 221, 4233, 14, 1887, 2277, 1344, 2942, 12, 257, 378, 2020, 5504, 14, 11990, 19226, 845, 12, 267, 446, 1194, 14, 11990, 19226, 845, 12, 257, 378, 14, 263, 1622, 1993, 789, 199, 199, 16656, 63, 87, 1086, 63, 807, 275, 469, 272, 283, 368, 368, 356, 359, 16, 14, 16, 17702, 17702, 12, 378, 14, 10834, 10834, 12, 378, 14, 1643, 11990, 1216, 12, 378, 14, 975, 30303, 12, 378, 14, 614, 2426, 12205, 12 ]
[ 199, 2486, 763, 199, 33, 596, 265, 4674, 315, 1023, 14116, 377, 43, 568, 5542, 351, 199, 2486, 763, 199, 199, 33, 596, 265, 4674, 315, 1023, 14116, 377, 43, 568, 5542, 351, 14598, 687, 662, 25844, 820, 736, 79, 674, 12267, 1159, 199, 1014, 921, 6836, 14, 745, 14, 9870, 14, 696, 15, 6836, 15, 10458, 15, 29199, 19, 3269, 15, 199, 199, 703, 28966, 447, 4431, 455, 598, 3617, 29291, 665, 27679, 14, 71, 14, 903, 9264, 17629, 32, 6799, 14, 957, 30, 199, 199, 2377, 3261, 199, 19628, 19628, 11871, 199, 199, 624, 199, 646, 2680, 465, 980, 199, 504, 10382, 321, 346, 390, 14, 311, 3269, 492, 6118, 3269, 199, 504, 10382, 321, 346, 390, 14, 18142, 14, 462, 815, 492, 2235, 815, 1296, 12, 1262, 815, 199, 646, 5542, 351, 199, 646, 8027, 14, 67, 2706, 465, 6118, 2894, 199, 646, 1331, 199, 646, 1402, 421, 199, 604, 63, 1247, 275, 788, 368, 368, 1673, 8122, 357, 2027, 1673, 10480, 10480, 1673, 13672, 13672, 418, 199, 199, 5646, 63, 807, 275, 469, 5591, 283, 368, 368, 356, 258, 6546, 14, 19421, 13725, 69, 25, 12, 272, 283, 8122, 357, 2027, 356, 258, 6546, 14, 23, 11085, 6772, 21, 69, 25, 12, 272, 283, 10480, 10480, 356, 6546, 14, 1555, 614, 11700, 69, 25, 12, 272, 283, 13672, 13672, 356, 257, 5504, 14, 26980, 10143, 69, 25, 12, 272, 789, 199, 65, 637, 63, 807, 275, 469, 272, 283, 368, 368, 356, 258, 413, 14, 29527, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 845, 538, 19, 10, 6553, 16, 538, 18, 5830, 17, 15, 18, 4959, 272, 283, 8122, 357, 2027, 356, 258, 499, 14, 16319, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 1081, 538, 19, 10, 6553, 16, 538, 18, 5830, 18, 15, 19, 4959, 272, 283, 10480, 10480, 356, 499, 14, 22475, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 1153, 538, 19, 10, 6553, 16, 538, 18, 5830, 19, 15, 20, 4959, 272, 283, 13672, 13672, 356, 257, 650, 14, 10806, 69, 13, 23, 12, 221, 327, 772, 10, 1, 1038, 538, 20, 7985, 19, 10, 72, 10, 67, 538, 19, 3342, 4850, 1602, 538, 19, 10, 6553, 16, 538, 18, 5830, 20, 15, 21, 4959, 272, 789, 199, 11297, 79, 63, 807, 275, 469, 272, 283, 368, 368, 356, 258, 756, 12, 272, 283, 8122, 357, 2027, 356, 258, 756, 12, 272, 283, 10480, 10480, 356, 715, 12, 272, 283, 13672, 13672, 356, 257, 756, 12, 272, 789, 199, 78, 63, 11297, 79, 275, 980, 14, 5605, 8, 16, 12, 1651, 12, 19, 9, 327, 378, 703, 19, 703, 1465, 199, 78, 63, 12227, 275, 980, 14, 1144, 779, 88, 367, 671, 315, 1425, 8, 1651, 9, 340, 671, 450, 650, 1137, 378, 566, 199, 199, 86, 1997, 63, 1278, 63, 807, 275, 469, 272, 283, 368, 368, 356, 359, 1167, 14, 2426, 969, 12, 5851, 14, 19, 9327, 12, 1520, 14, 31830, 1876, 12, 1520, 14, 16112, 1822, 12, 1520, 14, 1276, 6557, 12, 378, 14, 2466, 966, 1643, 12, 378, 14, 708, 6686, 18, 12, 267, 446, 16, 14, 19339, 975, 1257, 12, 446, 16, 14, 14271, 8262, 12, 378, 14, 2192, 709, 1082, 12, 378, 14, 1167, 1081, 1272, 12, 446, 16, 14, 6557, 16244, 12, 446, 16, 14, 821, 1643, 1789, 12, 446, 23, 14, 1789, 11991, 12, 267, 446, 23, 14, 15541, 1257, 12, 446, 23, 14, 28250, 1479, 12, 446, 1167, 14, 20, 7362, 12, 446, 1167, 14, 1229, 383, 467, 272, 283, 8122, 357, 2027, 15211, 1479, 14, 21, 14622, 12, 7875, 14, 28107, 12, 5661, 14, 25, 13938, 12, 3193, 14, 1355, 1196, 12, 3193, 14, 1401, 3129, 12, 4114, 14, 24, 15463, 12, 378, 14, 1367, 821, 1644, 12, 267, 378, 14, 2528, 1349, 2036, 12, 378, 14, 30730, 17007, 12, 378, 14, 614, 12870, 1165, 12, 446, 16, 14, 383, 12015, 1960, 12, 446, 16, 14, 614, 12870, 1165, 12, 446, 16, 14, 8216, 24, 2192, 12, 267, 446, 16, 14, 2481, 969, 2167, 12, 446, 16, 14, 21, 13173, 1257, 12, 446, 1046, 14, 24, 16710, 12, 446, 975, 14, 1344, 2905, 12, 446, 975, 14, 1703, 1081, 12, 446, 821, 14, 25, 13938, 12, 446, 1479, 14, 28107, 12, 267, 446, 1479, 14, 21, 14622, 467, 272, 283, 10480, 10480, 15211, 1398, 14, 1167, 1400, 2905, 12, 7349, 14, 9111, 11160, 12, 7294, 14, 2635, 1085, 1138, 12, 7294, 14, 25, 7636, 2036, 12, 7829, 14, 5533, 32096, 12, 267, 7829, 14, 6886, 30270, 12, 7829, 14, 969, 2766, 1555, 12, 7829, 14, 2036, 1342, 1367, 12, 413, 14, 7972, 7507, 12, 378, 14, 11901, 19171, 12, 378, 14, 1138, 1257, 2789, 12, 267, 378, 14, 22, 1651, 15143, 12, 378, 14, 614, 1822, 1477, 12, 446, 16, 14, 30760, 1407, 12, 446, 16, 14, 614, 1082, 614, 12, 446, 16, 14, 22, 13145, 1082, 12, 446, 16, 14, 1342, 13267, 20, 12, 267, 446, 17, 14, 1644, 1167, 1194, 12, 446, 2025, 14, 6889, 9485, 12, 446, 2025, 14, 1165, 1082, 2953, 12, 446, 2025, 14, 11583, 11228, 12, 446, 2025, 14, 21439, 16319, 12, 446, 1651, 14, 2710, 1257, 1822, 12, 267, 446, 1651, 14, 25, 13846, 1789, 12, 446, 1398, 14, 966, 1780, 2635, 12, 446, 1398, 14, 1167, 1196, 1602, 467, 272, 283, 13672, 13672, 15211, 221, 378, 14, 263, 2360, 446, 1216, 14, 1887, 2277, 1344, 2942, 12, 221, 4233, 14, 1887, 2277, 1344, 2942, 12, 257, 378, 2020, 5504, 14, 11990, 19226, 845, 12, 267, 446, 1194, 14, 11990, 19226, 845, 12, 257, 378, 14, 263, 1622, 1993, 789, 199, 199, 16656, 63, 87, 1086, 63, 807, 275, 469, 272, 283, 368, 368, 356, 359, 16, 14, 16, 17702, 17702, 12, 378, 14, 10834, 10834, 12, 378, 14, 1643, 11990, 1216, 12, 378, 14, 975, 30303, 12, 378, 14, 614, 2426, 12205, 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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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 ]
Yelp/pootle
tests/import_export/import.py
1
1745
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) Pootle contributors. # # This file is a part of the Pootle project. It is distributed under the GPL3 # or later license. See the LICENSE file for a copy of the license and the # AUTHORS file for copyright and authorship information. import os import pytest from django.core.files.uploadedfile import SimpleUploadedFile from import_export.utils import import_file from import_export.exceptions import UnsupportedFiletypeError from pootle_store.models import NEW, PARSED, Store TEST_PO_DIR = "tests/data/po/tutorial/en" IMPORT_SUCCESS = "headers_correct.po" IMPORT_UNSUPP_FILE = "tutorial.ts" def _import_file(file_name, file_dir=TEST_PO_DIR, content_type="text/x-gettext-translation"): with open(os.path.join(file_dir, file_name), "r") as f: import_file(SimpleUploadedFile(file_name, f.read(), content_type)) @pytest.mark.django_db def test_import_success(en_tutorial_po_no_file): assert en_tutorial_po_no_file.state == NEW _import_file(IMPORT_SUCCESS) store = Store.objects.get(pk=en_tutorial_po_no_file.pk) assert store.state == PARSED @pytest.mark.django_db def test_import_failure(file_import_failure, en_tutorial_po): filename, exception = file_import_failure with pytest.raises(exception): _import_file(filename) @pytest.mark.django_db def test_import_unsupported(en_tutorial_ts, ts_directory): with pytest.raises(UnsupportedFiletypeError): _import_file(IMPORT_UNSUPP_FILE, file_dir=os.path.join(ts_directory, "tutorial/en"), content_type="text/vnd.trolltech.linguist")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 4376, 24629, 8417, 14, 199, 3, 199, 3, 961, 570, 365, 282, 1777, 402, 314, 4376, 24629, 2199, 14, 2779, 365, 1854, 1334, 314, 14629, 19, 199, 3, 503, 2945, 4190, 14, 1666, 314, 5113, 570, 367, 282, 1331, 402, 314, 4190, 436, 314, 199, 3, 10610, 570, 367, 4248, 436, 4132, 3319, 2556, 14, 199, 199, 646, 747, 199, 646, 4613, 199, 199, 504, 1639, 14, 1018, 14, 1725, 14, 19044, 493, 492, 5870, 24665, 199, 199, 504, 492, 63, 3790, 14, 1208, 492, 492, 63, 493, 199, 504, 492, 63, 3790, 14, 3924, 492, 19022, 1173, 466, 547, 199, 504, 1115, 24629, 63, 1617, 14, 992, 492, 18689, 12, 10263, 10934, 12, 13874, 421, 199, 2864, 63, 1512, 63, 3022, 275, 298, 2219, 15, 576, 15, 555, 15, 23561, 15, 287, 2, 199, 17576, 63, 12779, 275, 298, 2139, 63, 4525, 14, 555, 2, 199, 17576, 63, 1734, 7380, 48, 63, 3817, 275, 298, 23561, 14, 1086, 2, 421, 199, 318, 485, 646, 63, 493, 8, 493, 63, 354, 12, 570, 63, 694, 29, 2864, 63, 1512, 63, 3022, 12, 326, 1564, 63, 466, 628, 505, 15, 88, 13, 5152, 13, 6893, 2349, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 493, 63, 694, 12, 570, 63, 354, 395, 298, 82, 531, 465, 289, 26, 267, 492, 63, 493, 8, 3184, 24665, 8, 493, 63, 354, 12, 4318, 289, 14, 739, 1062, 4318, 1564, 63, 466, 430, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 646, 63, 3742, 8, 287, 63, 23561, 63, 555, 63, 889, 63, 493, 304, 272, 702, 655, 63, 23561, 63, 555, 63, 889, 63, 493, 14, 929, 508, 18689, 272, 485, 646, 63, 493, 8, 17576, 63, 12779, 9, 272, 3877, 275, 13874, 14, 1462, 14, 362, 8, 2051, 29, 287, 63, 23561, 63, 555, 63, 889, 63, 493, 14, 2051, 9, 272, 702, 3877, 14, 929, 508, 10263, 10934, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 646, 63, 5328, 8, 493, 63, 646, 63, 5328, 12, 655, 63, 23561, 63, 555, 304, 272, 1788, 12, 1919, 275, 570, 63, 646, 63, 5328, 272, 543, 4613, 14, 3536, 8, 1971, 304, 267, 485, 646, 63, 493, 8, 1501, 9, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 646, 63, 15267, 8, 287, 63, 23561, 63, 1086, 12, 6714, 63, 3619, 304, 272, 543, 4613, 14, 3536, 8, 12647, 1173, 466, 547, 304, 267, 485, 646, 63, 493, 8, 17576, 63, 1734, 7380, 48, 63, 3817, 12, 2151, 570, 63, 694, 29, 736, 14, 515, 14, 904, 8, 1086, 63, 3619, 12, 298, 23561, 15, 287, 1288, 2151, 1564, 63, 466, 628, 505, 15, 26379, 14, 1374, 914, 15970, 14, 2983, 85, 631, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 4376, 24629, 8417, 14, 199, 3, 199, 3, 961, 570, 365, 282, 1777, 402, 314, 4376, 24629, 2199, 14, 2779, 365, 1854, 1334, 314, 14629, 19, 199, 3, 503, 2945, 4190, 14, 1666, 314, 5113, 570, 367, 282, 1331, 402, 314, 4190, 436, 314, 199, 3, 10610, 570, 367, 4248, 436, 4132, 3319, 2556, 14, 199, 199, 646, 747, 199, 646, 4613, 199, 199, 504, 1639, 14, 1018, 14, 1725, 14, 19044, 493, 492, 5870, 24665, 199, 199, 504, 492, 63, 3790, 14, 1208, 492, 492, 63, 493, 199, 504, 492, 63, 3790, 14, 3924, 492, 19022, 1173, 466, 547, 199, 504, 1115, 24629, 63, 1617, 14, 992, 492, 18689, 12, 10263, 10934, 12, 13874, 421, 199, 2864, 63, 1512, 63, 3022, 275, 298, 2219, 15, 576, 15, 555, 15, 23561, 15, 287, 2, 199, 17576, 63, 12779, 275, 298, 2139, 63, 4525, 14, 555, 2, 199, 17576, 63, 1734, 7380, 48, 63, 3817, 275, 298, 23561, 14, 1086, 2, 421, 199, 318, 485, 646, 63, 493, 8, 493, 63, 354, 12, 570, 63, 694, 29, 2864, 63, 1512, 63, 3022, 12, 326, 1564, 63, 466, 628, 505, 15, 88, 13, 5152, 13, 6893, 2349, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 493, 63, 694, 12, 570, 63, 354, 395, 298, 82, 531, 465, 289, 26, 267, 492, 63, 493, 8, 3184, 24665, 8, 493, 63, 354, 12, 4318, 289, 14, 739, 1062, 4318, 1564, 63, 466, 430, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 646, 63, 3742, 8, 287, 63, 23561, 63, 555, 63, 889, 63, 493, 304, 272, 702, 655, 63, 23561, 63, 555, 63, 889, 63, 493, 14, 929, 508, 18689, 272, 485, 646, 63, 493, 8, 17576, 63, 12779, 9, 272, 3877, 275, 13874, 14, 1462, 14, 362, 8, 2051, 29, 287, 63, 23561, 63, 555, 63, 889, 63, 493, 14, 2051, 9, 272, 702, 3877, 14, 929, 508, 10263, 10934, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 646, 63, 5328, 8, 493, 63, 646, 63, 5328, 12, 655, 63, 23561, 63, 555, 304, 272, 1788, 12, 1919, 275, 570, 63, 646, 63, 5328, 272, 543, 4613, 14, 3536, 8, 1971, 304, 267, 485, 646, 63, 493, 8, 1501, 9, 421, 199, 32, 4462, 14, 1657, 14, 1176, 63, 697, 199, 318, 511, 63, 646, 63, 15267, 8, 287, 63, 23561, 63, 1086, 12, 6714, 63, 3619, 304, 272, 543, 4613, 14, 3536, 8, 12647, 1173, 466, 547, 304, 267, 485, 646, 63, 493, 8, 17576, 63, 1734, 7380, 48, 63, 3817, 12, 2151, 570, 63, 694, 29, 736, 14, 515, 14, 904, 8, 1086, 63, 3619, 12, 298, 23561, 15, 287, 1288, 2151, 1564, 63, 466, 628, 505, 15, 26379, 14, 1374, 914, 15970, 14, 2983, 85, 631, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jakobj/nest-simulator
pynest/nest/tests/test_urbanczik_synapse.py
14
9912
# -*- coding: utf-8 -*- # # test_urbanczik_synapse.py # # This file is part of NEST. # # Copyright (C) 2004 The NEST Initiative # # NEST is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # NEST 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 NEST. If not, see <http://www.gnu.org/licenses/>. """ Test functionality of the Urbanczik synapse """ import unittest import nest import numpy as np HAVE_GSL = nest.ll_api.sli_func("statusdict/have_gsl ::") @nest.ll_api.check_stack @unittest.skipIf(not HAVE_GSL, 'GSL is not available') class UrbanczikSynapseTestCase(unittest.TestCase): """Test Urbanczik synapse""" def test_ConnectNeuronsWithUrbanczikSynapse(self): """Ensures that the restriction to supported neuron models works.""" nest.set_verbosity('M_WARNING') # Multi-compartment models mc_models = [ "iaf_cond_alpha_mc", "pp_cond_exp_mc_urbanczik", ] # Supported models supported_models = [ "pp_cond_exp_mc_urbanczik", ] # Compute not supported models not_supported_models = [n for n in nest.Models(mtype='nodes') if n not in supported_models] # Connect supported models with Urbanczik synapse for nm in supported_models: nest.ResetKernel() r_type = 0 if nm in mc_models: syns = nest.GetDefaults(nm)["receptor_types"] r_type = syns["soma_exc"] n = nest.Create(nm, 2) nest.Connect(n, n, {"rule": "all_to_all"}, {"synapse_model": "urbanczik_synapse", "receptor_type": r_type}) # Ensure that connecting not supported models fails for nm in not_supported_models: nest.ResetKernel() r_type = 0 if nm in mc_models: syns = nest.GetDefaults(nm)["receptor_types"] r_type = syns["soma_exc"] n = nest.Create(nm, 2) # try to connect with urbanczik synapse with self.assertRaises(nest.kernel.NESTError): nest.Connect(n, n, {"rule": "all_to_all"}, {"synapse_model": "urbanczik_synapse", "receptor_type": r_type}) def test_SynapseDepressionFacilitation(self): """Ensure that depression and facilitation work correctly""" nest.set_verbosity('M_WARNING') nest.ResetKernel() resolution = 0.1 nest.SetKernelStatus({'resolution': resolution}) ''' neuron parameters ''' nrn_model = 'pp_cond_exp_mc_urbanczik' nrn_params = { 't_ref': 3.0, # refractory period 'g_sp': 600.0, # somato-dendritic coupling conductance 'soma': { 'V_m': -70.0, # initial value of V_m 'C_m': 300.0, # capacitance of membrane 'E_L': -70.0, # resting potential 'g_L': 30.0, # somatic leak conductance 'E_ex': 0.0, # resting potential for exc input 'E_in': -75.0, # resting potential for inh input 'tau_syn_ex': 3.0, # time constant of exc conductance 'tau_syn_in': 3.0, # time constant of inh conductance }, 'dendritic': { 'V_m': -70.0, # initial value of V_m 'C_m': 300.0, # capacitance of membrane 'E_L': -70.0, # resting potential 'g_L': 30.0, # dendritic leak conductance 'tau_syn_ex': 3.0, # time constant of exc input current 'tau_syn_in': 3.0, # time constant of inh input current }, # parameters of rate function 'phi_max': 0.15, # max rate 'rate_slope': 0.5, # called 'k' in the paper 'beta': 1.0 / 3.0, 'theta': -55.0, } ''' synapse params ''' syns = nest.GetDefaults(nrn_model)['receptor_types'] init_w = 100.0 syn_params = { 'synapse_model': 'urbanczik_synapse_wr', 'receptor_type': syns['dendritic_exc'], 'tau_Delta': 100.0, # time constant of low pass filtering of the weight change 'eta': 0.75, # learning rate 'weight': init_w, 'Wmax': 4.5*nrn_params['dendritic']['C_m'], 'delay': resolution, } ''' neuron and devices ''' nest.SetDefaults(nrn_model, nrn_params) nrn = nest.Create(nrn_model) # spike generator is connected to a parrot neuron which is connected to the mc neuron prrt_nrn = nest.Create('parrot_neuron') # excitatory input to the dendrite pre_syn_spike_times = np.array([1.0, 98.0]) sg_prox = nest.Create('spike_generator', params={ 'spike_times': pre_syn_spike_times}) # excitatory input to the soma spike_times_soma_inp = np.arange(10.0, 50.0, resolution) spike_weights_soma = 10.0*np.ones_like(spike_times_soma_inp) sg_soma_exc = nest.Create('spike_generator', params={'spike_times': spike_times_soma_inp, 'spike_weights': spike_weights_soma}) # for recording all parameters of the Urbanczik neuron rqs = nest.GetDefaults(nrn_model)['recordables'] mm = nest.Create('multimeter', params={ 'record_from': rqs, 'interval': 0.1}) # for recoding the synaptic weights of the Urbanczik synapses wr = nest.Create('weight_recorder') # for recording the spiking of the soma sr_soma = nest.Create('spike_recorder') ''' create connections ''' nest.Connect(sg_prox, prrt_nrn, syn_spec={'delay': resolution}) nest.CopyModel('urbanczik_synapse', 'urbanczik_synapse_wr', {'weight_recorder': wr[0]}) nest.Connect(prrt_nrn, nrn, syn_spec=syn_params) nest.Connect(sg_soma_exc, nrn, syn_spec={'receptor_type': syns['soma_exc'], 'weight': 10.0*resolution, 'delay': resolution}) nest.Connect(mm, nrn, syn_spec={'delay': resolution}) nest.Connect(nrn, sr_soma, syn_spec={'delay': resolution}) ''' simulation ''' nest.Simulate(100.0) ''' read out devices ''' # multimeter rec = nest.GetStatus(mm)[0]['events'] t = rec['times'] V_w = rec['V_m.p'] # compute dendritic prediction of somatic membrane potential g_D = nrn_params['g_sp'] g_L = nrn_params['soma']['g_L'] E_L = nrn_params['soma']['E_L'] V_w_star = (g_L*E_L + g_D*V_w) / (g_L + g_D) # weight recorder data = nest.GetStatus(wr) senders = data[0]['events']['senders'] targets = data[0]['events']['targets'] weights = data[0]['events']['weights'] times = data[0]['events']['times'] # spike recorder data = nest.GetStatus(sr_soma)[0]['events'] spike_times_soma = data['times'] # compute predicted rate phi_max = nrn_params['phi_max'] k = nrn_params['rate_slope'] beta = nrn_params['beta'] theta = nrn_params['theta'] rate = (phi_max / (1.0 + k*np.exp(beta*(theta - V_w_star)))) # compute h(V_w_star) h = (15.0*beta / (1.0 + np.exp(-beta*(theta - V_w_star)) / k)) # compute alpha response kernel tau_s = nrn_params['dendritic']['tau_syn_ex'] g_L_prox = nrn_params['dendritic']['g_L'] C_m_prox = nrn_params['dendritic']['C_m'] tau_L = C_m_prox / g_L_prox E_L_prox = nrn_params['dendritic']['E_L'] t0 = 1.2 alpha_response = (np.heaviside(t - t0, 0.5)*tau_s*(np.exp(-(t - t0) / tau_L) - np.exp(-(t - t0) / tau_s)) / (g_L_prox*(tau_L - tau_s))) # compute PI(t) if len(spike_times_soma) > 0: t = np.around(t, 4) spike_times_soma = np.around(spike_times_soma + 0.2, 4) idx = np.nonzero(np.in1d(t, spike_times_soma))[0] rate[idx] -= 1.0 / resolution w_change_raw = -15.0*C_m_prox*rate*h*alpha_response # compute low pass filtered version of PI tau_Delta = syn_params['tau_Delta'] eta = syn_params['eta'] w_change_low_pass = eta * np.exp(-t / tau_Delta)*np.cumsum( np.exp(t / tau_Delta)*w_change_raw)*resolution / tau_Delta integrated_w_change = np.cumsum(w_change_low_pass)*resolution syn_weight_comp = init_w + integrated_w_change ''' comparison between Nest and python implementation ''' # extract the weight computed in python at the times of the presynaptic spikes idx = np.nonzero(np.in1d(np.around(t, 4), np.around(pre_syn_spike_times + resolution, 4)))[0] syn_w_comp_at_spike_times = syn_weight_comp[idx] realtive_error = ( (weights[-1] - syn_w_comp_at_spike_times[-1]) / (weights[-1] - init_w)) self.assertTrue(abs(realtive_error) < 0.001) def suite(): suite = unittest.makeSuite(UrbanczikSynapseTestCase, 'test') return suite def run(): runner = unittest.TextTestRunner(verbosity=2) runner.run(suite()) if __name__ == "__main__": run()
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 511, 63, 300, 13206, 16823, 3258, 63, 9466, 19111, 14, 647, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28878, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8353, 710, 28878, 21412, 1905, 199, 3, 199, 3, 28878, 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, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28878, 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, 28878, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 774, 9330, 402, 314, 738, 4848, 290, 16823, 3258, 9560, 19111, 199, 624, 199, 199, 646, 2882, 199, 646, 10715, 199, 646, 2680, 465, 980, 199, 199, 10767, 63, 39, 4929, 275, 10715, 14, 914, 63, 1246, 14, 23766, 63, 1532, 480, 1205, 807, 15, 7804, 63, 458, 76, 3800, 531, 421, 199, 32, 15272, 14, 914, 63, 1246, 14, 1074, 63, 2340, 199, 32, 2796, 14, 15118, 8, 1397, 25227, 63, 39, 4929, 12, 283, 39, 4929, 365, 440, 2808, 358, 199, 533, 738, 4848, 290, 16823, 3258, 17746, 19111, 1746, 8, 2796, 14, 1746, 304, 272, 408, 774, 738, 4848, 290, 16823, 3258, 9560, 19111, 624, 339, 347, 511, 63, 8631, 4698, 32073, 3007, 53, 4848, 290, 16823, 3258, 17746, 19111, 8, 277, 304, 267, 408, 37, 561, 1482, 626, 314, 10588, 370, 3748, 20242, 1709, 5419, 1041, 398, 10715, 14, 409, 63, 9833, 360, 45, 63, 9171, 358, 398, 327, 6879, 13, 863, 580, 434, 1709, 267, 16377, 63, 992, 275, 359, 288, 298, 73, 2756, 63, 2067, 63, 4468, 63, 5466, 401, 288, 298, 802, 63, 2067, 63, 1474, 63, 5466, 63, 300, 13206, 16823, 3258, 401, 267, 1622, 398, 327, 26167, 1709, 267, 3748, 63, 992, 275, 359, 288, 298, 802, 63, 2067, 63, 1474, 63, 5466, 63, 300, 13206, 16823, 3258, 401, 267, 1622, 398, 327, 8354, 440, 3748, 1709, 267, 440, 63, 4946, 63, 992, 275, 359, 78, 367, 302, 315, 10715, 14, 20474, 8, 77, 466, 534, 2415, 358, 1816, 340, 302, 440, 315, 3748, 63, 992, 61, 398, 327, 15175, 3748, 1709, 543, 738, 4848, 290, 16823, 3258, 9560, 19111, 267, 367, 16751, 315, 3748, 63, 992, 26, 288, 10715, 14, 9637, 14127, 342, 953, 519, 63, 466, 275, 378, 288, 340, 16751, 315, 16377, 63, 992, 26, 355, 1847, 561, 275, 10715, 14, 1002, 16986, 8, 10756, 26332, 264, 716, 269, 63, 1313, 937, 355, 519, 63, 466, 275, 1847, 561, 905, 1152, 391, 63, 2804, 937, 953, 302, 275, 10715, 14, 2499, 8, 10756, 12, 499, 9, 953, 10715, 14, 8631, 8, 78, 12, 302, 12, 2420, 2200, 582, 298, 452, 63, 475, 63, 452, 6018, 586, 2420, 9466, 19111, 63, 1238, 582, 298, 300, 13206, 16823, 3258, 63, 9466, 19111, 401, 298, 264, 716, 269, 63, 466, 582, 519, 63, 466, 1552, 398, 327, 7523, 626, 18170, 440, 3748, 1709, 6918, 267, 367, 16751, 315, 440, 63, 4946, 63, 992, 26, 288, 10715, 14, 9637, 14127, 342, 953, 519, 63, 466, 275, 378, 288, 340, 16751, 315, 16377, 63, 992, 26, 355, 1847, 561, 275, 10715, 14, 1002, 16986, 8, 10756, 26332, 264, 716, 269, 63, 1313, 937, 355, 519, 63, 466, 275, 1847, 561, 905, 1152, 391, 63, 2804, 937, 953, 302, 275, 10715, 14, 2499, 8, 10756, 12, 499, 9, 953, 327, 862, 370, 4907, 543, 7629, 13206, 16823, 3258, 9560, 19111, 288, 543, 291, 14, 1855, 8, 15272, 14, 4989, 14, 46, 1719, 547, 304, 355, 10715, 14, 8631, 8, 78, 12, 302, 12, 2420, 2200, 582, 298, 452, 63, 475, 63, 452, 6018, 2490, 2420, 9466, 19111, 63, 1238, 582, 298, 300, 13206, 16823, 3258, 63, 9466, 19111, 401, 298, 264, 716, 269, 63, 466, 582, 519, 63, 466, 1552, 339, 347, 511, 63, 17746, 19111, 8598, 1941, 1906, 559, 1051, 425, 8, 277, 304, 267, 408, 13913, 626, 2657, 1941, 436, 30242, 1051, 425, 1736, 6657, 624, 398, 10715, 14, 409, 63, 9833, 360, 45, 63, 9171, 358, 267, 10715, 14, 9637, 14127, 342, 398, 12401, 275, 378, 14, 17, 267, 10715, 14, 1084, 14127, 3694, 3252, 12588, 356, 12401, 1552, 398, 1449, 267, 20242, 2633, 267, 1449, 267, 302, 11641, 63, 1238, 275, 283, 802, 63, 2067, 63, 1474, 63, 5466, 63, 300, 13206, 16823, 3258, 7, 267, 302, 11641, 63, 1162, 275, 469, 288, 283, 84, 63, 1121, 356, 650, 14, 16, 12, 263, 327, 2984, 345, 1076, 6247, 288, 283, 71, 63, 681, 356, 11624, 14, 16, 12, 755, 327, 880, 569, 79, 13, 848, 17824, 764, 512, 384, 2983, 406, 1601, 554, 288, 283, 1152, 391, 356, 469, 355, 283, 54, 63, 77, 356, 446, 2760, 14, 16, 12, 259, 327, 2536, 574, 402, 812, 63, 77, 355, 283, 35, 63, 77, 356, 9601, 14, 16, 12, 259, 327, 28068, 14422, 554, 402, 562, 887, 26364, 355, 283, 37, 63, 44, 356, 446, 2760, 14, 16, 12, 259, 327, 4618, 316, 12330, 355, 283, 71, 63, 44, 356, 4233, 14, 16, 12, 258, 327, 880, 3889, 25831, 406, 1601, 554, 355, 283, 37, 63, 476, 356, 378, 14, 16, 12, 258, 327, 4618, 316, 12330, 367, 3178, 1324, 355, 283, 37, 63, 262, 356, 446, 2194, 14, 16, 12, 257, 327, 4618, 316, 12330, 367, 315, 72, 1324, 355, 283, 16656, 63, 9466, 63, 476, 356, 650, 14, 16, 12, 221, 327, 900, 4413, 402, 3178, 406, 1601, 554, 355, 283, 16656, 63, 9466, 63, 262, 356, 650, 14, 16, 12, 221, 327, 900 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 511, 63, 300, 13206, 16823, 3258, 63, 9466, 19111, 14, 647, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28878, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8353, 710, 28878, 21412, 1905, 199, 3, 199, 3, 28878, 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, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 28878, 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, 28878, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 774, 9330, 402, 314, 738, 4848, 290, 16823, 3258, 9560, 19111, 199, 624, 199, 199, 646, 2882, 199, 646, 10715, 199, 646, 2680, 465, 980, 199, 199, 10767, 63, 39, 4929, 275, 10715, 14, 914, 63, 1246, 14, 23766, 63, 1532, 480, 1205, 807, 15, 7804, 63, 458, 76, 3800, 531, 421, 199, 32, 15272, 14, 914, 63, 1246, 14, 1074, 63, 2340, 199, 32, 2796, 14, 15118, 8, 1397, 25227, 63, 39, 4929, 12, 283, 39, 4929, 365, 440, 2808, 358, 199, 533, 738, 4848, 290, 16823, 3258, 17746, 19111, 1746, 8, 2796, 14, 1746, 304, 272, 408, 774, 738, 4848, 290, 16823, 3258, 9560, 19111, 624, 339, 347, 511, 63, 8631, 4698, 32073, 3007, 53, 4848, 290, 16823, 3258, 17746, 19111, 8, 277, 304, 267, 408, 37, 561, 1482, 626, 314, 10588, 370, 3748, 20242, 1709, 5419, 1041, 398, 10715, 14, 409, 63, 9833, 360, 45, 63, 9171, 358, 398, 327, 6879, 13, 863, 580, 434, 1709, 267, 16377, 63, 992, 275, 359, 288, 298, 73, 2756, 63, 2067, 63, 4468, 63, 5466, 401, 288, 298, 802, 63, 2067, 63, 1474, 63, 5466, 63, 300, 13206, 16823, 3258, 401, 267, 1622, 398, 327, 26167, 1709, 267, 3748, 63, 992, 275, 359, 288, 298, 802, 63, 2067, 63, 1474, 63, 5466, 63, 300, 13206, 16823, 3258, 401, 267, 1622, 398, 327, 8354, 440, 3748, 1709, 267, 440, 63, 4946, 63, 992, 275, 359, 78, 367, 302, 315, 10715, 14, 20474, 8, 77, 466, 534, 2415, 358, 1816, 340, 302, 440, 315, 3748, 63, 992, 61, 398, 327, 15175, 3748, 1709, 543, 738, 4848, 290, 16823, 3258, 9560, 19111, 267, 367, 16751, 315, 3748, 63, 992, 26, 288, 10715, 14, 9637, 14127, 342, 953, 519, 63, 466, 275, 378, 288, 340, 16751, 315, 16377, 63, 992, 26, 355, 1847, 561, 275, 10715, 14, 1002, 16986, 8, 10756, 26332, 264, 716, 269, 63, 1313, 937, 355, 519, 63, 466, 275, 1847, 561, 905, 1152, 391, 63, 2804, 937, 953, 302, 275, 10715, 14, 2499, 8, 10756, 12, 499, 9, 953, 10715, 14, 8631, 8, 78, 12, 302, 12, 2420, 2200, 582, 298, 452, 63, 475, 63, 452, 6018, 586, 2420, 9466, 19111, 63, 1238, 582, 298, 300, 13206, 16823, 3258, 63, 9466, 19111, 401, 298, 264, 716, 269, 63, 466, 582, 519, 63, 466, 1552, 398, 327, 7523, 626, 18170, 440, 3748, 1709, 6918, 267, 367, 16751, 315, 440, 63, 4946, 63, 992, 26, 288, 10715, 14, 9637, 14127, 342, 953, 519, 63, 466, 275, 378, 288, 340, 16751, 315, 16377, 63, 992, 26, 355, 1847, 561, 275, 10715, 14, 1002, 16986, 8, 10756, 26332, 264, 716, 269, 63, 1313, 937, 355, 519, 63, 466, 275, 1847, 561, 905, 1152, 391, 63, 2804, 937, 953, 302, 275, 10715, 14, 2499, 8, 10756, 12, 499, 9, 953, 327, 862, 370, 4907, 543, 7629, 13206, 16823, 3258, 9560, 19111, 288, 543, 291, 14, 1855, 8, 15272, 14, 4989, 14, 46, 1719, 547, 304, 355, 10715, 14, 8631, 8, 78, 12, 302, 12, 2420, 2200, 582, 298, 452, 63, 475, 63, 452, 6018, 2490, 2420, 9466, 19111, 63, 1238, 582, 298, 300, 13206, 16823, 3258, 63, 9466, 19111, 401, 298, 264, 716, 269, 63, 466, 582, 519, 63, 466, 1552, 339, 347, 511, 63, 17746, 19111, 8598, 1941, 1906, 559, 1051, 425, 8, 277, 304, 267, 408, 13913, 626, 2657, 1941, 436, 30242, 1051, 425, 1736, 6657, 624, 398, 10715, 14, 409, 63, 9833, 360, 45, 63, 9171, 358, 267, 10715, 14, 9637, 14127, 342, 398, 12401, 275, 378, 14, 17, 267, 10715, 14, 1084, 14127, 3694, 3252, 12588, 356, 12401, 1552, 398, 1449, 267, 20242, 2633, 267, 1449, 267, 302, 11641, 63, 1238, 275, 283, 802, 63, 2067, 63, 1474, 63, 5466, 63, 300, 13206, 16823, 3258, 7, 267, 302, 11641, 63, 1162, 275, 469, 288, 283, 84, 63, 1121, 356, 650, 14, 16, 12, 263, 327, 2984, 345, 1076, 6247, 288, 283, 71, 63, 681, 356, 11624, 14, 16, 12, 755, 327, 880, 569, 79, 13, 848, 17824, 764, 512, 384, 2983, 406, 1601, 554, 288, 283, 1152, 391, 356, 469, 355, 283, 54, 63, 77, 356, 446, 2760, 14, 16, 12, 259, 327, 2536, 574, 402, 812, 63, 77, 355, 283, 35, 63, 77, 356, 9601, 14, 16, 12, 259, 327, 28068, 14422, 554, 402, 562, 887, 26364, 355, 283, 37, 63, 44, 356, 446, 2760, 14, 16, 12, 259, 327, 4618, 316, 12330, 355, 283, 71, 63, 44, 356, 4233, 14, 16, 12, 258, 327, 880, 3889, 25831, 406, 1601, 554, 355, 283, 37, 63, 476, 356, 378, 14, 16, 12, 258, 327, 4618, 316, 12330, 367, 3178, 1324, 355, 283, 37, 63, 262, 356, 446, 2194, 14, 16, 12, 257, 327, 4618, 316, 12330, 367, 315, 72, 1324, 355, 283, 16656, 63, 9466, 63, 476, 356, 650, 14, 16, 12, 221, 327, 900, 4413, 402, 3178, 406, 1601, 554, 355, 283, 16656, 63, 9466, 63, 262, 356, 650, 14, 16, 12, 221, 327, 900, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
skirsdeda/django
tests/test_discovery_sample/doctests.py
471
1245
""" Doctest example from the official Python documentation. https://docs.python.org/3/library/doctest.html """ def factorial(n): """Return the factorial of n, an exact integer >= 0. >>> [factorial(n) for n in range(6)] [1, 1, 2, 6, 24, 120] >>> factorial(30) # doctest: +ELLIPSIS 265252859812191058636308480000000... >>> factorial(-1) Traceback (most recent call last): ... ValueError: n must be >= 0 Factorials of floats are OK, but the float must be an exact integer: >>> factorial(30.1) Traceback (most recent call last): ... ValueError: n must be exact integer >>> factorial(30.0) # doctest: +ELLIPSIS 265252859812191058636308480000000... It must also not be ridiculously large: >>> factorial(1e100) Traceback (most recent call last): ... OverflowError: n too large """ import math if not n >= 0: raise ValueError("n must be >= 0") if math.floor(n) != n: raise ValueError("n must be exact integer") if n + 1 == n: # catch a value like 1e300 raise OverflowError("n too large") result = 1 factor = 2 while factor <= n: result *= factor factor += 1 return result
bsd-3-clause
[ 624, 199, 3768, 396, 2893, 687, 314, 25410, 2018, 3794, 14, 199, 2859, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 4342, 15, 11390, 14, 1360, 199, 624, 421, 199, 318, 32618, 8, 78, 304, 272, 408, 1767, 314, 32618, 402, 302, 12, 376, 5835, 3000, 2356, 378, 14, 339, 1306, 359, 28165, 8, 78, 9, 367, 302, 315, 1425, 8, 22, 1874, 272, 359, 17, 12, 413, 12, 499, 12, 1227, 12, 5504, 12, 13960, 61, 272, 1306, 32618, 8, 1216, 9, 221, 327, 8868, 26, 435, 21677, 272, 499, 2182, 821, 1651, 15897, 713, 1167, 7320, 1184, 1344, 1216, 15186, 9084, 1396, 272, 1306, 32618, 2801, 17, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 267, 2263, 272, 1722, 26, 302, 1471, 506, 2356, 378, 339, 27348, 2380, 83, 402, 15657, 787, 9949, 12, 1325, 314, 2069, 1471, 506, 376, 5835, 3000, 26, 272, 1306, 32618, 8, 1216, 14, 17, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 267, 2263, 272, 1722, 26, 302, 1471, 506, 5835, 3000, 272, 1306, 32618, 8, 1216, 14, 16, 9, 221, 327, 8868, 26, 435, 21677, 272, 499, 2182, 821, 1651, 15897, 713, 1167, 7320, 1184, 1344, 1216, 15186, 9084, 1396, 339, 2779, 1471, 2597, 440, 506, 8012, 5000, 13957, 527, 590, 7031, 26, 272, 1306, 32618, 8, 17, 69, 1960, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 267, 2263, 272, 23870, 26, 302, 4634, 7031, 272, 408, 339, 492, 3473, 272, 340, 440, 302, 2356, 378, 26, 267, 746, 1722, 480, 78, 1471, 506, 2356, 378, 531, 272, 340, 3473, 14, 11289, 8, 78, 9, 1137, 302, 26, 267, 746, 1722, 480, 78, 1471, 506, 5835, 3000, 531, 272, 340, 302, 435, 413, 508, 302, 26, 221, 327, 8579, 282, 574, 2839, 413, 69, 5863, 267, 746, 23870, 480, 78, 4634, 7031, 531, 272, 754, 275, 413, 272, 6535, 275, 499, 272, 1830, 6535, 2695, 302, 26, 267, 754, 9000, 6535, 267, 6535, 847, 413, 272, 372, 754, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3768, 396, 2893, 687, 314, 25410, 2018, 3794, 14, 199, 2859, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 4342, 15, 11390, 14, 1360, 199, 624, 421, 199, 318, 32618, 8, 78, 304, 272, 408, 1767, 314, 32618, 402, 302, 12, 376, 5835, 3000, 2356, 378, 14, 339, 1306, 359, 28165, 8, 78, 9, 367, 302, 315, 1425, 8, 22, 1874, 272, 359, 17, 12, 413, 12, 499, 12, 1227, 12, 5504, 12, 13960, 61, 272, 1306, 32618, 8, 1216, 9, 221, 327, 8868, 26, 435, 21677, 272, 499, 2182, 821, 1651, 15897, 713, 1167, 7320, 1184, 1344, 1216, 15186, 9084, 1396, 272, 1306, 32618, 2801, 17, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 267, 2263, 272, 1722, 26, 302, 1471, 506, 2356, 378, 339, 27348, 2380, 83, 402, 15657, 787, 9949, 12, 1325, 314, 2069, 1471, 506, 376, 5835, 3000, 26, 272, 1306, 32618, 8, 1216, 14, 17, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 267, 2263, 272, 1722, 26, 302, 1471, 506, 5835, 3000, 272, 1306, 32618, 8, 1216, 14, 16, 9, 221, 327, 8868, 26, 435, 21677, 272, 499, 2182, 821, 1651, 15897, 713, 1167, 7320, 1184, 1344, 1216, 15186, 9084, 1396, 339, 2779, 1471, 2597, 440, 506, 8012, 5000, 13957, 527, 590, 7031, 26, 272, 1306, 32618, 8, 17, 69, 1960, 9, 272, 15273, 334, 2786, 8058, 1240, 2061, 304, 267, 2263, 272, 23870, 26, 302, 4634, 7031, 272, 408, 339, 492, 3473, 272, 340, 440, 302, 2356, 378, 26, 267, 746, 1722, 480, 78, 1471, 506, 2356, 378, 531, 272, 340, 3473, 14, 11289, 8, 78, 9, 1137, 302, 26, 267, 746, 1722, 480, 78, 1471, 506, 5835, 3000, 531, 272, 340, 302, 435, 413, 508, 302, 26, 221, 327, 8579, 282, 574, 2839, 413, 69, 5863, 267, 746, 23870, 480, 78, 4634, 7031, 531, 272, 754, 275, 413, 272, 6535, 275, 499, 272, 1830, 6535, 2695, 302, 26, 267, 754, 9000, 6535, 267, 6535, 847, 413, 272, 372, 754, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
CopeX/odoo
addons/website_twitter/models/twitter_config.py
377
2095
import logging from openerp.osv import fields, osv from openerp.tools.translate import _ _logger = logging.getLogger(__name__) class twitter_config_settings(osv.osv_memory): _inherit = 'website.config.settings' _columns = { 'twitter_api_key': fields.related( 'website_id', 'twitter_api_key', type="char", string='Twitter API Key', help="Twitter API key you can get it from https://apps.twitter.com/app/new"), 'twitter_api_secret': fields.related( 'website_id', 'twitter_api_secret', type="char", string='Twitter API secret', help="Twitter API secret you can get it from https://apps.twitter.com/app/new"), 'twitter_tutorial': fields.dummy( type="boolean", string="Show me how to obtain the Twitter API Key and Secret"), 'twitter_screen_name': fields.related( 'website_id', 'twitter_screen_name', type="char", string='Get favorites from this screen name', help="Screen Name of the Twitter Account from which you want to load favorites." "It does not have to match the API Key/Secret."), } def _check_twitter_authorization(self, cr, uid, config_id, context=None): website_obj = self.pool['website'] website_config = self.browse(cr, uid, config_id, context=context) try: website_obj.fetch_favorite_tweets(cr, uid, [website_config.website_id.id], context=context) except Exception: _logger.warning('Failed to verify twitter API authorization', exc_info=True) raise osv.except_osv(_('Twitter authorization error!'), _('Please double-check your Twitter API Key and Secret')) def create(self, cr, uid, vals, context=None): res_id = super(twitter_config_settings, self).create(cr, uid, vals, context=context) if vals.get('twitter_api_key') and vals.get('twitter_api_secret'): self._check_twitter_authorization(cr, uid, res_id, context=context) return res_id
agpl-3.0
[ 646, 2050, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 15811, 63, 888, 63, 1751, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 6486, 275, 283, 7360, 14, 888, 14, 1751, 7, 339, 485, 3406, 275, 469, 268, 283, 13746, 63, 1246, 63, 498, 356, 1504, 14, 2407, 8, 355, 283, 7360, 63, 344, 297, 283, 13746, 63, 1246, 63, 498, 297, 730, 628, 1560, 401, 355, 1059, 534, 24540, 3261, 2606, 297, 355, 1720, 628, 24540, 3261, 790, 1265, 883, 664, 652, 687, 4178, 921, 5181, 14, 13746, 14, 957, 15, 571, 15, 1222, 1288, 268, 283, 13746, 63, 1246, 63, 4731, 356, 1504, 14, 2407, 8, 355, 283, 7360, 63, 344, 297, 283, 13746, 63, 1246, 63, 4731, 297, 730, 628, 1560, 401, 355, 1059, 534, 24540, 3261, 7565, 297, 355, 1720, 628, 24540, 3261, 7565, 1265, 883, 664, 652, 687, 4178, 921, 5181, 14, 13746, 14, 957, 15, 571, 15, 1222, 1288, 268, 283, 13746, 63, 23561, 356, 1504, 14, 5869, 8, 355, 730, 628, 4871, 401, 1059, 628, 6824, 562, 4212, 370, 3332, 314, 19259, 3261, 2606, 436, 23580, 1288, 268, 283, 13746, 63, 5410, 63, 354, 356, 1504, 14, 2407, 8, 355, 283, 7360, 63, 344, 297, 283, 13746, 63, 5410, 63, 354, 297, 355, 730, 628, 1560, 401, 1059, 534, 1002, 17914, 4033, 687, 642, 6426, 536, 297, 355, 1720, 628, 9616, 2812, 402, 314, 19259, 9973, 687, 1314, 1265, 2934, 370, 2248, 17914, 4033, 2122, 355, 298, 7940, 1630, 440, 1172, 370, 1336, 314, 3261, 2606, 15, 13790, 7651, 272, 789, 2286, 347, 485, 1074, 63, 13746, 63, 15846, 8, 277, 12, 2467, 12, 1747, 12, 1101, 63, 344, 12, 1067, 29, 403, 304, 267, 10691, 63, 1113, 275, 291, 14, 2293, 459, 7360, 418, 267, 10691, 63, 888, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 1101, 63, 344, 12, 1067, 29, 1100, 9, 267, 862, 26, 288, 10691, 63, 1113, 14, 3535, 63, 23874, 63, 84, 18588, 8, 1556, 12, 1747, 12, 359, 7360, 63, 888, 14, 7360, 63, 344, 14, 344, 467, 1067, 29, 1100, 9, 267, 871, 2186, 26, 288, 485, 2921, 14, 3764, 360, 4276, 370, 4911, 15811, 3261, 13448, 297, 3178, 63, 815, 29, 549, 9, 288, 746, 9506, 14, 2590, 63, 4795, 6723, 24540, 13448, 1125, 15659, 4018, 8254, 4270, 13, 1074, 2195, 19259, 3261, 2606, 436, 23580, 1333, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 5322, 12, 1067, 29, 403, 304, 267, 522, 63, 344, 275, 1613, 8, 13746, 63, 888, 63, 1751, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 29, 1100, 9, 267, 340, 5322, 14, 362, 360, 13746, 63, 1246, 63, 498, 358, 436, 5322, 14, 362, 360, 13746, 63, 1246, 63, 4731, 735, 288, 291, 423, 1074, 63, 13746, 63, 15846, 8, 1556, 12, 1747, 12, 522, 63, 344, 12, 1067, 29, 1100, 9, 267, 372, 522, 63, 344, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2050, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 15811, 63, 888, 63, 1751, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 6486, 275, 283, 7360, 14, 888, 14, 1751, 7, 339, 485, 3406, 275, 469, 268, 283, 13746, 63, 1246, 63, 498, 356, 1504, 14, 2407, 8, 355, 283, 7360, 63, 344, 297, 283, 13746, 63, 1246, 63, 498, 297, 730, 628, 1560, 401, 355, 1059, 534, 24540, 3261, 2606, 297, 355, 1720, 628, 24540, 3261, 790, 1265, 883, 664, 652, 687, 4178, 921, 5181, 14, 13746, 14, 957, 15, 571, 15, 1222, 1288, 268, 283, 13746, 63, 1246, 63, 4731, 356, 1504, 14, 2407, 8, 355, 283, 7360, 63, 344, 297, 283, 13746, 63, 1246, 63, 4731, 297, 730, 628, 1560, 401, 355, 1059, 534, 24540, 3261, 7565, 297, 355, 1720, 628, 24540, 3261, 7565, 1265, 883, 664, 652, 687, 4178, 921, 5181, 14, 13746, 14, 957, 15, 571, 15, 1222, 1288, 268, 283, 13746, 63, 23561, 356, 1504, 14, 5869, 8, 355, 730, 628, 4871, 401, 1059, 628, 6824, 562, 4212, 370, 3332, 314, 19259, 3261, 2606, 436, 23580, 1288, 268, 283, 13746, 63, 5410, 63, 354, 356, 1504, 14, 2407, 8, 355, 283, 7360, 63, 344, 297, 283, 13746, 63, 5410, 63, 354, 297, 355, 730, 628, 1560, 401, 1059, 534, 1002, 17914, 4033, 687, 642, 6426, 536, 297, 355, 1720, 628, 9616, 2812, 402, 314, 19259, 9973, 687, 1314, 1265, 2934, 370, 2248, 17914, 4033, 2122, 355, 298, 7940, 1630, 440, 1172, 370, 1336, 314, 3261, 2606, 15, 13790, 7651, 272, 789, 2286, 347, 485, 1074, 63, 13746, 63, 15846, 8, 277, 12, 2467, 12, 1747, 12, 1101, 63, 344, 12, 1067, 29, 403, 304, 267, 10691, 63, 1113, 275, 291, 14, 2293, 459, 7360, 418, 267, 10691, 63, 888, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 1101, 63, 344, 12, 1067, 29, 1100, 9, 267, 862, 26, 288, 10691, 63, 1113, 14, 3535, 63, 23874, 63, 84, 18588, 8, 1556, 12, 1747, 12, 359, 7360, 63, 888, 14, 7360, 63, 344, 14, 344, 467, 1067, 29, 1100, 9, 267, 871, 2186, 26, 288, 485, 2921, 14, 3764, 360, 4276, 370, 4911, 15811, 3261, 13448, 297, 3178, 63, 815, 29, 549, 9, 288, 746, 9506, 14, 2590, 63, 4795, 6723, 24540, 13448, 1125, 15659, 4018, 8254, 4270, 13, 1074, 2195, 19259, 3261, 2606, 436, 23580, 1333, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 5322, 12, 1067, 29, 403, 304, 267, 522, 63, 344, 275, 1613, 8, 13746, 63, 888, 63, 1751, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 29, 1100, 9, 267, 340, 5322, 14, 362, 360, 13746, 63, 1246, 63, 498, 358, 436, 5322, 14, 362, 360, 13746, 63, 1246, 63, 4731, 735, 288, 291, 423, 1074, 63, 13746, 63, 15846, 8, 1556, 12, 1747, 12, 522, 63, 344, 12, 1067, 29, 1100, 9, 267, 372, 522, 63, 344, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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form.compat import render_to_string, format_html, field_defaults_factory, render_template, Template from .compat import RequestFactory, SafeText def test_render_to_string(): assert render_to_string( template_name='tri_form/non_editable.html', request=RequestFactory().get('/'), context=dict( field=dict( id=SafeText('<a b c><d><e>'), rendered_value=SafeText('<a b c><d><e>'), ), ) ).strip() == '<span id="<a b c><d><e>"><a b c><d><e></span>' def test_format_html(): assert format_html('<{a}>{b}{c}', a='a', b=format_html('<b>'), c='<c>') == '<a><b>&lt;c&gt;' def test_format_html2(): assert render_template(RequestFactory().get('/'), Template('{{foo}}'), dict(foo=format_html('<a href="foo">foo</a>'))) == '<a href="foo">foo</a>' def test_format_html3(): assert render_template(RequestFactory().get('/'), Template('{{foo}}'), dict(foo=format_html('{}', format_html('<a href="foo">foo</a>')))) == '<a href="foo">foo</a>' def test_format_html4(): actual = render_template( RequestFactory().get('/'), Template('{{foo}}'), dict( foo=Form(fields=[Field(name='foo')]), ) ) print(actual) assert '<input type="text" value="" name="foo" id="id_foo"' in actual def test_format_html5(): actual = Form(fields=[Field(name='foo')], request=RequestFactory().get('/')).render() print(actual) assert type(actual) == SafeText def test_format_html6(): form = Form(fields=[Field(name='foo')], request=RequestFactory().get('/')) actual = form.fields_by_name.foo.render() print(actual) assert type(actual) == SafeText def test_render_template(): actual = render_template(RequestFactory().get('/'), Template('{{foo}}'), dict(foo=1)) print(actual) assert type(actual) == SafeText @pytest.mark.django def test_field_defaults_factory(): from django.db import models base = dict(parse_empty_string_as_none=True, required=True, display_name=None) assert field_defaults_factory(models.CharField(null=False, blank=False)) == merged(base, dict(parse_empty_string_as_none=False)) assert field_defaults_factory(models.CharField(null=False, blank=True)) == merged(base, dict(parse_empty_string_as_none=False, required=False)) assert field_defaults_factory(models.CharField(null=True, blank=False)) == merged(base, dict(required=False)) assert field_defaults_factory(models.CharField(null=True, blank=True)) == merged(base, dict(required=False)) @pytest.mark.django def test_field_defaults_factory_boolean(): from django.db import models django_null_default = not models.BooleanField().null base = dict(parse_empty_string_as_none=django_null_default, display_name=None) assert field_defaults_factory(models.BooleanField(null=False, blank=False)) == merged(base, dict(parse_empty_string_as_none=False)) assert field_defaults_factory(models.BooleanField(null=False, blank=True)) == merged(base, dict(parse_empty_string_as_none=False)) assert field_defaults_factory(models.BooleanField(null=True, blank=False)) == base assert field_defaults_factory(models.BooleanField(null=True, blank=True)) == base
bsd-3-clause
[ 646, 4613, 199, 504, 3229, 63, 1820, 492, 9545, 199, 199, 504, 3229, 63, 964, 492, 5024, 12, 8204, 199, 504, 3229, 63, 964, 14, 5819, 492, 3795, 63, 475, 63, 875, 12, 1475, 63, 1360, 12, 901, 63, 4322, 63, 3702, 12, 3795, 63, 1160, 12, 5458, 199, 504, 1275, 5819, 492, 18638, 12, 14969, 1872, 421, 199, 318, 511, 63, 3352, 63, 475, 63, 875, 837, 272, 702, 3795, 63, 475, 63, 875, 8, 267, 1978, 63, 354, 534, 599, 63, 964, 15, 2865, 63, 10820, 14, 1360, 297, 267, 1056, 29, 2017, 2927, 1252, 362, 2336, 659, 267, 1067, 29, 807, 8, 288, 901, 29, 807, 8, 355, 1305, 29, 11090, 1872, 4827, 65, 330, 286, 2535, 68, 2535, 69, 25642, 355, 8018, 63, 585, 29, 11090, 1872, 4827, 65, 330, 286, 2535, 68, 2535, 69, 25642, 288, 2318, 267, 776, 272, 7092, 1913, 342, 508, 2650, 3751, 1305, 28066, 65, 330, 286, 2535, 68, 2535, 69, 30, 8186, 65, 330, 286, 2535, 68, 2535, 69, 2957, 3751, 3524, 421, 199, 318, 511, 63, 908, 63, 1360, 837, 272, 702, 1475, 63, 1360, 4827, 91, 65, 93, 22266, 66, 8847, 67, 7293, 282, 534, 65, 297, 330, 29, 908, 63, 1360, 4827, 66, 25642, 286, 15829, 67, 5971, 508, 2650, 65, 2535, 66, 18181, 4116, 27, 67, 6, 3308, 8942, 421, 199, 318, 511, 63, 908, 63, 1360, 18, 837, 272, 702, 3795, 63, 1160, 8, 2017, 2927, 1252, 362, 2336, 659, 5458, 18976, 1421, 4863, 659, 1211, 8, 1421, 29, 908, 63, 1360, 4827, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 5971, 430, 508, 2650, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 3524, 421, 199, 318, 511, 63, 908, 63, 1360, 19, 837, 272, 702, 3795, 63, 1160, 8, 2017, 2927, 1252, 362, 2336, 659, 5458, 18976, 1421, 4863, 659, 1211, 8, 1421, 29, 908, 63, 1360, 17519, 297, 1475, 63, 1360, 4827, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 5971, 1724, 508, 2650, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 3524, 421, 199, 318, 511, 63, 908, 63, 1360, 20, 837, 272, 3503, 275, 3795, 63, 1160, 8, 267, 18638, 1252, 362, 2336, 659, 267, 5458, 18976, 1421, 4863, 659, 267, 1211, 8, 288, 3925, 29, 2821, 8, 955, 1524, 792, 8, 354, 534, 1421, 22864, 267, 776, 272, 776, 272, 870, 8, 6514, 9, 272, 702, 2650, 1210, 730, 628, 505, 2, 574, 9287, 536, 628, 1421, 2, 1305, 628, 344, 63, 1421, 4507, 315, 3503, 421, 199, 318, 511, 63, 908, 63, 1360, 21, 837, 272, 3503, 275, 8204, 8, 955, 1524, 792, 8, 354, 534, 1421, 2665, 1056, 29, 2017, 2927, 1252, 362, 7825, 680, 3352, 342, 272, 870, 8, 6514, 9, 272, 702, 730, 8, 6514, 9, 508, 14969, 1872, 421, 199, 318, 511, 63, 908, 63, 1360, 22, 837, 272, 1824, 275, 8204, 8, 955, 1524, 792, 8, 354, 534, 1421, 2665, 1056, 29, 2017, 2927, 1252, 362, 28684, 272, 3503, 275, 1824, 14, 955, 63, 991, 63, 354, 14, 1421, 14, 3352, 342, 272, 870, 8, 6514, 9, 272, 702, 730, 8, 6514, 9, 508, 14969, 1872, 421, 199, 318, 511, 63, 3352, 63, 1160, 837, 272, 3503, 275, 3795, 63, 1160, 8, 2017, 2927, 1252, 362, 2336, 659, 5458, 18976, 1421, 4863, 659, 1211, 8, 1421, 29, 17, 430, 272, 870, 8, 6514, 9, 272, 702, 730, 8, 6514, 9, 508, 14969, 1872, 421, 199, 32, 4462, 14, 1657, 14, 1176, 199, 318, 511, 63, 698, 63, 4322, 63, 3702, 837, 272, 687, 1639, 14, 697, 492, 1709, 272, 1300, 275, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 549, 12, 1415, 29, 549, 12, 2929, 63, 354, 29, 403, 9, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 797, 12, 4596, 29, 797, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 430, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 797, 12, 4596, 29, 549, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 12, 1415, 29, 797, 430, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 797, 430, 508, 9545, 8, 1095, 12, 1211, 8, 2427, 29, 797, 430, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 549, 430, 508, 9545, 8, 1095, 12, 1211, 8, 2427, 29, 797, 430, 421, 199, 32, 4462, 14, 1657, 14, 1176, 199, 318, 511, 63, 698, 63, 4322, 63, 3702, 63, 4871, 837, 272, 687, 1639, 14, 697, 492, 1709, 339, 1639, 63, 2307, 63, 885, 275, 440, 1709, 14, 5036, 1252, 2307, 339, 1300, 275, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 1176, 63, 2307, 63, 885, 12, 2929, 63, 354, 29, 403, 9, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 797, 12, 4596, 29, 797, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 430, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 797, 12, 4596, 29, 549, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 430, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 549, 12, 4596, 29, 797, 430, 508, 1300, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 549, 12, 4596, 29, 549, 430, 508, 1300, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4613, 199, 504, 3229, 63, 1820, 492, 9545, 199, 199, 504, 3229, 63, 964, 492, 5024, 12, 8204, 199, 504, 3229, 63, 964, 14, 5819, 492, 3795, 63, 475, 63, 875, 12, 1475, 63, 1360, 12, 901, 63, 4322, 63, 3702, 12, 3795, 63, 1160, 12, 5458, 199, 504, 1275, 5819, 492, 18638, 12, 14969, 1872, 421, 199, 318, 511, 63, 3352, 63, 475, 63, 875, 837, 272, 702, 3795, 63, 475, 63, 875, 8, 267, 1978, 63, 354, 534, 599, 63, 964, 15, 2865, 63, 10820, 14, 1360, 297, 267, 1056, 29, 2017, 2927, 1252, 362, 2336, 659, 267, 1067, 29, 807, 8, 288, 901, 29, 807, 8, 355, 1305, 29, 11090, 1872, 4827, 65, 330, 286, 2535, 68, 2535, 69, 25642, 355, 8018, 63, 585, 29, 11090, 1872, 4827, 65, 330, 286, 2535, 68, 2535, 69, 25642, 288, 2318, 267, 776, 272, 7092, 1913, 342, 508, 2650, 3751, 1305, 28066, 65, 330, 286, 2535, 68, 2535, 69, 30, 8186, 65, 330, 286, 2535, 68, 2535, 69, 2957, 3751, 3524, 421, 199, 318, 511, 63, 908, 63, 1360, 837, 272, 702, 1475, 63, 1360, 4827, 91, 65, 93, 22266, 66, 8847, 67, 7293, 282, 534, 65, 297, 330, 29, 908, 63, 1360, 4827, 66, 25642, 286, 15829, 67, 5971, 508, 2650, 65, 2535, 66, 18181, 4116, 27, 67, 6, 3308, 8942, 421, 199, 318, 511, 63, 908, 63, 1360, 18, 837, 272, 702, 3795, 63, 1160, 8, 2017, 2927, 1252, 362, 2336, 659, 5458, 18976, 1421, 4863, 659, 1211, 8, 1421, 29, 908, 63, 1360, 4827, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 5971, 430, 508, 2650, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 3524, 421, 199, 318, 511, 63, 908, 63, 1360, 19, 837, 272, 702, 3795, 63, 1160, 8, 2017, 2927, 1252, 362, 2336, 659, 5458, 18976, 1421, 4863, 659, 1211, 8, 1421, 29, 908, 63, 1360, 17519, 297, 1475, 63, 1360, 4827, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 5971, 1724, 508, 2650, 65, 4369, 628, 1421, 1743, 1421, 1108, 65, 3524, 421, 199, 318, 511, 63, 908, 63, 1360, 20, 837, 272, 3503, 275, 3795, 63, 1160, 8, 267, 18638, 1252, 362, 2336, 659, 267, 5458, 18976, 1421, 4863, 659, 267, 1211, 8, 288, 3925, 29, 2821, 8, 955, 1524, 792, 8, 354, 534, 1421, 22864, 267, 776, 272, 776, 272, 870, 8, 6514, 9, 272, 702, 2650, 1210, 730, 628, 505, 2, 574, 9287, 536, 628, 1421, 2, 1305, 628, 344, 63, 1421, 4507, 315, 3503, 421, 199, 318, 511, 63, 908, 63, 1360, 21, 837, 272, 3503, 275, 8204, 8, 955, 1524, 792, 8, 354, 534, 1421, 2665, 1056, 29, 2017, 2927, 1252, 362, 7825, 680, 3352, 342, 272, 870, 8, 6514, 9, 272, 702, 730, 8, 6514, 9, 508, 14969, 1872, 421, 199, 318, 511, 63, 908, 63, 1360, 22, 837, 272, 1824, 275, 8204, 8, 955, 1524, 792, 8, 354, 534, 1421, 2665, 1056, 29, 2017, 2927, 1252, 362, 28684, 272, 3503, 275, 1824, 14, 955, 63, 991, 63, 354, 14, 1421, 14, 3352, 342, 272, 870, 8, 6514, 9, 272, 702, 730, 8, 6514, 9, 508, 14969, 1872, 421, 199, 318, 511, 63, 3352, 63, 1160, 837, 272, 3503, 275, 3795, 63, 1160, 8, 2017, 2927, 1252, 362, 2336, 659, 5458, 18976, 1421, 4863, 659, 1211, 8, 1421, 29, 17, 430, 272, 870, 8, 6514, 9, 272, 702, 730, 8, 6514, 9, 508, 14969, 1872, 421, 199, 32, 4462, 14, 1657, 14, 1176, 199, 318, 511, 63, 698, 63, 4322, 63, 3702, 837, 272, 687, 1639, 14, 697, 492, 1709, 272, 1300, 275, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 549, 12, 1415, 29, 549, 12, 2929, 63, 354, 29, 403, 9, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 797, 12, 4596, 29, 797, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 430, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 797, 12, 4596, 29, 549, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 12, 1415, 29, 797, 430, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 797, 430, 508, 9545, 8, 1095, 12, 1211, 8, 2427, 29, 797, 430, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 2183, 8, 2307, 29, 549, 12, 4596, 29, 549, 430, 508, 9545, 8, 1095, 12, 1211, 8, 2427, 29, 797, 430, 421, 199, 32, 4462, 14, 1657, 14, 1176, 199, 318, 511, 63, 698, 63, 4322, 63, 3702, 63, 4871, 837, 272, 687, 1639, 14, 697, 492, 1709, 339, 1639, 63, 2307, 63, 885, 275, 440, 1709, 14, 5036, 1252, 2307, 339, 1300, 275, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 1176, 63, 2307, 63, 885, 12, 2929, 63, 354, 29, 403, 9, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 797, 12, 4596, 29, 797, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 430, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 797, 12, 4596, 29, 549, 430, 508, 9545, 8, 1095, 12, 1211, 8, 1122, 63, 1667, 63, 875, 63, 305, 63, 3592, 29, 797, 430, 339, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 549, 12, 4596, 29, 797, 430, 508, 1300, 272, 702, 901, 63, 4322, 63, 3702, 8, 992, 14, 5036, 8, 2307, 29, 549, 12, 4596, 29, 549, 430, 508, 1300, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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miriade.py
2
4481
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest import os import astropy.units as u from ...utils.testing_tools import MockResponse from .. import Miriade, MiriadeClass # files in data/ for different query types def data_path(filename): data_dir = os.path.join(os.path.dirname(__file__), 'data') return os.path.join(data_dir, filename) # monkeypatch replacement request function def nonremote_request(self, request_type, url, **kwargs): filename = '3552_coordtype{}.dat'.format( kwargs['params']['-tcoor']) with open(data_path(filename), 'rb') as f: response = MockResponse(content=f.read(), url=url) return response # use a pytest fixture to create a dummy 'requests.get' function, # that mocks(monkeypatches) the actual 'requests.get' function: @pytest.fixture def patch_request(request): try: mp = request.getfixturevalue("monkeypatch") except AttributeError: # pytest < 3 mp = request.getfuncargvalue("monkeypatch") mp.setattr(MiriadeClass, '_request', nonremote_request) return mp # --------------------------------- actual test functions def test_spherical_coordinates(patch_request): eph = Miriade.get_ephemerides('3552', coordtype=1) cols = ('target', 'epoch', 'RA', 'DEC', 'delta', 'V', 'alpha', 'elong', 'RAcosD_rate', 'DEC_rate', 'delta_rate') units = (None, u.d, u.deg, u.deg, u.au, u.mag, u.deg, u.deg, u.arcsec / u.minute, u.arcsec / u.minute, u.km / u.s) for i in range(len(cols)): assert cols[i] in eph.columns assert eph[cols[i]].unit == units[i] def test_rectangular_coordinates(patch_request): eph = Miriade.get_ephemerides('3552', coordtype=2) cols = ('target', 'epoch', 'x', 'y', 'z', 'vx', 'vy', 'vz', 'delta', 'V', 'alpha', 'elong', 'rv', 'heldist', 'x_h', 'y_h', 'z_h', 'vx_h', 'vy_h', 'vz_h') units = (None, u.d, u.au, u.au, u.au, u.au/u.day, u.au/u.day, u.au/u.day, u.au, u.mag, u.deg, u.deg, u.km/u.s, u.au, u.au, u.au, u.au, u.au/u.day, u.au/u.day, u.au/u.day) for i in range(len(cols)): assert cols[i] in eph.columns assert eph[cols[i]].unit == units[i] def test_local_coordinates(patch_request): eph = Miriade.get_ephemerides('3552', coordtype=3) cols = ('target', 'epoch', 'AZ', 'EL', 'V', 'delta', 'alpha', 'elong') units = (None, u.day, u.deg, u.deg, u.mag, u.au, u.deg, u.deg) for i in range(len(cols)): assert cols[i] in eph.columns assert eph[cols[i]].unit == units[i] def test_hourangle_coordinates(patch_request): eph = Miriade.get_ephemerides('3552', coordtype=4) cols = ('target', 'epoch', 'hourangle', 'DEC', 'V', 'delta', 'alpha', 'elong') units = (None, u.d, u.deg, u.deg, u.mag, u.au, u.deg, u.deg) for i in range(len(cols)): assert cols[i] in eph.columns assert eph[cols[i]].unit == units[i] def test_observation_coordinates(patch_request): eph = Miriade.get_ephemerides('3552', coordtype=5) cols = ('target', 'epoch', 'siderealtime', 'RAJ2000', 'DECJ2000', 'hourangle', 'DEC', 'AZ', 'EL', 'refraction', 'V', 'delta', 'heldist', 'alpha', 'elong', 'posunc', 'RAcosD_rate', 'DEC_rate', 'delta_rate') units = (None, u.d, u.h, u.deg, u.deg, u.deg, u.deg, u.deg, u.deg, u.arcsec, u.mag, u.au, u.au, u.deg, u.deg, u.arcsec, u.arcsec / u.minute, u.arcsec / u.minute, u.km / u.s) for i in range(len(cols)): assert cols[i] in eph.columns assert eph[cols[i]].unit == units[i] def test_aoobservation_coordinates(patch_request): eph = Miriade.get_ephemerides('3552', coordtype=6) cols = ('target', 'epoch', 'siderealtime', 'RAJ2000', 'DECJ2000', 'refraction', 'V', 'delta', 'heldist', 'alpha', 'elong', 'posunc', 'RAcosD_rate', 'DEC_rate', 'delta_rate') units = (None, u.d, u.h, u.deg, u.deg, u.arcsec, u.mag, u.au, u.au, u.deg, u.deg, u.arcsec, u.arcsec / u.minute, u.arcsec / u.minute, u.km / u.s) for i in range(len(cols)): assert cols[i] in eph.columns assert eph[cols[i]].unit == units[i] def test_get_raw_response(patch_request): raw_eph = Miriade.get_ephemerides( '3552', coordtype=1, get_raw_response=True) assert "<?xml version='1.0' encoding='UTF-8'?>" in raw_eph
bsd-3-clause
[ 3, 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 421, 199, 646, 4613, 199, 646, 747, 199, 199, 646, 28753, 14, 5260, 465, 399, 199, 504, 2263, 1208, 14, 4776, 63, 2537, 492, 4420, 2364, 199, 199, 504, 2508, 492, 603, 19081, 9587, 12, 603, 19081, 9587, 2543, 199, 199, 3, 1584, 315, 666, 15, 367, 3365, 1827, 2943, 421, 199, 318, 666, 63, 515, 8, 1501, 304, 272, 666, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 576, 358, 272, 372, 747, 14, 515, 14, 904, 8, 576, 63, 694, 12, 1788, 9, 421, 199, 3, 17309, 8343, 1056, 805, 199, 318, 2222, 3846, 63, 1069, 8, 277, 12, 1056, 63, 466, 12, 1166, 12, 1011, 958, 304, 339, 1788, 275, 283, 10156, 18, 63, 7988, 466, 31270, 4616, 1370, 908, 8, 267, 2074, 459, 1162, 2545, 13, 84, 331, 269, 1105, 272, 543, 1551, 8, 576, 63, 515, 8, 1501, 395, 283, 4848, 358, 465, 289, 26, 267, 1177, 275, 4420, 2364, 8, 1317, 29, 70, 14, 739, 1062, 1166, 29, 633, 9, 339, 372, 1177, 421, 199, 3, 675, 282, 4613, 10949, 370, 1218, 282, 7283, 283, 6615, 14, 362, 7, 805, 12, 199, 3, 626, 26500, 8, 20372, 11350, 9, 314, 3503, 283, 6615, 14, 362, 7, 805, 26, 199, 32, 4462, 14, 5997, 199, 318, 3371, 63, 1069, 8, 1069, 304, 272, 862, 26, 267, 6118, 275, 1056, 14, 362, 5997, 585, 480, 20372, 2068, 531, 272, 871, 4281, 26, 221, 327, 4613, 665, 650, 267, 6118, 275, 1056, 14, 362, 1532, 1273, 585, 480, 20372, 2068, 531, 272, 6118, 14, 10202, 8, 14738, 322, 9587, 2543, 12, 2513, 1069, 297, 2049, 2222, 3846, 63, 1069, 9, 272, 372, 6118, 421, 199, 3, 11016, 13, 3503, 511, 3423, 421, 199, 318, 511, 63, 23286, 2652, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 17, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 2847, 297, 283, 16387, 297, 283, 3136, 297, 283, 54, 297, 283, 4468, 297, 283, 352, 951, 297, 288, 283, 2847, 5197, 36, 63, 1866, 297, 283, 16387, 63, 1866, 297, 283, 3136, 63, 1866, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 68, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 3844, 12, 399, 14, 5615, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 1467, 399, 14, 9912, 3321, 1182, 399, 14, 10698, 12, 399, 14, 9912, 3321, 1182, 399, 14, 10698, 12, 399, 14, 14595, 1182, 399, 14, 83, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 3248, 508, 6204, 59, 73, 61, 421, 199, 318, 511, 63, 1201, 11572, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 18, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 88, 297, 283, 89, 297, 283, 90, 297, 288, 283, 18843, 297, 283, 16091, 297, 283, 31007, 297, 283, 3136, 297, 283, 54, 297, 288, 283, 4468, 297, 283, 352, 951, 297, 283, 6310, 297, 283, 30586, 2686, 297, 288, 283, 88, 63, 72, 297, 283, 89, 63, 72, 297, 283, 90, 63, 72, 297, 288, 283, 18843, 63, 72, 297, 283, 16091, 63, 72, 297, 283, 31007, 63, 72, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 68, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 1467, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 12, 399, 14, 5615, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 14595, 15, 85, 14, 83, 12, 1467, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 15, 85, 14, 2977, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 3248, 508, 6204, 59, 73, 61, 421, 199, 318, 511, 63, 1832, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 19, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 17613, 297, 283, 2901, 297, 283, 54, 297, 283, 3136, 297, 283, 4468, 297, 283, 352, 951, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 2977, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 5615, 12, 399, 14, 3844, 12, 399, 14, 6458, 12, 399, 14, 6458, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 3248, 508, 6204, 59, 73, 61, 421, 199, 318, 511, 63, 5180, 4593, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 20, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 5180, 4593, 297, 288, 283, 16387, 297, 283, 54, 297, 283, 3136, 297, 283, 4468, 297, 283, 352, 951, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 68, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 5615, 12, 399, 14, 3844, 12, 399, 14, 6458, 12, 399, 14, 6458, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230 ]
[ 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 421, 199, 646, 4613, 199, 646, 747, 199, 199, 646, 28753, 14, 5260, 465, 399, 199, 504, 2263, 1208, 14, 4776, 63, 2537, 492, 4420, 2364, 199, 199, 504, 2508, 492, 603, 19081, 9587, 12, 603, 19081, 9587, 2543, 199, 199, 3, 1584, 315, 666, 15, 367, 3365, 1827, 2943, 421, 199, 318, 666, 63, 515, 8, 1501, 304, 272, 666, 63, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 576, 358, 272, 372, 747, 14, 515, 14, 904, 8, 576, 63, 694, 12, 1788, 9, 421, 199, 3, 17309, 8343, 1056, 805, 199, 318, 2222, 3846, 63, 1069, 8, 277, 12, 1056, 63, 466, 12, 1166, 12, 1011, 958, 304, 339, 1788, 275, 283, 10156, 18, 63, 7988, 466, 31270, 4616, 1370, 908, 8, 267, 2074, 459, 1162, 2545, 13, 84, 331, 269, 1105, 272, 543, 1551, 8, 576, 63, 515, 8, 1501, 395, 283, 4848, 358, 465, 289, 26, 267, 1177, 275, 4420, 2364, 8, 1317, 29, 70, 14, 739, 1062, 1166, 29, 633, 9, 339, 372, 1177, 421, 199, 3, 675, 282, 4613, 10949, 370, 1218, 282, 7283, 283, 6615, 14, 362, 7, 805, 12, 199, 3, 626, 26500, 8, 20372, 11350, 9, 314, 3503, 283, 6615, 14, 362, 7, 805, 26, 199, 32, 4462, 14, 5997, 199, 318, 3371, 63, 1069, 8, 1069, 304, 272, 862, 26, 267, 6118, 275, 1056, 14, 362, 5997, 585, 480, 20372, 2068, 531, 272, 871, 4281, 26, 221, 327, 4613, 665, 650, 267, 6118, 275, 1056, 14, 362, 1532, 1273, 585, 480, 20372, 2068, 531, 272, 6118, 14, 10202, 8, 14738, 322, 9587, 2543, 12, 2513, 1069, 297, 2049, 2222, 3846, 63, 1069, 9, 272, 372, 6118, 421, 199, 3, 11016, 13, 3503, 511, 3423, 421, 199, 318, 511, 63, 23286, 2652, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 17, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 2847, 297, 283, 16387, 297, 283, 3136, 297, 283, 54, 297, 283, 4468, 297, 283, 352, 951, 297, 288, 283, 2847, 5197, 36, 63, 1866, 297, 283, 16387, 63, 1866, 297, 283, 3136, 63, 1866, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 68, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 3844, 12, 399, 14, 5615, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 1467, 399, 14, 9912, 3321, 1182, 399, 14, 10698, 12, 399, 14, 9912, 3321, 1182, 399, 14, 10698, 12, 399, 14, 14595, 1182, 399, 14, 83, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 3248, 508, 6204, 59, 73, 61, 421, 199, 318, 511, 63, 1201, 11572, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 18, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 88, 297, 283, 89, 297, 283, 90, 297, 288, 283, 18843, 297, 283, 16091, 297, 283, 31007, 297, 283, 3136, 297, 283, 54, 297, 288, 283, 4468, 297, 283, 352, 951, 297, 283, 6310, 297, 283, 30586, 2686, 297, 288, 283, 88, 63, 72, 297, 283, 89, 63, 72, 297, 283, 90, 63, 72, 297, 288, 283, 18843, 63, 72, 297, 283, 16091, 63, 72, 297, 283, 31007, 63, 72, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 68, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 1467, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 12, 399, 14, 5615, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 14595, 15, 85, 14, 83, 12, 1467, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 15, 85, 14, 2977, 12, 399, 14, 3844, 15, 85, 14, 2977, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 3248, 508, 6204, 59, 73, 61, 421, 199, 318, 511, 63, 1832, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 19, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 17613, 297, 283, 2901, 297, 283, 54, 297, 283, 3136, 297, 283, 4468, 297, 283, 352, 951, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 2977, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 5615, 12, 399, 14, 3844, 12, 399, 14, 6458, 12, 399, 14, 6458, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 3248, 508, 6204, 59, 73, 61, 421, 199, 318, 511, 63, 5180, 4593, 63, 12924, 8, 2068, 63, 1069, 304, 272, 325, 838, 275, 603, 19081, 9587, 14, 362, 63, 1545, 426, 278, 2188, 83, 360, 10156, 18, 297, 11021, 466, 29, 20, 9, 272, 8850, 275, 661, 1375, 297, 283, 7367, 297, 283, 5180, 4593, 297, 288, 283, 16387, 297, 283, 54, 297, 283, 3136, 297, 283, 4468, 297, 283, 352, 951, 358, 272, 6204, 275, 334, 403, 12, 399, 14, 68, 12, 399, 14, 6458, 12, 399, 14, 6458, 12, 399, 14, 5615, 12, 399, 14, 3844, 12, 399, 14, 6458, 12, 399, 14, 6458, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 4574, 2298, 267, 702, 8850, 59, 73, 61, 315, 325, 838, 14, 3406, 267, 702, 325, 838, 59, 4574, 59, 73, 20230, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TiddlySpace/tiddlywebplugins.jsondispatcher
setup.py
1
1099
AUTHOR = 'Chris Dent' AUTHOR_EMAIL = 'cdent@peermore.com' MAINTAINER = 'Ben Paddock' MAINTAINER_EMAIL = 'pads@thisispads.me.uk' NAME = 'tiddlywebplugins.jsondispatcher' DESCRIPTION = 'A TiddlyWeb plugin to allow the dispatching of tiddlers to non-Python handlers by serialising tiddler data to JSON' VERSION = '0.1.4' import os from setuptools import setup, find_packages setup( namespace_packages = ['tiddlywebplugins'], name = NAME, version = VERSION, description = DESCRIPTION, long_description = file(os.path.join(os.path.dirname(__file__), 'README')).read(), author = AUTHOR, author_email = AUTHOR_EMAIL, maintainer = MAINTAINER, maintainer_email = MAINTAINER_EMAIL, url = 'http://pypi.python.org/pypi/%s' % NAME, packages = find_packages(exclude=['test']), platforms = 'Posix; MacOS X; Windows', install_requires = [ 'tiddlyweb', 'tiddlywebplugins.dispatcher', 'tiddlywebplugins.utils', 'beanstalkc' ], zip_safe = False, )
bsd-3-clause
[ 27938, 275, 283, 1049, 5719, 577, 484, 7, 199, 27938, 63, 10089, 275, 283, 67, 1326, 32, 7866, 6878, 14, 957, 7, 199, 2054, 2919, 9021, 540, 275, 283, 31231, 510, 525, 766, 7, 199, 2054, 2919, 9021, 540, 63, 10089, 275, 283, 6226, 83, 32, 273, 29022, 681, 9402, 14, 278, 14, 3210, 7, 199, 2339, 275, 283, 280, 617, 590, 2520, 5265, 14, 1001, 14913, 7, 199, 17705, 275, 283, 33, 377, 344, 68, 590, 5926, 3589, 370, 2040, 314, 7634, 316, 402, 3367, 617, 29099, 370, 2222, 13, 4718, 8297, 701, 3012, 11136, 3367, 617, 1435, 666, 370, 4840, 7, 199, 4612, 275, 283, 16, 14, 17, 14, 20, 7, 199, 199, 646, 747, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 199, 2758, 8, 267, 3231, 63, 5154, 275, 788, 280, 617, 590, 2520, 5265, 995, 267, 536, 275, 13637, 12, 267, 1015, 275, 15945, 12, 267, 1369, 275, 17410, 1075, 12, 267, 1846, 63, 1802, 275, 570, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 18195, 11103, 739, 1062, 267, 4132, 275, 17632, 12, 267, 4132, 63, 2123, 275, 17632, 63, 10089, 12, 267, 11075, 281, 275, 4828, 2919, 9021, 540, 12, 267, 11075, 281, 63, 2123, 275, 4828, 2919, 9021, 540, 63, 10089, 12, 267, 1166, 275, 283, 1014, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 3149, 83, 7, 450, 13637, 12, 267, 6117, 275, 2342, 63, 5154, 8, 5473, 2968, 396, 3815, 267, 10677, 275, 283, 1575, 4174, 27, 10444, 3100, 1323, 27, 5417, 297, 267, 3907, 63, 6537, 275, 359, 288, 283, 280, 617, 590, 2520, 297, 288, 283, 280, 617, 590, 2520, 5265, 14, 14913, 297, 288, 283, 280, 617, 590, 2520, 5265, 14, 1208, 297, 288, 283, 28142, 270, 4878, 67, 7, 267, 2156, 267, 3482, 63, 3489, 275, 756, 12, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 275, 283, 1049, 5719, 577, 484, 7, 199, 27938, 63, 10089, 275, 283, 67, 1326, 32, 7866, 6878, 14, 957, 7, 199, 2054, 2919, 9021, 540, 275, 283, 31231, 510, 525, 766, 7, 199, 2054, 2919, 9021, 540, 63, 10089, 275, 283, 6226, 83, 32, 273, 29022, 681, 9402, 14, 278, 14, 3210, 7, 199, 2339, 275, 283, 280, 617, 590, 2520, 5265, 14, 1001, 14913, 7, 199, 17705, 275, 283, 33, 377, 344, 68, 590, 5926, 3589, 370, 2040, 314, 7634, 316, 402, 3367, 617, 29099, 370, 2222, 13, 4718, 8297, 701, 3012, 11136, 3367, 617, 1435, 666, 370, 4840, 7, 199, 4612, 275, 283, 16, 14, 17, 14, 20, 7, 199, 199, 646, 747, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 199, 2758, 8, 267, 3231, 63, 5154, 275, 788, 280, 617, 590, 2520, 5265, 995, 267, 536, 275, 13637, 12, 267, 1015, 275, 15945, 12, 267, 1369, 275, 17410, 1075, 12, 267, 1846, 63, 1802, 275, 570, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 18195, 11103, 739, 1062, 267, 4132, 275, 17632, 12, 267, 4132, 63, 2123, 275, 17632, 63, 10089, 12, 267, 11075, 281, 275, 4828, 2919, 9021, 540, 12, 267, 11075, 281, 63, 2123, 275, 4828, 2919, 9021, 540, 63, 10089, 12, 267, 1166, 275, 283, 1014, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 3149, 83, 7, 450, 13637, 12, 267, 6117, 275, 2342, 63, 5154, 8, 5473, 2968, 396, 3815, 267, 10677, 275, 283, 1575, 4174, 27, 10444, 3100, 1323, 27, 5417, 297, 267, 3907, 63, 6537, 275, 359, 288, 283, 280, 617, 590, 2520, 297, 288, 283, 280, 617, 590, 2520, 5265, 14, 14913, 297, 288, 283, 280, 617, 590, 2520, 5265, 14, 1208, 297, 288, 283, 28142, 270, 4878, 67, 7, 267, 2156, 267, 3482, 63, 3489, 275, 756, 12, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
yannrouillard/weboob
modules/parolesmania/test.py
4
1700
# -*- coding: utf-8 -*- # Copyright(C) 2013 Julien Veyssier # # This file is part of weboob. # # weboob 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. # # weboob 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 weboob. If not, see <http://www.gnu.org/licenses/>. from weboob.tools.test import BackendTest from weboob.capabilities.base import NotLoaded class ParolesmaniaTest(BackendTest): BACKEND = 'parolesmania' def test_search_song_n_get(self): l_lyrics = list(self.backend.iter_lyrics('song', 'chien')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded full_lyr = self.backend.get_lyrics(songlyrics.id) assert full_lyr.id assert full_lyr.title assert full_lyr.artist assert full_lyr.content is not NotLoaded def test_search_artist(self): l_lyrics = list(self.backend.iter_lyrics('artist', 'boris')) for songlyrics in l_lyrics: assert songlyrics.id assert songlyrics.title assert songlyrics.artist assert songlyrics.content is NotLoaded
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6171, 1603, 13987, 287, 25777, 588, 338, 281, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 29896, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 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, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 29896, 14, 2537, 14, 396, 492, 25674, 774, 199, 504, 29896, 14, 10732, 14, 1095, 492, 2832, 19757, 421, 199, 533, 2235, 79, 2978, 1237, 4674, 774, 8, 8447, 774, 304, 272, 22658, 3902, 275, 283, 462, 79, 2978, 1237, 4674, 7, 339, 347, 511, 63, 1733, 63, 19351, 63, 78, 63, 362, 8, 277, 304, 267, 634, 63, 590, 11818, 275, 769, 8, 277, 14, 4620, 14, 1661, 63, 590, 11818, 360, 19351, 297, 283, 13175, 287, 1333, 267, 367, 20178, 590, 11818, 315, 634, 63, 590, 11818, 26, 288, 702, 20178, 590, 11818, 14, 344, 288, 702, 20178, 590, 11818, 14, 1213, 288, 702, 20178, 590, 11818, 14, 11215, 288, 702, 20178, 590, 11818, 14, 1317, 365, 2832, 19757, 288, 2615, 63, 590, 82, 275, 291, 14, 4620, 14, 362, 63, 590, 11818, 8, 19351, 590, 11818, 14, 344, 9, 288, 702, 2615, 63, 590, 82, 14, 344, 288, 702, 2615, 63, 590, 82, 14, 1213, 288, 702, 2615, 63, 590, 82, 14, 11215, 288, 702, 2615, 63, 590, 82, 14, 1317, 365, 440, 2832, 19757, 339, 347, 511, 63, 1733, 63, 11215, 8, 277, 304, 267, 634, 63, 590, 11818, 275, 769, 8, 277, 14, 4620, 14, 1661, 63, 590, 11818, 360, 11215, 297, 283, 31938, 374, 1333, 267, 367, 20178, 590, 11818, 315, 634, 63, 590, 11818, 26, 288, 702, 20178, 590, 11818, 14, 344, 288, 702, 20178, 590, 11818, 14, 1213, 288, 702, 20178, 590, 11818, 14, 11215, 288, 702, 20178, 590, 11818, 14, 1317, 365, 2832, 19757, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 8, 35, 9, 6171, 1603, 13987, 287, 25777, 588, 338, 281, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 29896, 14, 199, 3, 199, 3, 29896, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 29896, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 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, 29896, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 29896, 14, 2537, 14, 396, 492, 25674, 774, 199, 504, 29896, 14, 10732, 14, 1095, 492, 2832, 19757, 421, 199, 533, 2235, 79, 2978, 1237, 4674, 774, 8, 8447, 774, 304, 272, 22658, 3902, 275, 283, 462, 79, 2978, 1237, 4674, 7, 339, 347, 511, 63, 1733, 63, 19351, 63, 78, 63, 362, 8, 277, 304, 267, 634, 63, 590, 11818, 275, 769, 8, 277, 14, 4620, 14, 1661, 63, 590, 11818, 360, 19351, 297, 283, 13175, 287, 1333, 267, 367, 20178, 590, 11818, 315, 634, 63, 590, 11818, 26, 288, 702, 20178, 590, 11818, 14, 344, 288, 702, 20178, 590, 11818, 14, 1213, 288, 702, 20178, 590, 11818, 14, 11215, 288, 702, 20178, 590, 11818, 14, 1317, 365, 2832, 19757, 288, 2615, 63, 590, 82, 275, 291, 14, 4620, 14, 362, 63, 590, 11818, 8, 19351, 590, 11818, 14, 344, 9, 288, 702, 2615, 63, 590, 82, 14, 344, 288, 702, 2615, 63, 590, 82, 14, 1213, 288, 702, 2615, 63, 590, 82, 14, 11215, 288, 702, 2615, 63, 590, 82, 14, 1317, 365, 440, 2832, 19757, 339, 347, 511, 63, 1733, 63, 11215, 8, 277, 304, 267, 634, 63, 590, 11818, 275, 769, 8, 277, 14, 4620, 14, 1661, 63, 590, 11818, 360, 11215, 297, 283, 31938, 374, 1333, 267, 367, 20178, 590, 11818, 315, 634, 63, 590, 11818, 26, 288, 702, 20178, 590, 11818, 14, 344, 288, 702, 20178, 590, 11818, 14, 1213, 288, 702, 20178, 590, 11818, 14, 11215, 288, 702, 20178, 590, 11818, 14, 1317, 365, 2832, 19757, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vdods/fabric
bddtests/devops_pb2.py
46
23887
# Generated by the protocol buffer compiler. DO NOT EDIT! # source: devops.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() import chaincode_pb2 as chaincode__pb2 import fabric_pb2 as fabric__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='devops.proto', package='protos', syntax='proto3', serialized_pb=_b('\n\x0c\x64\x65vops.proto\x12\x06protos\x1a\x0f\x63haincode.proto\x1a\x0c\x66\x61\x62ric.proto\"0\n\x06Secret\x12\x10\n\x08\x65nrollId\x18\x01 \x01(\t\x12\x14\n\x0c\x65nrollSecret\x18\x02 \x01(\t\"L\n\nSigmaInput\x12\x1e\n\x06secret\x18\x01 \x01(\x0b\x32\x0e.protos.Secret\x12\x10\n\x08\x61ppTCert\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"g\n\x12\x45xecuteWithBinding\x12@\n\x17\x63haincodeInvocationSpec\x18\x01 \x01(\x0b\x32\x1f.protos.ChaincodeInvocationSpec\x12\x0f\n\x07\x62inding\x18\x02 \x01(\x0c\"A\n\x0bSigmaOutput\x12\r\n\x05tcert\x18\x01 \x01(\x0c\x12\r\n\x05sigma\x18\x02 \x01(\x0c\x12\x14\n\x0c\x61sn1Encoding\x18\x03 \x01(\x0c\"\xba\x01\n\x0b\x42uildResult\x12.\n\x06status\x18\x01 \x01(\x0e\x32\x1e.protos.BuildResult.StatusCode\x12\x0b\n\x03msg\x18\x02 \x01(\t\x12\x37\n\x0e\x64\x65ploymentSpec\x18\x03 \x01(\x0b\x32\x1f.protos.ChaincodeDeploymentSpec\"5\n\nStatusCode\x12\r\n\tUNDEFINED\x10\x00\x12\x0b\n\x07SUCCESS\x10\x01\x12\x0b\n\x07\x46\x41ILURE\x10\x02\"-\n\x12TransactionRequest\x12\x17\n\x0ftransactionUuid\x18\x01 \x01(\t2\xfe\x04\n\x06\x44\x65vops\x12+\n\x05Login\x12\x0e.protos.Secret\x1a\x10.protos.Response\"\x00\x12\x41\n\x05\x42uild\x12\x15.protos.ChaincodeSpec\x1a\x1f.protos.ChaincodeDeploymentSpec\"\x00\x12\x42\n\x06\x44\x65ploy\x12\x15.protos.ChaincodeSpec\x1a\x1f.protos.ChaincodeDeploymentSpec\"\x00\x12=\n\x06Invoke\x12\x1f.protos.ChaincodeInvocationSpec\x1a\x10.protos.Response\"\x00\x12<\n\x05Query\x12\x1f.protos.ChaincodeInvocationSpec\x1a\x10.protos.Response\"\x00\x12\x46\n\x14GetTransactionResult\x12\x1a.protos.TransactionRequest\x1a\x10.protos.Response\"\x00\x12=\n\x17\x45XP_GetApplicationTCert\x12\x0e.protos.Secret\x1a\x10.protos.Response\"\x00\x12\x36\n\x10\x45XP_PrepareForTx\x12\x0e.protos.Secret\x1a\x10.protos.Response\"\x00\x12:\n\x10\x45XP_ProduceSigma\x12\x12.protos.SigmaInput\x1a\x10.protos.Response\"\x00\x12H\n\x16\x45XP_ExecuteWithBinding\x12\x1a.protos.ExecuteWithBinding\x1a\x10.protos.Response\"\x00\x62\x06proto3') , dependencies=[chaincode__pb2.DESCRIPTOR,fabric__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) _BUILDRESULT_STATUSCODE = _descriptor.EnumDescriptor( name='StatusCode', full_name='protos.BuildResult.StatusCode', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor( name='UNDEFINED', index=0, number=0, options=None, type=None), _descriptor.EnumValueDescriptor( name='SUCCESS', index=1, number=1, options=None, type=None), _descriptor.EnumValueDescriptor( name='FAILURE', index=2, number=2, options=None, type=None), ], containing_type=None, options=None, serialized_start=489, serialized_end=542, ) _sym_db.RegisterEnumDescriptor(_BUILDRESULT_STATUSCODE) _SECRET = _descriptor.Descriptor( name='Secret', full_name='protos.Secret', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='enrollId', full_name='protos.Secret.enrollId', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='enrollSecret', full_name='protos.Secret.enrollSecret', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=55, serialized_end=103, ) _SIGMAINPUT = _descriptor.Descriptor( name='SigmaInput', full_name='protos.SigmaInput', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='secret', full_name='protos.SigmaInput.secret', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='appTCert', full_name='protos.SigmaInput.appTCert', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='data', full_name='protos.SigmaInput.data', index=2, number=3, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=105, serialized_end=181, ) _EXECUTEWITHBINDING = _descriptor.Descriptor( name='ExecuteWithBinding', full_name='protos.ExecuteWithBinding', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='chaincodeInvocationSpec', full_name='protos.ExecuteWithBinding.chaincodeInvocationSpec', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='binding', full_name='protos.ExecuteWithBinding.binding', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=183, serialized_end=286, ) _SIGMAOUTPUT = _descriptor.Descriptor( name='SigmaOutput', full_name='protos.SigmaOutput', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='tcert', full_name='protos.SigmaOutput.tcert', index=0, number=1, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='sigma', full_name='protos.SigmaOutput.sigma', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='asn1Encoding', full_name='protos.SigmaOutput.asn1Encoding', index=2, number=3, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=288, serialized_end=353, ) _BUILDRESULT = _descriptor.Descriptor( name='BuildResult', full_name='protos.BuildResult', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='status', full_name='protos.BuildResult.status', index=0, number=1, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='msg', full_name='protos.BuildResult.msg', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( name='deploymentSpec', full_name='protos.BuildResult.deploymentSpec', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ _BUILDRESULT_STATUSCODE, ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=356, serialized_end=542, ) _TRANSACTIONREQUEST = _descriptor.Descriptor( name='TransactionRequest', full_name='protos.TransactionRequest', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( name='transactionUuid', full_name='protos.TransactionRequest.transactionUuid', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], nested_types=[], enum_types=[ ], options=None, is_extendable=False, syntax='proto3', extension_ranges=[], oneofs=[ ], serialized_start=544, serialized_end=589, ) _SIGMAINPUT.fields_by_name['secret'].message_type = _SECRET _EXECUTEWITHBINDING.fields_by_name['chaincodeInvocationSpec'].message_type = chaincode__pb2._CHAINCODEINVOCATIONSPEC _BUILDRESULT.fields_by_name['status'].enum_type = _BUILDRESULT_STATUSCODE _BUILDRESULT.fields_by_name['deploymentSpec'].message_type = chaincode__pb2._CHAINCODEDEPLOYMENTSPEC _BUILDRESULT_STATUSCODE.containing_type = _BUILDRESULT DESCRIPTOR.message_types_by_name['Secret'] = _SECRET DESCRIPTOR.message_types_by_name['SigmaInput'] = _SIGMAINPUT DESCRIPTOR.message_types_by_name['ExecuteWithBinding'] = _EXECUTEWITHBINDING DESCRIPTOR.message_types_by_name['SigmaOutput'] = _SIGMAOUTPUT DESCRIPTOR.message_types_by_name['BuildResult'] = _BUILDRESULT DESCRIPTOR.message_types_by_name['TransactionRequest'] = _TRANSACTIONREQUEST Secret = _reflection.GeneratedProtocolMessageType('Secret', (_message.Message,), dict( DESCRIPTOR = _SECRET, __module__ = 'devops_pb2' # @@protoc_insertion_point(class_scope:protos.Secret) )) _sym_db.RegisterMessage(Secret) SigmaInput = _reflection.GeneratedProtocolMessageType('SigmaInput', (_message.Message,), dict( DESCRIPTOR = _SIGMAINPUT, __module__ = 'devops_pb2' # @@protoc_insertion_point(class_scope:protos.SigmaInput) )) _sym_db.RegisterMessage(SigmaInput) ExecuteWithBinding = _reflection.GeneratedProtocolMessageType('ExecuteWithBinding', (_message.Message,), dict( DESCRIPTOR = _EXECUTEWITHBINDING, __module__ = 'devops_pb2' # @@protoc_insertion_point(class_scope:protos.ExecuteWithBinding) )) _sym_db.RegisterMessage(ExecuteWithBinding) SigmaOutput = _reflection.GeneratedProtocolMessageType('SigmaOutput', (_message.Message,), dict( DESCRIPTOR = _SIGMAOUTPUT, __module__ = 'devops_pb2' # @@protoc_insertion_point(class_scope:protos.SigmaOutput) )) _sym_db.RegisterMessage(SigmaOutput) BuildResult = _reflection.GeneratedProtocolMessageType('BuildResult', (_message.Message,), dict( DESCRIPTOR = _BUILDRESULT, __module__ = 'devops_pb2' # @@protoc_insertion_point(class_scope:protos.BuildResult) )) _sym_db.RegisterMessage(BuildResult) TransactionRequest = _reflection.GeneratedProtocolMessageType('TransactionRequest', (_message.Message,), dict( DESCRIPTOR = _TRANSACTIONREQUEST, __module__ = 'devops_pb2' # @@protoc_insertion_point(class_scope:protos.TransactionRequest) )) _sym_db.RegisterMessage(TransactionRequest) import abc import six from grpc.beta import implementations as beta_implementations from grpc.beta import interfaces as beta_interfaces from grpc.framework.common import cardinality from grpc.framework.interfaces.face import utilities as face_utilities class BetaDevopsServicer(object): """Interface exported by the server. """ def Login(self, request, context): """Log in - passed Secret object and returns Response object, where msg is the security context to be used in subsequent invocations """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def Build(self, request, context): """Build the chaincode package. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def Deploy(self, request, context): """Deploy the chaincode package to the chain. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def Invoke(self, request, context): """Invoke chaincode. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def Query(self, request, context): """Invoke chaincode. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def GetTransactionResult(self, request, context): """Request a TransactionResult. The Response.Msg will contain the TransactionResult if successfully found the transaction in the chain. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def EXP_GetApplicationTCert(self, request, context): """Retrieve a TCert. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def EXP_PrepareForTx(self, request, context): """Prepare for performing a TX, which will return a binding that can later be used to sign and then execute a transaction. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def EXP_ProduceSigma(self, request, context): """Prepare for performing a TX, which will return a binding that can later be used to sign and then execute a transaction. """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def EXP_ExecuteWithBinding(self, request, context): """Execute a transaction with a specific binding """ context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) class BetaDevopsStub(object): """Interface exported by the server. """ def Login(self, request, timeout): """Log in - passed Secret object and returns Response object, where msg is the security context to be used in subsequent invocations """ raise NotImplementedError() Login.future = None def Build(self, request, timeout): """Build the chaincode package. """ raise NotImplementedError() Build.future = None def Deploy(self, request, timeout): """Deploy the chaincode package to the chain. """ raise NotImplementedError() Deploy.future = None def Invoke(self, request, timeout): """Invoke chaincode. """ raise NotImplementedError() Invoke.future = None def Query(self, request, timeout): """Invoke chaincode. """ raise NotImplementedError() Query.future = None def GetTransactionResult(self, request, timeout): """Request a TransactionResult. The Response.Msg will contain the TransactionResult if successfully found the transaction in the chain. """ raise NotImplementedError() GetTransactionResult.future = None def EXP_GetApplicationTCert(self, request, timeout): """Retrieve a TCert. """ raise NotImplementedError() EXP_GetApplicationTCert.future = None def EXP_PrepareForTx(self, request, timeout): """Prepare for performing a TX, which will return a binding that can later be used to sign and then execute a transaction. """ raise NotImplementedError() EXP_PrepareForTx.future = None def EXP_ProduceSigma(self, request, timeout): """Prepare for performing a TX, which will return a binding that can later be used to sign and then execute a transaction. """ raise NotImplementedError() EXP_ProduceSigma.future = None def EXP_ExecuteWithBinding(self, request, timeout): """Execute a transaction with a specific binding """ raise NotImplementedError() EXP_ExecuteWithBinding.future = None def beta_create_Devops_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): import devops_pb2 import fabric_pb2 import chaincode_pb2 import chaincode_pb2 import chaincode_pb2 import chaincode_pb2 import chaincode_pb2 import fabric_pb2 import chaincode_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 request_deserializers = { ('protos.Devops', 'Build'): chaincode_pb2.ChaincodeSpec.FromString, ('protos.Devops', 'Deploy'): chaincode_pb2.ChaincodeSpec.FromString, ('protos.Devops', 'EXP_ExecuteWithBinding'): devops_pb2.ExecuteWithBinding.FromString, ('protos.Devops', 'EXP_GetApplicationTCert'): devops_pb2.Secret.FromString, ('protos.Devops', 'EXP_PrepareForTx'): devops_pb2.Secret.FromString, ('protos.Devops', 'EXP_ProduceSigma'): devops_pb2.SigmaInput.FromString, ('protos.Devops', 'GetTransactionResult'): devops_pb2.TransactionRequest.FromString, ('protos.Devops', 'Invoke'): chaincode_pb2.ChaincodeInvocationSpec.FromString, ('protos.Devops', 'Login'): devops_pb2.Secret.FromString, ('protos.Devops', 'Query'): chaincode_pb2.ChaincodeInvocationSpec.FromString, } response_serializers = { ('protos.Devops', 'Build'): chaincode_pb2.ChaincodeDeploymentSpec.SerializeToString, ('protos.Devops', 'Deploy'): chaincode_pb2.ChaincodeDeploymentSpec.SerializeToString, ('protos.Devops', 'EXP_ExecuteWithBinding'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'EXP_GetApplicationTCert'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'EXP_PrepareForTx'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'EXP_ProduceSigma'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'GetTransactionResult'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'Invoke'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'Login'): fabric_pb2.Response.SerializeToString, ('protos.Devops', 'Query'): fabric_pb2.Response.SerializeToString, } method_implementations = { ('protos.Devops', 'Build'): face_utilities.unary_unary_inline(servicer.Build), ('protos.Devops', 'Deploy'): face_utilities.unary_unary_inline(servicer.Deploy), ('protos.Devops', 'EXP_ExecuteWithBinding'): face_utilities.unary_unary_inline(servicer.EXP_ExecuteWithBinding), ('protos.Devops', 'EXP_GetApplicationTCert'): face_utilities.unary_unary_inline(servicer.EXP_GetApplicationTCert), ('protos.Devops', 'EXP_PrepareForTx'): face_utilities.unary_unary_inline(servicer.EXP_PrepareForTx), ('protos.Devops', 'EXP_ProduceSigma'): face_utilities.unary_unary_inline(servicer.EXP_ProduceSigma), ('protos.Devops', 'GetTransactionResult'): face_utilities.unary_unary_inline(servicer.GetTransactionResult), ('protos.Devops', 'Invoke'): face_utilities.unary_unary_inline(servicer.Invoke), ('protos.Devops', 'Login'): face_utilities.unary_unary_inline(servicer.Login), ('protos.Devops', 'Query'): face_utilities.unary_unary_inline(servicer.Query), } server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) return beta_implementations.server(method_implementations, options=server_options) def beta_create_Devops_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): import devops_pb2 import fabric_pb2 import chaincode_pb2 import chaincode_pb2 import chaincode_pb2 import chaincode_pb2 import chaincode_pb2 import fabric_pb2 import chaincode_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 import devops_pb2 import fabric_pb2 request_serializers = { ('protos.Devops', 'Build'): chaincode_pb2.ChaincodeSpec.SerializeToString, ('protos.Devops', 'Deploy'): chaincode_pb2.ChaincodeSpec.SerializeToString, ('protos.Devops', 'EXP_ExecuteWithBinding'): devops_pb2.ExecuteWithBinding.SerializeToString, ('protos.Devops', 'EXP_GetApplicationTCert'): devops_pb2.Secret.SerializeToString, ('protos.Devops', 'EXP_PrepareForTx'): devops_pb2.Secret.SerializeToString, ('protos.Devops', 'EXP_ProduceSigma'): devops_pb2.SigmaInput.SerializeToString, ('protos.Devops', 'GetTransactionResult'): devops_pb2.TransactionRequest.SerializeToString, ('protos.Devops', 'Invoke'): chaincode_pb2.ChaincodeInvocationSpec.SerializeToString, ('protos.Devops', 'Login'): devops_pb2.Secret.SerializeToString, ('protos.Devops', 'Query'): chaincode_pb2.ChaincodeInvocationSpec.SerializeToString, } response_deserializers = { ('protos.Devops', 'Build'): chaincode_pb2.ChaincodeDeploymentSpec.FromString, ('protos.Devops', 'Deploy'): chaincode_pb2.ChaincodeDeploymentSpec.FromString, ('protos.Devops', 'EXP_ExecuteWithBinding'): fabric_pb2.Response.FromString, ('protos.Devops', 'EXP_GetApplicationTCert'): fabric_pb2.Response.FromString, ('protos.Devops', 'EXP_PrepareForTx'): fabric_pb2.Response.FromString, ('protos.Devops', 'EXP_ProduceSigma'): fabric_pb2.Response.FromString, ('protos.Devops', 'GetTransactionResult'): fabric_pb2.Response.FromString, ('protos.Devops', 'Invoke'): fabric_pb2.Response.FromString, ('protos.Devops', 'Login'): fabric_pb2.Response.FromString, ('protos.Devops', 'Query'): fabric_pb2.Response.FromString, } cardinalities = { 'Build': cardinality.Cardinality.UNARY_UNARY, 'Deploy': cardinality.Cardinality.UNARY_UNARY, 'EXP_ExecuteWithBinding': cardinality.Cardinality.UNARY_UNARY, 'EXP_GetApplicationTCert': cardinality.Cardinality.UNARY_UNARY, 'EXP_PrepareForTx': cardinality.Cardinality.UNARY_UNARY, 'EXP_ProduceSigma': cardinality.Cardinality.UNARY_UNARY, 'GetTransactionResult': cardinality.Cardinality.UNARY_UNARY, 'Invoke': cardinality.Cardinality.UNARY_UNARY, 'Login': cardinality.Cardinality.UNARY_UNARY, 'Query': cardinality.Cardinality.UNARY_UNARY, } stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) return beta_implementations.dynamic_stub(channel, 'protos.Devops', cardinalities, options=stub_options) # @@protoc_insertion_point(module_scope)
apache-2.0
[ 3, 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 4866, 1483, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 646, 6036, 600, 63, 3317, 18, 465, 6036, 600, 363, 3317, 18, 199, 646, 2630, 63, 3317, 18, 465, 2630, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 2374, 1483, 14, 2625, 297, 523, 2559, 534, 27478, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 60, 88, 16, 67, 60, 88, 772, 60, 88, 2182, 86, 1483, 14, 2625, 60, 88, 713, 60, 88, 1690, 27478, 60, 88, 17, 65, 60, 88, 16, 70, 60, 88, 2766, 72, 1581, 600, 14, 2625, 60, 88, 17, 65, 60, 88, 16, 67, 60, 88, 1272, 60, 88, 2976, 60, 88, 2789, 1567, 14, 2625, 4451, 16, 60, 78, 60, 88, 1690, 13790, 60, 88, 713, 60, 88, 709, 60, 78, 60, 88, 2036, 60, 88, 2182, 78, 2827, 1304, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1079, 60, 78, 60, 88, 16, 67, 60, 88, 2182, 78, 2827, 13790, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 4451, 44, 60, 78, 60, 78, 23394, 3205, 60, 88, 713, 60, 88, 17, 69, 60, 78, 60, 88, 1690, 4731, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 16, 69, 14, 27478, 14, 13790, 60, 88, 713, 60, 88, 709, 60, 78, 60, 88, 2036, 60, 88, 2976, 802, 5708, 15299, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 60, 88, 772, 60, 88, 2976, 502, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 16, 67, 4451, 71, 60, 78, 60, 88, 713, 60, 88, 2322, 9542, 938, 3007, 17490, 60, 88, 713, 32, 60, 78, 60, 88, 1196, 60, 88, 2766, 72, 1581, 600, 14883, 13364, 5307, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 14883, 13364, 5307, 60, 88, 713, 60, 88, 16, 70, 60, 78, 60, 88, 1780, 60, 88, 2789, 688, 316, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 67, 4451, 33, 60, 78, 60, 88, 16, 66, 23394, 2959, 60, 88, 713, 60, 82, 60, 78, 60, 88, 1717, 84, 4736, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 60, 82, 60, 78, 60, 88, 1717, 9412, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 60, 88, 1079, 60, 78, 60, 88, 16, 67, 60, 88, 2976, 5167, 17, 7630, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 16, 67, 13356, 10539, 60, 88, 614, 60, 78, 60, 88, 16, 66, 60, 88, 2260, 85, 668, 2889, 60, 88, 713, 3134, 78, 60, 88, 1690, 1205, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 60, 88, 17, 69, 14, 27478, 14, 3425, 2889, 14, 23018, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1644, 1328, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1401, 60, 78, 60, 88, 16, 69, 60, 88, 772, 60, 88, 2182, 80, 7775, 5307, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 25434, 5307, 4451, 21, 60, 78, 60, 78, 23018, 60, 88, 713, 60, 82, 60, 78, 60, 84, 1734, 12857, 60, 88, 709, 60, 88, 383, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1780, 12779, 60, 88, 709, 60, 88, 614, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1780, 60, 88, 2466, 60, 88, 2953, 1193, 3942, 60, 88, 709, 60, 88, 996, 4451, 2696, 78, 60, 88, 713, 10161, 2017, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 5945, 19557, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 18, 60, 8371, 60, 88, 966, 60, 78, 60, 88, 1690, 60, 88, 1602, 60, 88, 2182, 86, 1483, 60, 88, 713, 7896, 78, 60, 88, 1717, 8880, 60, 88, 713, 60, 88, 16, 69, 14, 27478, 14, 13790, 60, 88, 17, 65, 60, 88, 709, 14, 27478, 14, 2364, 13356, 88, 383, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 1717, 60, 88, 2260, 85, 668, 60, 88, 713, 60, 88, 1046, 14, 27478, 14, 10720, 600, 5307, 60, 88, 17, 65, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 25434, 5307, 13356, 88, 383, 60, 88, 713, 60, 88, 2260, 60, 78, 60, 88, 1690, 60, 88, 1602, 60, 88, 2182, 80, 3374, 60, 88, 713, 60, 88, 1046, 14, 27478, 14, 10720, 600, 5307, 60, 88, 17, 65, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 25434, 5307, 13356, 88, 383, 60, 88, 713, 9529, 78, 60, 88, 1690, 27736, 60, 88, 713, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 14883, 13364, 5307, 60, 88, 17, 65, 60, 88, 709, 14, 27478, 14, 2364, 13356, 88, 383, 60, 88, 713, 31873 ]
[ 17065, 701, 314, 4113, 3335, 6365, 14, 221, 3506, 2845, 24981, 1, 199, 3, 1350, 26, 4866, 1483, 14, 2625, 199, 199, 646, 984, 199, 63, 66, 29, 1274, 14, 1023, 63, 815, 59, 16, 61, 28, 19, 436, 334, 2734, 671, 26, 88, 9, 503, 334, 2734, 671, 26, 88, 14, 2143, 360, 10378, 17, 1333, 199, 504, 6233, 14, 7204, 492, 5872, 465, 485, 4120, 199, 504, 6233, 14, 7204, 492, 1245, 465, 485, 1188, 199, 504, 6233, 14, 7204, 492, 25572, 465, 485, 14906, 199, 504, 6233, 14, 7204, 492, 5272, 63, 4659, 465, 485, 5155, 63, 4659, 199, 504, 6233, 14, 7204, 492, 5872, 63, 3317, 18, 199, 3, 13365, 16311, 63, 14739, 63, 1403, 8, 12775, 9, 199, 199, 63, 3840, 63, 697, 275, 485, 5155, 63, 4659, 14, 2698, 342, 421, 199, 646, 6036, 600, 63, 3317, 18, 465, 6036, 600, 363, 3317, 18, 199, 646, 2630, 63, 3317, 18, 465, 2630, 363, 3317, 18, 421, 199, 7580, 275, 485, 4120, 14, 23859, 8, 523, 536, 534, 2374, 1483, 14, 2625, 297, 523, 2559, 534, 27478, 297, 523, 6302, 534, 2625, 19, 297, 523, 6380, 63, 3317, 3699, 66, 2258, 78, 60, 88, 16, 67, 60, 88, 772, 60, 88, 2182, 86, 1483, 14, 2625, 60, 88, 713, 60, 88, 1690, 27478, 60, 88, 17, 65, 60, 88, 16, 70, 60, 88, 2766, 72, 1581, 600, 14, 2625, 60, 88, 17, 65, 60, 88, 16, 67, 60, 88, 1272, 60, 88, 2976, 60, 88, 2789, 1567, 14, 2625, 4451, 16, 60, 78, 60, 88, 1690, 13790, 60, 88, 713, 60, 88, 709, 60, 78, 60, 88, 2036, 60, 88, 2182, 78, 2827, 1304, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1079, 60, 78, 60, 88, 16, 67, 60, 88, 2182, 78, 2827, 13790, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 4451, 44, 60, 78, 60, 78, 23394, 3205, 60, 88, 713, 60, 88, 17, 69, 60, 78, 60, 88, 1690, 4731, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 16, 69, 14, 27478, 14, 13790, 60, 88, 713, 60, 88, 709, 60, 78, 60, 88, 2036, 60, 88, 2976, 802, 5708, 15299, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 60, 88, 16, 67, 60, 78, 60, 88, 966, 60, 88, 772, 60, 88, 2976, 502, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 16, 67, 4451, 71, 60, 78, 60, 88, 713, 60, 88, 2322, 9542, 938, 3007, 17490, 60, 88, 713, 32, 60, 78, 60, 88, 1196, 60, 88, 2766, 72, 1581, 600, 14883, 13364, 5307, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 14883, 13364, 5307, 60, 88, 713, 60, 88, 16, 70, 60, 78, 60, 88, 1780, 60, 88, 2789, 688, 316, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 67, 4451, 33, 60, 78, 60, 88, 16, 66, 23394, 2959, 60, 88, 713, 60, 82, 60, 78, 60, 88, 1717, 84, 4736, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 60, 82, 60, 78, 60, 88, 1717, 9412, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 88, 16, 67, 60, 88, 713, 60, 88, 1079, 60, 78, 60, 88, 16, 67, 60, 88, 2976, 5167, 17, 7630, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 16, 67, 13356, 10539, 60, 88, 614, 60, 78, 60, 88, 16, 66, 60, 88, 2260, 85, 668, 2889, 60, 88, 713, 3134, 78, 60, 88, 1690, 1205, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 88, 16, 69, 60, 88, 708, 60, 88, 17, 69, 14, 27478, 14, 3425, 2889, 14, 23018, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1644, 1328, 60, 88, 1085, 60, 88, 996, 971, 88, 614, 2961, 84, 60, 88, 713, 60, 88, 1401, 60, 78, 60, 88, 16, 69, 60, 88, 772, 60, 88, 2182, 80, 7775, 5307, 60, 88, 1085, 60, 88, 1644, 971, 88, 614, 2961, 88, 16, 66, 60, 88, 708, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 25434, 5307, 4451, 21, 60, 78, 60, 78, 23018, 60, 88, 713, 60, 82, 60, 78, 60, 84, 1734, 12857, 60, 88, 709, 60, 88, 383, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1780, 12779, 60, 88, 709, 60, 88, 614, 60, 88, 713, 60, 88, 16, 66, 60, 78, 60, 88, 1780, 60, 88, 2466, 60, 88, 2953, 1193, 3942, 60, 88, 709, 60, 88, 996, 4451, 2696, 78, 60, 88, 713, 10161, 2017, 60, 88, 713, 60, 88, 1196, 60, 78, 60, 88, 16, 70, 5945, 19557, 60, 88, 1085, 60, 88, 614, 971, 88, 614, 2961, 84, 18, 60, 8371, 60, 88, 966, 60, 78, 60, 88, 1690, 60, 88, 1602, 60, 88, 2182, 86, 1483, 60, 88, 713, 7896, 78, 60, 88, 1717, 8880, 60, 88, 713, 60, 88, 16, 69, 14, 27478, 14, 13790, 60, 88, 17, 65, 60, 88, 709, 14, 27478, 14, 2364, 13356, 88, 383, 60, 88, 713, 60, 88, 2953, 60, 78, 60, 88, 1717, 60, 88, 2260, 85, 668, 60, 88, 713, 60, 88, 1046, 14, 27478, 14, 10720, 600, 5307, 60, 88, 17, 65, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 25434, 5307, 13356, 88, 383, 60, 88, 713, 60, 88, 2260, 60, 78, 60, 88, 1690, 60, 88, 1602, 60, 88, 2182, 80, 3374, 60, 88, 713, 60, 88, 1046, 14, 27478, 14, 10720, 600, 5307, 60, 88, 17, 65, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 25434, 5307, 13356, 88, 383, 60, 88, 713, 9529, 78, 60, 88, 1690, 27736, 60, 88, 713, 60, 88, 17, 70, 14, 27478, 14, 10720, 600, 14883, 13364, 5307, 60, 88, 17, 65, 60, 88, 709, 14, 27478, 14, 2364, 13356, 88, 383, 60, 88, 713, 31873, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
digimarc/django
django/http/__init__.py
98
1186
from django.http.cookie import SimpleCookie, parse_cookie from django.http.request import (HttpRequest, QueryDict, RawPostDataException, UnreadablePostError, build_request_repr) from django.http.response import ( HttpResponse, StreamingHttpResponse, FileResponse, HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseNotModified, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseNotAllowed, HttpResponseGone, HttpResponseServerError, Http404, BadHeaderError, JsonResponse, ) from django.http.utils import fix_location_header, conditional_content_removal __all__ = [ 'SimpleCookie', 'parse_cookie', 'HttpRequest', 'QueryDict', 'RawPostDataException', 'UnreadablePostError', 'build_request_repr', 'HttpResponse', 'StreamingHttpResponse', 'HttpResponseRedirect', 'HttpResponsePermanentRedirect', 'HttpResponseNotModified', 'HttpResponseBadRequest', 'HttpResponseForbidden', 'HttpResponseNotFound', 'HttpResponseNotAllowed', 'HttpResponseGone', 'HttpResponseServerError', 'Http404', 'BadHeaderError', 'fix_location_header', 'JsonResponse', 'FileResponse', 'conditional_content_removal', ]
bsd-3-clause
[ 504, 1639, 14, 1014, 14, 5306, 492, 5870, 7810, 12, 2198, 63, 5306, 199, 504, 1639, 14, 1014, 14, 1069, 492, 334, 10441, 12, 8133, 2141, 12, 272, 13480, 6564, 1451, 1726, 12, 1910, 11875, 6564, 547, 12, 1900, 63, 1069, 63, 2722, 9, 199, 504, 1639, 14, 1014, 14, 1310, 492, 334, 272, 6183, 12, 28167, 16287, 12, 3814, 2364, 12, 272, 14935, 12, 6183, 31776, 7071, 12, 272, 6183, 1763, 11911, 12, 6183, 12380, 12, 6183, 17454, 12, 272, 6183, 4667, 12, 6183, 29967, 12, 6183, 39, 368, 12, 272, 6183, 17692, 12, 4760, 5188, 12, 8857, 26599, 12, 21072, 12, 199, 9, 199, 504, 1639, 14, 1014, 14, 1208, 492, 5325, 63, 1985, 63, 1291, 12, 12303, 63, 1317, 63, 25818, 199, 199, 363, 452, 363, 275, 359, 272, 283, 3184, 7810, 297, 283, 1122, 63, 5306, 297, 283, 10441, 297, 283, 3227, 2141, 297, 272, 283, 7963, 6564, 1451, 1726, 297, 283, 1358, 11875, 6564, 547, 297, 283, 1506, 63, 1069, 63, 2722, 297, 272, 283, 16287, 297, 283, 22555, 16287, 297, 283, 16287, 7071, 297, 272, 283, 16287, 31776, 7071, 297, 283, 16287, 1763, 11911, 297, 272, 283, 16287, 12380, 297, 283, 16287, 17454, 297, 283, 16287, 4667, 297, 272, 283, 16287, 29967, 297, 283, 16287, 39, 368, 297, 283, 16287, 17692, 297, 272, 283, 5779, 5188, 297, 283, 5725, 26599, 297, 283, 970, 63, 1985, 63, 1291, 297, 283, 9653, 2364, 297, 272, 283, 1173, 2364, 297, 283, 14353, 63, 1317, 63, 25818, 297, 199, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1014, 14, 5306, 492, 5870, 7810, 12, 2198, 63, 5306, 199, 504, 1639, 14, 1014, 14, 1069, 492, 334, 10441, 12, 8133, 2141, 12, 272, 13480, 6564, 1451, 1726, 12, 1910, 11875, 6564, 547, 12, 1900, 63, 1069, 63, 2722, 9, 199, 504, 1639, 14, 1014, 14, 1310, 492, 334, 272, 6183, 12, 28167, 16287, 12, 3814, 2364, 12, 272, 14935, 12, 6183, 31776, 7071, 12, 272, 6183, 1763, 11911, 12, 6183, 12380, 12, 6183, 17454, 12, 272, 6183, 4667, 12, 6183, 29967, 12, 6183, 39, 368, 12, 272, 6183, 17692, 12, 4760, 5188, 12, 8857, 26599, 12, 21072, 12, 199, 9, 199, 504, 1639, 14, 1014, 14, 1208, 492, 5325, 63, 1985, 63, 1291, 12, 12303, 63, 1317, 63, 25818, 199, 199, 363, 452, 363, 275, 359, 272, 283, 3184, 7810, 297, 283, 1122, 63, 5306, 297, 283, 10441, 297, 283, 3227, 2141, 297, 272, 283, 7963, 6564, 1451, 1726, 297, 283, 1358, 11875, 6564, 547, 297, 283, 1506, 63, 1069, 63, 2722, 297, 272, 283, 16287, 297, 283, 22555, 16287, 297, 283, 16287, 7071, 297, 272, 283, 16287, 31776, 7071, 297, 283, 16287, 1763, 11911, 297, 272, 283, 16287, 12380, 297, 283, 16287, 17454, 297, 283, 16287, 4667, 297, 272, 283, 16287, 29967, 297, 283, 16287, 39, 368, 297, 283, 16287, 17692, 297, 272, 283, 5779, 5188, 297, 283, 5725, 26599, 297, 283, 970, 63, 1985, 63, 1291, 297, 283, 9653, 2364, 297, 272, 283, 1173, 2364, 297, 283, 14353, 63, 1317, 63, 25818, 297, 199, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
brodyberg/autorest
AutoRest/Generators/Python/Python.Tests/Expected/AcceptanceTests/BodyComplex/autorestcomplextestservice/models/sawshark.py
4
1804
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from .shark import Shark class Sawshark(Shark): """Sawshark :param species: :type species: str :param length: :type length: float :param siblings: :type siblings: list of :class:`Fish <fixtures.acceptancetestsbodycomplex.models.Fish>` :param fishtype: Polymorphic Discriminator :type fishtype: str :param age: :type age: int :param birthday: :type birthday: datetime :param picture: :type picture: bytearray """ _validation = { 'length': {'required': True}, 'fishtype': {'required': True}, 'birthday': {'required': True}, } _attribute_map = { 'species': {'key': 'species', 'type': 'str'}, 'length': {'key': 'length', 'type': 'float'}, 'siblings': {'key': 'siblings', 'type': '[Fish]'}, 'fishtype': {'key': 'fishtype', 'type': 'str'}, 'age': {'key': 'age', 'type': 'int'}, 'birthday': {'key': 'birthday', 'type': 'iso-8601'}, 'picture': {'key': 'picture', 'type': 'bytearray'}, } def __init__(self, length, birthday, species=None, siblings=None, age=None, picture=None): super(Sawshark, self).__init__(species=species, length=length, siblings=siblings, age=age, birthday=birthday) self.picture = picture self.fishtype = 'sawshark'
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 1275, 609, 1096, 492, 5244, 1096, 421, 199, 533, 428, 10084, 609, 1096, 8, 2662, 1096, 304, 272, 408, 51, 10084, 609, 1096, 339, 520, 635, 20340, 26, 272, 520, 466, 20340, 26, 620, 272, 520, 635, 2582, 26, 272, 520, 466, 2582, 26, 2069, 272, 520, 635, 31871, 26, 272, 520, 466, 31871, 26, 769, 402, 520, 533, 1705, 38, 2453, 1362, 665, 8769, 14, 28519, 2219, 2030, 5254, 14, 992, 14, 38, 2453, 8637, 272, 520, 635, 289, 2453, 466, 26, 16869, 12543, 5289, 1408, 827, 707, 272, 520, 466, 289, 2453, 466, 26, 620, 272, 520, 635, 11437, 26, 272, 520, 466, 11437, 26, 1109, 272, 520, 635, 21036, 2977, 26, 272, 520, 466, 21036, 2977, 26, 2197, 272, 520, 635, 24945, 26, 272, 520, 466, 24945, 26, 11640, 272, 408, 18407, 485, 6136, 275, 469, 267, 283, 1267, 356, 791, 2427, 356, 715, 1386, 267, 283, 16056, 466, 356, 791, 2427, 356, 715, 1386, 267, 283, 15881, 356, 791, 2427, 356, 715, 1386, 272, 789, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 17168, 356, 791, 498, 356, 283, 17168, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 1267, 356, 791, 498, 356, 283, 1267, 297, 283, 466, 356, 283, 1609, 2267, 267, 283, 338, 3345, 780, 356, 791, 498, 356, 283, 338, 3345, 780, 297, 283, 466, 356, 6730, 38, 2453, 30375, 267, 283, 16056, 466, 356, 791, 498, 356, 283, 16056, 466, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 474, 356, 791, 498, 356, 283, 474, 297, 283, 466, 356, 283, 442, 2267, 267, 283, 15881, 356, 791, 498, 356, 283, 15881, 297, 283, 466, 356, 283, 4595, 13, 15363, 2267, 267, 283, 12538, 356, 791, 498, 356, 283, 12538, 297, 283, 466, 356, 283, 20108, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 12, 2582, 12, 21036, 2977, 12, 20340, 29, 403, 12, 31871, 29, 403, 12, 11437, 29, 403, 12, 24945, 29, 403, 304, 267, 1613, 8, 51, 10084, 609, 1096, 12, 291, 2843, 826, 721, 17168, 29, 17168, 12, 2582, 29, 1267, 12, 31871, 29, 338, 3345, 780, 12, 11437, 29, 474, 12, 21036, 2977, 29, 15881, 9, 267, 291, 14, 12538, 275, 24945, 267, 291, 14, 16056, 466, 275, 283, 2231, 87, 609, 1096, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3, 24775, 199, 3, 1898, 334, 67, 9, 15332, 11098, 14, 2900, 4481, 4644, 14, 199, 3, 3909, 1334, 314, 10697, 844, 14, 1666, 844, 14, 2424, 315, 314, 2199, 1738, 367, 199, 3, 4190, 2556, 14, 199, 3, 199, 3, 5495, 4046, 701, 15332, 334, 50, 9, 9195, 13726, 5495, 15042, 14, 199, 3, 18784, 1443, 7675, 8927, 5953, 436, 911, 506, 14669, 340, 314, 1233, 365, 199, 3, 31904, 14, 199, 3, 24775, 199, 199, 504, 1275, 609, 1096, 492, 5244, 1096, 421, 199, 533, 428, 10084, 609, 1096, 8, 2662, 1096, 304, 272, 408, 51, 10084, 609, 1096, 339, 520, 635, 20340, 26, 272, 520, 466, 20340, 26, 620, 272, 520, 635, 2582, 26, 272, 520, 466, 2582, 26, 2069, 272, 520, 635, 31871, 26, 272, 520, 466, 31871, 26, 769, 402, 520, 533, 1705, 38, 2453, 1362, 665, 8769, 14, 28519, 2219, 2030, 5254, 14, 992, 14, 38, 2453, 8637, 272, 520, 635, 289, 2453, 466, 26, 16869, 12543, 5289, 1408, 827, 707, 272, 520, 466, 289, 2453, 466, 26, 620, 272, 520, 635, 11437, 26, 272, 520, 466, 11437, 26, 1109, 272, 520, 635, 21036, 2977, 26, 272, 520, 466, 21036, 2977, 26, 2197, 272, 520, 635, 24945, 26, 272, 520, 466, 24945, 26, 11640, 272, 408, 18407, 485, 6136, 275, 469, 267, 283, 1267, 356, 791, 2427, 356, 715, 1386, 267, 283, 16056, 466, 356, 791, 2427, 356, 715, 1386, 267, 283, 15881, 356, 791, 2427, 356, 715, 1386, 272, 789, 339, 485, 3215, 63, 1130, 275, 469, 267, 283, 17168, 356, 791, 498, 356, 283, 17168, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 1267, 356, 791, 498, 356, 283, 1267, 297, 283, 466, 356, 283, 1609, 2267, 267, 283, 338, 3345, 780, 356, 791, 498, 356, 283, 338, 3345, 780, 297, 283, 466, 356, 6730, 38, 2453, 30375, 267, 283, 16056, 466, 356, 791, 498, 356, 283, 16056, 466, 297, 283, 466, 356, 283, 495, 2267, 267, 283, 474, 356, 791, 498, 356, 283, 474, 297, 283, 466, 356, 283, 442, 2267, 267, 283, 15881, 356, 791, 498, 356, 283, 15881, 297, 283, 466, 356, 283, 4595, 13, 15363, 2267, 267, 283, 12538, 356, 791, 498, 356, 283, 12538, 297, 283, 466, 356, 283, 20108, 2267, 272, 789, 339, 347, 636, 826, 721, 277, 12, 2582, 12, 21036, 2977, 12, 20340, 29, 403, 12, 31871, 29, 403, 12, 11437, 29, 403, 12, 24945, 29, 403, 304, 267, 1613, 8, 51, 10084, 609, 1096, 12, 291, 2843, 826, 721, 17168, 29, 17168, 12, 2582, 29, 1267, 12, 31871, 29, 338, 3345, 780, 12, 11437, 29, 474, 12, 21036, 2977, 29, 15881, 9, 267, 291, 14, 12538, 275, 24945, 267, 291, 14, 16056, 466, 275, 283, 2231, 87, 609, 1096, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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2013 OpenStack Foundation # # 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 urllib from itertools import ifilter from swift.common import bufferedhttp from swift.common import exceptions from swift.common import http class Sender(object): """ Sends SSYNC requests to the object server. These requests are eventually handled by :py:mod:`.ssync_receiver` and full documentation about the process is there. """ def __init__(self, daemon, node, job, suffixes, remote_check_objs=None): self.daemon = daemon self.df_mgr = self.daemon._diskfile_mgr self.node = node self.job = job self.suffixes = suffixes self.connection = None self.response = None self.response_buffer = '' self.response_chunk_left = 0 # available_map has an entry for each object in given suffixes that # is available to be sync'd; each entry is a hash => timestamp self.available_map = {} # When remote_check_objs is given in job, ssync_sender trys only to # make sure those objects exist or not in remote. self.remote_check_objs = remote_check_objs # send_list has an entry for each object that the receiver wants to # be sync'ed; each entry is an object hash self.send_list = [] self.failures = 0 def __call__(self): """ Perform ssync with remote node. :returns: a 2-tuple, in the form (success, can_delete_objs) where success is a boolean and can_delete_objs is the map of objects that are in sync with the receiver. Each entry in can_delete_objs maps a hash => timestamp """ if not self.suffixes: return True, {} try: # Double try blocks in case our main error handler fails. try: # The general theme for these functions is that they should # raise exceptions.MessageTimeout for client timeouts and # exceptions.ReplicationException for common issues that will # abort the replication attempt and log a simple error. All # other exceptions will be logged with a full stack trace. self.connect() self.missing_check() if self.remote_check_objs is None: self.updates() can_delete_obj = self.available_map else: # when we are initialized with remote_check_objs we don't # *send* any requested updates; instead we only collect # what's already in sync and safe for deletion in_sync_hashes = (set(self.available_map.keys()) - set(self.send_list)) can_delete_obj = dict((hash_, self.available_map[hash_]) for hash_ in in_sync_hashes) self.disconnect() if not self.failures: return True, can_delete_obj else: return False, {} except (exceptions.MessageTimeout, exceptions.ReplicationException) as err: self.daemon.logger.error( '%s:%s/%s/%s %s', self.node.get('replication_ip'), self.node.get('replication_port'), self.node.get('device'), self.job.get('partition'), err) except Exception: # We don't want any exceptions to escape our code and possibly # mess up the original replicator code that called us since it # was originally written to shell out to rsync which would do # no such thing. self.daemon.logger.exception( '%s:%s/%s/%s EXCEPTION in replication.Sender', self.node.get('replication_ip'), self.node.get('replication_port'), self.node.get('device'), self.job.get('partition')) except Exception: # We don't want any exceptions to escape our code and possibly # mess up the original replicator code that called us since it # was originally written to shell out to rsync which would do # no such thing. # This particular exception handler does the minimal amount as it # would only get called if the above except Exception handler # failed (bad node or job data). self.daemon.logger.exception('EXCEPTION in replication.Sender') return False, {} def connect(self): """ Establishes a connection and starts an SSYNC request with the object server. """ with exceptions.MessageTimeout( self.daemon.conn_timeout, 'connect send'): self.connection = bufferedhttp.BufferedHTTPConnection( '%s:%s' % (self.node['replication_ip'], self.node['replication_port'])) self.connection.putrequest('SSYNC', '/%s/%s' % ( self.node['device'], self.job['partition'])) self.connection.putheader('Transfer-Encoding', 'chunked') self.connection.putheader('X-Backend-Storage-Policy-Index', int(self.job['policy'])) # a sync job must use the node's index for the frag_index of the # rebuilt fragments instead of the frag_index from the job which # will be rebuilding them self.connection.putheader( 'X-Backend-Ssync-Frag-Index', self.node.get( 'index', self.job.get('frag_index', ''))) # a revert job to a handoff will not have a node index self.connection.putheader('X-Backend-Ssync-Node-Index', self.node.get('index', '')) self.connection.endheaders() with exceptions.MessageTimeout( self.daemon.node_timeout, 'connect receive'): self.response = self.connection.getresponse() if self.response.status != http.HTTP_OK: self.response.read() raise exceptions.ReplicationException( 'Expected status %s; got %s' % (http.HTTP_OK, self.response.status)) def readline(self): """ Reads a line from the SSYNC response body. httplib has no readline and will block on read(x) until x is read, so we have to do the work ourselves. A bit of this is taken from Python's httplib itself. """ data = self.response_buffer self.response_buffer = '' while '\n' not in data and len(data) < self.daemon.network_chunk_size: if self.response_chunk_left == -1: # EOF-already indicator break if self.response_chunk_left == 0: line = self.response.fp.readline() i = line.find(';') if i >= 0: line = line[:i] # strip chunk-extensions try: self.response_chunk_left = int(line.strip(), 16) except ValueError: # close the connection as protocol synchronisation is # probably lost self.response.close() raise exceptions.ReplicationException('Early disconnect') if self.response_chunk_left == 0: self.response_chunk_left = -1 break chunk = self.response.fp.read(min( self.response_chunk_left, self.daemon.network_chunk_size - len(data))) if not chunk: # close the connection as protocol synchronisation is # probably lost self.response.close() raise exceptions.ReplicationException('Early disconnect') self.response_chunk_left -= len(chunk) if self.response_chunk_left == 0: self.response.fp.read(2) # discard the trailing \r\n data += chunk if '\n' in data: data, self.response_buffer = data.split('\n', 1) data += '\n' return data def missing_check(self): """ Handles the sender-side of the MISSING_CHECK step of a SSYNC request. Full documentation of this can be found at :py:meth:`.Receiver.missing_check`. """ # First, send our list. with exceptions.MessageTimeout( self.daemon.node_timeout, 'missing_check start'): msg = ':MISSING_CHECK: START\r\n' self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) hash_gen = self.df_mgr.yield_hashes( self.job['device'], self.job['partition'], self.job['policy'], self.suffixes, frag_index=self.job.get('frag_index')) if self.remote_check_objs is not None: hash_gen = ifilter( lambda path_objhash_timestamp: path_objhash_timestamp[1] in self.remote_check_objs, hash_gen) for path, object_hash, timestamp in hash_gen: self.available_map[object_hash] = timestamp with exceptions.MessageTimeout( self.daemon.node_timeout, 'missing_check send line'): msg = '%s %s\r\n' % ( urllib.quote(object_hash), urllib.quote(timestamp)) self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) with exceptions.MessageTimeout( self.daemon.node_timeout, 'missing_check end'): msg = ':MISSING_CHECK: END\r\n' self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) # Now, retrieve the list of what they want. while True: with exceptions.MessageTimeout( self.daemon.http_timeout, 'missing_check start wait'): line = self.readline() if not line: raise exceptions.ReplicationException('Early disconnect') line = line.strip() if line == ':MISSING_CHECK: START': break elif line: raise exceptions.ReplicationException( 'Unexpected response: %r' % line[:1024]) while True: with exceptions.MessageTimeout( self.daemon.http_timeout, 'missing_check line wait'): line = self.readline() if not line: raise exceptions.ReplicationException('Early disconnect') line = line.strip() if line == ':MISSING_CHECK: END': break parts = line.split() if parts: self.send_list.append(parts[0]) def updates(self): """ Handles the sender-side of the UPDATES step of an SSYNC request. Full documentation of this can be found at :py:meth:`.Receiver.updates`. """ # First, send all our subrequests based on the send_list. with exceptions.MessageTimeout( self.daemon.node_timeout, 'updates start'): msg = ':UPDATES: START\r\n' self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) for object_hash in self.send_list: try: df = self.df_mgr.get_diskfile_from_hash( self.job['device'], self.job['partition'], object_hash, self.job['policy'], frag_index=self.job.get('frag_index')) except exceptions.DiskFileNotExist: continue url_path = urllib.quote( '/%s/%s/%s' % (df.account, df.container, df.obj)) try: df.open() # EC reconstructor may have passed a callback to build # an alternative diskfile... df = self.job.get('sync_diskfile_builder', lambda *args: df)( self.job, self.node, df.get_metadata()) except exceptions.DiskFileDeleted as err: self.send_delete(url_path, err.timestamp) except exceptions.DiskFileError: pass else: self.send_put(url_path, df) with exceptions.MessageTimeout( self.daemon.node_timeout, 'updates end'): msg = ':UPDATES: END\r\n' self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) # Now, read their response for any issues. while True: with exceptions.MessageTimeout( self.daemon.http_timeout, 'updates start wait'): line = self.readline() if not line: raise exceptions.ReplicationException('Early disconnect') line = line.strip() if line == ':UPDATES: START': break elif line: raise exceptions.ReplicationException( 'Unexpected response: %r' % line[:1024]) while True: with exceptions.MessageTimeout( self.daemon.http_timeout, 'updates line wait'): line = self.readline() if not line: raise exceptions.ReplicationException('Early disconnect') line = line.strip() if line == ':UPDATES: END': break elif line: raise exceptions.ReplicationException( 'Unexpected response: %r' % line[:1024]) def send_delete(self, url_path, timestamp): """ Sends a DELETE subrequest with the given information. """ msg = ['DELETE ' + url_path, 'X-Timestamp: ' + timestamp.internal] msg = '\r\n'.join(msg) + '\r\n\r\n' with exceptions.MessageTimeout( self.daemon.node_timeout, 'send_delete'): self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) def send_put(self, url_path, df): """ Sends a PUT subrequest for the url_path using the source df (DiskFile) and content_length. """ msg = ['PUT ' + url_path, 'Content-Length: ' + str(df.content_length)] # Sorted to make it easier to test. for key, value in sorted(df.get_metadata().items()): if key not in ('name', 'Content-Length'): msg.append('%s: %s' % (key, value)) msg = '\r\n'.join(msg) + '\r\n\r\n' with exceptions.MessageTimeout(self.daemon.node_timeout, 'send_put'): self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) for chunk in df.reader(): with exceptions.MessageTimeout( self.daemon.node_timeout, 'send_put chunk'): self.connection.send('%x\r\n%s\r\n' % (len(chunk), chunk)) def disconnect(self): """ Closes down the connection to the object server once done with the SSYNC request. """ try: with exceptions.MessageTimeout( self.daemon.node_timeout, 'disconnect'): self.connection.send('0\r\n\r\n') except (Exception, exceptions.Timeout): pass # We're okay with the above failing. self.connection.close()
apache-2.0
[ 3, 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 4011, 199, 504, 7975, 492, 284, 1541, 199, 504, 16275, 14, 2330, 492, 20224, 1014, 199, 504, 16275, 14, 2330, 492, 4967, 199, 504, 16275, 14, 2330, 492, 1455, 421, 199, 533, 428, 13747, 8, 785, 304, 272, 408, 272, 428, 3198, 428, 22012, 4145, 370, 314, 909, 1654, 14, 339, 5723, 4145, 787, 21356, 8860, 701, 272, 520, 647, 26, 1494, 5026, 385, 1870, 63, 10244, 64, 436, 2615, 3794, 3595, 314, 272, 2112, 365, 2337, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 11128, 12, 1031, 12, 3906, 12, 19475, 12, 3982, 63, 1074, 63, 8718, 29, 403, 304, 267, 291, 14, 10824, 275, 11128, 267, 291, 14, 1587, 63, 7755, 275, 291, 14, 10824, 423, 4032, 493, 63, 7755, 267, 291, 14, 932, 275, 1031, 267, 291, 14, 2423, 275, 3906, 267, 291, 14, 16097, 275, 19475, 267, 291, 14, 2105, 275, 488, 267, 291, 14, 1310, 275, 488, 267, 291, 14, 1310, 63, 2738, 275, 2125, 267, 291, 14, 1310, 63, 4604, 63, 3039, 275, 378, 267, 327, 2808, 63, 1130, 965, 376, 2397, 367, 1924, 909, 315, 1627, 19475, 626, 267, 327, 365, 2808, 370, 506, 7604, 5121, 27, 1924, 2397, 365, 282, 2631, 9265, 4913, 267, 291, 14, 4561, 63, 1130, 275, 1052, 267, 327, 3979, 3982, 63, 1074, 63, 8718, 365, 1627, 315, 3906, 12, 308, 5186, 63, 8114, 5651, 588, 1454, 370, 267, 327, 1852, 3238, 5204, 2251, 2187, 503, 440, 315, 3982, 14, 267, 291, 14, 3846, 63, 1074, 63, 8718, 275, 3982, 63, 1074, 63, 8718, 267, 327, 3222, 63, 513, 965, 376, 2397, 367, 1924, 909, 626, 314, 13035, 15061, 370, 267, 327, 506, 7604, 7, 379, 27, 1924, 2397, 365, 376, 909, 2631, 267, 291, 14, 2254, 63, 513, 275, 942, 267, 291, 14, 9968, 275, 378, 339, 347, 636, 1250, 721, 277, 304, 267, 408, 267, 14795, 308, 5186, 543, 3982, 1031, 14, 398, 520, 5808, 26, 282, 499, 13, 2960, 12, 315, 314, 1824, 334, 3742, 12, 883, 63, 1807, 63, 8718, 9, 2382, 2116, 3182, 365, 282, 5046, 436, 883, 63, 1807, 63, 8718, 365, 314, 2341, 402, 2116, 2251, 626, 787, 315, 7604, 543, 314, 13035, 14, 7048, 2397, 315, 2116, 883, 63, 1807, 63, 8718, 9033, 282, 2631, 9265, 4913, 267, 408, 267, 340, 440, 291, 14, 16097, 26, 288, 372, 715, 12, 1052, 267, 862, 26, 288, 327, 22945, 862, 5664, 315, 1930, 4154, 2446, 1125, 3016, 6918, 14, 288, 862, 26, 355, 327, 710, 8605, 8879, 367, 3520, 3423, 365, 626, 2985, 1077, 355, 327, 746, 4967, 14, 2209, 6372, 367, 1890, 25870, 436, 355, 327, 4967, 14, 31320, 1726, 367, 2863, 10876, 626, 911, 355, 327, 12004, 314, 20797, 7427, 436, 943, 282, 3486, 1125, 14, 2900, 355, 327, 1163, 4967, 911, 506, 10367, 543, 282, 2615, 3464, 3307, 14, 355, 291, 14, 2242, 342, 355, 291, 14, 4752, 63, 1074, 342, 355, 340, 291, 14, 3846, 63, 1074, 63, 8718, 365, 488, 26, 490, 291, 14, 7618, 342, 490, 883, 63, 1807, 63, 1113, 275, 291, 14, 4561, 63, 1130, 355, 587, 26, 490, 327, 1380, 781, 787, 10038, 543, 3982, 63, 1074, 63, 8718, 781, 2793, 1133, 490, 327, 627, 2254, 10, 1263, 5839, 7029, 27, 3140, 781, 1454, 8775, 490, 327, 4052, 1159, 2575, 315, 7604, 436, 5048, 367, 14068, 490, 315, 63, 5186, 63, 12428, 275, 334, 409, 8, 277, 14, 4561, 63, 1130, 14, 1612, 1012, 446, 4228, 663, 8, 277, 14, 2254, 63, 513, 430, 490, 883, 63, 1807, 63, 1113, 275, 1211, 1332, 2227, 3131, 291, 14, 4561, 63, 1130, 59, 2227, 63, 566, 5101, 367, 2631, 63, 315, 315, 63, 5186, 63, 12428, 9, 355, 291, 14, 10673, 342, 355, 340, 440, 291, 14, 9968, 26, 490, 372, 715, 12, 883, 63, 1807, 63, 1113, 355, 587, 26, 490, 372, 756, 12, 1052, 288, 871, 334, 3924, 14, 2209, 6372, 12, 490, 4967, 14, 31320, 1726, 9, 465, 2329, 26, 355, 291, 14, 10824, 14, 2921, 14, 705, 8, 490, 1543, 83, 2689, 83, 3149, 83, 3149, 83, 450, 83, 297, 291, 14, 932, 14, 362, 360, 17144, 63, 711, 659, 490, 291, 14, 932, 14, 362, 360, 17144, 63, 719, 659, 291, 14, 932, 14, 362, 360, 1782, 659, 490, 291, 14, 2423, 14, 362, 360, 5312, 659, 2329, 9, 288, 871, 2186, 26, 355, 327, 2136, 2793, 1133, 2934, 1263, 4967, 370, 4772, 4154, 1233, 436, 12570, 355, 327, 15634, 1536, 314, 3379, 1833, 32182, 1233, 626, 2797, 2739, 3967, 652, 355, 327, 1990, 20657, 5313, 370, 5218, 734, 370, 27633, 1314, 3955, 886, 355, 327, 949, 4066, 8377, 14, 355, 291, 14, 10824, 14, 2921, 14, 1971, 8, 490, 1543, 83, 2689, 83, 3149, 83, 3149, 83, 3651, 7177, 1075, 315, 20797, 14, 28002, 297, 490, 291, 14, 932, 14, 362, 360, 17144, 63, 711, 659, 490, 291, 14, 932, 14, 362, 360, 17144, 63, 719, 659, 490, 291, 14, 932, 14, 362, 360, 1782, 659, 291, 14, 2423, 14, 362, 360, 5312, 1333, 267, 871, 2186, 26, 288, 327, 2136, 2793, 1133, 2934, 1263, 4967, 370, 4772, 4154, 1233, 436, 12570, 288, 327, 15634, 1536, 314, 3379, 1833, 32182, 1233, 626, 2797, 2739, 3967, 652, 288, 327, 1990, 20657, 5313, 370, 5218, 734, 370, 27633, 1314 ]
[ 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 4011, 199, 504, 7975, 492, 284, 1541, 199, 504, 16275, 14, 2330, 492, 20224, 1014, 199, 504, 16275, 14, 2330, 492, 4967, 199, 504, 16275, 14, 2330, 492, 1455, 421, 199, 533, 428, 13747, 8, 785, 304, 272, 408, 272, 428, 3198, 428, 22012, 4145, 370, 314, 909, 1654, 14, 339, 5723, 4145, 787, 21356, 8860, 701, 272, 520, 647, 26, 1494, 5026, 385, 1870, 63, 10244, 64, 436, 2615, 3794, 3595, 314, 272, 2112, 365, 2337, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 11128, 12, 1031, 12, 3906, 12, 19475, 12, 3982, 63, 1074, 63, 8718, 29, 403, 304, 267, 291, 14, 10824, 275, 11128, 267, 291, 14, 1587, 63, 7755, 275, 291, 14, 10824, 423, 4032, 493, 63, 7755, 267, 291, 14, 932, 275, 1031, 267, 291, 14, 2423, 275, 3906, 267, 291, 14, 16097, 275, 19475, 267, 291, 14, 2105, 275, 488, 267, 291, 14, 1310, 275, 488, 267, 291, 14, 1310, 63, 2738, 275, 2125, 267, 291, 14, 1310, 63, 4604, 63, 3039, 275, 378, 267, 327, 2808, 63, 1130, 965, 376, 2397, 367, 1924, 909, 315, 1627, 19475, 626, 267, 327, 365, 2808, 370, 506, 7604, 5121, 27, 1924, 2397, 365, 282, 2631, 9265, 4913, 267, 291, 14, 4561, 63, 1130, 275, 1052, 267, 327, 3979, 3982, 63, 1074, 63, 8718, 365, 1627, 315, 3906, 12, 308, 5186, 63, 8114, 5651, 588, 1454, 370, 267, 327, 1852, 3238, 5204, 2251, 2187, 503, 440, 315, 3982, 14, 267, 291, 14, 3846, 63, 1074, 63, 8718, 275, 3982, 63, 1074, 63, 8718, 267, 327, 3222, 63, 513, 965, 376, 2397, 367, 1924, 909, 626, 314, 13035, 15061, 370, 267, 327, 506, 7604, 7, 379, 27, 1924, 2397, 365, 376, 909, 2631, 267, 291, 14, 2254, 63, 513, 275, 942, 267, 291, 14, 9968, 275, 378, 339, 347, 636, 1250, 721, 277, 304, 267, 408, 267, 14795, 308, 5186, 543, 3982, 1031, 14, 398, 520, 5808, 26, 282, 499, 13, 2960, 12, 315, 314, 1824, 334, 3742, 12, 883, 63, 1807, 63, 8718, 9, 2382, 2116, 3182, 365, 282, 5046, 436, 883, 63, 1807, 63, 8718, 365, 314, 2341, 402, 2116, 2251, 626, 787, 315, 7604, 543, 314, 13035, 14, 7048, 2397, 315, 2116, 883, 63, 1807, 63, 8718, 9033, 282, 2631, 9265, 4913, 267, 408, 267, 340, 440, 291, 14, 16097, 26, 288, 372, 715, 12, 1052, 267, 862, 26, 288, 327, 22945, 862, 5664, 315, 1930, 4154, 2446, 1125, 3016, 6918, 14, 288, 862, 26, 355, 327, 710, 8605, 8879, 367, 3520, 3423, 365, 626, 2985, 1077, 355, 327, 746, 4967, 14, 2209, 6372, 367, 1890, 25870, 436, 355, 327, 4967, 14, 31320, 1726, 367, 2863, 10876, 626, 911, 355, 327, 12004, 314, 20797, 7427, 436, 943, 282, 3486, 1125, 14, 2900, 355, 327, 1163, 4967, 911, 506, 10367, 543, 282, 2615, 3464, 3307, 14, 355, 291, 14, 2242, 342, 355, 291, 14, 4752, 63, 1074, 342, 355, 340, 291, 14, 3846, 63, 1074, 63, 8718, 365, 488, 26, 490, 291, 14, 7618, 342, 490, 883, 63, 1807, 63, 1113, 275, 291, 14, 4561, 63, 1130, 355, 587, 26, 490, 327, 1380, 781, 787, 10038, 543, 3982, 63, 1074, 63, 8718, 781, 2793, 1133, 490, 327, 627, 2254, 10, 1263, 5839, 7029, 27, 3140, 781, 1454, 8775, 490, 327, 4052, 1159, 2575, 315, 7604, 436, 5048, 367, 14068, 490, 315, 63, 5186, 63, 12428, 275, 334, 409, 8, 277, 14, 4561, 63, 1130, 14, 1612, 1012, 446, 4228, 663, 8, 277, 14, 2254, 63, 513, 430, 490, 883, 63, 1807, 63, 1113, 275, 1211, 1332, 2227, 3131, 291, 14, 4561, 63, 1130, 59, 2227, 63, 566, 5101, 367, 2631, 63, 315, 315, 63, 5186, 63, 12428, 9, 355, 291, 14, 10673, 342, 355, 340, 440, 291, 14, 9968, 26, 490, 372, 715, 12, 883, 63, 1807, 63, 1113, 355, 587, 26, 490, 372, 756, 12, 1052, 288, 871, 334, 3924, 14, 2209, 6372, 12, 490, 4967, 14, 31320, 1726, 9, 465, 2329, 26, 355, 291, 14, 10824, 14, 2921, 14, 705, 8, 490, 1543, 83, 2689, 83, 3149, 83, 3149, 83, 450, 83, 297, 291, 14, 932, 14, 362, 360, 17144, 63, 711, 659, 490, 291, 14, 932, 14, 362, 360, 17144, 63, 719, 659, 291, 14, 932, 14, 362, 360, 1782, 659, 490, 291, 14, 2423, 14, 362, 360, 5312, 659, 2329, 9, 288, 871, 2186, 26, 355, 327, 2136, 2793, 1133, 2934, 1263, 4967, 370, 4772, 4154, 1233, 436, 12570, 355, 327, 15634, 1536, 314, 3379, 1833, 32182, 1233, 626, 2797, 2739, 3967, 652, 355, 327, 1990, 20657, 5313, 370, 5218, 734, 370, 27633, 1314, 3955, 886, 355, 327, 949, 4066, 8377, 14, 355, 291, 14, 10824, 14, 2921, 14, 1971, 8, 490, 1543, 83, 2689, 83, 3149, 83, 3149, 83, 3651, 7177, 1075, 315, 20797, 14, 28002, 297, 490, 291, 14, 932, 14, 362, 360, 17144, 63, 711, 659, 490, 291, 14, 932, 14, 362, 360, 17144, 63, 719, 659, 490, 291, 14, 932, 14, 362, 360, 1782, 659, 291, 14, 2423, 14, 362, 360, 5312, 1333, 267, 871, 2186, 26, 288, 327, 2136, 2793, 1133, 2934, 1263, 4967, 370, 4772, 4154, 1233, 436, 12570, 288, 327, 15634, 1536, 314, 3379, 1833, 32182, 1233, 626, 2797, 2739, 3967, 652, 288, 327, 1990, 20657, 5313, 370, 5218, 734, 370, 27633, 1314, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
maurerpe/FreeCAD
src/Mod/Ship/shipAreasCurve/__init__.py
60
1809
#*************************************************************************** #* * #* Copyright (c) 2011, 2016 * #* Jose Luis Cercos Pita <jlcercos@gmail.com> * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * #* as published by the Free Software Foundation; either version 2 of * #* the License, or (at your option) any later version. * #* for detail see the LICENCE text file. * #* * #* 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 Library General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * #* License along with this program; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #*************************************************************************** import TaskPanel def load(): """ Loads the tool """ TaskPanel.createTask()
lgpl-2.1
[ 3, 17623, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 1898, 334, 67, 9, 7760, 12, 7800, 2476, 4519, 627, 202, 199, 15002, 257, 1603, 3362, 30936, 374, 11002, 5197, 510, 21492, 665, 74, 76, 2247, 5197, 32, 6799, 14, 957, 30, 14960, 627, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 202, 199, 15002, 257, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 44, 12006, 9, 259, 627, 202, 199, 15002, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 258, 627, 202, 199, 15002, 257, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 7861, 627, 202, 199, 15002, 257, 367, 10093, 1937, 314, 5059, 6013, 1318, 570, 14, 2476, 627, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 755, 627, 202, 199, 15002, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 263, 627, 202, 199, 15002, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 260, 627, 202, 199, 15002, 257, 1664, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 8295, 627, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 258, 627, 202, 199, 15002, 257, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 257, 627, 202, 199, 15002, 257, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 627, 202, 199, 15002, 257, 8217, 6208, 257, 627, 202, 199, 15002, 17997, 627, 202, 199, 3, 17623, 2999, 199, 646, 8495, 10185, 8065, 199, 318, 2248, 837, 1128, 408, 30367, 314, 4744, 408, 1128, 8495, 10185, 14, 981, 4476, 342, 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 ]
[ 17623, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 1898, 334, 67, 9, 7760, 12, 7800, 2476, 4519, 627, 202, 199, 15002, 257, 1603, 3362, 30936, 374, 11002, 5197, 510, 21492, 665, 74, 76, 2247, 5197, 32, 6799, 14, 957, 30, 14960, 627, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 202, 199, 15002, 257, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 44, 12006, 9, 259, 627, 202, 199, 15002, 257, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 258, 627, 202, 199, 15002, 257, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 7861, 627, 202, 199, 15002, 257, 367, 10093, 1937, 314, 5059, 6013, 1318, 570, 14, 2476, 627, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 755, 627, 202, 199, 15002, 257, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 263, 627, 202, 199, 15002, 257, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 260, 627, 202, 199, 15002, 257, 1664, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 8295, 627, 202, 199, 15002, 17997, 627, 202, 199, 15002, 257, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 258, 627, 202, 199, 15002, 257, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 257, 627, 202, 199, 15002, 257, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 627, 202, 199, 15002, 257, 8217, 6208, 257, 627, 202, 199, 15002, 17997, 627, 202, 199, 3, 17623, 2999, 199, 646, 8495, 10185, 8065, 199, 318, 2248, 837, 1128, 408, 30367, 314, 4744, 408, 1128, 8495, 10185, 14, 981, 4476, 342, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cctaylor/googleads-python-lib
examples/dfp/v201408/custom_field_service/create_custom_fields.py
4
2145
#!/usr/bin/python # # Copyright 2014 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """This example creates custom fields. To determine which custom fields exist, run get_all_custom_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: CustomFieldService.createCustomFields """ __author__ = ('Nicholas Chen', 'Joseph DiLallo') import uuid # Import appropriate modules from the client library. from googleads import dfp def main(client): # Initialize appropriate service. custom_field_service = client.GetService( 'CustomFieldService', version='v201408') # Create custom field objects. custom_fields = [ { 'name': 'Customer comments #%s' % uuid.uuid4(), 'entityType': 'LINE_ITEM', 'dataType': 'STRING', 'visibility': 'FULL' }, { 'name': 'Internal approval status #%s' % uuid.uuid4(), 'entityType': 'LINE_ITEM', 'dataType': 'DROP_DOWN', 'visibility': 'FULL' } ] # Add custom fields. custom_fields = custom_field_service.createCustomFields(custom_fields) # Display results. for custom_field in custom_fields: print ('Custom field with ID \'%s\' and name \'%s\' was created.' % (custom_field['id'], custom_field['name'])) if __name__ == '__main__': # Initialize client object. dfp_client = dfp.DfpClient.LoadFromStorage() main(dfp_client)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 6927, 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, 8491, 3537, 1504, 14, 199, 199, 1378, 6705, 1314, 3537, 1504, 2187, 12, 1255, 664, 63, 452, 63, 4229, 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, 8388, 792, 3167, 14, 981, 7223, 7304, 199, 624, 199, 199, 363, 2502, 363, 275, 661, 46, 1158, 393, 305, 2799, 287, 297, 1598, 283, 42, 3362, 838, 3757, 44, 279, 320, 358, 199, 199, 646, 5377, 199, 199, 3, 3161, 5827, 4621, 687, 314, 1890, 3555, 14, 199, 504, 6233, 9402, 492, 366, 3997, 421, 199, 318, 2446, 8, 1258, 304, 523, 327, 11578, 5827, 2435, 14, 523, 3537, 63, 698, 63, 1364, 275, 1890, 14, 1002, 3167, 8, 489, 283, 7223, 792, 3167, 297, 1015, 534, 86, 7280, 2036, 358, 819, 327, 2790, 3537, 901, 2251, 14, 523, 3537, 63, 955, 275, 359, 489, 469, 881, 283, 354, 356, 283, 17025, 6786, 24307, 83, 7, 450, 5377, 14, 2580, 20, 1062, 881, 283, 4502, 804, 356, 283, 6174, 63, 10439, 297, 881, 283, 576, 804, 356, 283, 5353, 297, 881, 283, 11269, 356, 283, 14742, 7, 489, 1660, 469, 881, 283, 354, 356, 283, 8405, 4286, 637, 2004, 24307, 83, 7, 450, 5377, 14, 2580, 20, 1062, 881, 283, 4502, 804, 356, 283, 6174, 63, 10439, 297, 881, 283, 576, 804, 356, 283, 14764, 63, 8819, 297, 881, 283, 11269, 356, 283, 14742, 7, 489, 789, 523, 1622, 819, 327, 2654, 3537, 1504, 14, 523, 3537, 63, 955, 275, 3537, 63, 698, 63, 1364, 14, 981, 7223, 7304, 8, 4229, 63, 955, 9, 819, 327, 12175, 2058, 14, 523, 367, 3537, 63, 698, 315, 3537, 63, 955, 26, 272, 870, 661, 7223, 901, 543, 2870, 19095, 83, 3985, 436, 536, 19095, 83, 3985, 1990, 2737, 3530, 1779, 450, 334, 4229, 63, 698, 459, 344, 995, 3537, 63, 698, 459, 354, 5156, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 11578, 1890, 909, 14, 523, 366, 3997, 63, 1258, 275, 366, 3997, 14, 36, 3997, 3041, 14, 6200, 2532, 6408, 342, 523, 2446, 8, 1587, 80, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6927, 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, 8491, 3537, 1504, 14, 199, 199, 1378, 6705, 1314, 3537, 1504, 2187, 12, 1255, 664, 63, 452, 63, 4229, 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, 8388, 792, 3167, 14, 981, 7223, 7304, 199, 624, 199, 199, 363, 2502, 363, 275, 661, 46, 1158, 393, 305, 2799, 287, 297, 1598, 283, 42, 3362, 838, 3757, 44, 279, 320, 358, 199, 199, 646, 5377, 199, 199, 3, 3161, 5827, 4621, 687, 314, 1890, 3555, 14, 199, 504, 6233, 9402, 492, 366, 3997, 421, 199, 318, 2446, 8, 1258, 304, 523, 327, 11578, 5827, 2435, 14, 523, 3537, 63, 698, 63, 1364, 275, 1890, 14, 1002, 3167, 8, 489, 283, 7223, 792, 3167, 297, 1015, 534, 86, 7280, 2036, 358, 819, 327, 2790, 3537, 901, 2251, 14, 523, 3537, 63, 955, 275, 359, 489, 469, 881, 283, 354, 356, 283, 17025, 6786, 24307, 83, 7, 450, 5377, 14, 2580, 20, 1062, 881, 283, 4502, 804, 356, 283, 6174, 63, 10439, 297, 881, 283, 576, 804, 356, 283, 5353, 297, 881, 283, 11269, 356, 283, 14742, 7, 489, 1660, 469, 881, 283, 354, 356, 283, 8405, 4286, 637, 2004, 24307, 83, 7, 450, 5377, 14, 2580, 20, 1062, 881, 283, 4502, 804, 356, 283, 6174, 63, 10439, 297, 881, 283, 576, 804, 356, 283, 14764, 63, 8819, 297, 881, 283, 11269, 356, 283, 14742, 7, 489, 789, 523, 1622, 819, 327, 2654, 3537, 1504, 14, 523, 3537, 63, 955, 275, 3537, 63, 698, 63, 1364, 14, 981, 7223, 7304, 8, 4229, 63, 955, 9, 819, 327, 12175, 2058, 14, 523, 367, 3537, 63, 698, 315, 3537, 63, 955, 26, 272, 870, 661, 7223, 901, 543, 2870, 19095, 83, 3985, 436, 536, 19095, 83, 3985, 1990, 2737, 3530, 1779, 450, 334, 4229, 63, 698, 459, 344, 995, 3537, 63, 698, 459, 354, 5156, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 11578, 1890, 909, 14, 523, 366, 3997, 63, 1258, 275, 366, 3997, 14, 36, 3997, 3041, 14, 6200, 2532, 6408, 342, 523, 2446, 8, 1587, 80, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
bdero/edx-platform
cms/djangoapps/contentstore/features/course-export.py
11
2452
# pylint: disable=C0111 # pylint: disable=W0621 # pylint: disable=W0613 from lettuce import world, step from component_settings_editor_helpers import enter_xml_in_advanced_problem from nose.tools import assert_true, assert_equal from opaque_keys.edx.locations import SlashSeparatedCourseKey from contentstore.utils import reverse_usage_url @step('I go to the export page$') def i_go_to_the_export_page(step): world.click_tools() link_css = 'li.nav-course-tools-export a' world.css_click(link_css) @step('I export the course$') def i_export_the_course(step): step.given('I go to the export page') world.css_click('a.action-export') @step('I edit and enter bad XML$') def i_enter_bad_xml(step): enter_xml_in_advanced_problem(step, """<problem><h1>Smallest Canvas</h1> <p>You want to make the smallest canvas you can.</p> <multiplechoiceresponse> <choicegroup type="MultipleChoice"> <choice correct="false"><verbatim><canvas id="myCanvas" width = 10 height = 100> </canvas></verbatim></choice> <choice correct="true"><code><canvas id="myCanvas" width = 10 height = 10> </canvas></code></choice> </choicegroup> </multiplechoiceresponse> </problem>""" ) @step('I edit and enter an ampersand$') def i_enter_an_ampersand(step): enter_xml_in_advanced_problem(step, "<problem>&</problem>") @step('I get an error dialog$') def get_an_error_dialog(step): assert_true(world.is_css_present("div.prompt.error")) @step('I can click to go to the unit with the error$') def i_click_on_error_dialog(step): world.click_link_by_text('Correct failed component') assert_true(world.css_html("span.inline-error").startswith("Problem i4x://MITx/999/problem")) course_key = SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course") # we don't know the actual ID of the vertical. So just check that we did go to a # vertical page in the course (there should only be one). vertical_usage_key = course_key.make_usage_key("vertical", None) vertical_url = reverse_usage_url('container_handler', vertical_usage_key) # Remove the trailing "/None" from the URL - we don't know the course ID, so we just want to # check that we visited a vertical URL. if vertical_url.endswith("/None"): vertical_url = vertical_url[:-5] assert_equal(1, world.browser.url.count(vertical_url))
agpl-3.0
[ 3, 4287, 26, 3507, 29, 35, 28107, 199, 3, 4287, 26, 3507, 29, 55, 1690, 2025, 199, 3, 4287, 26, 3507, 29, 55, 1690, 969, 199, 199, 504, 4691, 84, 3683, 492, 6701, 12, 3650, 199, 504, 3931, 63, 1751, 63, 7515, 63, 7546, 492, 9509, 63, 1652, 63, 262, 63, 14652, 63, 6462, 199, 504, 11354, 14, 2537, 492, 702, 63, 2052, 12, 702, 63, 1452, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 30687, 199, 504, 23061, 14, 1208, 492, 3837, 63, 3807, 63, 633, 421, 199, 32, 2926, 360, 41, 2621, 370, 314, 4843, 2034, 9988, 199, 318, 284, 63, 1939, 63, 475, 63, 1589, 63, 3790, 63, 1606, 8, 2926, 304, 272, 6701, 14, 4891, 63, 2537, 342, 272, 2142, 63, 3919, 275, 283, 317, 14, 10927, 13, 1972, 13, 2537, 13, 3790, 282, 7, 272, 6701, 14, 3919, 63, 4891, 8, 1073, 63, 3919, 9, 421, 199, 32, 2926, 360, 41, 4843, 314, 2518, 9988, 199, 318, 284, 63, 3790, 63, 1589, 63, 1972, 8, 2926, 304, 272, 3650, 14, 11809, 360, 41, 2621, 370, 314, 4843, 2034, 358, 272, 6701, 14, 3919, 63, 4891, 360, 65, 14, 1287, 13, 3790, 358, 421, 199, 32, 2926, 360, 41, 5283, 436, 9509, 4875, 4692, 9988, 199, 318, 284, 63, 4200, 63, 4087, 63, 1652, 8, 2926, 304, 272, 9509, 63, 1652, 63, 262, 63, 14652, 63, 6462, 8, 2926, 12, 267, 8894, 6462, 2535, 72, 17, 30, 51, 2174, 14899, 29349, 1108, 72, 17, 30, 288, 665, 80, 30, 5556, 2934, 370, 1852, 314, 18604, 10218, 1265, 883, 9758, 80, 30, 288, 665, 6048, 5095, 1310, 30, 288, 665, 5095, 923, 730, 628, 8433, 9054, 1743, 1598, 665, 5095, 3211, 628, 3910, 8186, 17050, 24218, 2535, 7682, 1305, 628, 1662, 15174, 2, 3462, 275, 1616, 4569, 275, 2948, 30, 3068, 7682, 2957, 17050, 24218, 2957, 5095, 30, 1598, 665, 5095, 3211, 628, 2052, 8186, 600, 2535, 7682, 1305, 628, 1662, 15174, 2, 3462, 275, 1616, 4569, 275, 1616, 30, 3068, 7682, 2957, 600, 2957, 5095, 30, 288, 3068, 5095, 923, 30, 288, 3068, 6048, 5095, 1310, 30, 288, 3068, 6462, 11193, 272, 776, 421, 199, 32, 2926, 360, 41, 5283, 436, 9509, 376, 15204, 1192, 460, 9988, 199, 318, 284, 63, 4200, 63, 290, 63, 5282, 1192, 460, 8, 2926, 304, 272, 9509, 63, 1652, 63, 262, 63, 14652, 63, 6462, 8, 2926, 12, 3886, 6462, 18181, 1108, 6462, 9579, 421, 199, 32, 2926, 360, 41, 664, 376, 1125, 9592, 9988, 199, 318, 664, 63, 290, 63, 705, 63, 7196, 8, 2926, 304, 272, 702, 63, 2052, 8, 7617, 14, 374, 63, 3919, 63, 1881, 480, 3015, 14, 7650, 14, 705, 2237, 421, 199, 32, 2926, 360, 41, 883, 8968, 370, 2621, 370, 314, 4137, 543, 314, 1125, 9988, 199, 318, 284, 63, 4891, 63, 265, 63, 705, 63, 7196, 8, 2926, 304, 272, 6701, 14, 4891, 63, 1073, 63, 991, 63, 505, 360, 19993, 3405, 3931, 358, 272, 702, 63, 2052, 8, 7617, 14, 3919, 63, 1360, 480, 3751, 14, 6460, 13, 705, 3471, 2460, 480, 16467, 284, 20, 88, 921, 13965, 88, 15, 5637, 15, 6462, 2237, 272, 2518, 63, 498, 275, 30687, 480, 13965, 88, 401, 298, 5637, 401, 298, 21823, 63, 11823, 63, 6979, 531, 272, 327, 781, 2793, 1133, 5715, 314, 3503, 2870, 402, 314, 13763, 14, 2002, 2951, 1104, 626, 781, 8103, 2621, 370, 282, 272, 327, 13763, 2034, 315, 314, 2518, 334, 16990, 1077, 1454, 506, 1373, 680, 272, 13763, 63, 3807, 63, 498, 275, 2518, 63, 498, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 488, 9, 272, 13763, 63, 633, 275, 3837, 63, 3807, 63, 633, 360, 3600, 63, 2232, 297, 13763, 63, 3807, 63, 498, 9, 272, 327, 5852, 314, 8520, 3286, 403, 2, 687, 314, 2851, 446, 781, 2793, 1133, 5715, 314, 2518, 2870, 12, 880, 781, 2951, 2934, 370, 272, 327, 1104, 626, 781, 15867, 282, 13763, 2851, 14, 272, 340, 13763, 63, 633, 14, 4130, 4769, 403, 2349, 267, 13763, 63, 633, 275, 13763, 63, 633, 4439, 21, 61, 272, 702, 63, 1452, 8, 17, 12, 6701, 14, 5750, 14, 633, 14, 835, 8, 7870, 63, 633, 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 ]
[ 4287, 26, 3507, 29, 35, 28107, 199, 3, 4287, 26, 3507, 29, 55, 1690, 2025, 199, 3, 4287, 26, 3507, 29, 55, 1690, 969, 199, 199, 504, 4691, 84, 3683, 492, 6701, 12, 3650, 199, 504, 3931, 63, 1751, 63, 7515, 63, 7546, 492, 9509, 63, 1652, 63, 262, 63, 14652, 63, 6462, 199, 504, 11354, 14, 2537, 492, 702, 63, 2052, 12, 702, 63, 1452, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 30687, 199, 504, 23061, 14, 1208, 492, 3837, 63, 3807, 63, 633, 421, 199, 32, 2926, 360, 41, 2621, 370, 314, 4843, 2034, 9988, 199, 318, 284, 63, 1939, 63, 475, 63, 1589, 63, 3790, 63, 1606, 8, 2926, 304, 272, 6701, 14, 4891, 63, 2537, 342, 272, 2142, 63, 3919, 275, 283, 317, 14, 10927, 13, 1972, 13, 2537, 13, 3790, 282, 7, 272, 6701, 14, 3919, 63, 4891, 8, 1073, 63, 3919, 9, 421, 199, 32, 2926, 360, 41, 4843, 314, 2518, 9988, 199, 318, 284, 63, 3790, 63, 1589, 63, 1972, 8, 2926, 304, 272, 3650, 14, 11809, 360, 41, 2621, 370, 314, 4843, 2034, 358, 272, 6701, 14, 3919, 63, 4891, 360, 65, 14, 1287, 13, 3790, 358, 421, 199, 32, 2926, 360, 41, 5283, 436, 9509, 4875, 4692, 9988, 199, 318, 284, 63, 4200, 63, 4087, 63, 1652, 8, 2926, 304, 272, 9509, 63, 1652, 63, 262, 63, 14652, 63, 6462, 8, 2926, 12, 267, 8894, 6462, 2535, 72, 17, 30, 51, 2174, 14899, 29349, 1108, 72, 17, 30, 288, 665, 80, 30, 5556, 2934, 370, 1852, 314, 18604, 10218, 1265, 883, 9758, 80, 30, 288, 665, 6048, 5095, 1310, 30, 288, 665, 5095, 923, 730, 628, 8433, 9054, 1743, 1598, 665, 5095, 3211, 628, 3910, 8186, 17050, 24218, 2535, 7682, 1305, 628, 1662, 15174, 2, 3462, 275, 1616, 4569, 275, 2948, 30, 3068, 7682, 2957, 17050, 24218, 2957, 5095, 30, 1598, 665, 5095, 3211, 628, 2052, 8186, 600, 2535, 7682, 1305, 628, 1662, 15174, 2, 3462, 275, 1616, 4569, 275, 1616, 30, 3068, 7682, 2957, 600, 2957, 5095, 30, 288, 3068, 5095, 923, 30, 288, 3068, 6048, 5095, 1310, 30, 288, 3068, 6462, 11193, 272, 776, 421, 199, 32, 2926, 360, 41, 5283, 436, 9509, 376, 15204, 1192, 460, 9988, 199, 318, 284, 63, 4200, 63, 290, 63, 5282, 1192, 460, 8, 2926, 304, 272, 9509, 63, 1652, 63, 262, 63, 14652, 63, 6462, 8, 2926, 12, 3886, 6462, 18181, 1108, 6462, 9579, 421, 199, 32, 2926, 360, 41, 664, 376, 1125, 9592, 9988, 199, 318, 664, 63, 290, 63, 705, 63, 7196, 8, 2926, 304, 272, 702, 63, 2052, 8, 7617, 14, 374, 63, 3919, 63, 1881, 480, 3015, 14, 7650, 14, 705, 2237, 421, 199, 32, 2926, 360, 41, 883, 8968, 370, 2621, 370, 314, 4137, 543, 314, 1125, 9988, 199, 318, 284, 63, 4891, 63, 265, 63, 705, 63, 7196, 8, 2926, 304, 272, 6701, 14, 4891, 63, 1073, 63, 991, 63, 505, 360, 19993, 3405, 3931, 358, 272, 702, 63, 2052, 8, 7617, 14, 3919, 63, 1360, 480, 3751, 14, 6460, 13, 705, 3471, 2460, 480, 16467, 284, 20, 88, 921, 13965, 88, 15, 5637, 15, 6462, 2237, 272, 2518, 63, 498, 275, 30687, 480, 13965, 88, 401, 298, 5637, 401, 298, 21823, 63, 11823, 63, 6979, 531, 272, 327, 781, 2793, 1133, 5715, 314, 3503, 2870, 402, 314, 13763, 14, 2002, 2951, 1104, 626, 781, 8103, 2621, 370, 282, 272, 327, 13763, 2034, 315, 314, 2518, 334, 16990, 1077, 1454, 506, 1373, 680, 272, 13763, 63, 3807, 63, 498, 275, 2518, 63, 498, 14, 1875, 63, 3807, 63, 498, 480, 7870, 401, 488, 9, 272, 13763, 63, 633, 275, 3837, 63, 3807, 63, 633, 360, 3600, 63, 2232, 297, 13763, 63, 3807, 63, 498, 9, 272, 327, 5852, 314, 8520, 3286, 403, 2, 687, 314, 2851, 446, 781, 2793, 1133, 5715, 314, 2518, 2870, 12, 880, 781, 2951, 2934, 370, 272, 327, 1104, 626, 781, 15867, 282, 13763, 2851, 14, 272, 340, 13763, 63, 633, 14, 4130, 4769, 403, 2349, 267, 13763, 63, 633, 275, 13763, 63, 633, 4439, 21, 61, 272, 702, 63, 1452, 8, 17, 12, 6701, 14, 5750, 14, 633, 14, 835, 8, 7870, 63, 633, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
camptocamp/ngo-addons-backport
addons/l10n_es/__init__.py
100
1273
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (c) 2007 ACYSOS S.L. (http://acysos.com) All Rights Reserved. # Pedro Tarrafeta (pedro@acysos.com) # Copyright (c) 2008-2010 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. # Jordi Esteve <jesteve@zikzakmedia.com> # $Id$ # # 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/>. # ############################################################################## # 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, 67, 9, 10219, 6570, 20238, 3100, 428, 14, 44, 14, 334, 1014, 921, 645, 588, 736, 14, 957, 9, 2900, 5924, 5702, 14, 199, 3, 9668, 510, 379, 293, 16017, 345, 70, 1841, 334, 1915, 293, 32, 645, 588, 736, 14, 957, 9, 199, 3, 259, 1898, 334, 67, 9, 9079, 13, 6542, 3107, 3258, 90, 1151, 4603, 428, 14, 44, 14, 334, 1014, 921, 90, 3258, 90, 1151, 4603, 14, 957, 9, 2900, 5924, 5702, 14, 199, 3, 14960, 1603, 269, 328, 662, 1597, 432, 665, 74, 397, 266, 432, 32, 90, 3258, 90, 1151, 4603, 14, 957, 30, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 4388, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 67, 9, 10219, 6570, 20238, 3100, 428, 14, 44, 14, 334, 1014, 921, 645, 588, 736, 14, 957, 9, 2900, 5924, 5702, 14, 199, 3, 9668, 510, 379, 293, 16017, 345, 70, 1841, 334, 1915, 293, 32, 645, 588, 736, 14, 957, 9, 199, 3, 259, 1898, 334, 67, 9, 9079, 13, 6542, 3107, 3258, 90, 1151, 4603, 428, 14, 44, 14, 334, 1014, 921, 90, 3258, 90, 1151, 4603, 14, 957, 9, 2900, 5924, 5702, 14, 199, 3, 14960, 1603, 269, 328, 662, 1597, 432, 665, 74, 397, 266, 432, 32, 90, 3258, 90, 1151, 4603, 14, 957, 30, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 4388, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vincentchoqueuse/parametrix
parametrix/bayesian_linear_model/signal_models.py
1
1666
from parametrix.core.signal_models import BaseSignalModel import numpy as np import scipy.linalg as lg from scipy.stats import multivariate_normal class M_Bayesian_L(BaseSignalModel): """ Bayesian Linear Signal Model (Eq 10.26)[KAY93]_ .. math:: \\textbf{y}=\\textbf{H}\\textbf{x}+\\textbf{b} where *x* is a p * 1 random vector with prior PDF N(m_x,C_x) and b is a random vector with PDF N(0,C_w) .. [KAY93] Kay, Steven M. "Fundamentals of statistical signal processing: estimation theory." (1993). """ name="M_Bayesian_L" def __init__(self,H,m_x,C_x,C_w,x=None,name="M_Bayesian_L"): self.H=H self.m_x=m_x self.C_x=C_x self.C_w=C_w self.N=H.shape[0] self.L=self.H.shape[1] self.name=name if isinstance(x, np.ndarray): self.x=x else: self.x=m_x def compute_sigma2s(self): return np.trace(self.C_x)/self.C_x.shape[0] @property def sigma2(self): return np.trace(self.C_w)/self.C_w.shape[0] def __setattr__(self, attribute, value): if attribute =="SNR": sigma2=self.get_sigma2s()/(10**(value/10)) self.C_w=(sigma2/self.sigma2)*self.C_w else: super().__setattr__(attribute, value) @property def S(self): self.x=multivariate_normal.rvs(mean=self.m_x,cov=self.C_x) H=np.matrix(self.H) x=np.matrix(self.x).T return H*x def rvs(self): b=np.matrix(multivariate_normal.rvs(cov=self.C_w)).T return self.S+b
bsd-3-clause
[ 504, 18117, 599, 88, 14, 1018, 14, 4653, 63, 992, 492, 3523, 11274, 1685, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 10096, 465, 634, 71, 199, 504, 7026, 14, 3200, 492, 32409, 63, 3302, 199, 199, 533, 603, 63, 29115, 69, 6214, 63, 44, 8, 1563, 11274, 1685, 304, 2286, 408, 29434, 69, 6214, 12489, 18288, 5822, 334, 19706, 1616, 14, 1479, 2788, 43, 3448, 3129, 25276, 2728, 2508, 3473, 447, 288, 8522, 505, 4361, 91, 89, 93, 29, 1103, 505, 4361, 91, 40, 32201, 505, 4361, 91, 88, 93, 11, 1103, 505, 4361, 91, 66, 93, 10631, 2382, 627, 88, 10, 365, 282, 299, 627, 413, 2196, 5477, 543, 6791, 15537, 653, 8, 77, 63, 88, 12, 35, 63, 88, 9, 436, 330, 365, 282, 2196, 5477, 543, 15537, 653, 8, 16, 12, 35, 63, 87, 9, 13857, 2508, 359, 43, 3448, 3129, 61, 1804, 1187, 12, 17854, 1856, 603, 14, 298, 32197, 14040, 2551, 402, 8753, 270, 2652, 4673, 6661, 26, 27156, 30629, 2122, 334, 7155, 19, 680, 2728, 408, 2286, 536, 628, 45, 63, 29115, 69, 6214, 63, 44, 2, 2286, 347, 636, 826, 721, 277, 12, 40, 12, 77, 63, 88, 12, 35, 63, 88, 12, 35, 63, 87, 12, 88, 29, 403, 12, 354, 628, 45, 63, 29115, 69, 6214, 63, 44, 2349, 267, 291, 14, 40, 29, 40, 267, 291, 14, 77, 63, 88, 29, 77, 63, 88, 267, 291, 14, 35, 63, 88, 29, 35, 63, 88, 267, 291, 14, 35, 63, 87, 29, 35, 63, 87, 267, 291, 14, 46, 29, 40, 14, 1392, 59, 16, 61, 267, 291, 14, 44, 29, 277, 14, 40, 14, 1392, 59, 17, 61, 267, 291, 14, 354, 29, 354, 2728, 340, 1228, 8, 88, 12, 980, 14, 8237, 304, 288, 291, 14, 88, 29, 88, 267, 587, 26, 288, 291, 14, 88, 29, 77, 63, 88, 339, 347, 4526, 63, 9412, 18, 83, 8, 277, 304, 267, 372, 980, 14, 3446, 8, 277, 14, 35, 63, 88, 2447, 277, 14, 35, 63, 88, 14, 1392, 59, 16, 61, 2286, 768, 1829, 272, 347, 10819, 18, 8, 277, 304, 267, 372, 980, 14, 3446, 8, 277, 14, 35, 63, 87, 2447, 277, 14, 35, 63, 87, 14, 1392, 59, 16, 61, 2286, 347, 636, 10202, 721, 277, 12, 2225, 12, 574, 304, 267, 340, 2225, 508, 2, 8199, 50, 582, 288, 10819, 18, 29, 277, 14, 362, 63, 9412, 18, 83, 342, 7985, 709, 14192, 585, 15, 709, 430, 288, 291, 14, 35, 63, 87, 2687, 9412, 18, 15, 277, 14, 9412, 18, 3342, 277, 14, 35, 63, 87, 267, 587, 26, 288, 1613, 11027, 10202, 721, 3215, 12, 574, 9, 339, 768, 1829, 272, 347, 428, 8, 277, 304, 267, 291, 14, 88, 29, 3029, 13805, 63, 3302, 14, 23322, 8, 3670, 29, 277, 14, 77, 63, 88, 12, 8695, 29, 277, 14, 35, 63, 88, 9, 267, 869, 29, 1590, 14, 3642, 8, 277, 14, 40, 9, 267, 671, 29, 1590, 14, 3642, 8, 277, 14, 88, 680, 52, 267, 372, 869, 10, 88, 339, 347, 519, 3122, 8, 277, 304, 267, 330, 29, 1590, 14, 3642, 8, 3029, 13805, 63, 3302, 14, 23322, 8, 8695, 29, 277, 14, 35, 63, 87, 4992, 52, 267, 372, 291, 14, 51, 11, 66, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 18117, 599, 88, 14, 1018, 14, 4653, 63, 992, 492, 3523, 11274, 1685, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 10096, 465, 634, 71, 199, 504, 7026, 14, 3200, 492, 32409, 63, 3302, 199, 199, 533, 603, 63, 29115, 69, 6214, 63, 44, 8, 1563, 11274, 1685, 304, 2286, 408, 29434, 69, 6214, 12489, 18288, 5822, 334, 19706, 1616, 14, 1479, 2788, 43, 3448, 3129, 25276, 2728, 2508, 3473, 447, 288, 8522, 505, 4361, 91, 89, 93, 29, 1103, 505, 4361, 91, 40, 32201, 505, 4361, 91, 88, 93, 11, 1103, 505, 4361, 91, 66, 93, 10631, 2382, 627, 88, 10, 365, 282, 299, 627, 413, 2196, 5477, 543, 6791, 15537, 653, 8, 77, 63, 88, 12, 35, 63, 88, 9, 436, 330, 365, 282, 2196, 5477, 543, 15537, 653, 8, 16, 12, 35, 63, 87, 9, 13857, 2508, 359, 43, 3448, 3129, 61, 1804, 1187, 12, 17854, 1856, 603, 14, 298, 32197, 14040, 2551, 402, 8753, 270, 2652, 4673, 6661, 26, 27156, 30629, 2122, 334, 7155, 19, 680, 2728, 408, 2286, 536, 628, 45, 63, 29115, 69, 6214, 63, 44, 2, 2286, 347, 636, 826, 721, 277, 12, 40, 12, 77, 63, 88, 12, 35, 63, 88, 12, 35, 63, 87, 12, 88, 29, 403, 12, 354, 628, 45, 63, 29115, 69, 6214, 63, 44, 2349, 267, 291, 14, 40, 29, 40, 267, 291, 14, 77, 63, 88, 29, 77, 63, 88, 267, 291, 14, 35, 63, 88, 29, 35, 63, 88, 267, 291, 14, 35, 63, 87, 29, 35, 63, 87, 267, 291, 14, 46, 29, 40, 14, 1392, 59, 16, 61, 267, 291, 14, 44, 29, 277, 14, 40, 14, 1392, 59, 17, 61, 267, 291, 14, 354, 29, 354, 2728, 340, 1228, 8, 88, 12, 980, 14, 8237, 304, 288, 291, 14, 88, 29, 88, 267, 587, 26, 288, 291, 14, 88, 29, 77, 63, 88, 339, 347, 4526, 63, 9412, 18, 83, 8, 277, 304, 267, 372, 980, 14, 3446, 8, 277, 14, 35, 63, 88, 2447, 277, 14, 35, 63, 88, 14, 1392, 59, 16, 61, 2286, 768, 1829, 272, 347, 10819, 18, 8, 277, 304, 267, 372, 980, 14, 3446, 8, 277, 14, 35, 63, 87, 2447, 277, 14, 35, 63, 87, 14, 1392, 59, 16, 61, 2286, 347, 636, 10202, 721, 277, 12, 2225, 12, 574, 304, 267, 340, 2225, 508, 2, 8199, 50, 582, 288, 10819, 18, 29, 277, 14, 362, 63, 9412, 18, 83, 342, 7985, 709, 14192, 585, 15, 709, 430, 288, 291, 14, 35, 63, 87, 2687, 9412, 18, 15, 277, 14, 9412, 18, 3342, 277, 14, 35, 63, 87, 267, 587, 26, 288, 1613, 11027, 10202, 721, 3215, 12, 574, 9, 339, 768, 1829, 272, 347, 428, 8, 277, 304, 267, 291, 14, 88, 29, 3029, 13805, 63, 3302, 14, 23322, 8, 3670, 29, 277, 14, 77, 63, 88, 12, 8695, 29, 277, 14, 35, 63, 88, 9, 267, 869, 29, 1590, 14, 3642, 8, 277, 14, 40, 9, 267, 671, 29, 1590, 14, 3642, 8, 277, 14, 88, 680, 52, 267, 372, 869, 10, 88, 339, 347, 519, 3122, 8, 277, 304, 267, 330, 29, 1590, 14, 3642, 8, 3029, 13805, 63, 3302, 14, 23322, 8, 8695, 29, 277, 14, 35, 63, 87, 4992, 52, 267, 372, 291, 14, 51, 11, 66, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vipul-sharma20/oh-mainline
vendor/packages/celery/celery/worker/buckets.py
18
11077
# -*- coding: utf-8 -*- """ celery.worker.buckets ~~~~~~~~~~~~~~~~~~~~~ This module implements the rate limiting of tasks, by having a token bucket queue for each task type. When a task is allowed to be processed it's moved over the the ``ready_queue`` The :mod:`celery.worker.mediator` is then responsible for moving tasks from the ``ready_queue`` to the worker pool. :copyright: (c) 2009 - 2011 by Ask Solem. :license: BSD, see LICENSE for more details. """ from __future__ import absolute_import from __future__ import with_statement import threading from collections import deque from time import time, sleep from Queue import Queue, Empty from ..datastructures import TokenBucket from ..utils import timeutils from ..utils.compat import zip_longest, chain_from_iterable class RateLimitExceeded(Exception): """The token buckets rate limit has been exceeded.""" class TaskBucket(object): """This is a collection of token buckets, each task type having its own token bucket. If the task type doesn't have a rate limit, it will have a plain :class:`~Queue.Queue` object instead of a :class:`TokenBucketQueue`. The :meth:`put` operation forwards the task to its appropriate bucket, while the :meth:`get` operation iterates over the buckets and retrieves the first available item. Say we have three types of tasks in the registry: `celery.ping`, `feed.refresh` and `video.compress`, the TaskBucket will consist of the following items:: {"celery.ping": TokenBucketQueue(fill_rate=300), "feed.refresh": Queue(), "video.compress": TokenBucketQueue(fill_rate=2)} The get operation will iterate over these until one of the buckets is able to return an item. The underlying datastructure is a `dict`, so the order is ignored here. :param task_registry: The task registry used to get the task type class for a given task name. """ def __init__(self, task_registry): self.task_registry = task_registry self.buckets = {} self.init_with_registry() self.immediate = deque() self.mutex = threading.Lock() self.not_empty = threading.Condition(self.mutex) def put(self, request): """Put a :class:`~celery.worker.job.TaskRequest` into the appropiate bucket.""" with self.mutex: if request.task_name not in self.buckets: self.add_bucket_for_type(request.task_name) self.buckets[request.task_name].put_nowait(request) self.not_empty.notify() put_nowait = put def _get_immediate(self): try: return self.immediate.popleft() except IndexError: raise Empty() def _get(self): # If the first bucket is always returning items, we would never # get to fetch items from the other buckets. So we always iterate over # all the buckets and put any ready items into a queue called # "immediate". This queue is always checked for cached items first. try: return 0, self._get_immediate() except Empty: pass remaining_times = [] for bucket in self.buckets.values(): remaining = bucket.expected_time() if not remaining: try: # Just put any ready items into the immediate queue. self.immediate.append(bucket.get_nowait()) except Empty: pass except RateLimitExceeded: remaining_times.append(bucket.expected_time()) else: remaining_times.append(remaining) # Try the immediate queue again. try: return 0, self._get_immediate() except Empty: if not remaining_times: # No items in any of the buckets. raise # There's items, but have to wait before we can retrieve them, # return the shortest remaining time. return min(remaining_times), None def get(self, block=True, timeout=None): """Retrive the task from the first available bucket. Available as in, there is an item in the queue and you can consume tokens from it. """ time_start = time() did_timeout = lambda: timeout and time() - time_start > timeout with self.not_empty: while True: try: remaining_time, item = self._get() except Empty: if not block or did_timeout(): raise self.not_empty.wait(timeout) continue if remaining_time: if not block or did_timeout(): raise Empty() sleep(min(remaining_time, timeout or 1)) else: return item def get_nowait(self): return self.get(block=False) def init_with_registry(self): """Initialize with buckets for all the task types in the registry.""" for task in self.task_registry.keys(): self.add_bucket_for_type(task) def refresh(self): """Refresh rate limits for all task types in the registry.""" for task in self.task_registry.keys(): self.update_bucket_for_type(task) def get_bucket_for_type(self, task_name): """Get the bucket for a particular task type.""" if task_name not in self.buckets: return self.add_bucket_for_type(task_name) return self.buckets[task_name] def _get_queue_for_type(self, task_name): bucket = self.buckets[task_name] if isinstance(bucket, TokenBucketQueue): return bucket.queue return bucket def update_bucket_for_type(self, task_name): task_type = self.task_registry[task_name] rate_limit = getattr(task_type, "rate_limit", None) rate_limit = timeutils.rate(rate_limit) task_queue = FastQueue() if task_name in self.buckets: task_queue = self._get_queue_for_type(task_name) else: task_queue = FastQueue() if rate_limit: task_queue = TokenBucketQueue(rate_limit, queue=task_queue) self.buckets[task_name] = task_queue return task_queue def add_bucket_for_type(self, task_name): """Add a bucket for a task type. Will read the tasks rate limit and create a :class:`TokenBucketQueue` if it has one. If the task doesn't have a rate limit :class:`FastQueue` will be used instead. """ if task_name not in self.buckets: return self.update_bucket_for_type(task_name) def qsize(self): """Get the total size of all the queues.""" return sum(bucket.qsize() for bucket in self.buckets.values()) def empty(self): """Returns :const:`True` if all of the buckets are empty.""" return all(bucket.empty() for bucket in self.buckets.values()) def clear(self): """Delete the data in all of the buckets.""" for bucket in self.buckets.values(): bucket.clear() @property def items(self): """Flattens the data in all of the buckets into a single list.""" # for queues with contents [(1, 2), (3, 4), (5, 6), (7, 8)] # zips and flattens to [1, 3, 5, 7, 2, 4, 6, 8] return filter(None, chain_from_iterable(zip_longest(*[bucket.items for bucket in self.buckets.values()]))) class FastQueue(Queue): """:class:`Queue.Queue` supporting the interface of :class:`TokenBucketQueue`.""" def clear(self): return self.queue.clear() def expected_time(self, tokens=1): return 0 def wait(self, block=True): return self.get(block=block) @property def items(self): return self.queue class TokenBucketQueue(object): """Queue with rate limited get operations. This uses the token bucket algorithm to rate limit the queue on get operations. :param fill_rate: The rate in tokens/second that the bucket will be refilled. :keyword capacity: Maximum number of tokens in the bucket. Default is 1. """ RateLimitExceeded = RateLimitExceeded def __init__(self, fill_rate, queue=None, capacity=1): self._bucket = TokenBucket(fill_rate, capacity) self.queue = queue if not self.queue: self.queue = Queue() def put(self, item, block=True): """Put an item onto the queue.""" self.queue.put(item, block=block) def put_nowait(self, item): """Put an item into the queue without blocking. :raises Queue.Full: If a free slot is not immediately available. """ return self.put(item, block=False) def get(self, block=True): """Remove and return an item from the queue. :raises RateLimitExceeded: If a token could not be consumed from the token bucket (consuming from the queue too fast). :raises Queue.Empty: If an item is not immediately available. """ get = block and self.queue.get or self.queue.get_nowait if not block and not self.items: raise Empty() if not self._bucket.can_consume(1): raise RateLimitExceeded() return get() def get_nowait(self): """Remove and return an item from the queue without blocking. :raises RateLimitExceeded: If a token could not be consumed from the token bucket (consuming from the queue too fast). :raises Queue.Empty: If an item is not immediately available. """ return self.get(block=False) def qsize(self): """Returns the size of the queue.""" return self.queue.qsize() def empty(self): """Returns :const:`True` if the queue is empty.""" return self.queue.empty() def clear(self): """Delete all data in the queue.""" return self.items.clear() def wait(self, block=False): """Wait until a token can be retrieved from the bucket and return the next item.""" get = self.get expected_time = self.expected_time while 1: remaining = expected_time() if not remaining: return get(block=block) sleep(remaining) def expected_time(self, tokens=1): """Returns the expected time in seconds of when a new token should be available.""" if not self.items: return 0 return self._bucket.expected_time(tokens) @property def items(self): """Underlying data. Do not modify.""" return self.queue.queue
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 22748, 14, 6599, 14, 15065, 272, 18294, 2878, 94, 339, 961, 859, 9031, 314, 6634, 2304, 316, 402, 6527, 12, 272, 701, 9445, 282, 1526, 5315, 4126, 367, 1924, 2120, 730, 14, 272, 3979, 282, 2120, 365, 4370, 370, 506, 7686, 652, 1159, 12155, 272, 1806, 314, 314, 1124, 2179, 63, 1825, 1040, 339, 710, 520, 1494, 1705, 23593, 14, 6599, 14, 3700, 707, 64, 365, 2066, 17845, 272, 367, 12876, 6527, 687, 314, 1124, 2179, 63, 1825, 1040, 370, 314, 7239, 4203, 14, 339, 520, 7307, 26, 334, 67, 9, 8937, 446, 7760, 701, 30481, 2002, 3701, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 5796, 199, 199, 504, 5055, 492, 15782, 199, 504, 900, 492, 900, 12, 9435, 199, 504, 10703, 492, 10703, 12, 9630, 199, 199, 504, 2508, 23004, 492, 8767, 12311, 199, 504, 2508, 1208, 492, 23011, 199, 504, 2508, 1208, 14, 5819, 492, 3482, 63, 20820, 12, 6036, 63, 504, 63, 8147, 421, 199, 533, 26311, 8407, 24748, 8, 1726, 304, 272, 408, 1918, 1526, 18655, 6634, 2304, 965, 2757, 22007, 1041, 421, 199, 533, 8495, 12311, 8, 785, 304, 272, 408, 2765, 365, 282, 3245, 402, 1526, 18655, 12, 1924, 2120, 730, 9445, 272, 2399, 5705, 1526, 5315, 14, 221, 982, 314, 2120, 730, 3181, 1133, 1172, 282, 6634, 2304, 12, 272, 652, 911, 1172, 282, 8971, 520, 533, 6054, 3737, 14, 3737, 64, 909, 3140, 402, 282, 272, 520, 533, 1705, 3264, 12311, 3737, 2313, 339, 710, 520, 5247, 1705, 524, 64, 3439, 17465, 314, 2120, 370, 2399, 5827, 5315, 12, 272, 1830, 314, 520, 5247, 1705, 362, 64, 3439, 2740, 2335, 1806, 314, 18655, 436, 9619, 2310, 272, 314, 1642, 2808, 1242, 14, 339, 428, 1187, 781, 1172, 7795, 2943, 402, 6527, 315, 314, 7086, 26, 658, 23593, 14, 4073, 3559, 272, 658, 3871, 14, 6635, 64, 436, 658, 3722, 14, 6447, 3559, 314, 8495, 12311, 911, 17568, 272, 402, 314, 2569, 2974, 447, 398, 2420, 23593, 14, 4073, 582, 8767, 12311, 3737, 8, 4498, 63, 1866, 29, 5863, 395, 268, 298, 3871, 14, 6635, 582, 10703, 1062, 268, 298, 3722, 14, 6447, 582, 8767, 12311, 3737, 8, 4498, 63, 1866, 29, 18, 6769, 339, 710, 664, 3439, 911, 13974, 1806, 3520, 5133, 1373, 402, 314, 18655, 272, 365, 7688, 370, 372, 376, 1242, 14, 221, 710, 8793, 666, 6976, 365, 282, 658, 807, 3559, 272, 880, 314, 1865, 365, 5525, 2348, 14, 339, 520, 635, 2120, 63, 5189, 26, 710, 2120, 7086, 1202, 370, 664, 314, 2120, 2079, 730, 1021, 367, 282, 1627, 2120, 536, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 2120, 63, 5189, 304, 267, 291, 14, 1765, 63, 5189, 275, 2120, 63, 5189, 267, 291, 14, 15065, 275, 1052, 267, 291, 14, 826, 63, 1045, 63, 5189, 342, 267, 291, 14, 20250, 275, 15782, 342, 267, 291, 14, 19078, 275, 5796, 14, 6432, 342, 267, 291, 14, 1397, 63, 1667, 275, 5796, 14, 9558, 8, 277, 14, 19078, 9, 339, 347, 5324, 8, 277, 12, 1056, 304, 267, 408, 18989, 282, 520, 533, 6054, 23593, 14, 6599, 14, 2423, 14, 4476, 2017, 64, 1901, 267, 314, 4286, 1038, 323, 5315, 1041, 267, 543, 291, 14, 19078, 26, 288, 340, 1056, 14, 1765, 63, 354, 440, 315, 291, 14, 15065, 26, 355, 291, 14, 525, 63, 4623, 63, 509, 63, 466, 8, 1069, 14, 1765, 63, 354, 9, 288, 291, 14, 15065, 59, 1069, 14, 1765, 63, 354, 1055, 524, 63, 20870, 8, 1069, 9, 288, 291, 14, 1397, 63, 1667, 14, 6814, 342, 272, 5324, 63, 20870, 275, 5324, 339, 347, 485, 362, 63, 20250, 8, 277, 304, 267, 862, 26, 288, 372, 291, 14, 20250, 14, 25704, 342, 267, 871, 7888, 26, 288, 746, 9630, 342, 339, 347, 485, 362, 8, 277, 304, 267, 327, 982, 314, 1642, 5315, 365, 3544, 8152, 2974, 12, 781, 3955, 7078, 267, 327, 664, 370, 5267, 2974, 687, 314, 1163, 18655, 14, 2002, 781, 3544, 13974, 1806, 267, 327, 1006, 314, 18655, 436, 5324, 1263, 10144, 2974, 1901, 282, 4126, 2797, 267, 327, 298, 20250, 1674, 961, 4126, 365, 3544, 7923, 367, 6328, 2974, 1642, 14, 267, 862, 26, 288, 372, 378, 12, 291, 423, 362, 63, 20250, 342, 267, 871, 9630, 26, 288, 986, 398, 7971, 63, 4508, 275, 942, 267, 367, 5315, 315, 291, 14, 15065, 14, 1459, 837, 288, 7971, 275, 5315, 14, 2062, 63, 521, 342, 288, 340, 440, 7971, 26, 355, 862, 26, 490, 327, 13870, 5324, 1263, 10144, 2974, 1901, 314, 8569, 4126, 14, 490, 291, 14, 20250, 14, 740, 8, 4623, 14, 362, 63, 20870, 1012, 355, 871, 9630, 26, 490, 986, 355, 871, 26311, 8407, 24748, 26, 490, 7971, 63, 4508, 14, 740, 8, 4623, 14, 2062, 63, 521, 1012, 288, 587, 26, 355, 7971, 63, 4508, 14, 740, 8, 11266, 9, 398, 327, 7649, 314, 8569, 4126, 4020, 14, 267, 862, 26, 288, 372, 378, 12, 291, 423, 362, 63, 20250, 342, 267, 871, 9630, 26, 288, 340, 440, 7971, 63, 4508, 26, 355, 327, 3091, 2974, 315, 1263, 402, 314, 18655, 14, 355, 746, 953, 327, 6006, 1159, 2974, 12, 1325, 1172, 370, 3618, 2544, 781, 883, 8044, 3062, 12, 288, 327, 372, 314, 26564, 7971, 900, 14, 288, 372, 1748, 8, 11266, 63, 4508, 395, 488, 339, 347, 664, 8, 277, 12, 1853, 29, 549, 12, 2653, 29, 403, 304, 267, 408, 6816, 6053, 314, 2120, 687, 314, 1642, 2808, 5315, 14, 398, 23840, 465, 315, 12, 2337, 365, 376, 1242, 315, 314, 4126, 436, 1265, 883, 267, 9451, 4645, 687, 652, 14, 398, 408, 267, 900, 63, 928, 275, 900, 342, 267, 8103, 63, 2593, 275, 2400, 26, 2653, 436, 900, 342, 446, 900, 63, 928, 690, 2653, 398, 543, 291, 14, 1397, 63, 1667, 26, 288, 1830, 715, 26, 355, 862, 26, 490, 7971, 63, 521, 12, 1242, 275, 291, 423, 362, 342, 355, 871, 9630, 26, 490, 340 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 22748, 14, 6599, 14, 15065, 272, 18294, 2878, 94, 339, 961, 859, 9031, 314, 6634, 2304, 316, 402, 6527, 12, 272, 701, 9445, 282, 1526, 5315, 4126, 367, 1924, 2120, 730, 14, 272, 3979, 282, 2120, 365, 4370, 370, 506, 7686, 652, 1159, 12155, 272, 1806, 314, 314, 1124, 2179, 63, 1825, 1040, 339, 710, 520, 1494, 1705, 23593, 14, 6599, 14, 3700, 707, 64, 365, 2066, 17845, 272, 367, 12876, 6527, 687, 314, 1124, 2179, 63, 1825, 1040, 370, 314, 7239, 4203, 14, 339, 520, 7307, 26, 334, 67, 9, 8937, 446, 7760, 701, 30481, 2002, 3701, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 5796, 199, 199, 504, 5055, 492, 15782, 199, 504, 900, 492, 900, 12, 9435, 199, 504, 10703, 492, 10703, 12, 9630, 199, 199, 504, 2508, 23004, 492, 8767, 12311, 199, 504, 2508, 1208, 492, 23011, 199, 504, 2508, 1208, 14, 5819, 492, 3482, 63, 20820, 12, 6036, 63, 504, 63, 8147, 421, 199, 533, 26311, 8407, 24748, 8, 1726, 304, 272, 408, 1918, 1526, 18655, 6634, 2304, 965, 2757, 22007, 1041, 421, 199, 533, 8495, 12311, 8, 785, 304, 272, 408, 2765, 365, 282, 3245, 402, 1526, 18655, 12, 1924, 2120, 730, 9445, 272, 2399, 5705, 1526, 5315, 14, 221, 982, 314, 2120, 730, 3181, 1133, 1172, 282, 6634, 2304, 12, 272, 652, 911, 1172, 282, 8971, 520, 533, 6054, 3737, 14, 3737, 64, 909, 3140, 402, 282, 272, 520, 533, 1705, 3264, 12311, 3737, 2313, 339, 710, 520, 5247, 1705, 524, 64, 3439, 17465, 314, 2120, 370, 2399, 5827, 5315, 12, 272, 1830, 314, 520, 5247, 1705, 362, 64, 3439, 2740, 2335, 1806, 314, 18655, 436, 9619, 2310, 272, 314, 1642, 2808, 1242, 14, 339, 428, 1187, 781, 1172, 7795, 2943, 402, 6527, 315, 314, 7086, 26, 658, 23593, 14, 4073, 3559, 272, 658, 3871, 14, 6635, 64, 436, 658, 3722, 14, 6447, 3559, 314, 8495, 12311, 911, 17568, 272, 402, 314, 2569, 2974, 447, 398, 2420, 23593, 14, 4073, 582, 8767, 12311, 3737, 8, 4498, 63, 1866, 29, 5863, 395, 268, 298, 3871, 14, 6635, 582, 10703, 1062, 268, 298, 3722, 14, 6447, 582, 8767, 12311, 3737, 8, 4498, 63, 1866, 29, 18, 6769, 339, 710, 664, 3439, 911, 13974, 1806, 3520, 5133, 1373, 402, 314, 18655, 272, 365, 7688, 370, 372, 376, 1242, 14, 221, 710, 8793, 666, 6976, 365, 282, 658, 807, 3559, 272, 880, 314, 1865, 365, 5525, 2348, 14, 339, 520, 635, 2120, 63, 5189, 26, 710, 2120, 7086, 1202, 370, 664, 314, 2120, 2079, 730, 1021, 367, 282, 1627, 2120, 536, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 2120, 63, 5189, 304, 267, 291, 14, 1765, 63, 5189, 275, 2120, 63, 5189, 267, 291, 14, 15065, 275, 1052, 267, 291, 14, 826, 63, 1045, 63, 5189, 342, 267, 291, 14, 20250, 275, 15782, 342, 267, 291, 14, 19078, 275, 5796, 14, 6432, 342, 267, 291, 14, 1397, 63, 1667, 275, 5796, 14, 9558, 8, 277, 14, 19078, 9, 339, 347, 5324, 8, 277, 12, 1056, 304, 267, 408, 18989, 282, 520, 533, 6054, 23593, 14, 6599, 14, 2423, 14, 4476, 2017, 64, 1901, 267, 314, 4286, 1038, 323, 5315, 1041, 267, 543, 291, 14, 19078, 26, 288, 340, 1056, 14, 1765, 63, 354, 440, 315, 291, 14, 15065, 26, 355, 291, 14, 525, 63, 4623, 63, 509, 63, 466, 8, 1069, 14, 1765, 63, 354, 9, 288, 291, 14, 15065, 59, 1069, 14, 1765, 63, 354, 1055, 524, 63, 20870, 8, 1069, 9, 288, 291, 14, 1397, 63, 1667, 14, 6814, 342, 272, 5324, 63, 20870, 275, 5324, 339, 347, 485, 362, 63, 20250, 8, 277, 304, 267, 862, 26, 288, 372, 291, 14, 20250, 14, 25704, 342, 267, 871, 7888, 26, 288, 746, 9630, 342, 339, 347, 485, 362, 8, 277, 304, 267, 327, 982, 314, 1642, 5315, 365, 3544, 8152, 2974, 12, 781, 3955, 7078, 267, 327, 664, 370, 5267, 2974, 687, 314, 1163, 18655, 14, 2002, 781, 3544, 13974, 1806, 267, 327, 1006, 314, 18655, 436, 5324, 1263, 10144, 2974, 1901, 282, 4126, 2797, 267, 327, 298, 20250, 1674, 961, 4126, 365, 3544, 7923, 367, 6328, 2974, 1642, 14, 267, 862, 26, 288, 372, 378, 12, 291, 423, 362, 63, 20250, 342, 267, 871, 9630, 26, 288, 986, 398, 7971, 63, 4508, 275, 942, 267, 367, 5315, 315, 291, 14, 15065, 14, 1459, 837, 288, 7971, 275, 5315, 14, 2062, 63, 521, 342, 288, 340, 440, 7971, 26, 355, 862, 26, 490, 327, 13870, 5324, 1263, 10144, 2974, 1901, 314, 8569, 4126, 14, 490, 291, 14, 20250, 14, 740, 8, 4623, 14, 362, 63, 20870, 1012, 355, 871, 9630, 26, 490, 986, 355, 871, 26311, 8407, 24748, 26, 490, 7971, 63, 4508, 14, 740, 8, 4623, 14, 2062, 63, 521, 1012, 288, 587, 26, 355, 7971, 63, 4508, 14, 740, 8, 11266, 9, 398, 327, 7649, 314, 8569, 4126, 4020, 14, 267, 862, 26, 288, 372, 378, 12, 291, 423, 362, 63, 20250, 342, 267, 871, 9630, 26, 288, 340, 440, 7971, 63, 4508, 26, 355, 327, 3091, 2974, 315, 1263, 402, 314, 18655, 14, 355, 746, 953, 327, 6006, 1159, 2974, 12, 1325, 1172, 370, 3618, 2544, 781, 883, 8044, 3062, 12, 288, 327, 372, 314, 26564, 7971, 900, 14, 288, 372, 1748, 8, 11266, 63, 4508, 395, 488, 339, 347, 664, 8, 277, 12, 1853, 29, 549, 12, 2653, 29, 403, 304, 267, 408, 6816, 6053, 314, 2120, 687, 314, 1642, 2808, 5315, 14, 398, 23840, 465, 315, 12, 2337, 365, 376, 1242, 315, 314, 4126, 436, 1265, 883, 267, 9451, 4645, 687, 652, 14, 398, 408, 267, 900, 63, 928, 275, 900, 342, 267, 8103, 63, 2593, 275, 2400, 26, 2653, 436, 900, 342, 446, 900, 63, 928, 690, 2653, 398, 543, 291, 14, 1397, 63, 1667, 26, 288, 1830, 715, 26, 355, 862, 26, 490, 7971, 63, 521, 12, 1242, 275, 291, 423, 362, 342, 355, 871, 9630, 26, 490, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
benfinke/ns_python
build/lib/nssrc/com/citrix/netscaler/nitro/resource/config/lb/lbmonbindings_binding.py
3
3899
# # Copyright (c) 2008-2015 Citrix Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_resource from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_response from nssrc.com.citrix.netscaler.nitro.service.options import options from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception from nssrc.com.citrix.netscaler.nitro.util.nitro_util import nitro_util class lbmonbindings_binding(base_resource): """ Binding class showing the resources that can be bound to lbmonbindings_binding. """ def __init__(self) : self._monitorname = "" self.lbmonbindings_servicegroup_binding = [] self.lbmonbindings_service_binding = [] @property def monitorname(self) : ur"""The name of the monitor.<br/>Minimum length = 1. """ try : return self._monitorname except Exception as e: raise e @monitorname.setter def monitorname(self, monitorname) : ur"""The name of the monitor.<br/>Minimum length = 1 """ try : self._monitorname = monitorname except Exception as e: raise e @property def lbmonbindings_service_bindings(self) : ur"""service that can be bound to lbmonbindings. """ try : return self._lbmonbindings_service_binding except Exception as e: raise e @property def lbmonbindings_servicegroup_bindings(self) : ur"""servicegroup that can be bound to lbmonbindings. """ try : return self._lbmonbindings_servicegroup_binding except Exception as e: raise e def _get_nitro_response(self, service, response) : ur""" converts nitro response into object and returns the object array in case of get request. """ try : result = service.payload_formatter.string_to_resource(lbmonbindings_binding_response, response, self.__class__.__name__) if(result.errorcode != 0) : if (result.errorcode == 444) : service.clear_session(self) if result.severity : if (result.severity == "ERROR") : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) else : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) return result.lbmonbindings_binding except Exception as e : raise e def _get_object_name(self) : ur""" Returns the value of object identifier argument """ try : if self.monitorname is not None : return str(self.monitorname) return None except Exception as e : raise e @classmethod def get(self, service, monitorname) : ur""" Use this API to fetch lbmonbindings_binding resource. """ try : if type(monitorname) is not list : obj = lbmonbindings_binding() obj.monitorname = monitorname response = obj.get_resource(service) else : if monitorname and len(monitorname) > 0 : obj = [lbmonbindings_binding() for _ in range(len(monitorname))] for i in range(len(monitorname)) : obj[i].monitorname = monitorname[i]; response[i] = obj[i].get_resource(service) return response except Exception as e: raise e class lbmonbindings_binding_response(base_response) : def __init__(self, length=1) : self.lbmonbindings_binding = [] self.errorcode = 0 self.message = "" self.severity = "" self.sessionid = "" self.lbmonbindings_binding = [lbmonbindings_binding() for _ in range(length)]
apache-2.0
[ 3, 199, 3, 1898, 334, 67, 9, 9079, 13, 7806, 445, 390, 1904, 15285, 12, 3277, 14, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 531, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 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, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1927, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1310, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1364, 14, 1419, 492, 1511, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1971, 14, 18893, 63, 1971, 492, 20107, 63, 1971, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1974, 14, 18893, 63, 1974, 492, 20107, 63, 1974, 199, 199, 533, 11104, 2106, 10880, 63, 9140, 8, 1095, 63, 1927, 304, 199, 198, 624, 22630, 316, 1021, 21207, 314, 5944, 626, 883, 506, 3914, 370, 11104, 2106, 10880, 63, 9140, 14, 9948, 198, 624, 199, 198, 318, 636, 826, 721, 277, 9, 520, 507, 198, 277, 423, 7157, 354, 275, 3087, 507, 198, 277, 14, 6374, 2106, 10880, 63, 29409, 63, 9140, 275, 942, 507, 198, 277, 14, 6374, 2106, 10880, 63, 1364, 63, 9140, 275, 942, 421, 198, 32, 1829, 199, 198, 318, 8372, 354, 8, 277, 9, 520, 507, 198, 300, 624, 1918, 536, 402, 314, 8372, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 7157, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 7157, 354, 14, 8345, 199, 198, 318, 8372, 354, 8, 277, 12, 8372, 354, 9, 520, 507, 198, 300, 624, 1918, 536, 402, 314, 8372, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 7157, 354, 275, 8372, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 11104, 2106, 10880, 63, 1364, 63, 10880, 8, 277, 9, 520, 507, 198, 300, 624, 1364, 626, 883, 506, 3914, 370, 11104, 2106, 10880, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 6374, 2106, 10880, 63, 1364, 63, 9140, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 11104, 2106, 10880, 63, 29409, 63, 10880, 8, 277, 9, 520, 507, 198, 300, 624, 29409, 626, 883, 506, 3914, 370, 11104, 2106, 10880, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 6374, 2106, 10880, 63, 29409, 63, 9140, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 318, 485, 362, 63, 18893, 63, 1310, 8, 277, 12, 2435, 12, 1177, 9, 520, 507, 198, 300, 624, 15373, 20107, 1177, 1901, 909, 436, 2529, 314, 909, 1625, 315, 1930, 402, 664, 1056, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1099, 275, 2435, 14, 4749, 63, 8911, 14, 875, 63, 475, 63, 1927, 8, 6374, 2106, 10880, 63, 9140, 63, 1310, 12, 1177, 12, 291, 855, 533, 4914, 354, 3368, 686, 198, 692, 8, 1099, 14, 28857, 1137, 378, 9, 520, 1585, 198, 692, 334, 1099, 14, 28857, 508, 841, 1602, 9, 520, 1871, 198, 1364, 14, 3584, 63, 1730, 8, 277, 9, 1585, 198, 692, 754, 14, 20394, 520, 1871, 198, 692, 334, 1099, 14, 20394, 508, 298, 3170, 531, 520, 4671, 198, 3730, 20107, 63, 1971, 8, 1099, 14, 28857, 12, 620, 8, 1099, 14, 1188, 395, 620, 8, 1099, 14, 20394, 430, 1585, 198, 2836, 520, 1871, 198, 3730, 20107, 63, 1971, 8, 1099, 14, 28857, 12, 620, 8, 1099, 14, 1188, 395, 620, 8, 1099, 14, 20394, 430, 686, 198, 1107, 754, 14, 6374, 2106, 10880, 63, 9140, 507, 198, 2590, 2186, 465, 325, 520, 686, 198, 3730, 325, 421, 198, 318, 485, 362, 63, 785, 63, 354, 8, 277, 9, 520, 507, 198, 300, 624, 1803, 314, 574, 402, 909, 5148, 1423, 507, 198, 624, 507, 198, 893, 520, 686, 198, 692, 291, 14, 7157, 354, 365, 440, 488, 520, 1585, 198, 1107, 620, 8, 277, 14, 7157, 354, 9, 686, 198, 1107, 488, 507, 198, 2590, 2186, 465, 325, 520, 686, 198, 3730, 325, 6905, 198, 32, 3744, 199, 198, 318, 664, 8, 277, 12, 2435, 12, 8372, 354, 9, 520, 507, 198, 300, 624, 3645, 642, 3261, 370, 5267, 11104, 2106, 10880, 63, 9140, 2073, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 692, 730, 8, 7157, 354, 9, 365, 440, 769, 520, 1585, 198, 1113, 275, 11104, 2106, 10880, 63, 9140, 342, 1585, 198, 1113, 14, 7157, 354, 275, 8372, 354, 1585, 198, 1310, 275, 1559, 14, 362, 63, 1927, 8, 1364, 9, 686, 198, 2836, 520, 1585, 198, 692, 8372, 354, 436, 822, 8, 7157, 354, 9, 690, 378, 520, 1871, 198, 1113, 275, 359, 6374, 2106, 10880, 63, 9140, 342, 367, 485, 315, 1425, 8, 552, 8, 7157, 354, 10524, 1871, 198, 509, 284, 315, 1425, 8, 552, 8, 7157, 354, 430, 520, 4671, 198, 1113, 59, 73, 1055, 7157, 354, 275, 8372, 354, 59, 73, 11566, 4671, 198, 1310, 59, 73, 61, 275, 1559, 59, 73, 1055, 362 ]
[ 199, 3, 1898, 334, 67, 9, 9079, 13, 7806, 445, 390, 1904, 15285, 12, 3277, 14, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 531, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 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, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1927, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1927, 14, 1095, 14, 1095, 63, 1927, 492, 1300, 63, 1310, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1364, 14, 1419, 492, 1511, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1971, 14, 18893, 63, 1971, 492, 20107, 63, 1971, 199, 199, 504, 302, 32231, 14, 957, 14, 14422, 1904, 14, 18860, 14, 18893, 14, 1974, 14, 18893, 63, 1974, 492, 20107, 63, 1974, 199, 199, 533, 11104, 2106, 10880, 63, 9140, 8, 1095, 63, 1927, 304, 199, 198, 624, 22630, 316, 1021, 21207, 314, 5944, 626, 883, 506, 3914, 370, 11104, 2106, 10880, 63, 9140, 14, 9948, 198, 624, 199, 198, 318, 636, 826, 721, 277, 9, 520, 507, 198, 277, 423, 7157, 354, 275, 3087, 507, 198, 277, 14, 6374, 2106, 10880, 63, 29409, 63, 9140, 275, 942, 507, 198, 277, 14, 6374, 2106, 10880, 63, 1364, 63, 9140, 275, 942, 421, 198, 32, 1829, 199, 198, 318, 8372, 354, 8, 277, 9, 520, 507, 198, 300, 624, 1918, 536, 402, 314, 8372, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 7157, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 7157, 354, 14, 8345, 199, 198, 318, 8372, 354, 8, 277, 12, 8372, 354, 9, 520, 507, 198, 300, 624, 1918, 536, 402, 314, 8372, 21455, 3289, 3133, 12092, 2582, 275, 221, 413, 507, 198, 624, 507, 198, 893, 520, 686, 198, 277, 423, 7157, 354, 275, 8372, 354, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 11104, 2106, 10880, 63, 1364, 63, 10880, 8, 277, 9, 520, 507, 198, 300, 624, 1364, 626, 883, 506, 3914, 370, 11104, 2106, 10880, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 6374, 2106, 10880, 63, 1364, 63, 9140, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 32, 1829, 199, 198, 318, 11104, 2106, 10880, 63, 29409, 63, 10880, 8, 277, 9, 520, 507, 198, 300, 624, 29409, 626, 883, 506, 3914, 370, 11104, 2106, 10880, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1107, 291, 423, 6374, 2106, 10880, 63, 29409, 63, 9140, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 3730, 325, 421, 198, 318, 485, 362, 63, 18893, 63, 1310, 8, 277, 12, 2435, 12, 1177, 9, 520, 507, 198, 300, 624, 15373, 20107, 1177, 1901, 909, 436, 2529, 314, 909, 1625, 315, 1930, 402, 664, 1056, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 1099, 275, 2435, 14, 4749, 63, 8911, 14, 875, 63, 475, 63, 1927, 8, 6374, 2106, 10880, 63, 9140, 63, 1310, 12, 1177, 12, 291, 855, 533, 4914, 354, 3368, 686, 198, 692, 8, 1099, 14, 28857, 1137, 378, 9, 520, 1585, 198, 692, 334, 1099, 14, 28857, 508, 841, 1602, 9, 520, 1871, 198, 1364, 14, 3584, 63, 1730, 8, 277, 9, 1585, 198, 692, 754, 14, 20394, 520, 1871, 198, 692, 334, 1099, 14, 20394, 508, 298, 3170, 531, 520, 4671, 198, 3730, 20107, 63, 1971, 8, 1099, 14, 28857, 12, 620, 8, 1099, 14, 1188, 395, 620, 8, 1099, 14, 20394, 430, 1585, 198, 2836, 520, 1871, 198, 3730, 20107, 63, 1971, 8, 1099, 14, 28857, 12, 620, 8, 1099, 14, 1188, 395, 620, 8, 1099, 14, 20394, 430, 686, 198, 1107, 754, 14, 6374, 2106, 10880, 63, 9140, 507, 198, 2590, 2186, 465, 325, 520, 686, 198, 3730, 325, 421, 198, 318, 485, 362, 63, 785, 63, 354, 8, 277, 9, 520, 507, 198, 300, 624, 1803, 314, 574, 402, 909, 5148, 1423, 507, 198, 624, 507, 198, 893, 520, 686, 198, 692, 291, 14, 7157, 354, 365, 440, 488, 520, 1585, 198, 1107, 620, 8, 277, 14, 7157, 354, 9, 686, 198, 1107, 488, 507, 198, 2590, 2186, 465, 325, 520, 686, 198, 3730, 325, 6905, 198, 32, 3744, 199, 198, 318, 664, 8, 277, 12, 2435, 12, 8372, 354, 9, 520, 507, 198, 300, 624, 3645, 642, 3261, 370, 5267, 11104, 2106, 10880, 63, 9140, 2073, 14, 507, 198, 624, 507, 198, 893, 520, 686, 198, 692, 730, 8, 7157, 354, 9, 365, 440, 769, 520, 1585, 198, 1113, 275, 11104, 2106, 10880, 63, 9140, 342, 1585, 198, 1113, 14, 7157, 354, 275, 8372, 354, 1585, 198, 1310, 275, 1559, 14, 362, 63, 1927, 8, 1364, 9, 686, 198, 2836, 520, 1585, 198, 692, 8372, 354, 436, 822, 8, 7157, 354, 9, 690, 378, 520, 1871, 198, 1113, 275, 359, 6374, 2106, 10880, 63, 9140, 342, 367, 485, 315, 1425, 8, 552, 8, 7157, 354, 10524, 1871, 198, 509, 284, 315, 1425, 8, 552, 8, 7157, 354, 430, 520, 4671, 198, 1113, 59, 73, 1055, 7157, 354, 275, 8372, 354, 59, 73, 11566, 4671, 198, 1310, 59, 73, 61, 275, 1559, 59, 73, 1055, 362, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
espadrine/opera
chromium/src/tools/grit/grit/tool/postprocess_unittest.py
61
1851
#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. '''Unit test that checks postprocessing of files. Tests postprocessing by having the postprocessor modify the grd data tree, changing the message name attributes. ''' import os import re import sys if __name__ == '__main__': sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) import unittest import grit.tool.postprocess_interface from grit.tool import rc2grd class PostProcessingUnittest(unittest.TestCase): def testPostProcessing(self): rctext = '''STRINGTABLE BEGIN DUMMY_STRING_1 "String 1" // Some random description DUMMY_STRING_2 "This text was added during preprocessing" END ''' tool = rc2grd.Rc2Grd() class DummyOpts(object): verbose = False extra_verbose = False tool.o = DummyOpts() tool.post_process = 'grit.tool.postprocess_unittest.DummyPostProcessor' result = tool.Process(rctext, '.\resource.rc') self.failUnless( result.children[2].children[2].children[0].attrs['name'] == 'SMART_STRING_1') self.failUnless( result.children[2].children[2].children[1].attrs['name'] == 'SMART_STRING_2') class DummyPostProcessor(grit.tool.postprocess_interface.PostProcessor): ''' Post processing replaces all message name attributes containing "DUMMY" to "SMART". ''' def Process(self, rctext, rcpath, grdnode): smarter = re.compile(r'(DUMMY)(.*)') messages = grdnode.children[2].children[2] for node in messages.children: name_attr = node.attrs['name'] m = smarter.search(name_attr) if m: node.attrs['name'] = 'SMART' + m.group(2) return grdnode if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 2344, 5072, 511, 626, 5920, 2963, 6338, 402, 1584, 14, 2043, 6496, 2963, 6338, 701, 9445, 314, 2963, 6459, 2043, 2811, 314, 486, 6883, 666, 3123, 12, 13729, 314, 1245, 536, 3004, 14, 199, 2344, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 20644, 703, 1333, 199, 199, 646, 2882, 199, 199, 646, 486, 11133, 14, 3557, 14, 32238, 63, 3266, 199, 504, 486, 11133, 14, 3557, 492, 4819, 18, 2587, 68, 421, 199, 533, 7711, 9589, 1358, 1770, 8, 2796, 14, 1746, 304, 819, 347, 511, 6564, 9589, 8, 277, 304, 272, 4819, 505, 275, 1449, 5353, 8723, 199, 15947, 523, 577, 22472, 63, 5353, 63, 17, 260, 298, 1558, 413, 2, 523, 5001, 6601, 2196, 1369, 523, 577, 22472, 63, 5353, 63, 18, 263, 298, 2765, 1318, 1990, 3483, 5309, 26471, 2, 199, 3902, 272, 1449, 272, 4744, 275, 4819, 18, 2587, 68, 14, 19360, 18, 39, 6883, 342, 272, 1021, 9762, 24429, 8, 785, 304, 489, 3376, 275, 756, 489, 2402, 63, 3832, 275, 756, 272, 4744, 14, 79, 275, 9762, 24429, 342, 272, 4744, 14, 1932, 63, 1412, 275, 283, 7928, 84, 14, 3557, 14, 32238, 63, 2796, 14, 11324, 6564, 10438, 7, 272, 754, 275, 4744, 14, 3498, 8, 1195, 505, 12, 1987, 60, 1927, 14, 1195, 358, 339, 291, 14, 7589, 8, 489, 754, 14, 3223, 59, 18, 1055, 3223, 59, 18, 1055, 3223, 59, 16, 1055, 3288, 459, 354, 418, 508, 283, 4029, 2294, 63, 5353, 63, 17, 358, 272, 291, 14, 7589, 8, 489, 754, 14, 3223, 59, 18, 1055, 3223, 59, 18, 1055, 3223, 59, 17, 1055, 3288, 459, 354, 418, 508, 283, 4029, 2294, 63, 5353, 63, 18, 358, 199, 199, 533, 9762, 6564, 10438, 8, 7928, 84, 14, 3557, 14, 32238, 63, 3266, 14, 6564, 10438, 304, 523, 1449, 523, 7711, 6661, 19058, 1006, 1245, 536, 3004, 3035, 298, 26778, 2, 370, 523, 298, 4029, 2294, 1674, 523, 1449, 523, 347, 7132, 8, 277, 12, 4819, 505, 12, 4819, 515, 12, 486, 6883, 932, 304, 272, 4383, 16972, 275, 295, 14, 2014, 8, 82, 6774, 26778, 5130, 2795, 5942, 272, 3788, 275, 486, 6883, 932, 14, 3223, 59, 18, 1055, 3223, 59, 18, 61, 272, 367, 1031, 315, 3788, 14, 3223, 26, 489, 536, 63, 962, 275, 1031, 14, 3288, 459, 354, 418, 489, 333, 275, 4383, 16972, 14, 1733, 8, 354, 63, 962, 9, 489, 340, 333, 26, 268, 1031, 14, 3288, 459, 354, 418, 275, 283, 4029, 2294, 7, 435, 333, 14, 923, 8, 18, 9, 272, 372, 486, 6883, 932, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2882, 14, 973, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 2344, 5072, 511, 626, 5920, 2963, 6338, 402, 1584, 14, 2043, 6496, 2963, 6338, 701, 9445, 314, 2963, 6459, 2043, 2811, 314, 486, 6883, 666, 3123, 12, 13729, 314, 1245, 536, 3004, 14, 199, 2344, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 20644, 703, 1333, 199, 199, 646, 2882, 199, 199, 646, 486, 11133, 14, 3557, 14, 32238, 63, 3266, 199, 504, 486, 11133, 14, 3557, 492, 4819, 18, 2587, 68, 421, 199, 533, 7711, 9589, 1358, 1770, 8, 2796, 14, 1746, 304, 819, 347, 511, 6564, 9589, 8, 277, 304, 272, 4819, 505, 275, 1449, 5353, 8723, 199, 15947, 523, 577, 22472, 63, 5353, 63, 17, 260, 298, 1558, 413, 2, 523, 5001, 6601, 2196, 1369, 523, 577, 22472, 63, 5353, 63, 18, 263, 298, 2765, 1318, 1990, 3483, 5309, 26471, 2, 199, 3902, 272, 1449, 272, 4744, 275, 4819, 18, 2587, 68, 14, 19360, 18, 39, 6883, 342, 272, 1021, 9762, 24429, 8, 785, 304, 489, 3376, 275, 756, 489, 2402, 63, 3832, 275, 756, 272, 4744, 14, 79, 275, 9762, 24429, 342, 272, 4744, 14, 1932, 63, 1412, 275, 283, 7928, 84, 14, 3557, 14, 32238, 63, 2796, 14, 11324, 6564, 10438, 7, 272, 754, 275, 4744, 14, 3498, 8, 1195, 505, 12, 1987, 60, 1927, 14, 1195, 358, 339, 291, 14, 7589, 8, 489, 754, 14, 3223, 59, 18, 1055, 3223, 59, 18, 1055, 3223, 59, 16, 1055, 3288, 459, 354, 418, 508, 283, 4029, 2294, 63, 5353, 63, 17, 358, 272, 291, 14, 7589, 8, 489, 754, 14, 3223, 59, 18, 1055, 3223, 59, 18, 1055, 3223, 59, 17, 1055, 3288, 459, 354, 418, 508, 283, 4029, 2294, 63, 5353, 63, 18, 358, 199, 199, 533, 9762, 6564, 10438, 8, 7928, 84, 14, 3557, 14, 32238, 63, 3266, 14, 6564, 10438, 304, 523, 1449, 523, 7711, 6661, 19058, 1006, 1245, 536, 3004, 3035, 298, 26778, 2, 370, 523, 298, 4029, 2294, 1674, 523, 1449, 523, 347, 7132, 8, 277, 12, 4819, 505, 12, 4819, 515, 12, 486, 6883, 932, 304, 272, 4383, 16972, 275, 295, 14, 2014, 8, 82, 6774, 26778, 5130, 2795, 5942, 272, 3788, 275, 486, 6883, 932, 14, 3223, 59, 18, 1055, 3223, 59, 18, 61, 272, 367, 1031, 315, 3788, 14, 3223, 26, 489, 536, 63, 962, 275, 1031, 14, 3288, 459, 354, 418, 489, 333, 275, 4383, 16972, 14, 1733, 8, 354, 63, 962, 9, 489, 340, 333, 26, 268, 1031, 14, 3288, 459, 354, 418, 275, 283, 4029, 2294, 7, 435, 333, 14, 923, 8, 18, 9, 272, 372, 486, 6883, 932, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2882, 14, 973, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
milwaukeegdi/milwaukeegdi.github.io
intro/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py
1361
45045
# 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. r"""Code to validate and convert settings of the Microsoft build tools. This file contains code to validate and convert settings of the Microsoft build tools. The function ConvertToMSBuildSettings(), ValidateMSVSSettings(), and ValidateMSBuildSettings() are the entry points. This file was created by comparing the projects created by Visual Studio 2008 and Visual Studio 2010 for all available settings through the user interface. The MSBuild schemas were also considered. They are typically found in the MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild """ import sys import re # Dictionaries of settings validators. The key is the tool name, the value is # a dictionary mapping setting names to validation functions. _msvs_validators = {} _msbuild_validators = {} # A dictionary of settings converters. The key is the tool name, the value is # a dictionary mapping setting names to conversion functions. _msvs_to_msbuild_converters = {} # Tool name mapping from MSVS to MSBuild. _msbuild_name_of_tool = {} class _Tool(object): """Represents a tool used by MSVS or MSBuild. Attributes: msvs_name: The name of the tool in MSVS. msbuild_name: The name of the tool in MSBuild. """ def __init__(self, msvs_name, msbuild_name): self.msvs_name = msvs_name self.msbuild_name = msbuild_name def _AddTool(tool): """Adds a tool to the four dictionaries used to process settings. This only defines the tool. Each setting also needs to be added. Args: tool: The _Tool object to be added. """ _msvs_validators[tool.msvs_name] = {} _msbuild_validators[tool.msbuild_name] = {} _msvs_to_msbuild_converters[tool.msvs_name] = {} _msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name def _GetMSBuildToolSettings(msbuild_settings, tool): """Returns an MSBuild tool dictionary. Creates it if needed.""" return msbuild_settings.setdefault(tool.msbuild_name, {}) class _Type(object): """Type of settings (Base class).""" def ValidateMSVS(self, value): """Verifies that the value is legal for MSVS. Args: value: the value to check for this type. Raises: ValueError if value is not valid for MSVS. """ def ValidateMSBuild(self, value): """Verifies that the value is legal for MSBuild. Args: value: the value to check for this type. Raises: ValueError if value is not valid for MSBuild. """ def ConvertToMSBuild(self, value): """Returns the MSBuild equivalent of the MSVS value given. Args: value: the MSVS value to convert. Returns: the MSBuild equivalent. Raises: ValueError if value is not valid. """ return value class _String(_Type): """A setting that's just a string.""" def ValidateMSVS(self, value): if not isinstance(value, basestring): raise ValueError('expected string; got %r' % value) def ValidateMSBuild(self, value): if not isinstance(value, basestring): raise ValueError('expected string; got %r' % value) def ConvertToMSBuild(self, value): # Convert the macros return ConvertVCMacrosToMSBuild(value) class _StringList(_Type): """A settings that's a list of strings.""" def ValidateMSVS(self, value): if not isinstance(value, basestring) and not isinstance(value, list): raise ValueError('expected string list; got %r' % value) def ValidateMSBuild(self, value): if not isinstance(value, basestring) and not isinstance(value, list): raise ValueError('expected string list; got %r' % value) def ConvertToMSBuild(self, value): # Convert the macros if isinstance(value, list): return [ConvertVCMacrosToMSBuild(i) for i in value] else: return ConvertVCMacrosToMSBuild(value) class _Boolean(_Type): """Boolean settings, can have the values 'false' or 'true'.""" def _Validate(self, value): if value != 'true' and value != 'false': raise ValueError('expected bool; got %r' % value) def ValidateMSVS(self, value): self._Validate(value) def ValidateMSBuild(self, value): self._Validate(value) def ConvertToMSBuild(self, value): self._Validate(value) return value class _Integer(_Type): """Integer settings.""" def __init__(self, msbuild_base=10): _Type.__init__(self) self._msbuild_base = msbuild_base def ValidateMSVS(self, value): # Try to convert, this will raise ValueError if invalid. self.ConvertToMSBuild(value) def ValidateMSBuild(self, value): # Try to convert, this will raise ValueError if invalid. int(value, self._msbuild_base) def ConvertToMSBuild(self, value): msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x' return msbuild_format % int(value) class _Enumeration(_Type): """Type of settings that is an enumeration. In MSVS, the values are indexes like '0', '1', and '2'. MSBuild uses text labels that are more representative, like 'Win32'. Constructor args: label_list: an array of MSBuild labels that correspond to the MSVS index. In the rare cases where MSVS has skipped an index value, None is used in the array to indicate the unused spot. new: an array of labels that are new to MSBuild. """ def __init__(self, label_list, new=None): _Type.__init__(self) self._label_list = label_list self._msbuild_values = set(value for value in label_list if value is not None) if new is not None: self._msbuild_values.update(new) def ValidateMSVS(self, value): # Try to convert. It will raise an exception if not valid. self.ConvertToMSBuild(value) def ValidateMSBuild(self, value): if value not in self._msbuild_values: raise ValueError('unrecognized enumerated value %s' % value) def ConvertToMSBuild(self, value): index = int(value) if index < 0 or index >= len(self._label_list): raise ValueError('index value (%d) not in expected range [0, %d)' % (index, len(self._label_list))) label = self._label_list[index] if label is None: raise ValueError('converted value for %s not specified.' % value) return label # Instantiate the various generic types. _boolean = _Boolean() _integer = _Integer() # For now, we don't do any special validation on these types: _string = _String() _file_name = _String() _folder_name = _String() _file_list = _StringList() _folder_list = _StringList() _string_list = _StringList() # Some boolean settings went from numerical values to boolean. The # mapping is 0: default, 1: false, 2: true. _newly_boolean = _Enumeration(['', 'false', 'true']) def _Same(tool, name, setting_type): """Defines a setting that has the same name in MSVS and MSBuild. Args: tool: a dictionary that gives the names of the tool for MSVS and MSBuild. name: the name of the setting. setting_type: the type of this setting. """ _Renamed(tool, name, name, setting_type) def _Renamed(tool, msvs_name, msbuild_name, setting_type): """Defines a setting for which the name has changed. Args: tool: a dictionary that gives the names of the tool for MSVS and MSBuild. msvs_name: the name of the MSVS setting. msbuild_name: the name of the MSBuild setting. setting_type: the type of this setting. """ def _Translate(value, msbuild_settings): msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool) msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value) _msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS _msbuild_validators[tool.msbuild_name][msbuild_name] = ( setting_type.ValidateMSBuild) _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate def _Moved(tool, settings_name, msbuild_tool_name, setting_type): _MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name, setting_type) def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name, msbuild_settings_name, setting_type): """Defines a setting that may have moved to a new section. Args: tool: a dictionary that gives the names of the tool for MSVS and MSBuild. msvs_settings_name: the MSVS name of the setting. msbuild_tool_name: the name of the MSBuild tool to place the setting under. msbuild_settings_name: the MSBuild name of the setting. setting_type: the type of this setting. """ def _Translate(value, msbuild_settings): tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {}) tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value) _msvs_validators[tool.msvs_name][msvs_settings_name] = ( setting_type.ValidateMSVS) validator = setting_type.ValidateMSBuild _msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator _msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate def _MSVSOnly(tool, name, setting_type): """Defines a setting that is only found in MSVS. Args: tool: a dictionary that gives the names of the tool for MSVS and MSBuild. name: the name of the setting. setting_type: the type of this setting. """ def _Translate(unused_value, unused_msbuild_settings): # Since this is for MSVS only settings, no translation will happen. pass _msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate def _MSBuildOnly(tool, name, setting_type): """Defines a setting that is only found in MSBuild. Args: tool: a dictionary that gives the names of the tool for MSVS and MSBuild. name: the name of the setting. setting_type: the type of this setting. """ def _Translate(value, msbuild_settings): # Let msbuild-only properties get translated as-is from msvs_settings. tool_settings = msbuild_settings.setdefault(tool.msbuild_name, {}) tool_settings[name] = value _msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate def _ConvertedToAdditionalOption(tool, msvs_name, flag): """Defines a setting that's handled via a command line option in MSBuild. Args: tool: a dictionary that gives the names of the tool for MSVS and MSBuild. msvs_name: the name of the MSVS setting that if 'true' becomes a flag flag: the flag to insert at the end of the AdditionalOptions """ def _Translate(value, msbuild_settings): if value == 'true': tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool) if 'AdditionalOptions' in tool_settings: new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag) else: new_flags = flag tool_settings['AdditionalOptions'] = new_flags _msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate def _CustomGeneratePreprocessedFile(tool, msvs_name): def _Translate(value, msbuild_settings): tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool) if value == '0': tool_settings['PreprocessToFile'] = 'false' tool_settings['PreprocessSuppressLineNumbers'] = 'false' elif value == '1': # /P tool_settings['PreprocessToFile'] = 'true' tool_settings['PreprocessSuppressLineNumbers'] = 'false' elif value == '2': # /EP /P tool_settings['PreprocessToFile'] = 'true' tool_settings['PreprocessSuppressLineNumbers'] = 'true' else: raise ValueError('value must be one of [0, 1, 2]; got %s' % value) # Create a bogus validator that looks for '0', '1', or '2' msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS _msvs_validators[tool.msvs_name][msvs_name] = msvs_validator msbuild_validator = _boolean.ValidateMSBuild msbuild_tool_validators = _msbuild_validators[tool.msbuild_name] msbuild_tool_validators['PreprocessToFile'] = msbuild_validator msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate fix_vc_macro_slashes_regex_list = ('IntDir', 'OutDir') fix_vc_macro_slashes_regex = re.compile( r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list) ) # Regular expression to detect keys that were generated by exclusion lists _EXCLUDED_SUFFIX_RE = re.compile('^(.*)_excluded$') def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr): """Verify that 'setting' is valid if it is generated from an exclusion list. If the setting appears to be generated from an exclusion list, the root name is checked. Args: setting: A string that is the setting name to validate settings: A dictionary where the keys are valid settings error_msg: The message to emit in the event of error stderr: The stream receiving the error messages. """ # This may be unrecognized because it's an exclusion list. If the # setting name has the _excluded suffix, then check the root name. unrecognized = True m = re.match(_EXCLUDED_SUFFIX_RE, setting) if m: root_setting = m.group(1) unrecognized = root_setting not in settings if unrecognized: # We don't know this setting. Give a warning. print >> stderr, error_msg def FixVCMacroSlashes(s): """Replace macros which have excessive following slashes. These macros are known to have a built-in trailing slash. Furthermore, many scripts hiccup on processing paths with extra slashes in the middle. This list is probably not exhaustive. Add as needed. """ if '$' in s: s = fix_vc_macro_slashes_regex.sub(r'\1', s) return s def ConvertVCMacrosToMSBuild(s): """Convert the the MSVS macros found in the string to the MSBuild equivalent. This list is probably not exhaustive. Add as needed. """ if '$' in s: replace_map = { '$(ConfigurationName)': '$(Configuration)', '$(InputDir)': '%(RelativeDir)', '$(InputExt)': '%(Extension)', '$(InputFileName)': '%(Filename)%(Extension)', '$(InputName)': '%(Filename)', '$(InputPath)': '%(Identity)', '$(ParentName)': '$(ProjectFileName)', '$(PlatformName)': '$(Platform)', '$(SafeInputName)': '%(Filename)', } for old, new in replace_map.iteritems(): s = s.replace(old, new) s = FixVCMacroSlashes(s) return s def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr): """Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+). Args: msvs_settings: A dictionary. The key is the tool name. The values are themselves dictionaries of settings and their values. stderr: The stream receiving the error messages. Returns: A dictionary of MSBuild settings. The key is either the MSBuild tool name or the empty string (for the global settings). The values are themselves dictionaries of settings and their values. """ msbuild_settings = {} for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems(): if msvs_tool_name in _msvs_to_msbuild_converters: msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name] for msvs_setting, msvs_value in msvs_tool_settings.iteritems(): if msvs_setting in msvs_tool: # Invoke the translation function. try: msvs_tool[msvs_setting](msvs_value, msbuild_settings) except ValueError, e: print >> stderr, ('Warning: while converting %s/%s to MSBuild, ' '%s' % (msvs_tool_name, msvs_setting, e)) else: _ValidateExclusionSetting(msvs_setting, msvs_tool, ('Warning: unrecognized setting %s/%s ' 'while converting to MSBuild.' % (msvs_tool_name, msvs_setting)), stderr) else: print >> stderr, ('Warning: unrecognized tool %s while converting to ' 'MSBuild.' % msvs_tool_name) return msbuild_settings def ValidateMSVSSettings(settings, stderr=sys.stderr): """Validates that the names of the settings are valid for MSVS. Args: settings: A dictionary. The key is the tool name. The values are themselves dictionaries of settings and their values. stderr: The stream receiving the error messages. """ _ValidateSettings(_msvs_validators, settings, stderr) def ValidateMSBuildSettings(settings, stderr=sys.stderr): """Validates that the names of the settings are valid for MSBuild. Args: settings: A dictionary. The key is the tool name. The values are themselves dictionaries of settings and their values. stderr: The stream receiving the error messages. """ _ValidateSettings(_msbuild_validators, settings, stderr) def _ValidateSettings(validators, settings, stderr): """Validates that the settings are valid for MSBuild or MSVS. We currently only validate the names of the settings, not their values. Args: validators: A dictionary of tools and their validators. settings: A dictionary. The key is the tool name. The values are themselves dictionaries of settings and their values. stderr: The stream receiving the error messages. """ for tool_name in settings: if tool_name in validators: tool_validators = validators[tool_name] for setting, value in settings[tool_name].iteritems(): if setting in tool_validators: try: tool_validators[setting](value) except ValueError, e: print >> stderr, ('Warning: for %s/%s, %s' % (tool_name, setting, e)) else: _ValidateExclusionSetting(setting, tool_validators, ('Warning: unrecognized setting %s/%s' % (tool_name, setting)), stderr) else: print >> stderr, ('Warning: unrecognized tool %s' % tool_name) # MSVS and MBuild names of the tools. _compile = _Tool('VCCLCompilerTool', 'ClCompile') _link = _Tool('VCLinkerTool', 'Link') _midl = _Tool('VCMIDLTool', 'Midl') _rc = _Tool('VCResourceCompilerTool', 'ResourceCompile') _lib = _Tool('VCLibrarianTool', 'Lib') _manifest = _Tool('VCManifestTool', 'Manifest') _masm = _Tool('MASM', 'MASM') _AddTool(_compile) _AddTool(_link) _AddTool(_midl) _AddTool(_rc) _AddTool(_lib) _AddTool(_manifest) _AddTool(_masm) # Add sections only found in the MSBuild settings. _msbuild_validators[''] = {} _msbuild_validators['ProjectReference'] = {} _msbuild_validators['ManifestResourceCompile'] = {} # Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and # ClCompile in MSBuild. # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for # the schema of the MSBuild ClCompile settings. # Options that have the same name in MSVS and MSBuild _Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I _Same(_compile, 'AdditionalOptions', _string_list) _Same(_compile, 'AdditionalUsingDirectories', _folder_list) # /AI _Same(_compile, 'AssemblerListingLocation', _file_name) # /Fa _Same(_compile, 'BrowseInformationFile', _file_name) _Same(_compile, 'BufferSecurityCheck', _boolean) # /GS _Same(_compile, 'DisableLanguageExtensions', _boolean) # /Za _Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd _Same(_compile, 'EnableFiberSafeOptimizations', _boolean) # /GT _Same(_compile, 'EnablePREfast', _boolean) # /analyze Visible='false' _Same(_compile, 'ExpandAttributedSource', _boolean) # /Fx _Same(_compile, 'FloatingPointExceptions', _boolean) # /fp:except _Same(_compile, 'ForceConformanceInForLoopScope', _boolean) # /Zc:forScope _Same(_compile, 'ForcedIncludeFiles', _file_list) # /FI _Same(_compile, 'ForcedUsingFiles', _file_list) # /FU _Same(_compile, 'GenerateXMLDocumentationFiles', _boolean) # /doc _Same(_compile, 'IgnoreStandardIncludePath', _boolean) # /X _Same(_compile, 'MinimalRebuild', _boolean) # /Gm _Same(_compile, 'OmitDefaultLibName', _boolean) # /Zl _Same(_compile, 'OmitFramePointers', _boolean) # /Oy _Same(_compile, 'PreprocessorDefinitions', _string_list) # /D _Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd _Same(_compile, 'RuntimeTypeInfo', _boolean) # /GR _Same(_compile, 'ShowIncludes', _boolean) # /showIncludes _Same(_compile, 'SmallerTypeCheck', _boolean) # /RTCc _Same(_compile, 'StringPooling', _boolean) # /GF _Same(_compile, 'SuppressStartupBanner', _boolean) # /nologo _Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean) # /Zc:wchar_t _Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean) # /u _Same(_compile, 'UndefinePreprocessorDefinitions', _string_list) # /U _Same(_compile, 'UseFullPaths', _boolean) # /FC _Same(_compile, 'WholeProgramOptimization', _boolean) # /GL _Same(_compile, 'XMLDocumentationFileName', _file_name) _Same(_compile, 'AssemblerOutput', _Enumeration(['NoListing', 'AssemblyCode', # /FA 'All', # /FAcs 'AssemblyAndMachineCode', # /FAc 'AssemblyAndSourceCode'])) # /FAs _Same(_compile, 'BasicRuntimeChecks', _Enumeration(['Default', 'StackFrameRuntimeCheck', # /RTCs 'UninitializedLocalUsageCheck', # /RTCu 'EnableFastChecks'])) # /RTC1 _Same(_compile, 'BrowseInformation', _Enumeration(['false', 'true', # /FR 'true'])) # /Fr _Same(_compile, 'CallingConvention', _Enumeration(['Cdecl', # /Gd 'FastCall', # /Gr 'StdCall', # /Gz 'VectorCall'])) # /Gv _Same(_compile, 'CompileAs', _Enumeration(['Default', 'CompileAsC', # /TC 'CompileAsCpp'])) # /TP _Same(_compile, 'DebugInformationFormat', _Enumeration(['', # Disabled 'OldStyle', # /Z7 None, 'ProgramDatabase', # /Zi 'EditAndContinue'])) # /ZI _Same(_compile, 'EnableEnhancedInstructionSet', _Enumeration(['NotSet', 'StreamingSIMDExtensions', # /arch:SSE 'StreamingSIMDExtensions2', # /arch:SSE2 'AdvancedVectorExtensions', # /arch:AVX (vs2012+) 'NoExtensions', # /arch:IA32 (vs2012+) # This one only exists in the new msbuild format. 'AdvancedVectorExtensions2', # /arch:AVX2 (vs2013r2+) ])) _Same(_compile, 'ErrorReporting', _Enumeration(['None', # /errorReport:none 'Prompt', # /errorReport:prompt 'Queue'], # /errorReport:queue new=['Send'])) # /errorReport:send" _Same(_compile, 'ExceptionHandling', _Enumeration(['false', 'Sync', # /EHsc 'Async'], # /EHa new=['SyncCThrow'])) # /EHs _Same(_compile, 'FavorSizeOrSpeed', _Enumeration(['Neither', 'Speed', # /Ot 'Size'])) # /Os _Same(_compile, 'FloatingPointModel', _Enumeration(['Precise', # /fp:precise 'Strict', # /fp:strict 'Fast'])) # /fp:fast _Same(_compile, 'InlineFunctionExpansion', _Enumeration(['Default', 'OnlyExplicitInline', # /Ob1 'AnySuitable'], # /Ob2 new=['Disabled'])) # /Ob0 _Same(_compile, 'Optimization', _Enumeration(['Disabled', # /Od 'MinSpace', # /O1 'MaxSpeed', # /O2 'Full'])) # /Ox _Same(_compile, 'RuntimeLibrary', _Enumeration(['MultiThreaded', # /MT 'MultiThreadedDebug', # /MTd 'MultiThreadedDLL', # /MD 'MultiThreadedDebugDLL'])) # /MDd _Same(_compile, 'StructMemberAlignment', _Enumeration(['Default', '1Byte', # /Zp1 '2Bytes', # /Zp2 '4Bytes', # /Zp4 '8Bytes', # /Zp8 '16Bytes'])) # /Zp16 _Same(_compile, 'WarningLevel', _Enumeration(['TurnOffAllWarnings', # /W0 'Level1', # /W1 'Level2', # /W2 'Level3', # /W3 'Level4'], # /W4 new=['EnableAllWarnings'])) # /Wall # Options found in MSVS that have been renamed in MSBuild. _Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking', _boolean) # /Gy _Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions', _boolean) # /Oi _Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean) # /C _Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name) # /Fo _Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean) # /openmp _Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile', _file_name) # Used with /Yc and /Yu _Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile', _file_name) # /Fp _Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader', _Enumeration(['NotUsing', # VS recognized '' for this value too. 'Create', # /Yc 'Use'])) # /Yu _Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean) # /WX _ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J') # MSVS options not found in MSBuild. _MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean) _MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean) # MSBuild options not found in MSVS. _MSBuildOnly(_compile, 'BuildingInIDE', _boolean) _MSBuildOnly(_compile, 'CompileAsManaged', _Enumeration([], new=['false', 'true'])) # /clr _MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch _MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP _MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi _MSBuildOnly(_compile, 'ProcessorNumber', _integer) # the number of processors _MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name) _MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we _MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean) # /FAu # Defines a setting that needs very customized processing _CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile') # Directives for converting MSVS VCLinkerTool to MSBuild Link. # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for # the schema of the MSBuild Link settings. # Options that have the same name in MSVS and MSBuild _Same(_link, 'AdditionalDependencies', _file_list) _Same(_link, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH # /MANIFESTDEPENDENCY: _Same(_link, 'AdditionalManifestDependencies', _file_list) _Same(_link, 'AdditionalOptions', _string_list) _Same(_link, 'AddModuleNamesToAssembly', _file_list) # /ASSEMBLYMODULE _Same(_link, 'AllowIsolation', _boolean) # /ALLOWISOLATION _Same(_link, 'AssemblyLinkResource', _file_list) # /ASSEMBLYLINKRESOURCE _Same(_link, 'BaseAddress', _string) # /BASE _Same(_link, 'CLRUnmanagedCodeCheck', _boolean) # /CLRUNMANAGEDCODECHECK _Same(_link, 'DelayLoadDLLs', _file_list) # /DELAYLOAD _Same(_link, 'DelaySign', _boolean) # /DELAYSIGN _Same(_link, 'EmbedManagedResourceFile', _file_list) # /ASSEMBLYRESOURCE _Same(_link, 'EnableUAC', _boolean) # /MANIFESTUAC _Same(_link, 'EntryPointSymbol', _string) # /ENTRY _Same(_link, 'ForceSymbolReferences', _file_list) # /INCLUDE _Same(_link, 'FunctionOrder', _file_name) # /ORDER _Same(_link, 'GenerateDebugInformation', _boolean) # /DEBUG _Same(_link, 'GenerateMapFile', _boolean) # /MAP _Same(_link, 'HeapCommitSize', _string) _Same(_link, 'HeapReserveSize', _string) # /HEAP _Same(_link, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB _Same(_link, 'IgnoreEmbeddedIDL', _boolean) # /IGNOREIDL _Same(_link, 'ImportLibrary', _file_name) # /IMPLIB _Same(_link, 'KeyContainer', _file_name) # /KEYCONTAINER _Same(_link, 'KeyFile', _file_name) # /KEYFILE _Same(_link, 'ManifestFile', _file_name) # /ManifestFile _Same(_link, 'MapExports', _boolean) # /MAPINFO:EXPORTS _Same(_link, 'MapFileName', _file_name) _Same(_link, 'MergedIDLBaseFileName', _file_name) # /IDLOUT _Same(_link, 'MergeSections', _string) # /MERGE _Same(_link, 'MidlCommandFile', _file_name) # /MIDL _Same(_link, 'ModuleDefinitionFile', _file_name) # /DEF _Same(_link, 'OutputFile', _file_name) # /OUT _Same(_link, 'PerUserRedirection', _boolean) _Same(_link, 'Profile', _boolean) # /PROFILE _Same(_link, 'ProfileGuidedDatabase', _file_name) # /PGD _Same(_link, 'ProgramDatabaseFile', _file_name) # /PDB _Same(_link, 'RegisterOutput', _boolean) _Same(_link, 'SetChecksum', _boolean) # /RELEASE _Same(_link, 'StackCommitSize', _string) _Same(_link, 'StackReserveSize', _string) # /STACK _Same(_link, 'StripPrivateSymbols', _file_name) # /PDBSTRIPPED _Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean) # /DELAY:UNLOAD _Same(_link, 'SuppressStartupBanner', _boolean) # /NOLOGO _Same(_link, 'SwapRunFromCD', _boolean) # /SWAPRUN:CD _Same(_link, 'TurnOffAssemblyGeneration', _boolean) # /NOASSEMBLY _Same(_link, 'TypeLibraryFile', _file_name) # /TLBOUT _Same(_link, 'TypeLibraryResourceID', _integer) # /TLBID _Same(_link, 'UACUIAccess', _boolean) # /uiAccess='true' _Same(_link, 'Version', _string) # /VERSION _Same(_link, 'EnableCOMDATFolding', _newly_boolean) # /OPT:ICF _Same(_link, 'FixedBaseAddress', _newly_boolean) # /FIXED _Same(_link, 'LargeAddressAware', _newly_boolean) # /LARGEADDRESSAWARE _Same(_link, 'OptimizeReferences', _newly_boolean) # /OPT:REF _Same(_link, 'RandomizedBaseAddress', _newly_boolean) # /DYNAMICBASE _Same(_link, 'TerminalServerAware', _newly_boolean) # /TSAWARE _subsystem_enumeration = _Enumeration( ['NotSet', 'Console', # /SUBSYSTEM:CONSOLE 'Windows', # /SUBSYSTEM:WINDOWS 'Native', # /SUBSYSTEM:NATIVE 'EFI Application', # /SUBSYSTEM:EFI_APPLICATION 'EFI Boot Service Driver', # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER 'EFI ROM', # /SUBSYSTEM:EFI_ROM 'EFI Runtime', # /SUBSYSTEM:EFI_RUNTIME_DRIVER 'WindowsCE'], # /SUBSYSTEM:WINDOWSCE new=['POSIX']) # /SUBSYSTEM:POSIX _target_machine_enumeration = _Enumeration( ['NotSet', 'MachineX86', # /MACHINE:X86 None, 'MachineARM', # /MACHINE:ARM 'MachineEBC', # /MACHINE:EBC 'MachineIA64', # /MACHINE:IA64 None, 'MachineMIPS', # /MACHINE:MIPS 'MachineMIPS16', # /MACHINE:MIPS16 'MachineMIPSFPU', # /MACHINE:MIPSFPU 'MachineMIPSFPU16', # /MACHINE:MIPSFPU16 None, None, None, 'MachineSH4', # /MACHINE:SH4 None, 'MachineTHUMB', # /MACHINE:THUMB 'MachineX64']) # /MACHINE:X64 _Same(_link, 'AssemblyDebug', _Enumeration(['', 'true', # /ASSEMBLYDEBUG 'false'])) # /ASSEMBLYDEBUG:DISABLE _Same(_link, 'CLRImageType', _Enumeration(['Default', 'ForceIJWImage', # /CLRIMAGETYPE:IJW 'ForcePureILImage', # /Switch="CLRIMAGETYPE:PURE 'ForceSafeILImage'])) # /Switch="CLRIMAGETYPE:SAFE _Same(_link, 'CLRThreadAttribute', _Enumeration(['DefaultThreadingAttribute', # /CLRTHREADATTRIBUTE:NONE 'MTAThreadingAttribute', # /CLRTHREADATTRIBUTE:MTA 'STAThreadingAttribute'])) # /CLRTHREADATTRIBUTE:STA _Same(_link, 'DataExecutionPrevention', _Enumeration(['', 'false', # /NXCOMPAT:NO 'true'])) # /NXCOMPAT _Same(_link, 'Driver', _Enumeration(['NotSet', 'Driver', # /Driver 'UpOnly', # /DRIVER:UPONLY 'WDM'])) # /DRIVER:WDM _Same(_link, 'LinkTimeCodeGeneration', _Enumeration(['Default', 'UseLinkTimeCodeGeneration', # /LTCG 'PGInstrument', # /LTCG:PGInstrument 'PGOptimization', # /LTCG:PGOptimize 'PGUpdate'])) # /LTCG:PGUpdate _Same(_link, 'ShowProgress', _Enumeration(['NotSet', 'LinkVerbose', # /VERBOSE 'LinkVerboseLib'], # /VERBOSE:Lib new=['LinkVerboseICF', # /VERBOSE:ICF 'LinkVerboseREF', # /VERBOSE:REF 'LinkVerboseSAFESEH', # /VERBOSE:SAFESEH 'LinkVerboseCLR'])) # /VERBOSE:CLR _Same(_link, 'SubSystem', _subsystem_enumeration) _Same(_link, 'TargetMachine', _target_machine_enumeration) _Same(_link, 'UACExecutionLevel', _Enumeration(['AsInvoker', # /level='asInvoker' 'HighestAvailable', # /level='highestAvailable' 'RequireAdministrator'])) # /level='requireAdministrator' _Same(_link, 'MinimumRequiredVersion', _string) _Same(_link, 'TreatLinkerWarningAsErrors', _boolean) # /WX # Options found in MSVS that have been renamed in MSBuild. _Renamed(_link, 'ErrorReporting', 'LinkErrorReporting', _Enumeration(['NoErrorReport', # /ERRORREPORT:NONE 'PromptImmediately', # /ERRORREPORT:PROMPT 'QueueForNextLogin'], # /ERRORREPORT:QUEUE new=['SendErrorReport'])) # /ERRORREPORT:SEND _Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB _Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean) # /NOENTRY _Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean) # /SWAPRUN:NET _Moved(_link, 'GenerateManifest', '', _boolean) _Moved(_link, 'IgnoreImportLibrary', '', _boolean) _Moved(_link, 'LinkIncremental', '', _newly_boolean) _Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean) _Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean) # MSVS options not found in MSBuild. _MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean) _MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean) # MSBuild options not found in MSVS. _MSBuildOnly(_link, 'BuildingInIDE', _boolean) _MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean) # /SAFESEH _MSBuildOnly(_link, 'LinkDLL', _boolean) # /DLL Visible='false' _MSBuildOnly(_link, 'LinkStatus', _boolean) # /LTCG:STATUS _MSBuildOnly(_link, 'PreventDllBinding', _boolean) # /ALLOWBIND _MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean) # /DELAY:NOBIND _MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name) _MSBuildOnly(_link, 'MSDOSStubFileName', _file_name) # /STUB Visible='false' _MSBuildOnly(_link, 'SectionAlignment', _integer) # /ALIGN _MSBuildOnly(_link, 'SpecifySectionAttributes', _string) # /SECTION _MSBuildOnly(_link, 'ForceFileOutput', _Enumeration([], new=['Enabled', # /FORCE # /FORCE:MULTIPLE 'MultiplyDefinedSymbolOnly', 'UndefinedSymbolOnly'])) # /FORCE:UNRESOLVED _MSBuildOnly(_link, 'CreateHotPatchableImage', _Enumeration([], new=['Enabled', # /FUNCTIONPADMIN 'X86Image', # /FUNCTIONPADMIN:5 'X64Image', # /FUNCTIONPADMIN:6 'ItaniumImage'])) # /FUNCTIONPADMIN:16 _MSBuildOnly(_link, 'CLRSupportLastError', _Enumeration([], new=['Enabled', # /CLRSupportLastError 'Disabled', # /CLRSupportLastError:NO # /CLRSupportLastError:SYSTEMDLL 'SystemDlls'])) # Directives for converting VCResourceCompilerTool to ResourceCompile. # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for # the schema of the MSBuild ResourceCompile settings. _Same(_rc, 'AdditionalOptions', _string_list) _Same(_rc, 'AdditionalIncludeDirectories', _folder_list) # /I _Same(_rc, 'Culture', _Integer(msbuild_base=16)) _Same(_rc, 'IgnoreStandardIncludePath', _boolean) # /X _Same(_rc, 'PreprocessorDefinitions', _string_list) # /D _Same(_rc, 'ResourceOutputFileName', _string) # /fo _Same(_rc, 'ShowProgress', _boolean) # /v # There is no UI in VisualStudio 2008 to set the following properties. # However they are found in CL and other tools. Include them here for # completeness, as they are very likely to have the same usage pattern. _Same(_rc, 'SuppressStartupBanner', _boolean) # /nologo _Same(_rc, 'UndefinePreprocessorDefinitions', _string_list) # /u # MSBuild options not found in MSVS. _MSBuildOnly(_rc, 'NullTerminateStrings', _boolean) # /n _MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name) # Directives for converting VCMIDLTool to Midl. # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for # the schema of the MSBuild Midl settings. _Same(_midl, 'AdditionalIncludeDirectories', _folder_list) # /I _Same(_midl, 'AdditionalOptions', _string_list) _Same(_midl, 'CPreprocessOptions', _string) # /cpp_opt _Same(_midl, 'ErrorCheckAllocations', _boolean) # /error allocation _Same(_midl, 'ErrorCheckBounds', _boolean) # /error bounds_check _Same(_midl, 'ErrorCheckEnumRange', _boolean) # /error enum _Same(_midl, 'ErrorCheckRefPointers', _boolean) # /error ref _Same(_midl, 'ErrorCheckStubData', _boolean) # /error stub_data _Same(_midl, 'GenerateStublessProxies', _boolean) # /Oicf _Same(_midl, 'GenerateTypeLibrary', _boolean) _Same(_midl, 'HeaderFileName', _file_name) # /h _Same(_midl, 'IgnoreStandardIncludePath', _boolean) # /no_def_idir _Same(_midl, 'InterfaceIdentifierFileName', _file_name) # /iid _Same(_midl, 'MkTypLibCompatible', _boolean) # /mktyplib203 _Same(_midl, 'OutputDirectory', _string) # /out _Same(_midl, 'PreprocessorDefinitions', _string_list) # /D _Same(_midl, 'ProxyFileName', _file_name) # /proxy _Same(_midl, 'RedirectOutputAndErrors', _file_name) # /o _Same(_midl, 'SuppressStartupBanner', _boolean) # /nologo _Same(_midl, 'TypeLibraryName', _file_name) # /tlb _Same(_midl, 'UndefinePreprocessorDefinitions', _string_list) # /U _Same(_midl, 'WarnAsError', _boolean) # /WX _Same(_midl, 'DefaultCharType', _Enumeration(['Unsigned', # /char unsigned 'Signed', # /char signed 'Ascii'])) # /char ascii7 _Same(_midl, 'TargetEnvironment', _Enumeration(['NotSet', 'Win32', # /env win32 'Itanium', # /env ia64 'X64'])) # /env x64 _Same(_midl, 'EnableErrorChecks', _Enumeration(['EnableCustom', 'None', # /error none 'All'])) # /error all _Same(_midl, 'StructMemberAlignment', _Enumeration(['NotSet', '1', # Zp1 '2', # Zp2 '4', # Zp4 '8'])) # Zp8 _Same(_midl, 'WarningLevel', _Enumeration(['0', # /W0 '1', # /W1 '2', # /W2 '3', # /W3 '4'])) # /W4 _Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name) # /dlldata _Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters', _boolean) # /robust # MSBuild options not found in MSVS. _MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean) # /app_config _MSBuildOnly(_midl, 'ClientStubFile', _file_name) # /cstub _MSBuildOnly(_midl, 'GenerateClientFiles', _Enumeration([], new=['Stub', # /client stub 'None'])) # /client none _MSBuildOnly(_midl, 'GenerateServerFiles', _Enumeration([], new=['Stub', # /client stub 'None'])) # /client none _MSBuildOnly(_midl, 'LocaleID', _integer) # /lcid DECIMAL _MSBuildOnly(_midl, 'ServerStubFile', _file_name) # /sstub _MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean) # /no_warn _MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name) _MSBuildOnly(_midl, 'TypeLibFormat', _Enumeration([], new=['NewFormat', # /newtlb 'OldFormat'])) # /oldtlb # Directives for converting VCLibrarianTool to Lib. # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for # the schema of the MSBuild Lib settings. _Same(_lib, 'AdditionalDependencies', _file_list) _Same(_lib, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH _Same(_lib, 'AdditionalOptions', _string_list) _Same(_lib, 'ExportNamedFunctions', _string_list) # /EXPORT _Same(_lib, 'ForceSymbolReferences', _string) # /INCLUDE _Same(_lib, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB _Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB _Same(_lib, 'ModuleDefinitionFile', _file_name) # /DEF _Same(_lib, 'OutputFile', _file_name) # /OUT _Same(_lib, 'SuppressStartupBanner', _boolean) # /NOLOGO _Same(_lib, 'UseUnicodeResponseFiles', _boolean) _Same(_lib, 'LinkTimeCodeGeneration', _boolean) # /LTCG _Same(_lib, 'TargetMachine', _target_machine_enumeration) # TODO(jeanluc) _link defines the same value that gets moved to # ProjectReference. We may want to validate that they are consistent. _Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean) _MSBuildOnly(_lib, 'DisplayLibrary', _string) # /LIST Visible='false' _MSBuildOnly(_lib, 'ErrorReporting', _Enumeration([], new=['PromptImmediately', # /ERRORREPORT:PROMPT 'QueueForNextLogin', # /ERRORREPORT:QUEUE 'SendErrorReport', # /ERRORREPORT:SEND 'NoErrorReport'])) # /ERRORREPORT:NONE _MSBuildOnly(_lib, 'MinimumRequiredVersion', _string) _MSBuildOnly(_lib, 'Name', _file_name) # /NAME _MSBuildOnly(_lib, 'RemoveObjects', _file_list) # /REMOVE _MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration) _MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name) _MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean) # /WX _MSBuildOnly(_lib, 'Verbose', _boolean) # Directives for converting VCManifestTool to Mt. # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for # the schema of the MSBuild Lib settings. # Options that have the same name in MSVS and MSBuild _Same(_manifest, 'AdditionalManifestFiles', _file_list) # /manifest _Same(_manifest, 'AdditionalOptions', _string_list) _Same(_manifest, 'AssemblyIdentity', _string) # /identity: _Same(_manifest, 'ComponentFileName', _file_name) # /dll _Same(_manifest, 'GenerateCatalogFiles', _boolean) # /makecdfs _Same(_manifest, 'InputResourceManifests', _string) # /inputresource _Same(_manifest, 'OutputManifestFile', _file_name) # /out _Same(_manifest, 'RegistrarScriptFile', _file_name) # /rgs _Same(_manifest, 'ReplacementsFile', _file_name) # /replacements _Same(_manifest, 'SuppressStartupBanner', _boolean) # /nologo _Same(_manifest, 'TypeLibraryFile', _file_name) # /tlb: _Same(_manifest, 'UpdateFileHashes', _boolean) # /hashupdate _Same(_manifest, 'UpdateFileHashesSearchPath', _file_name) _Same(_manifest, 'VerboseOutput', _boolean) # /verbose # Options that have moved location. _MovedAndRenamed(_manifest, 'ManifestResourceFile', 'ManifestResourceCompile', 'ResourceOutputFileName', _file_name) _Moved(_manifest, 'EmbedManifest', '', _boolean) # MSVS options not found in MSBuild. _MSVSOnly(_manifest, 'DependencyInformationFile', _file_name) _MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean) _MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean) # MSBuild options not found in MSVS. _MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean) _MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean) # /category _MSBuildOnly(_manifest, 'ManifestFromManagedAssembly', _file_name) # /managedassemblyname _MSBuildOnly(_manifest, 'OutputResourceManifests', _string) # /outputresource _MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean) # /nodependency _MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name) # Directives for MASM. # See "$(VCTargetsPath)\BuildCustomizations\masm.xml" for the schema of the # MSBuild MASM settings. # Options that have the same name in MSVS and MSBuild. _Same(_masm, 'UseSafeExceptionHandlers', _boolean) # /safeseh
mit
[ 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 82, 624, 3034, 370, 4107, 436, 3957, 2202, 402, 314, 15332, 1900, 7249, 14, 199, 199, 2765, 570, 3509, 1233, 370, 4107, 436, 3957, 2202, 402, 314, 15332, 199, 1506, 7249, 14, 221, 710, 805, 7905, 28361, 5268, 1062, 12134, 14206, 5268, 1062, 199, 460, 12134, 10733, 5268, 342, 787, 314, 2397, 4501, 14, 199, 199, 2765, 570, 1990, 2737, 701, 20234, 314, 11336, 2737, 701, 14702, 13225, 9079, 199, 460, 14702, 13225, 7129, 367, 1006, 2808, 2202, 4012, 314, 922, 3217, 14, 199, 1918, 21374, 32536, 4898, 2597, 8652, 14, 221, 9322, 787, 13609, 1911, 315, 314, 199, 10733, 3907, 2082, 12, 325, 14, 71, 14, 286, 3427, 9184, 16920, 334, 88, 1184, 2862, 10733, 199, 624, 199, 199, 646, 984, 199, 646, 295, 199, 199, 3, 3757, 10150, 402, 2202, 14370, 14, 710, 790, 365, 314, 4744, 536, 12, 314, 574, 365, 199, 3, 282, 2600, 4412, 4260, 1561, 370, 6411, 3423, 14, 199, 63, 8338, 63, 11346, 275, 1052, 199, 63, 14087, 63, 11346, 275, 1052, 421, 199, 3, 437, 2600, 402, 2202, 23172, 14, 710, 790, 365, 314, 4744, 536, 12, 314, 574, 365, 199, 3, 282, 2600, 4412, 4260, 1561, 370, 8603, 3423, 14, 199, 63, 8338, 63, 475, 63, 14087, 63, 17911, 275, 1052, 421, 199, 3, 15650, 536, 4412, 687, 13828, 370, 21374, 14, 199, 63, 14087, 63, 354, 63, 1618, 63, 3557, 275, 1052, 421, 199, 533, 485, 5157, 8, 785, 304, 523, 408, 18089, 282, 4744, 1202, 701, 13828, 503, 21374, 14, 819, 9382, 26, 489, 13795, 63, 354, 26, 710, 536, 402, 314, 4744, 315, 13828, 14, 489, 14835, 63, 354, 26, 710, 536, 402, 314, 4744, 315, 21374, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 13795, 63, 354, 12, 14835, 63, 354, 304, 272, 291, 14, 8338, 63, 354, 275, 13795, 63, 354, 272, 291, 14, 14087, 63, 354, 275, 14835, 63, 354, 421, 199, 318, 485, 1123, 5157, 8, 3557, 304, 523, 408, 14995, 282, 4744, 370, 314, 11648, 11196, 1202, 370, 2112, 2202, 14, 819, 961, 1454, 7890, 314, 4744, 14, 221, 7048, 4260, 2597, 4839, 370, 506, 3483, 14, 819, 3033, 26, 272, 4744, 26, 710, 485, 5157, 909, 370, 506, 3483, 14, 523, 408, 523, 485, 8338, 63, 11346, 59, 3557, 14, 8338, 63, 354, 61, 275, 1052, 523, 485, 14087, 63, 11346, 59, 3557, 14, 14087, 63, 354, 61, 275, 1052, 523, 485, 8338, 63, 475, 63, 14087, 63, 17911, 59, 3557, 14, 8338, 63, 354, 61, 275, 1052, 523, 485, 14087, 63, 354, 63, 1618, 63, 3557, 59, 3557, 14, 8338, 63, 354, 61, 275, 4744, 14, 14087, 63, 354, 421, 199, 318, 485, 26772, 5157, 5268, 8, 14087, 63, 1751, 12, 4744, 304, 523, 408, 3407, 376, 21374, 4744, 2600, 14, 221, 10560, 652, 340, 4346, 1041, 523, 372, 14835, 63, 1751, 14, 5486, 8, 3557, 14, 14087, 63, 354, 12, 5009, 421, 199, 533, 485, 804, 8, 785, 304, 523, 408, 804, 402, 2202, 334, 1563, 1021, 10477, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 408, 21168, 626, 314, 574, 365, 18393, 367, 13828, 14, 339, 3033, 26, 489, 574, 26, 314, 574, 370, 1104, 367, 642, 730, 14, 339, 6218, 26, 489, 1722, 340, 574, 365, 440, 1686, 367, 13828, 14, 272, 408, 819, 347, 12134, 10733, 8, 277, 12, 574, 304, 272, 408, 21168, 626, 314, 574, 365, 18393, 367, 21374, 14, 339, 3033, 26, 489, 574, 26, 314, 574, 370, 1104, 367, 642, 730, 14, 339, 6218, 26, 489, 1722, 340, 574, 365, 440, 1686, 367, 21374, 14, 272, 408, 819, 347, 7905, 28361, 8, 277, 12, 574, 304, 272, 408, 3407, 314, 21374, 7353, 402, 314, 13828, 574, 1627, 14, 339, 3033, 26, 489, 574, 26, 314, 13828, 574, 370, 3957, 14, 339, 1803, 26, 489, 314, 21374, 7353, 14, 339, 6218, 26, 489, 1722, 340, 574, 365, 440, 1686, 14, 272, 408, 272, 372, 574, 421, 199, 533, 485, 1558, 1547, 804, 304, 523, 408, 33, 4260, 626, 1159, 2951, 282, 1059, 1041, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 304, 489, 746, 1722, 360, 2062, 1059, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 12134, 10733, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 304, 489, 746, 1722, 360, 2062, 1059, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 7905, 28361, 8, 277, 12, 574, 304, 272, 327, 7905, 314, 16954, 272, 372, 7905, 9454, 25402, 28361, 8, 585, 9, 421, 199, 533, 485, 32216, 1547, 804, 304, 523, 408, 33, 2202, 626, 1159, 282, 769, 402, 3326, 1041, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 9, 436, 440, 1228, 8, 585, 12, 769, 304, 489, 746, 1722, 360, 2062, 1059, 769, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 12134, 10733, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 9, 436, 440, 1228, 8, 585, 12, 769, 304, 489, 746, 1722, 360, 2062, 1059, 769, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 7905, 28361, 8, 277, 12, 574, 304, 272, 327, 7905, 314, 16954, 272, 340, 1228, 8, 585, 12, 769, 304, 489, 372, 359, 7306, 9454, 25402, 28361, 8, 73, 9, 367, 284, 315, 574, 61, 272, 587, 26, 489, 372, 7905, 9454, 25402, 28361, 8, 585, 9, 421, 199, 533, 485, 4082, 1547, 804, 304, 523, 408, 4082, 2202, 12, 883, 1172, 314, 1338, 283, 3910, 7, 503, 283, 2052, 23690, 819, 347, 485, 12584, 8, 277, 12, 574, 304, 272, 340, 574, 1137, 283, 2052, 7, 436, 574, 1137, 283, 3910, 356, 489, 746, 1722, 360, 2062, 2155, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 291, 423, 12584 ]
[ 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, 82, 624, 3034, 370, 4107, 436, 3957, 2202, 402, 314, 15332, 1900, 7249, 14, 199, 199, 2765, 570, 3509, 1233, 370, 4107, 436, 3957, 2202, 402, 314, 15332, 199, 1506, 7249, 14, 221, 710, 805, 7905, 28361, 5268, 1062, 12134, 14206, 5268, 1062, 199, 460, 12134, 10733, 5268, 342, 787, 314, 2397, 4501, 14, 199, 199, 2765, 570, 1990, 2737, 701, 20234, 314, 11336, 2737, 701, 14702, 13225, 9079, 199, 460, 14702, 13225, 7129, 367, 1006, 2808, 2202, 4012, 314, 922, 3217, 14, 199, 1918, 21374, 32536, 4898, 2597, 8652, 14, 221, 9322, 787, 13609, 1911, 315, 314, 199, 10733, 3907, 2082, 12, 325, 14, 71, 14, 286, 3427, 9184, 16920, 334, 88, 1184, 2862, 10733, 199, 624, 199, 199, 646, 984, 199, 646, 295, 199, 199, 3, 3757, 10150, 402, 2202, 14370, 14, 710, 790, 365, 314, 4744, 536, 12, 314, 574, 365, 199, 3, 282, 2600, 4412, 4260, 1561, 370, 6411, 3423, 14, 199, 63, 8338, 63, 11346, 275, 1052, 199, 63, 14087, 63, 11346, 275, 1052, 421, 199, 3, 437, 2600, 402, 2202, 23172, 14, 710, 790, 365, 314, 4744, 536, 12, 314, 574, 365, 199, 3, 282, 2600, 4412, 4260, 1561, 370, 8603, 3423, 14, 199, 63, 8338, 63, 475, 63, 14087, 63, 17911, 275, 1052, 421, 199, 3, 15650, 536, 4412, 687, 13828, 370, 21374, 14, 199, 63, 14087, 63, 354, 63, 1618, 63, 3557, 275, 1052, 421, 199, 533, 485, 5157, 8, 785, 304, 523, 408, 18089, 282, 4744, 1202, 701, 13828, 503, 21374, 14, 819, 9382, 26, 489, 13795, 63, 354, 26, 710, 536, 402, 314, 4744, 315, 13828, 14, 489, 14835, 63, 354, 26, 710, 536, 402, 314, 4744, 315, 21374, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 13795, 63, 354, 12, 14835, 63, 354, 304, 272, 291, 14, 8338, 63, 354, 275, 13795, 63, 354, 272, 291, 14, 14087, 63, 354, 275, 14835, 63, 354, 421, 199, 318, 485, 1123, 5157, 8, 3557, 304, 523, 408, 14995, 282, 4744, 370, 314, 11648, 11196, 1202, 370, 2112, 2202, 14, 819, 961, 1454, 7890, 314, 4744, 14, 221, 7048, 4260, 2597, 4839, 370, 506, 3483, 14, 819, 3033, 26, 272, 4744, 26, 710, 485, 5157, 909, 370, 506, 3483, 14, 523, 408, 523, 485, 8338, 63, 11346, 59, 3557, 14, 8338, 63, 354, 61, 275, 1052, 523, 485, 14087, 63, 11346, 59, 3557, 14, 14087, 63, 354, 61, 275, 1052, 523, 485, 8338, 63, 475, 63, 14087, 63, 17911, 59, 3557, 14, 8338, 63, 354, 61, 275, 1052, 523, 485, 14087, 63, 354, 63, 1618, 63, 3557, 59, 3557, 14, 8338, 63, 354, 61, 275, 4744, 14, 14087, 63, 354, 421, 199, 318, 485, 26772, 5157, 5268, 8, 14087, 63, 1751, 12, 4744, 304, 523, 408, 3407, 376, 21374, 4744, 2600, 14, 221, 10560, 652, 340, 4346, 1041, 523, 372, 14835, 63, 1751, 14, 5486, 8, 3557, 14, 14087, 63, 354, 12, 5009, 421, 199, 533, 485, 804, 8, 785, 304, 523, 408, 804, 402, 2202, 334, 1563, 1021, 10477, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 408, 21168, 626, 314, 574, 365, 18393, 367, 13828, 14, 339, 3033, 26, 489, 574, 26, 314, 574, 370, 1104, 367, 642, 730, 14, 339, 6218, 26, 489, 1722, 340, 574, 365, 440, 1686, 367, 13828, 14, 272, 408, 819, 347, 12134, 10733, 8, 277, 12, 574, 304, 272, 408, 21168, 626, 314, 574, 365, 18393, 367, 21374, 14, 339, 3033, 26, 489, 574, 26, 314, 574, 370, 1104, 367, 642, 730, 14, 339, 6218, 26, 489, 1722, 340, 574, 365, 440, 1686, 367, 21374, 14, 272, 408, 819, 347, 7905, 28361, 8, 277, 12, 574, 304, 272, 408, 3407, 314, 21374, 7353, 402, 314, 13828, 574, 1627, 14, 339, 3033, 26, 489, 574, 26, 314, 13828, 574, 370, 3957, 14, 339, 1803, 26, 489, 314, 21374, 7353, 14, 339, 6218, 26, 489, 1722, 340, 574, 365, 440, 1686, 14, 272, 408, 272, 372, 574, 421, 199, 533, 485, 1558, 1547, 804, 304, 523, 408, 33, 4260, 626, 1159, 2951, 282, 1059, 1041, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 304, 489, 746, 1722, 360, 2062, 1059, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 12134, 10733, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 304, 489, 746, 1722, 360, 2062, 1059, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 7905, 28361, 8, 277, 12, 574, 304, 272, 327, 7905, 314, 16954, 272, 372, 7905, 9454, 25402, 28361, 8, 585, 9, 421, 199, 533, 485, 32216, 1547, 804, 304, 523, 408, 33, 2202, 626, 1159, 282, 769, 402, 3326, 1041, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 9, 436, 440, 1228, 8, 585, 12, 769, 304, 489, 746, 1722, 360, 2062, 1059, 769, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 12134, 10733, 8, 277, 12, 574, 304, 272, 340, 440, 1228, 8, 585, 12, 7116, 9, 436, 440, 1228, 8, 585, 12, 769, 304, 489, 746, 1722, 360, 2062, 1059, 769, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 7905, 28361, 8, 277, 12, 574, 304, 272, 327, 7905, 314, 16954, 272, 340, 1228, 8, 585, 12, 769, 304, 489, 372, 359, 7306, 9454, 25402, 28361, 8, 73, 9, 367, 284, 315, 574, 61, 272, 587, 26, 489, 372, 7905, 9454, 25402, 28361, 8, 585, 9, 421, 199, 533, 485, 4082, 1547, 804, 304, 523, 408, 4082, 2202, 12, 883, 1172, 314, 1338, 283, 3910, 7, 503, 283, 2052, 23690, 819, 347, 485, 12584, 8, 277, 12, 574, 304, 272, 340, 574, 1137, 283, 2052, 7, 436, 574, 1137, 283, 3910, 356, 489, 746, 1722, 360, 2062, 2155, 27, 4788, 450, 82, 7, 450, 574, 9, 819, 347, 12134, 14206, 8, 277, 12, 574, 304, 272, 291, 423, 12584, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Glf9832/AjkSpider
AjkSpider/spiders/AjkZsSpider.py
1
2002
# -*- coding: utf-8 -*- import scrapy from AjkSpider.items import AjkZsspiderItem class AjkzsspiderSpider(scrapy.Spider): name = "AjkZsSpider" allowed_domains = ["zs.fang.anjuke.com"] start_urls = ['http://zs.fang.anjuke.com/'] def parse(self, response): subSelector = response.xpath('//div[@class="item-mod"]') # items = [] for sub in subSelector: item = AjkZsspiderItem() if sub.xpath('./div[@class="infos"]/div[@class="lp-name"]/h3/a/text()') == []: item['loupanname'] = [u'无'] else: item['loupanname'] = sub.xpath('./div[@class="infos"]/div[@class="lp-name"]/h3/a/text()').extract() if sub.xpath('./div[@class="infos"]/div[@class="lp-name"]/h3/a/@href') == []: item['url'] = [u'无'] else: item['url'] = sub.xpath('./div[@class="infos"]/div[@class="lp-name"]/h3/a/@href').extract() if sub.xpath('./div[@class="infos"]/p[@class="address"]/a/text()') == []: item['address'] = [u'无'] else: item['address'] = sub.xpath('./div[@class="infos"]/p[@class="address"]/a/text()').extract() if sub.xpath('./div[@class="infos"]/div[@class="data-brief"]/a/text()') == []: item['brief'] = [u'暂无动态'] else: item['brief'] = sub.xpath('./div[@class="infos"]/div[@class="data-brief"]/a/text()').extract() if sub.xpath('./div[@class="favor-pos"]/p[@class="price"]/span/text()') == []: item['price'] = [u'0'] else: item['price'] = sub.xpath('./div[@class="favor-pos"]/p[@class="price"]/span/text()').extract() # items.append(item) yield item nextpage = response.xpath('//div[@class="list-page"]/div[@class="pagination"]/a[@class="next-page next-link"]/@href')[0].extract() yield scrapy.Request(url=nextpage,callback=self.parse)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 18918, 199, 504, 437, 17421, 25157, 14, 1744, 492, 437, 17421, 58, 385, 12508, 2081, 199, 199, 533, 437, 17421, 90, 385, 12508, 25157, 8, 26442, 14, 25157, 304, 272, 536, 275, 298, 33, 17421, 58, 83, 25157, 2, 272, 4370, 63, 9756, 275, 2097, 31765, 14, 70, 621, 14, 290, 27764, 415, 14, 957, 937, 272, 1343, 63, 3603, 275, 788, 1014, 921, 31765, 14, 70, 621, 14, 290, 27764, 415, 14, 957, 15, 418, 339, 347, 2198, 8, 277, 12, 1177, 304, 267, 1007, 11212, 275, 1177, 14, 8006, 15079, 3015, 14251, 533, 628, 1053, 13, 1494, 937, 358, 267, 327, 2974, 275, 942, 267, 367, 1007, 315, 1007, 11212, 26, 288, 1242, 275, 437, 17421, 58, 385, 12508, 2081, 342, 288, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 505, 19004, 508, 18410, 355, 1242, 459, 320, 384, 290, 354, 418, 275, 359, 85, 7, 11373, 255, 418, 288, 587, 26, 355, 1242, 459, 320, 384, 290, 354, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 505, 342, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 32, 6399, 358, 508, 18410, 355, 1242, 459, 633, 418, 275, 359, 85, 7, 11373, 255, 418, 288, 587, 26, 355, 1242, 459, 633, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 32, 6399, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 80, 14251, 533, 628, 1562, 937, 15, 65, 15, 505, 19004, 508, 18410, 355, 1242, 459, 1562, 418, 275, 359, 85, 7, 11373, 255, 418, 288, 587, 26, 355, 1242, 459, 1562, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 80, 14251, 533, 628, 1562, 937, 15, 65, 15, 505, 342, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 576, 13, 19127, 937, 15, 65, 15, 505, 19004, 508, 18410, 355, 1242, 459, 19127, 418, 275, 359, 85, 7, 163, 249, 225, 11373, 255, 31001, 26171, 418, 288, 587, 26, 355, 1242, 459, 19127, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 576, 13, 19127, 937, 15, 65, 15, 505, 342, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 17520, 13, 1712, 937, 15, 80, 14251, 533, 628, 4777, 937, 15, 3751, 15, 505, 19004, 508, 18410, 355, 1242, 459, 4777, 418, 275, 359, 85, 7, 16, 418, 288, 587, 26, 355, 1242, 459, 4777, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 17520, 13, 1712, 937, 15, 80, 14251, 533, 628, 4777, 937, 15, 3751, 15, 505, 342, 1959, 5005, 342, 953, 327, 2974, 14, 740, 8, 1053, 9, 288, 1995, 1242, 398, 2163, 1606, 275, 1177, 14, 8006, 15079, 3015, 14251, 533, 628, 513, 13, 1606, 937, 15, 3015, 14251, 533, 628, 22793, 937, 15, 65, 14251, 533, 628, 2184, 13, 1606, 2163, 13, 1073, 937, 15, 32, 6399, 5832, 16, 1055, 5005, 342, 267, 1995, 18918, 14, 2017, 8, 633, 29, 2184, 1606, 12, 3058, 29, 277, 14, 1122, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 18918, 199, 504, 437, 17421, 25157, 14, 1744, 492, 437, 17421, 58, 385, 12508, 2081, 199, 199, 533, 437, 17421, 90, 385, 12508, 25157, 8, 26442, 14, 25157, 304, 272, 536, 275, 298, 33, 17421, 58, 83, 25157, 2, 272, 4370, 63, 9756, 275, 2097, 31765, 14, 70, 621, 14, 290, 27764, 415, 14, 957, 937, 272, 1343, 63, 3603, 275, 788, 1014, 921, 31765, 14, 70, 621, 14, 290, 27764, 415, 14, 957, 15, 418, 339, 347, 2198, 8, 277, 12, 1177, 304, 267, 1007, 11212, 275, 1177, 14, 8006, 15079, 3015, 14251, 533, 628, 1053, 13, 1494, 937, 358, 267, 327, 2974, 275, 942, 267, 367, 1007, 315, 1007, 11212, 26, 288, 1242, 275, 437, 17421, 58, 385, 12508, 2081, 342, 288, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 505, 19004, 508, 18410, 355, 1242, 459, 320, 384, 290, 354, 418, 275, 359, 85, 7, 11373, 255, 418, 288, 587, 26, 355, 1242, 459, 320, 384, 290, 354, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 505, 342, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 32, 6399, 358, 508, 18410, 355, 1242, 459, 633, 418, 275, 359, 85, 7, 11373, 255, 418, 288, 587, 26, 355, 1242, 459, 633, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 10343, 13, 354, 937, 15, 72, 19, 15, 65, 15, 32, 6399, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 80, 14251, 533, 628, 1562, 937, 15, 65, 15, 505, 19004, 508, 18410, 355, 1242, 459, 1562, 418, 275, 359, 85, 7, 11373, 255, 418, 288, 587, 26, 355, 1242, 459, 1562, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 80, 14251, 533, 628, 1562, 937, 15, 65, 15, 505, 342, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 576, 13, 19127, 937, 15, 65, 15, 505, 19004, 508, 18410, 355, 1242, 459, 19127, 418, 275, 359, 85, 7, 163, 249, 225, 11373, 255, 31001, 26171, 418, 288, 587, 26, 355, 1242, 459, 19127, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 14195, 937, 15, 3015, 14251, 533, 628, 576, 13, 19127, 937, 15, 65, 15, 505, 342, 1959, 5005, 342, 953, 340, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 17520, 13, 1712, 937, 15, 80, 14251, 533, 628, 4777, 937, 15, 3751, 15, 505, 19004, 508, 18410, 355, 1242, 459, 4777, 418, 275, 359, 85, 7, 16, 418, 288, 587, 26, 355, 1242, 459, 4777, 418, 275, 1007, 14, 8006, 17371, 3015, 14251, 533, 628, 17520, 13, 1712, 937, 15, 80, 14251, 533, 628, 4777, 937, 15, 3751, 15, 505, 342, 1959, 5005, 342, 953, 327, 2974, 14, 740, 8, 1053, 9, 288, 1995, 1242, 398, 2163, 1606, 275, 1177, 14, 8006, 15079, 3015, 14251, 533, 628, 513, 13, 1606, 937, 15, 3015, 14251, 533, 628, 22793, 937, 15, 65, 14251, 533, 628, 2184, 13, 1606, 2163, 13, 1073, 937, 15, 32, 6399, 5832, 16, 1055, 5005, 342, 267, 1995, 18918, 14, 2017, 8, 633, 29, 2184, 1606, 12, 3058, 29, 277, 14, 1122, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
NightKev/fireplace
fireplace/managers.py
2
7529
from hearthstone.enums import GameTag from . import enums class Manager(object): def __init__(self, obj): self.obj = obj self.observers = [] def __getitem__(self, tag): if self.map.get(tag): return getattr(self.obj, self.map[tag], 0) raise KeyError def __setitem__(self, tag, value): setattr(self.obj, self.map[tag], value) def __iter__(self): for k in self.map: if self.map[k]: yield k def get(self, k, default=None): return self[k] if k in self.map else default def items(self): for k, v in self.map.items(): if v is not None: yield k, self[k] def register(self, observer): self.observers.append(observer) def update(self, tags): for k, v in tags.items(): if self.map.get(k) is not None: self[k] = v class GameManager(Manager): map = { GameTag.CARDTYPE: "type", GameTag.NEXT_STEP: "next_step", GameTag.NUM_MINIONS_KILLED_THIS_TURN: "minions_killed_this_turn", GameTag.PROPOSED_ATTACKER: "proposed_attacker", GameTag.PROPOSED_DEFENDER: "proposed_defender", GameTag.STATE: "state", GameTag.STEP: "step", GameTag.TURN: "turn", GameTag.ZONE: "zone", } def __init__(self, obj): super().__init__(obj) self.counter = 1 obj.entity_id = self.counter def action_start(self, type, source, index, target): for observer in self.observers: observer.action_start(type, source, index, target) def action_end(self, type, source): for observer in self.observers: observer.action_end(type, source) def new_entity(self, entity): self.counter += 1 entity.entity_id = self.counter for observer in self.observers: observer.new_entity(entity) def start_game(self): for observer in self.observers: observer.start_game() def step(self, step, next_step=None): for observer in self.observers: observer.game_step(step, next_step) self.obj.step = step if next_step is not None: self.obj.next_step = next_step def turn(self, player): for observer in self.observers: observer.turn(player) class BaseObserver: def action_start(self, type, source, index, target): pass def action_end(self, type, source): pass def game_step(self, step, next_step): pass def new_entity(self, entity): pass def start_game(): pass def turn(self, player): pass class PlayerManager(Manager): map = { GameTag.CANT_DRAW: "cant_draw", GameTag.CARDTYPE: "type", GameTag.COMBO_ACTIVE: "combo", GameTag.CONTROLLER: "controller", GameTag.CURRENT_PLAYER: "current_player", GameTag.CURRENT_SPELLPOWER: "spellpower", GameTag.EMBRACE_THE_SHADOW: "healing_as_damage", GameTag.FATIGUE: "fatigue_counter", GameTag.FIRST_PLAYER: "first_player", GameTag.HEALING_DOUBLE: "healing_double", GameTag.HERO_ENTITY: "hero", GameTag.LAST_CARD_PLAYED: "last_card_played", GameTag.MAXHANDSIZE: "max_hand_size", GameTag.MAXRESOURCES: "max_resources", GameTag.NUM_CARDS_DRAWN_THIS_TURN: "cards_drawn_this_turn", GameTag.NUM_CARDS_PLAYED_THIS_TURN: "cards_played_this_turn", GameTag.NUM_MINIONS_PLAYED_THIS_TURN: "minions_played_this_turn", GameTag.NUM_MINIONS_PLAYER_KILLED_THIS_TURN: "minions_killed_this_turn", GameTag.NUM_TIMES_HERO_POWER_USED_THIS_GAME: "times_hero_power_used_this_game", GameTag.OVERLOAD_LOCKED: "overload_locked", GameTag.OVERLOAD_OWED: "overloaded", GameTag.PLAYSTATE: "playstate", GameTag.RESOURCES: "max_mana", GameTag.RESOURCES_USED: "used_mana", GameTag.SPELLPOWER_DOUBLE: "spellpower_double", GameTag.STARTHANDSIZE: "start_hand_size", GameTag.HERO_POWER_DOUBLE: "hero_power_double", GameTag.TEMP_RESOURCES: "temp_mana", GameTag.TIMEOUT: "timeout", GameTag.TURN_START: "turn_start", enums.CANT_OVERLOAD: "cant_overload", } CARD_ATTRIBUTE_MAP = { GameTag.ADJACENT_BUFF: "adjacent_buff", GameTag.ARMOR: "armor", GameTag.ATK: "atk", GameTag.ATTACKING: "attacking", GameTag.ATTACHED: "owner", GameTag.AURA: "aura", GameTag.BATTLECRY: "has_battlecry", GameTag.CANNOT_ATTACK_HEROES: "cannot_attack_heroes", GameTag.CANT_ATTACK: "cant_attack", GameTag.CANT_BE_ATTACKED: "cant_be_attacked", GameTag.CANT_BE_DAMAGED: "cant_be_damaged", GameTag.CANT_BE_TARGETED_BY_ABILITIES: "cant_be_targeted_by_abilities", GameTag.CANT_BE_TARGETED_BY_HERO_POWERS: "cant_be_targeted_by_hero_powers", GameTag.CANT_BE_TARGETED_BY_OPPONENTS: "cant_be_targeted_by_opponents", GameTag.CANT_PLAY: "cant_play", GameTag.CARD_ID: "id", GameTag.CARD_TARGET: "target", GameTag.CARDNAME: "name", GameTag.CARDRACE: "race", GameTag.CARDTYPE: "type", GameTag.CHARGE: "charge", GameTag.CLASS: "card_class", GameTag.COMBO: "has_combo", GameTag.CONTROLLER: "controller", GameTag.COST: "cost", GameTag.CREATOR: "creator", GameTag.DAMAGE: "damage", GameTag.DEATHRATTLE: "has_deathrattle", GameTag.DEFENDING: "defending", GameTag.DIVINE_SHIELD: "divine_shield", GameTag.DURABILITY: "max_durability", GameTag.EMBRACE_THE_SHADOW: "healing_as_damage", GameTag.ENRAGED: "enrage", GameTag.EXHAUSTED: "exhausted", GameTag.EXTRA_DEATHRATTLES: "extra_deathrattles", GameTag.FORGETFUL: "forgetful", GameTag.FROZEN: "frozen", GameTag.HEALING_DOUBLE: "healing_double", GameTag.HEALTH: "max_health", GameTag.HEALTH_MINIMUM: "min_health", GameTag.HEAVILY_ARMORED: "heavily_armored", GameTag.HEROPOWER_ADDITIONAL_ACTIVATIONS: "additional_activations", GameTag.HEROPOWER_DAMAGE: "heropower_damage", GameTag.INCOMING_DAMAGE_MULTIPLIER: "incoming_damage_multiplier", GameTag.ImmuneToSpellpower: "immune_to_spellpower", GameTag.IMMUNE_WHILE_ATTACKING: "immune_while_attacking", GameTag.INSPIRE: "has_inspire", GameTag.NUM_ATTACKS_THIS_TURN: "num_attacks", GameTag.NUM_TURNS_IN_PLAY: "turns_in_play", GameTag.TAG_ONE_TURN_EFFECT: "one_turn_effect", GameTag.OVERLOAD: "overload", GameTag.PARENT_CARD: "parent_card", GameTag.POISONOUS: "poisonous", GameTag.POWERED_UP: "powered_up", GameTag.RARITY: "rarity", GameTag.RECEIVES_DOUBLE_SPELLDAMAGE_BONUS: "receives_double_spelldamage_bonus", GameTag.SECRET: "secret", GameTag.SHADOWFORM: "shadowform", GameTag.SHOULDEXITCOMBAT: "should_exit_combat", GameTag.SILENCED: "silenced", GameTag.SPELLPOWER: "spellpower", GameTag.SPELLPOWER_DOUBLE: "spellpower_double", GameTag.SPELLS_COST_HEALTH: "spells_cost_health", GameTag.STEALTH: "stealthed", GameTag.TAG_AI_MUST_PLAY: "autocast", GameTag.HERO_POWER_DOUBLE: "hero_power_double", GameTag.TAUNT: "taunt", GameTag.WINDFURY: "windfury", GameTag.ZONE: "zone", GameTag.ZONE_POSITION: "zone_position", enums.ALWAYS_WINS_BRAWLS: "always_wins_brawls", enums.EXTRA_BATTLECRIES: "extra_battlecries", enums.KILLED_THIS_TURN: "killed_this_turn", GameTag.AFFECTED_BY_SPELL_POWER: None, GameTag.ARTISTNAME: None, GameTag.AttackVisualType: None, GameTag.CARD_SET: None, GameTag.CARDTEXT_INHAND: None, GameTag.CardTextInPlay: None, GameTag.Collectible: None, GameTag.DevState: None, GameTag.ELITE: None, GameTag.ENCHANTMENT_IDLE_VISUAL: None, GameTag.ENCHANTMENT_BIRTH_VISUAL: None, GameTag.EVIL_GLOW: None, GameTag.FACTION: None, GameTag.FLAVORTEXT: None, GameTag.FREEZE: None, GameTag.HealTarget: None, GameTag.HIDE_COST: None, GameTag.HOW_TO_EARN: None, GameTag.HOW_TO_EARN_GOLDEN: None, GameTag.InvisibleDeathrattle: None, GameTag.MORPH: None, GameTag.SILENCE: None, GameTag.SUMMONED: None, GameTag.SPARE_PART: None, GameTag.SHOWN_HERO_POWER: None, GameTag.TARGETING_ARROW_TEXT: None, GameTag.TOPDECK: None, GameTag.TAG_AI_MUST_PLAY: None, GameTag.TRIGGER_VISUAL: None, } class CardManager(Manager): map = CARD_ATTRIBUTE_MAP
agpl-3.0
[ 504, 946, 19677, 8361, 14, 19921, 492, 25132, 1931, 199, 504, 1275, 492, 28441, 421, 199, 533, 13537, 8, 785, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1559, 304, 507, 198, 277, 14, 1113, 275, 1559, 507, 198, 277, 14, 2873, 5871, 275, 942, 421, 198, 318, 636, 6095, 721, 277, 12, 1947, 304, 507, 198, 692, 291, 14, 1130, 14, 362, 8, 1450, 304, 686, 198, 1107, 2519, 8, 277, 14, 1113, 12, 291, 14, 1130, 59, 1450, 467, 378, 9, 507, 198, 3730, 4067, 421, 198, 318, 636, 8617, 721, 277, 12, 1947, 12, 574, 304, 507, 198, 10202, 8, 277, 14, 1113, 12, 291, 14, 1130, 59, 1450, 467, 574, 9, 421, 198, 318, 636, 1661, 721, 277, 304, 507, 198, 509, 1022, 315, 291, 14, 1130, 26, 686, 198, 692, 291, 14, 1130, 59, 75, 2189, 1585, 198, 11481, 1022, 421, 198, 318, 664, 8, 277, 12, 1022, 12, 849, 29, 403, 304, 507, 198, 1107, 291, 59, 75, 61, 340, 1022, 315, 291, 14, 1130, 587, 849, 421, 198, 318, 2974, 8, 277, 304, 507, 198, 509, 1022, 12, 373, 315, 291, 14, 1130, 14, 1744, 837, 686, 198, 692, 373, 365, 440, 488, 26, 1585, 198, 11481, 1022, 12, 291, 59, 75, 61, 421, 198, 318, 2274, 8, 277, 12, 27336, 304, 507, 198, 277, 14, 2873, 5871, 14, 740, 8, 23968, 9, 421, 198, 318, 1678, 8, 277, 12, 3762, 304, 507, 198, 509, 1022, 12, 373, 315, 3762, 14, 1744, 837, 686, 198, 692, 291, 14, 1130, 14, 362, 8, 75, 9, 365, 440, 488, 26, 1585, 198, 277, 59, 75, 61, 275, 373, 421, 199, 533, 25132, 2988, 8, 2988, 304, 199, 198, 1130, 275, 469, 507, 198, 11454, 1931, 14, 35, 7816, 2711, 26, 298, 466, 401, 507, 198, 11454, 1931, 14, 21917, 63, 17988, 26, 298, 2184, 63, 2926, 401, 507, 198, 11454, 1931, 14, 7125, 63, 4896, 2823, 63, 43, 1193, 5290, 63, 24571, 63, 52, 7648, 26, 298, 827, 15293, 63, 75, 14535, 63, 3749, 63, 353, 401, 507, 198, 11454, 1931, 14, 2514, 3064, 36, 63, 11712, 3099, 540, 26, 298, 15676, 63, 24171, 281, 401, 507, 198, 11454, 1931, 14, 2514, 3064, 36, 63, 5638, 21951, 26, 298, 15676, 63, 318, 13747, 401, 507, 198, 11454, 1931, 14, 6689, 26, 298, 929, 401, 507, 198, 11454, 1931, 14, 17988, 26, 298, 2926, 401, 507, 198, 11454, 1931, 14, 52, 7648, 26, 298, 353, 401, 507, 198, 11454, 1931, 14, 15353, 26, 298, 2619, 401, 199, 198, 93, 421, 198, 318, 636, 826, 721, 277, 12, 1559, 304, 507, 198, 4792, 11027, 826, 721, 1113, 9, 507, 198, 277, 14, 5337, 275, 413, 507, 198, 1113, 14, 4502, 63, 344, 275, 291, 14, 5337, 421, 198, 318, 1595, 63, 928, 8, 277, 12, 730, 12, 1350, 12, 1478, 12, 1347, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 1287, 63, 928, 8, 466, 12, 1350, 12, 1478, 12, 1347, 9, 421, 198, 318, 1595, 63, 500, 8, 277, 12, 730, 12, 1350, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 1287, 63, 500, 8, 466, 12, 1350, 9, 421, 198, 318, 892, 63, 4502, 8, 277, 12, 4642, 304, 507, 198, 277, 14, 5337, 847, 413, 507, 198, 4502, 14, 4502, 63, 344, 275, 291, 14, 5337, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 1222, 63, 4502, 8, 4502, 9, 421, 198, 318, 1343, 63, 5097, 8, 277, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 928, 63, 5097, 342, 421, 198, 318, 3650, 8, 277, 12, 3650, 12, 2163, 63, 2926, 29, 403, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 5097, 63, 2926, 8, 2926, 12, 2163, 63, 2926, 9, 507, 198, 277, 14, 1113, 14, 2926, 275, 3650, 507, 198, 692, 2163, 63, 2926, 365, 440, 488, 26, 686, 198, 277, 14, 1113, 14, 2184, 63, 2926, 275, 2163, 63, 2926, 421, 198, 318, 7485, 8, 277, 12, 7748, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 353, 8, 6147, 9, 421, 199, 533, 3523, 22715, 26, 199, 198, 318, 1595, 63, 928, 8, 277, 12, 730, 12, 1350, 12, 1478, 12, 1347, 304, 507, 198, 1529, 421, 198, 318, 1595, 63, 500, 8, 277, 12, 730, 12, 1350, 304, 507, 198, 1529, 421, 198, 318, 9219, 63, 2926, 8, 277, 12, 3650, 12, 2163, 63, 2926, 304, 507, 198, 1529, 421, 198, 318, 892, 63, 4502, 8, 277, 12, 4642, 304, 507, 198, 1529, 421, 198, 318, 1343, 63, 5097, 837, 507, 198, 1529, 421, 198, 318, 7485, 8, 277, 12, 7748, 304, 507, 198, 1529, 421, 199, 533, 25610, 2988, 8, 2988, 304, 199, 198, 1130, 275, 469, 507, 198, 11454, 1931, 14, 35, 1441, 63, 12118, 26, 298, 67, 867, 63, 5485, 401, 507, 198, 11454, 1931, 14, 35, 7816, 2711, 26, 298, 466, 401, 507, 198, 11454, 1931, 14, 11265, 3973, 63, 10401, 26, 298, 12650, 401, 507, 198, 11454, 1931, 14, 5801, 14881, 540, 26, 298, 5538, 401, 507, 198, 11454, 1931, 14, 14211, 63, 11625, 540, 26, 298, 1818, 63, 6147, 401, 507, 198, 11454, 1931, 14, 14211, 63, 14179, 4464, 16064, 26, 298, 32252, 5652, 401, 507, 198, 11454, 1931, 14, 2769, 29246, 63, 18061, 63, 3234, 1554, 19716, 26, 298, 426, 29515, 63, 305, 63, 26551, 401, 507, 198, 11454, 1931, 14, 21331, 1277, 4187, 26, 298, 667, 17277, 310, 63, 5337, 401, 507, 198, 11454, 1931, 14, 12903, 63, 11625, 540, 26, 298, 2246, 63, 6147, 401, 507, 198, 11454, 1931, 14, 1645, 748, 1206, 63, 14989, 26, 298, 426, 29515, 63, 3157, 401, 507, 198, 11454, 1931, 14, 3452, 47, 63, 13630, 26, 298, 31863, 401, 507, 198, 11454, 1931, 14, 16901, 63, 35, 7816, 63, 11625, 1149, 26, 298, 2019, 63, 5841, 63, 2802, 379, 401, 507, 198, 11454, 1931, 14, 4283, 10854, 4305, 26, 298, 988, 63, 6868, 63, 890, 401 ]
[ 946, 19677, 8361, 14, 19921, 492, 25132, 1931, 199, 504, 1275, 492, 28441, 421, 199, 533, 13537, 8, 785, 304, 199, 198, 318, 636, 826, 721, 277, 12, 1559, 304, 507, 198, 277, 14, 1113, 275, 1559, 507, 198, 277, 14, 2873, 5871, 275, 942, 421, 198, 318, 636, 6095, 721, 277, 12, 1947, 304, 507, 198, 692, 291, 14, 1130, 14, 362, 8, 1450, 304, 686, 198, 1107, 2519, 8, 277, 14, 1113, 12, 291, 14, 1130, 59, 1450, 467, 378, 9, 507, 198, 3730, 4067, 421, 198, 318, 636, 8617, 721, 277, 12, 1947, 12, 574, 304, 507, 198, 10202, 8, 277, 14, 1113, 12, 291, 14, 1130, 59, 1450, 467, 574, 9, 421, 198, 318, 636, 1661, 721, 277, 304, 507, 198, 509, 1022, 315, 291, 14, 1130, 26, 686, 198, 692, 291, 14, 1130, 59, 75, 2189, 1585, 198, 11481, 1022, 421, 198, 318, 664, 8, 277, 12, 1022, 12, 849, 29, 403, 304, 507, 198, 1107, 291, 59, 75, 61, 340, 1022, 315, 291, 14, 1130, 587, 849, 421, 198, 318, 2974, 8, 277, 304, 507, 198, 509, 1022, 12, 373, 315, 291, 14, 1130, 14, 1744, 837, 686, 198, 692, 373, 365, 440, 488, 26, 1585, 198, 11481, 1022, 12, 291, 59, 75, 61, 421, 198, 318, 2274, 8, 277, 12, 27336, 304, 507, 198, 277, 14, 2873, 5871, 14, 740, 8, 23968, 9, 421, 198, 318, 1678, 8, 277, 12, 3762, 304, 507, 198, 509, 1022, 12, 373, 315, 3762, 14, 1744, 837, 686, 198, 692, 291, 14, 1130, 14, 362, 8, 75, 9, 365, 440, 488, 26, 1585, 198, 277, 59, 75, 61, 275, 373, 421, 199, 533, 25132, 2988, 8, 2988, 304, 199, 198, 1130, 275, 469, 507, 198, 11454, 1931, 14, 35, 7816, 2711, 26, 298, 466, 401, 507, 198, 11454, 1931, 14, 21917, 63, 17988, 26, 298, 2184, 63, 2926, 401, 507, 198, 11454, 1931, 14, 7125, 63, 4896, 2823, 63, 43, 1193, 5290, 63, 24571, 63, 52, 7648, 26, 298, 827, 15293, 63, 75, 14535, 63, 3749, 63, 353, 401, 507, 198, 11454, 1931, 14, 2514, 3064, 36, 63, 11712, 3099, 540, 26, 298, 15676, 63, 24171, 281, 401, 507, 198, 11454, 1931, 14, 2514, 3064, 36, 63, 5638, 21951, 26, 298, 15676, 63, 318, 13747, 401, 507, 198, 11454, 1931, 14, 6689, 26, 298, 929, 401, 507, 198, 11454, 1931, 14, 17988, 26, 298, 2926, 401, 507, 198, 11454, 1931, 14, 52, 7648, 26, 298, 353, 401, 507, 198, 11454, 1931, 14, 15353, 26, 298, 2619, 401, 199, 198, 93, 421, 198, 318, 636, 826, 721, 277, 12, 1559, 304, 507, 198, 4792, 11027, 826, 721, 1113, 9, 507, 198, 277, 14, 5337, 275, 413, 507, 198, 1113, 14, 4502, 63, 344, 275, 291, 14, 5337, 421, 198, 318, 1595, 63, 928, 8, 277, 12, 730, 12, 1350, 12, 1478, 12, 1347, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 1287, 63, 928, 8, 466, 12, 1350, 12, 1478, 12, 1347, 9, 421, 198, 318, 1595, 63, 500, 8, 277, 12, 730, 12, 1350, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 1287, 63, 500, 8, 466, 12, 1350, 9, 421, 198, 318, 892, 63, 4502, 8, 277, 12, 4642, 304, 507, 198, 277, 14, 5337, 847, 413, 507, 198, 4502, 14, 4502, 63, 344, 275, 291, 14, 5337, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 1222, 63, 4502, 8, 4502, 9, 421, 198, 318, 1343, 63, 5097, 8, 277, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 928, 63, 5097, 342, 421, 198, 318, 3650, 8, 277, 12, 3650, 12, 2163, 63, 2926, 29, 403, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 5097, 63, 2926, 8, 2926, 12, 2163, 63, 2926, 9, 507, 198, 277, 14, 1113, 14, 2926, 275, 3650, 507, 198, 692, 2163, 63, 2926, 365, 440, 488, 26, 686, 198, 277, 14, 1113, 14, 2184, 63, 2926, 275, 2163, 63, 2926, 421, 198, 318, 7485, 8, 277, 12, 7748, 304, 507, 198, 509, 27336, 315, 291, 14, 2873, 5871, 26, 686, 198, 23968, 14, 353, 8, 6147, 9, 421, 199, 533, 3523, 22715, 26, 199, 198, 318, 1595, 63, 928, 8, 277, 12, 730, 12, 1350, 12, 1478, 12, 1347, 304, 507, 198, 1529, 421, 198, 318, 1595, 63, 500, 8, 277, 12, 730, 12, 1350, 304, 507, 198, 1529, 421, 198, 318, 9219, 63, 2926, 8, 277, 12, 3650, 12, 2163, 63, 2926, 304, 507, 198, 1529, 421, 198, 318, 892, 63, 4502, 8, 277, 12, 4642, 304, 507, 198, 1529, 421, 198, 318, 1343, 63, 5097, 837, 507, 198, 1529, 421, 198, 318, 7485, 8, 277, 12, 7748, 304, 507, 198, 1529, 421, 199, 533, 25610, 2988, 8, 2988, 304, 199, 198, 1130, 275, 469, 507, 198, 11454, 1931, 14, 35, 1441, 63, 12118, 26, 298, 67, 867, 63, 5485, 401, 507, 198, 11454, 1931, 14, 35, 7816, 2711, 26, 298, 466, 401, 507, 198, 11454, 1931, 14, 11265, 3973, 63, 10401, 26, 298, 12650, 401, 507, 198, 11454, 1931, 14, 5801, 14881, 540, 26, 298, 5538, 401, 507, 198, 11454, 1931, 14, 14211, 63, 11625, 540, 26, 298, 1818, 63, 6147, 401, 507, 198, 11454, 1931, 14, 14211, 63, 14179, 4464, 16064, 26, 298, 32252, 5652, 401, 507, 198, 11454, 1931, 14, 2769, 29246, 63, 18061, 63, 3234, 1554, 19716, 26, 298, 426, 29515, 63, 305, 63, 26551, 401, 507, 198, 11454, 1931, 14, 21331, 1277, 4187, 26, 298, 667, 17277, 310, 63, 5337, 401, 507, 198, 11454, 1931, 14, 12903, 63, 11625, 540, 26, 298, 2246, 63, 6147, 401, 507, 198, 11454, 1931, 14, 1645, 748, 1206, 63, 14989, 26, 298, 426, 29515, 63, 3157, 401, 507, 198, 11454, 1931, 14, 3452, 47, 63, 13630, 26, 298, 31863, 401, 507, 198, 11454, 1931, 14, 16901, 63, 35, 7816, 63, 11625, 1149, 26, 298, 2019, 63, 5841, 63, 2802, 379, 401, 507, 198, 11454, 1931, 14, 4283, 10854, 4305, 26, 298, 988, 63, 6868, 63, 890, 401, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MKuranowski/WarsawGTFS
static/downloader.py
1
11293
from dataclasses import dataclass from datetime import date, datetime, timedelta from operator import itemgetter from typing import Dict, List, Optional, Set, Tuple from pytz import timezone import libarchive.public import logging import ftplib import json import re import os from .const import DIR_DOWNLOAD, DIR_CONVERTED, FTP_ADDR from .util import ensure_dir_exists """ Module containg code responsible for synchornising feeds with the FTP server. Calculates which feeds need to be converted, gets and decompresses required files. Information about specific feeds is passed around with the FileInfo objects. Main functionality is exposed in the sync_feeds() and append_modtimes() procedures. """ _logger = logging.getLogger("WarsawGTFS.downloader") @dataclass class FileInfo: """Info about a source file""" __slots__ = ("path", "version", "modtime", "start", "end", "is_converted") path: str version: str modtime: str start: date end: date is_converted: bool def read_modtimes() -> Dict[str, str]: """Reads {DIR_CONVERTED}/modtimes.json to determine modtimes of currently converted files. """ modtimes_file = os.path.join(DIR_CONVERTED, "modtimes.json") # File doesn't exist: no known files if not os.path.isfile(modtimes_file): return {} with open(str(modtimes_file), mode="r") as f: return json.load(f) def write_modtimes(x: Dict[str, str]): """Writes new content to the {DIR_CONVERTED}/modtimes.json""" with open(os.path.join(DIR_CONVERTED, "modtimes.json"), "w") as f: json.dump(x, f, indent=2) def append_modtimes(new: FileInfo): """Once a converted feed has been written to {DIR_CONVERTED}, call this function. Adds info about just converted feed to {DIR_CONVERTED}/modtimes.json/ """ c = read_modtimes() c[new.version] = new.modtime write_modtimes(c) def which_versions_ok(required_feeds: List[FileInfo], current_modtimes: Dict[str, str]) -> Set[str]: """Returns a set of versions which don't need to bee re-converted.""" ok_versions: Set[str] = set() for i in required_feeds: curr_modtime = current_modtimes.get(i.version, "") if curr_modtime == i.modtime: ok_versions.add(i.version) return ok_versions def remove_unused_converted(versions_ok: Set[str], curr_modtimes: Dict[str, str]): """Removes outdated and unnecessary feeds from {DIR_CONVERTED}, updates {DIR_CONVERTED}/modtimes.json """ _logger.info("removing unnecessary files from DIR_CONVERTED") # Calculate which files to remove all_files = set(os.listdir(DIR_CONVERTED)) expected_files = {"modtimes.json"} expected_files.update(i + ".zip" for i in versions_ok) unexpected_files = all_files.difference(expected_files) # Schedule removal of unexpected files for f in unexpected_files: os.remove(os.path.join(DIR_CONVERTED, f)) # Remove versions from curr_modtimes new_modtimes = {k: v for k, v in curr_modtimes.items() if k in versions_ok} write_modtimes(new_modtimes) def list_files(ftp: ftplib.FTP, max_files: int = 5, start_date: Optional[date] = None) -> List[FileInfo]: """Lists all files required to create a valid feed. At most {max_files} will be returned (defaults to 5). Required files are evaulated starting from start_date, which defaults to 'today' in Warsaw. """ _logger.info("calculating required files") files = ftp.mlsd() fn_match = re.compile(r"^RA\d{6}\.7z") # Ignore non-schedule files & sort files by date files = sorted( filter(lambda i: fn_match.fullmatch(str(i[0])), files), key=itemgetter(0) ) # User hasn't specified when the feed should be valid: start from 'today' (in Warsaw) if start_date is None: start_date = datetime.now(timezone("Europe/Warsaw")).date() active_files: List[FileInfo] = [] # Check which files should be converted for idx, (file_name, file_meta) in enumerate(files): file_start = datetime.strptime(file_name, "RA%y%m%d.7z").date() # Get last day when file is active (next file - 1 day) try: file_end = datetime.strptime(str(files[idx + 1][0]), "RA%y%m%d.7z").date() file_end -= timedelta(days=1) except IndexError: file_end = date.max # We don't need anything for previous dates if file_end < start_date: continue active_files.append(FileInfo( path=file_name, version=file_name[:-3], modtime=file_meta["modify"], start=file_start, end=file_end, is_converted=False )) # Limit files to max_files active_files = active_files[:max_files] # Last file shouldn't have an end_date active_files[-1].end = date.max return active_files def list_single_file(ftp: ftplib.FTP, for_day: Optional[date] = None) -> FileInfo: """Returns FileInfo about file valid in the given day (or today in Warsaw)""" # Variables from loop file_name = "" file_meta = {} file_start = date.min # List files from FTP files = ftp.mlsd() fn_match = re.compile(r"^RA\d{6}\.7z") # Ignore non-schedule files & sort files by date files = sorted( filter(lambda i: fn_match.fullmatch(str(i[0])), files), key=itemgetter(0) ) # Ensure for_day is not None if for_day is None: for_day = datetime.now(timezone("Europe/Warsaw")).date() # Iterate over files and to get one valid for `for_day` max_idx = len(files) - 1 for idx, (file_name, file_meta) in enumerate(files): file_start = datetime.strptime(file_name, "RA%y%m%d.7z").date() # If user requested file before the very first file - raise an error if idx == 0 and for_day < file_start: raise FileNotFoundError(f"No files for day {for_day.strftime('%Y-%m-%d')}") # Last file always matches if idx != max_idx: next_file_start = datetime.strptime(str(files[idx + 1][0]), "RA%y%m%d.7z").date() # Next file starts past for_day, so current file matches - break out of the loop if next_file_start > for_day: break # guard against no matches if not file_name: raise FileNotFoundError(f"Error matching files for day {for_day.strftime('%Y-%m-%d')}") # file_path, file_start and file_meta now contain info about matched file return FileInfo( path=file_name, version=file_name[:-3], modtime=file_meta["modify"], start=file_start, end=date.max, is_converted=False ) def get_and_decompress(ftp: ftplib.FTP, i: FileInfo): """Requests given file from the FTP server, and decompresses the included TXT file. Provided FileInfo object will be modified as such: - finfo.path points to the decompressed txt file - finfo.is_converted is False """ # Download the 7z file into DIR_DOWNLOAD archive_local_path = os.path.join(DIR_DOWNLOAD, i.path) txt_local_path = os.path.join(DIR_DOWNLOAD, (i.version + ".txt")) _logger.debug(f"Downloading file for version {i.version}") with open(archive_local_path, mode="wb") as f: ftp.retrbinary("RETR " + str(i.path), f.write) # Open the 7z file and decompress the txt file _logger.debug(f"Decompressing file for version {i.version}") with libarchive.public.file_reader(str(archive_local_path)) as arch: # Iterate over each file inside the archive for arch_file in arch: name = arch_file.pathname.upper() # Assert the file inside the archive is the TXT file we're looking for if name != f"{i.version}.TXT": continue # Open the target txt file with open(txt_local_path, mode="wb") as f: # Decompress the TXT file block by block and save it to the reader for block in arch_file.get_blocks(): f.write(block) # only one TXT file should be inside the archive break else: raise FileNotFoundError(f"no schedule file for ver {i.version!r} found inside " f"archive {i.path!r}") # Modify given FileInfo i.path = txt_local_path i.is_converted = False # Remove downloaded archive os.remove(archive_local_path) def mark_as_converted(i: FileInfo): """Modifies given FileInfo object to mark it as already-converted. finfo.is_converted will be Ture, and finfo.path will point to the GTFS .zip. """ i.path = os.path.join(DIR_CONVERTED, (i.version + ".zip")) i.is_converted = True def sync_files(max_files: int = 5, start_date: Optional[date] = None, reparse_all: bool = False) \ -> Tuple[List[FileInfo], bool]: """Manages required source feeds. 1. Lists required source feeds 2. Determines which feeds were already converted. 3. Removes non-required and outdated feeds 4. Downloads new/changed source feeds amd extarcts them. Returns 2 values: 1. List of *all* required feeds 2. Whether any new files were downloaded Please call append_modtimes for each sucessfuly converted file. """ # Ensure DIR_DOWNLOAD and DIR_CONVERTED exist ensure_dir_exists(DIR_DOWNLOAD, clear=True) ensure_dir_exists(DIR_CONVERTED, clear=False) with ftplib.FTP(FTP_ADDR) as ftp: ftp.login() # List source feeds required_feeds = list_files(ftp, max_files, start_date) # Determine which feeeds were already converted if not reparse_all: current_modtimes = read_modtimes() converted_versions = which_versions_ok(required_feeds, current_modtimes) else: current_modtimes = {} converted_versions = set() # Check if new files will be downloaded new_files = sum(1 for i in required_feeds if i.version not in converted_versions) # Clean-up {DIR_CONVERTED} if new_files > 0: _logger.info(f"new files to download&convert: {new_files}") remove_unused_converted(converted_versions, current_modtimes) else: _logger.info("no new files") # Download txt files or mark feeds as converted for i in required_feeds: if i.version in converted_versions: mark_as_converted(i) else: get_and_decompress(ftp, i) return required_feeds, (new_files > 0) def sync_single_file(valid_day: Optional[date] = None) -> FileInfo: """Manages required feed to create schedules for given day. Downloads and decompresses detected required file. Returns the FileInfo object containing data bout the required feed. Call append_modtimes after successfuly converting this feed. """ # Ensure DIR_DOWNLOAD and DIR_CONVERTED exist ensure_dir_exists(DIR_DOWNLOAD, clear=True) with ftplib.FTP(FTP_ADDR) as ftp: ftp.login() # Check which file to download finfo = list_single_file(ftp, valid_day) # Download said file _logger.info(f"Downloading feed for {finfo.version}") get_and_decompress(ftp, finfo) return finfo
mit
[ 504, 666, 2888, 492, 666, 533, 199, 504, 2197, 492, 1434, 12, 2197, 12, 6871, 199, 504, 4182, 492, 1242, 7416, 199, 504, 14090, 492, 7448, 12, 3820, 12, 4879, 12, 2494, 12, 11634, 199, 504, 15444, 492, 7137, 199, 646, 1973, 6404, 14, 3455, 199, 646, 2050, 199, 646, 14904, 773, 199, 646, 2022, 199, 646, 295, 199, 646, 747, 199, 199, 504, 1275, 1297, 492, 19253, 63, 24930, 12, 19253, 63, 1864, 27963, 12, 23125, 63, 7803, 199, 504, 1275, 1974, 492, 4868, 63, 694, 63, 2444, 199, 199, 624, 199, 2377, 406, 502, 316, 1233, 17845, 367, 308, 5654, 6161, 11136, 22295, 543, 314, 23125, 1654, 14, 199, 13862, 2335, 1314, 22295, 1929, 370, 506, 6702, 12, 7545, 436, 477, 863, 4357, 1415, 1584, 14, 199, 199, 4935, 3595, 2488, 22295, 365, 3032, 6818, 543, 314, 3814, 2354, 2251, 14, 199, 6756, 9330, 365, 19282, 315, 314, 7604, 63, 11522, 342, 436, 5666, 63, 1494, 4508, 342, 557, 6867, 1482, 14, 199, 624, 199, 199, 63, 2921, 275, 2050, 14, 5572, 480, 55, 285, 2231, 87, 39, 6145, 51, 14, 22846, 531, 421, 199, 32, 576, 533, 199, 533, 3814, 2354, 26, 272, 408, 2354, 3595, 282, 1350, 570, 624, 272, 636, 7257, 363, 275, 1689, 515, 401, 298, 1023, 401, 298, 1494, 521, 401, 298, 928, 401, 298, 500, 401, 298, 374, 63, 22818, 531, 339, 931, 26, 620, 272, 1015, 26, 620, 272, 3413, 521, 26, 620, 272, 1343, 26, 1434, 272, 1284, 26, 1434, 272, 365, 63, 22818, 26, 2155, 421, 199, 318, 1586, 63, 1494, 4508, 342, 1035, 7448, 59, 495, 12, 620, 2189, 272, 408, 23614, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 370, 6705, 3413, 4508, 402, 5544, 6702, 1584, 14, 272, 408, 272, 3413, 4508, 63, 493, 275, 747, 14, 515, 14, 904, 8, 3022, 63, 1864, 27963, 12, 298, 1494, 4508, 14, 1001, 531, 339, 327, 3814, 3181, 1133, 2187, 26, 949, 6040, 1584, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 1494, 4508, 63, 493, 304, 267, 372, 1052, 339, 543, 1551, 8, 495, 8, 1494, 4508, 63, 493, 395, 818, 628, 82, 531, 465, 289, 26, 267, 372, 2022, 14, 912, 8, 70, 9, 421, 199, 318, 2218, 63, 1494, 4508, 8, 88, 26, 7448, 59, 495, 12, 620, 4682, 272, 408, 20908, 892, 1564, 370, 314, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 624, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 3022, 63, 1864, 27963, 12, 298, 1494, 4508, 14, 1001, 1288, 298, 87, 531, 465, 289, 26, 267, 2022, 14, 2724, 8, 88, 12, 289, 12, 4363, 29, 18, 9, 421, 199, 318, 5666, 63, 1494, 4508, 8, 1222, 26, 3814, 2354, 304, 272, 408, 25690, 282, 6702, 4733, 965, 2757, 5313, 370, 469, 3022, 63, 1864, 27963, 1386, 1240, 642, 805, 14, 272, 15747, 2256, 3595, 2951, 6702, 4733, 370, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 15, 272, 408, 272, 286, 275, 1586, 63, 1494, 4508, 342, 272, 286, 59, 1222, 14, 1023, 61, 275, 892, 14, 1494, 521, 272, 2218, 63, 1494, 4508, 8, 67, 9, 421, 199, 318, 1314, 63, 6234, 63, 745, 8, 2427, 63, 11522, 26, 3820, 59, 1173, 2354, 467, 1993, 1453, 63, 1494, 4508, 26, 7448, 59, 495, 12, 620, 566, 1035, 2494, 59, 495, 2189, 272, 408, 3407, 282, 663, 402, 5459, 1314, 2793, 1133, 1929, 370, 506, 69, 295, 13, 22818, 1041, 272, 4112, 63, 6234, 26, 2494, 59, 495, 61, 275, 663, 342, 339, 367, 284, 315, 1415, 63, 11522, 26, 267, 8230, 63, 1494, 521, 275, 1453, 63, 1494, 4508, 14, 362, 8, 73, 14, 1023, 12, 6899, 267, 340, 8230, 63, 1494, 521, 508, 284, 14, 1494, 521, 26, 288, 4112, 63, 6234, 14, 525, 8, 73, 14, 1023, 9, 339, 372, 4112, 63, 6234, 421, 199, 318, 2813, 63, 8618, 63, 22818, 8, 6234, 63, 745, 26, 2494, 59, 495, 467, 8230, 63, 1494, 4508, 26, 7448, 59, 495, 12, 620, 4682, 272, 408, 22948, 734, 19074, 436, 23361, 22295, 687, 469, 3022, 63, 1864, 27963, 1386, 272, 7029, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 272, 408, 272, 485, 2921, 14, 815, 480, 264, 7665, 23361, 1584, 687, 19253, 63, 1864, 27963, 531, 339, 327, 12707, 1314, 1584, 370, 2813, 272, 1006, 63, 1725, 275, 663, 8, 736, 14, 7374, 8, 3022, 63, 1864, 27963, 430, 272, 1420, 63, 1725, 275, 2420, 1494, 4508, 14, 1001, 3570, 272, 1420, 63, 1725, 14, 873, 8, 73, 435, 3680, 3065, 2, 367, 284, 315, 5459, 63, 745, 9, 272, 10537, 63, 1725, 275, 1006, 63, 1725, 14, 9196, 8, 2062, 63, 1725, 9, 339, 327, 24317, 20055, 402, 10537, 1584, 272, 367, 289, 315, 10537, 63, 1725, 26, 267, 747, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 3022, 63, 1864, 27963, 12, 289, 430, 339, 327, 5852, 5459, 687, 8230, 63, 1494, 4508, 272, 892, 63, 1494, 4508, 275, 469, 75, 26, 373, 367, 1022, 12, 373, 315, 8230, 63, 1494, 4508, 14, 1744, 342, 340, 1022, 315, 5459, 63, 745, 93, 272, 2218, 63, 1494, 4508, 8, 1222, 63, 1494, 4508, 9, 421, 199, 318, 769, 63, 1725, 8, 8915, 26, 14904, 773, 14, 15123, 12, 1390, 63, 1725, 26, 1109, 275, 959, 12, 2049, 1343, 63, 602, 26, 4879, 59, 602, 61, 275, 488, 9, 1035, 3820, 59, 1173, 2354, 2189, 272, 408, 15116, 1006, 1584, 1415, 370, 1218, 282, 1686, 4733, 14, 272, 2854, 4750, 469, 988, 63, 1725, 93, 911, 506, 2138, 334, 4322, 370, 959, 680, 272, 11105, 1584, 787, 325, 3042, 8097, 6617, 687, 1343, 63, 602, 12, 1314, 4243, 370, 283, 8136, 7, 315, 644, 285, 2231, 87, 14, 272, 408, 272, 485, 2921, 14, 815, 480, 13494, 1958, 1415, 1584, 531, 272, 1584, 275, 14904, 14, 77, 478, 68, 342, 272, 4325, 63, 1431, 275, 295, 14, 2014, 8, 82, 16136, 2847, 60, 68, 91, 22, 93, 4537, 23, 90, 531, 339, 327, 14092, 2222, 13, 7211, 1584, 1253, 4069, 1584, 701, 1434, 272, 1584, 275, 3355, 8, 267, 2457 ]
[ 666, 2888, 492, 666, 533, 199, 504, 2197, 492, 1434, 12, 2197, 12, 6871, 199, 504, 4182, 492, 1242, 7416, 199, 504, 14090, 492, 7448, 12, 3820, 12, 4879, 12, 2494, 12, 11634, 199, 504, 15444, 492, 7137, 199, 646, 1973, 6404, 14, 3455, 199, 646, 2050, 199, 646, 14904, 773, 199, 646, 2022, 199, 646, 295, 199, 646, 747, 199, 199, 504, 1275, 1297, 492, 19253, 63, 24930, 12, 19253, 63, 1864, 27963, 12, 23125, 63, 7803, 199, 504, 1275, 1974, 492, 4868, 63, 694, 63, 2444, 199, 199, 624, 199, 2377, 406, 502, 316, 1233, 17845, 367, 308, 5654, 6161, 11136, 22295, 543, 314, 23125, 1654, 14, 199, 13862, 2335, 1314, 22295, 1929, 370, 506, 6702, 12, 7545, 436, 477, 863, 4357, 1415, 1584, 14, 199, 199, 4935, 3595, 2488, 22295, 365, 3032, 6818, 543, 314, 3814, 2354, 2251, 14, 199, 6756, 9330, 365, 19282, 315, 314, 7604, 63, 11522, 342, 436, 5666, 63, 1494, 4508, 342, 557, 6867, 1482, 14, 199, 624, 199, 199, 63, 2921, 275, 2050, 14, 5572, 480, 55, 285, 2231, 87, 39, 6145, 51, 14, 22846, 531, 421, 199, 32, 576, 533, 199, 533, 3814, 2354, 26, 272, 408, 2354, 3595, 282, 1350, 570, 624, 272, 636, 7257, 363, 275, 1689, 515, 401, 298, 1023, 401, 298, 1494, 521, 401, 298, 928, 401, 298, 500, 401, 298, 374, 63, 22818, 531, 339, 931, 26, 620, 272, 1015, 26, 620, 272, 3413, 521, 26, 620, 272, 1343, 26, 1434, 272, 1284, 26, 1434, 272, 365, 63, 22818, 26, 2155, 421, 199, 318, 1586, 63, 1494, 4508, 342, 1035, 7448, 59, 495, 12, 620, 2189, 272, 408, 23614, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 370, 6705, 3413, 4508, 402, 5544, 6702, 1584, 14, 272, 408, 272, 3413, 4508, 63, 493, 275, 747, 14, 515, 14, 904, 8, 3022, 63, 1864, 27963, 12, 298, 1494, 4508, 14, 1001, 531, 339, 327, 3814, 3181, 1133, 2187, 26, 949, 6040, 1584, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 1494, 4508, 63, 493, 304, 267, 372, 1052, 339, 543, 1551, 8, 495, 8, 1494, 4508, 63, 493, 395, 818, 628, 82, 531, 465, 289, 26, 267, 372, 2022, 14, 912, 8, 70, 9, 421, 199, 318, 2218, 63, 1494, 4508, 8, 88, 26, 7448, 59, 495, 12, 620, 4682, 272, 408, 20908, 892, 1564, 370, 314, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 624, 272, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 3022, 63, 1864, 27963, 12, 298, 1494, 4508, 14, 1001, 1288, 298, 87, 531, 465, 289, 26, 267, 2022, 14, 2724, 8, 88, 12, 289, 12, 4363, 29, 18, 9, 421, 199, 318, 5666, 63, 1494, 4508, 8, 1222, 26, 3814, 2354, 304, 272, 408, 25690, 282, 6702, 4733, 965, 2757, 5313, 370, 469, 3022, 63, 1864, 27963, 1386, 1240, 642, 805, 14, 272, 15747, 2256, 3595, 2951, 6702, 4733, 370, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 15, 272, 408, 272, 286, 275, 1586, 63, 1494, 4508, 342, 272, 286, 59, 1222, 14, 1023, 61, 275, 892, 14, 1494, 521, 272, 2218, 63, 1494, 4508, 8, 67, 9, 421, 199, 318, 1314, 63, 6234, 63, 745, 8, 2427, 63, 11522, 26, 3820, 59, 1173, 2354, 467, 1993, 1453, 63, 1494, 4508, 26, 7448, 59, 495, 12, 620, 566, 1035, 2494, 59, 495, 2189, 272, 408, 3407, 282, 663, 402, 5459, 1314, 2793, 1133, 1929, 370, 506, 69, 295, 13, 22818, 1041, 272, 4112, 63, 6234, 26, 2494, 59, 495, 61, 275, 663, 342, 339, 367, 284, 315, 1415, 63, 11522, 26, 267, 8230, 63, 1494, 521, 275, 1453, 63, 1494, 4508, 14, 362, 8, 73, 14, 1023, 12, 6899, 267, 340, 8230, 63, 1494, 521, 508, 284, 14, 1494, 521, 26, 288, 4112, 63, 6234, 14, 525, 8, 73, 14, 1023, 9, 339, 372, 4112, 63, 6234, 421, 199, 318, 2813, 63, 8618, 63, 22818, 8, 6234, 63, 745, 26, 2494, 59, 495, 467, 8230, 63, 1494, 4508, 26, 7448, 59, 495, 12, 620, 4682, 272, 408, 22948, 734, 19074, 436, 23361, 22295, 687, 469, 3022, 63, 1864, 27963, 1386, 272, 7029, 469, 3022, 63, 1864, 27963, 5995, 1494, 4508, 14, 1001, 272, 408, 272, 485, 2921, 14, 815, 480, 264, 7665, 23361, 1584, 687, 19253, 63, 1864, 27963, 531, 339, 327, 12707, 1314, 1584, 370, 2813, 272, 1006, 63, 1725, 275, 663, 8, 736, 14, 7374, 8, 3022, 63, 1864, 27963, 430, 272, 1420, 63, 1725, 275, 2420, 1494, 4508, 14, 1001, 3570, 272, 1420, 63, 1725, 14, 873, 8, 73, 435, 3680, 3065, 2, 367, 284, 315, 5459, 63, 745, 9, 272, 10537, 63, 1725, 275, 1006, 63, 1725, 14, 9196, 8, 2062, 63, 1725, 9, 339, 327, 24317, 20055, 402, 10537, 1584, 272, 367, 289, 315, 10537, 63, 1725, 26, 267, 747, 14, 2168, 8, 736, 14, 515, 14, 904, 8, 3022, 63, 1864, 27963, 12, 289, 430, 339, 327, 5852, 5459, 687, 8230, 63, 1494, 4508, 272, 892, 63, 1494, 4508, 275, 469, 75, 26, 373, 367, 1022, 12, 373, 315, 8230, 63, 1494, 4508, 14, 1744, 342, 340, 1022, 315, 5459, 63, 745, 93, 272, 2218, 63, 1494, 4508, 8, 1222, 63, 1494, 4508, 9, 421, 199, 318, 769, 63, 1725, 8, 8915, 26, 14904, 773, 14, 15123, 12, 1390, 63, 1725, 26, 1109, 275, 959, 12, 2049, 1343, 63, 602, 26, 4879, 59, 602, 61, 275, 488, 9, 1035, 3820, 59, 1173, 2354, 2189, 272, 408, 15116, 1006, 1584, 1415, 370, 1218, 282, 1686, 4733, 14, 272, 2854, 4750, 469, 988, 63, 1725, 93, 911, 506, 2138, 334, 4322, 370, 959, 680, 272, 11105, 1584, 787, 325, 3042, 8097, 6617, 687, 1343, 63, 602, 12, 1314, 4243, 370, 283, 8136, 7, 315, 644, 285, 2231, 87, 14, 272, 408, 272, 485, 2921, 14, 815, 480, 13494, 1958, 1415, 1584, 531, 272, 1584, 275, 14904, 14, 77, 478, 68, 342, 272, 4325, 63, 1431, 275, 295, 14, 2014, 8, 82, 16136, 2847, 60, 68, 91, 22, 93, 4537, 23, 90, 531, 339, 327, 14092, 2222, 13, 7211, 1584, 1253, 4069, 1584, 701, 1434, 272, 1584, 275, 3355, 8, 267, 2457, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nextgis/nextgisweb
nextgisweb/vector_layer/test/test_source_error.py
1
6886
# -*- coding: utf-8 -*- from __future__ import division, absolute_import, print_function, unicode_literals from uuid import uuid4 import six import pytest from osgeo import ogr from nextgisweb.models import DBSession from nextgisweb.auth import User from nextgisweb.compat import Path from nextgisweb.core.exception import ValidationError from nextgisweb.vector_layer import VectorLayer from nextgisweb.spatial_ref_sys import SRS path = Path(__file__).parent / 'data' / 'errors' # List of creation test cases: file name, creation options, and final checks. CREATE_TEST_PARAMS = ( ( 'geom-collection.geojson', dict(), dict(exception=ValidationError), ), ( 'geom-collection.geojson', dict(fix_errors='SAFE'), dict(feature_count=2), ), ( 'incomplete-linestring.geojson', dict(fix_errors='LOSSY'), dict(exception=ValidationError), ), ( 'incomplete-linestring.geojson', dict(skip_errors=True), dict(feature_count=1) ), ( 'incomplete-polygon.geojson', dict(fix_errors='LOSSY'), dict(exception=ValidationError), ), ( 'mixed-feature-geom.geojson', dict(geometry_type='POINT', skip_other_geometry_types=True), dict(geometry_type='MULTIPOINT', feature_count=2), ), ( # The second MULTIPOINT geometry must be converted to a SINGLE geometry. # The first POINT should be taken in LOSSY mode. 'mixed-feature-geom.geojson', dict( geometry_type='POINT', skip_other_geometry_types=True, fix_errors='LOSSY', is_multi=False), dict(geometry_type='POINT', feature_count=2), ), ( # The layer has only one LINESTRING geometry and it's valid. 'mixed-feature-geom.geojson', dict(geometry_type='LINESTRING', skip_other_geometry_types=True), dict(geometry_type='LINESTRING', feature_count=1), ), ( 'non-multi-geom.geojson', dict(), dict(geometry_type='MULTIPOINT', feature_count=2), ), ( 'null-geom.geojson', dict(skip_other_geometry_types=True), dict(geometry_type='POINT', feature_count=1), ), ( # Geometries with topology errors are accepted. 'self-intersection.geojson', dict(fix_errors=None), dict(feature_count=1), ), # ( # 'self-intersection.geojson', # dict(fix_errors='LOSSY'), # dict(geometry_type='POLYGON', feature_count=1), # ), ( 'single-geom-collection.geojson', dict(geometry_type='POINT', fix_errors='SAFE'), dict(geometry_type='POINT', feature_count=1), ), ( 'single-geom-collection.geojson', dict(geometry_type='POINT', skip_other_geometry_types=True), dict(geometry_type='POINT', feature_count=0), ), ( 'single-geom-collection.geojson', dict(geometry_type='POINT', fix_errors='LOSSSY'), dict(geometry_type='POINT', feature_count=1), ), ( 'single-geom-collection.geojson', dict(geometry_type='LINESTRING', fix_errors='SAFE'), dict(exception=ValidationError), ), ( 'single-geom-collection.geojson', dict(geometry_type='LINESTRING', fix_errors='LOSSY'), dict(geometry_type='LINESTRING', feature_count=1), ), ( # It's not possible to chose geometry type here. 'empty.geojson', dict(), dict(exception=ValidationError), ), ( # An empty layer with MULTIPOINTZ must be created. 'empty.geojson', dict(geometry_type='POINT', is_multi=True, has_z=True), dict(geometry_type='MULTIPOINTZ', feature_count=0), ), ( # The unclosed ring must be reported as an error. 'unclosed-ring.geojson', dict(), dict(exception=ValidationError), ), ( # The unclosed ring must be closed in SAFE mode, QGIS does it sielently. 'unclosed-ring.geojson', dict(fix_errors='SAFE'), dict(feature_count=1), ), ( # Just check loading of POINTZ layers. 'pointz.geojson', dict(geometry_type='POINT'), dict(geometry_type='POINTZ', feature_count=1), ), ( # Explicit setting of geometry type. 'pointz.geojson', dict(geometry_type='POINT', is_multi=False, has_z=True), dict(geometry_type='POINTZ', feature_count=1), ), ( # Z coordinate should be stripped here. 'pointz.geojson', dict(geometry_type='POINT', has_z=False, fix_errors='LOSSY'), dict(geometry_type='POINT', feature_count=1), ), ) @pytest.mark.parametrize('filename, options, checks', CREATE_TEST_PARAMS) def test_create(filename, options, checks, ngw_resource_group, ngw_txn): obj = VectorLayer( parent_id=ngw_resource_group, display_name='vector_layer', owner_user=User.by_keyname('administrator'), srs=SRS.filter_by(id=3857).one(), tbl_uuid=six.text_type(uuid4().hex) ).persist() src = str(path / filename) ds = ogr.Open(src) layer = ds.GetLayer(0) geom_cast_params = dict( geometry_type=options.get('geometry_type'), is_multi=options.get('is_multi'), has_z=options.get('has_z')) def setup_and_load(): setup_kwargs = dict() load_kwargs = dict() if 'skip_other_geometry_types' in options: setup_kwargs['skip_other_geometry_types'] = options['skip_other_geometry_types'] load_kwargs['skip_other_geometry_types'] = options['skip_other_geometry_types'] if 'fix_errors' in options: load_kwargs['fix_errors'] = options['fix_errors'] if 'skip_errors' in options: load_kwargs['skip_errors'] = options['skip_errors'] obj.setup_from_ogr(layer, geom_cast_params=geom_cast_params, **setup_kwargs) obj.load_from_ogr(layer, **load_kwargs) if 'exception' in checks: with pytest.raises(checks['exception']): setup_and_load() DBSession.expunge(obj) else: setup_and_load() DBSession.flush() if 'geometry_type' in checks: exp_geometry_type = checks['geometry_type'] assert obj.geometry_type == exp_geometry_type, \ "Expected geometry type was {} but actually got {}".format( exp_geometry_type, obj.geometry_type) if 'feature_count' in checks: exp_feature_count = checks['feature_count'] query = obj.feature_query() feature_count = query().total_count assert feature_count == exp_feature_count, \ "Expected feature count was {} but got {}".format( exp_feature_count, feature_count)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 504, 5377, 492, 5377, 20, 199, 646, 3816, 199, 199, 646, 4613, 199, 504, 747, 6721, 492, 20713, 199, 199, 504, 2163, 5668, 2520, 14, 992, 492, 6249, 4434, 199, 504, 2163, 5668, 2520, 14, 1178, 492, 2876, 199, 504, 2163, 5668, 2520, 14, 5819, 492, 6912, 199, 504, 2163, 5668, 2520, 14, 1018, 14, 1971, 492, 8505, 199, 504, 2163, 5668, 2520, 14, 4106, 63, 1897, 492, 11388, 5003, 199, 504, 2163, 5668, 2520, 14, 11679, 63, 1121, 63, 1274, 492, 12765, 51, 199, 199, 515, 275, 6912, 3460, 493, 28634, 1708, 1182, 283, 576, 7, 1182, 283, 2550, 7, 421, 199, 3, 3820, 402, 7143, 511, 5560, 26, 570, 536, 12, 7143, 1511, 12, 436, 4242, 5920, 14, 199, 8366, 63, 2864, 63, 17978, 275, 334, 272, 334, 267, 283, 6481, 13, 3627, 14, 27043, 297, 4960, 1211, 1062, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 283, 6481, 13, 3627, 14, 27043, 297, 4960, 1211, 8, 970, 63, 2550, 534, 27657, 659, 267, 1211, 8, 4445, 63, 835, 29, 18, 395, 272, 2318, 339, 334, 267, 283, 24575, 13, 604, 875, 14, 27043, 297, 267, 1211, 8, 970, 63, 2550, 534, 28010, 57, 659, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 283, 24575, 13, 604, 875, 14, 27043, 297, 267, 1211, 8, 2759, 63, 2550, 29, 549, 395, 267, 1211, 8, 4445, 63, 835, 29, 17, 9, 272, 2318, 339, 334, 267, 283, 24575, 13, 16295, 14, 27043, 297, 267, 1211, 8, 970, 63, 2550, 534, 28010, 57, 659, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 283, 10455, 13, 4445, 13, 6481, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 21389, 7217, 297, 3878, 63, 835, 29, 18, 395, 272, 2318, 339, 334, 267, 327, 710, 3499, 24895, 41, 7217, 3400, 1471, 506, 6702, 370, 282, 8655, 3400, 14, 267, 327, 710, 1642, 3625, 2919, 1077, 506, 9394, 315, 9102, 57, 818, 14, 267, 283, 10455, 13, 4445, 13, 6481, 14, 27043, 297, 267, 1211, 8, 288, 3400, 63, 466, 534, 7217, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 12, 288, 5325, 63, 2550, 534, 28010, 57, 297, 365, 63, 3029, 29, 797, 395, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 18, 395, 272, 2318, 272, 334, 267, 327, 710, 4045, 965, 1454, 1373, 491, 568, 29780, 3400, 436, 652, 1159, 1686, 14, 267, 283, 10455, 13, 4445, 13, 6481, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 339, 334, 267, 283, 2865, 13, 3029, 13, 6481, 14, 27043, 297, 267, 1211, 1062, 267, 1211, 8, 7660, 63, 466, 534, 21389, 7217, 297, 3878, 63, 835, 29, 18, 395, 272, 2318, 339, 334, 267, 283, 2307, 13, 6481, 14, 27043, 297, 267, 1211, 8, 2759, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 339, 334, 267, 327, 5346, 14100, 543, 14611, 2552, 787, 10226, 14, 267, 283, 277, 13, 12569, 14, 27043, 297, 267, 1211, 8, 970, 63, 2550, 29, 403, 395, 267, 1211, 8, 4445, 63, 835, 29, 17, 395, 272, 2318, 339, 327, 334, 272, 327, 258, 283, 277, 13, 12569, 14, 27043, 297, 272, 327, 258, 1211, 8, 970, 63, 2550, 534, 28010, 57, 659, 272, 327, 258, 1211, 8, 7660, 63, 466, 534, 23602, 297, 3878, 63, 835, 29, 17, 395, 272, 327, 2318, 339, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 5325, 63, 2550, 534, 27657, 659, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 16, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 5325, 63, 2550, 534, 28010, 4669, 659, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 5325, 63, 2550, 534, 27657, 659, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 5325, 63, 2550, 534, 28010, 57, 659, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 339, 334, 267, 327, 2779, 1159, 440, 3962, 370, 2468, 261, 3400, 730, 2348, 14, 267, 283, 1667, 14, 27043, 297, 267, 1211, 1062, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 272, 334, 267, 327, 1626, 2701, 4045, 543, 24895, 41, 7217, 58, 1471, 506, 2737, 14, 267, 283, 1667, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 365, 63, 3029, 29, 549, 12, 965, 63, 90, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 21389, 7217, 58, 297, 3878, 63, 835, 29, 16, 395, 272, 2318, 339, 334, 267, 327, 710, 625, 5938, 12133, 1471, 506, 14581, 465, 376, 1125, 14, 267, 283, 1097, 320, 939, 13, 5985, 14, 27043, 297, 267, 1211, 1062, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 327, 710, 625, 5938 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 504, 5377, 492, 5377, 20, 199, 646, 3816, 199, 199, 646, 4613, 199, 504, 747, 6721, 492, 20713, 199, 199, 504, 2163, 5668, 2520, 14, 992, 492, 6249, 4434, 199, 504, 2163, 5668, 2520, 14, 1178, 492, 2876, 199, 504, 2163, 5668, 2520, 14, 5819, 492, 6912, 199, 504, 2163, 5668, 2520, 14, 1018, 14, 1971, 492, 8505, 199, 504, 2163, 5668, 2520, 14, 4106, 63, 1897, 492, 11388, 5003, 199, 504, 2163, 5668, 2520, 14, 11679, 63, 1121, 63, 1274, 492, 12765, 51, 199, 199, 515, 275, 6912, 3460, 493, 28634, 1708, 1182, 283, 576, 7, 1182, 283, 2550, 7, 421, 199, 3, 3820, 402, 7143, 511, 5560, 26, 570, 536, 12, 7143, 1511, 12, 436, 4242, 5920, 14, 199, 8366, 63, 2864, 63, 17978, 275, 334, 272, 334, 267, 283, 6481, 13, 3627, 14, 27043, 297, 4960, 1211, 1062, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 283, 6481, 13, 3627, 14, 27043, 297, 4960, 1211, 8, 970, 63, 2550, 534, 27657, 659, 267, 1211, 8, 4445, 63, 835, 29, 18, 395, 272, 2318, 339, 334, 267, 283, 24575, 13, 604, 875, 14, 27043, 297, 267, 1211, 8, 970, 63, 2550, 534, 28010, 57, 659, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 283, 24575, 13, 604, 875, 14, 27043, 297, 267, 1211, 8, 2759, 63, 2550, 29, 549, 395, 267, 1211, 8, 4445, 63, 835, 29, 17, 9, 272, 2318, 339, 334, 267, 283, 24575, 13, 16295, 14, 27043, 297, 267, 1211, 8, 970, 63, 2550, 534, 28010, 57, 659, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 283, 10455, 13, 4445, 13, 6481, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 21389, 7217, 297, 3878, 63, 835, 29, 18, 395, 272, 2318, 339, 334, 267, 327, 710, 3499, 24895, 41, 7217, 3400, 1471, 506, 6702, 370, 282, 8655, 3400, 14, 267, 327, 710, 1642, 3625, 2919, 1077, 506, 9394, 315, 9102, 57, 818, 14, 267, 283, 10455, 13, 4445, 13, 6481, 14, 27043, 297, 267, 1211, 8, 288, 3400, 63, 466, 534, 7217, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 12, 288, 5325, 63, 2550, 534, 28010, 57, 297, 365, 63, 3029, 29, 797, 395, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 18, 395, 272, 2318, 272, 334, 267, 327, 710, 4045, 965, 1454, 1373, 491, 568, 29780, 3400, 436, 652, 1159, 1686, 14, 267, 283, 10455, 13, 4445, 13, 6481, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 339, 334, 267, 283, 2865, 13, 3029, 13, 6481, 14, 27043, 297, 267, 1211, 1062, 267, 1211, 8, 7660, 63, 466, 534, 21389, 7217, 297, 3878, 63, 835, 29, 18, 395, 272, 2318, 339, 334, 267, 283, 2307, 13, 6481, 14, 27043, 297, 267, 1211, 8, 2759, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 339, 334, 267, 327, 5346, 14100, 543, 14611, 2552, 787, 10226, 14, 267, 283, 277, 13, 12569, 14, 27043, 297, 267, 1211, 8, 970, 63, 2550, 29, 403, 395, 267, 1211, 8, 4445, 63, 835, 29, 17, 395, 272, 2318, 339, 327, 334, 272, 327, 258, 283, 277, 13, 12569, 14, 27043, 297, 272, 327, 258, 1211, 8, 970, 63, 2550, 534, 28010, 57, 659, 272, 327, 258, 1211, 8, 7660, 63, 466, 534, 23602, 297, 3878, 63, 835, 29, 17, 395, 272, 327, 2318, 339, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 5325, 63, 2550, 534, 27657, 659, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3372, 63, 1848, 63, 7660, 63, 1313, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 16, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 5325, 63, 2550, 534, 28010, 4669, 659, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 5325, 63, 2550, 534, 27657, 659, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 272, 334, 267, 283, 4780, 13, 6481, 13, 3627, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 5325, 63, 2550, 534, 28010, 57, 659, 267, 1211, 8, 7660, 63, 466, 534, 6143, 29780, 297, 3878, 63, 835, 29, 17, 395, 272, 2318, 339, 334, 267, 327, 2779, 1159, 440, 3962, 370, 2468, 261, 3400, 730, 2348, 14, 267, 283, 1667, 14, 27043, 297, 267, 1211, 1062, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 272, 334, 267, 327, 1626, 2701, 4045, 543, 24895, 41, 7217, 58, 1471, 506, 2737, 14, 267, 283, 1667, 14, 27043, 297, 267, 1211, 8, 7660, 63, 466, 534, 7217, 297, 365, 63, 3029, 29, 549, 12, 965, 63, 90, 29, 549, 395, 267, 1211, 8, 7660, 63, 466, 534, 21389, 7217, 58, 297, 3878, 63, 835, 29, 16, 395, 272, 2318, 339, 334, 267, 327, 710, 625, 5938, 12133, 1471, 506, 14581, 465, 376, 1125, 14, 267, 283, 1097, 320, 939, 13, 5985, 14, 27043, 297, 267, 1211, 1062, 267, 1211, 8, 1971, 29, 8172, 395, 272, 2318, 339, 334, 267, 327, 710, 625, 5938, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
glogiotatidis/compose
compose/container.py
39
5882
from __future__ import unicode_literals from __future__ import absolute_import import six from functools import reduce from .const import LABEL_CONTAINER_NUMBER, LABEL_SERVICE class Container(object): """ Represents a Docker container, constructed from the output of GET /containers/:id:/json. """ def __init__(self, client, dictionary, has_been_inspected=False): self.client = client self.dictionary = dictionary self.has_been_inspected = has_been_inspected @classmethod def from_ps(cls, client, dictionary, **kwargs): """ Construct a container object from the output of GET /containers/json. """ new_dictionary = { 'Id': dictionary['Id'], 'Image': dictionary['Image'], 'Name': '/' + get_container_name(dictionary), } return cls(client, new_dictionary, **kwargs) @classmethod def from_id(cls, client, id): return cls(client, client.inspect_container(id)) @classmethod def create(cls, client, **options): response = client.create_container(**options) return cls.from_id(client, response['Id']) @property def id(self): return self.dictionary['Id'] @property def image(self): return self.dictionary['Image'] @property def image_config(self): return self.client.inspect_image(self.image) @property def short_id(self): return self.id[:10] @property def name(self): return self.dictionary['Name'][1:] @property def name_without_project(self): return '{0}_{1}'.format(self.labels.get(LABEL_SERVICE), self.number) @property def number(self): number = self.labels.get(LABEL_CONTAINER_NUMBER) if not number: raise ValueError("Container {0} does not have a {1} label".format( self.short_id, LABEL_CONTAINER_NUMBER)) return int(number) @property def ports(self): self.inspect_if_not_inspected() return self.get('NetworkSettings.Ports') or {} @property def human_readable_ports(self): def format_port(private, public): if not public: return private return '{HostIp}:{HostPort}->{private}'.format( private=private, **public[0]) return ', '.join(format_port(*item) for item in sorted(six.iteritems(self.ports))) @property def labels(self): return self.get('Config.Labels') or {} @property def log_config(self): return self.get('HostConfig.LogConfig') or None @property def human_readable_state(self): if self.is_running: return 'Ghost' if self.get('State.Ghost') else 'Up' else: return 'Exit %s' % self.get('State.ExitCode') @property def human_readable_command(self): entrypoint = self.get('Config.Entrypoint') or [] cmd = self.get('Config.Cmd') or [] return ' '.join(entrypoint + cmd) @property def environment(self): return dict(var.split("=", 1) for var in self.get('Config.Env') or []) @property def is_running(self): return self.get('State.Running') def get(self, key): """Return a value from the container or None if the value is not set. :param key: a string using dotted notation for nested dictionary lookups """ self.inspect_if_not_inspected() def get_value(dictionary, key): return (dictionary or {}).get(key) return reduce(get_value, key.split('.'), self.dictionary) def get_local_port(self, port, protocol='tcp'): port = self.ports.get("%s/%s" % (port, protocol)) return "{HostIp}:{HostPort}".format(**port[0]) if port else None def start(self, **options): return self.client.start(self.id, **options) def stop(self, **options): return self.client.stop(self.id, **options) def kill(self, **options): return self.client.kill(self.id, **options) def restart(self, **options): return self.client.restart(self.id, **options) def remove(self, **options): return self.client.remove_container(self.id, **options) def inspect_if_not_inspected(self): if not self.has_been_inspected: self.inspect() def wait(self): return self.client.wait(self.id) def logs(self, *args, **kwargs): return self.client.logs(self.id, *args, **kwargs) def inspect(self): self.dictionary = self.client.inspect_container(self.id) self.has_been_inspected = True return self.dictionary # TODO: only used by tests, move to test module def links(self): links = [] for container in self.client.containers(): for name in container['Names']: bits = name.split('/') if len(bits) > 2 and bits[1] == self.name: links.append(bits[2]) return links def attach(self, *args, **kwargs): return self.client.attach(self.id, *args, **kwargs) def attach_socket(self, **kwargs): return self.client.attach_socket(self.id, **kwargs) def __repr__(self): return '<Container: %s (%s)>' % (self.name, self.id[:6]) def __eq__(self, other): if type(self) != type(other): return False return self.id == other.id def __hash__(self): return self.id.__hash__() def get_container_name(container): if not container.get('Name') and not container.get('Names'): return None # inspect if 'Name' in container: return container['Name'] # ps shortest_name = min(container['Names'], key=lambda n: len(n.split('/'))) return shortest_name.split('/')[-1]
apache-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 3816, 199, 504, 9143, 492, 7114, 199, 199, 504, 1275, 1297, 492, 491, 1217, 2901, 63, 31250, 63, 9190, 12, 491, 1217, 2901, 63, 10486, 421, 199, 533, 15395, 8, 785, 304, 272, 408, 272, 21591, 282, 22067, 3970, 12, 14701, 687, 314, 1072, 402, 272, 9576, 1182, 13577, 22075, 344, 11254, 1001, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1890, 12, 2600, 12, 965, 63, 1235, 287, 63, 3617, 1043, 29, 797, 304, 267, 291, 14, 1258, 275, 1890, 267, 291, 14, 9086, 275, 2600, 267, 291, 14, 1989, 63, 1235, 287, 63, 3617, 1043, 275, 965, 63, 1235, 287, 63, 3617, 1043, 339, 768, 3744, 272, 347, 687, 63, 1190, 8, 1886, 12, 1890, 12, 2600, 12, 1011, 958, 304, 267, 408, 267, 9215, 282, 3970, 909, 687, 314, 1072, 402, 9576, 1182, 13577, 15, 1001, 14, 267, 408, 267, 892, 63, 9086, 275, 469, 288, 283, 1304, 356, 2600, 459, 1304, 995, 288, 283, 3491, 356, 2600, 459, 3491, 995, 288, 283, 985, 356, 7324, 435, 664, 63, 3600, 63, 354, 8, 9086, 395, 267, 789, 267, 372, 843, 8, 1258, 12, 892, 63, 9086, 12, 1011, 958, 9, 339, 768, 3744, 272, 347, 687, 63, 344, 8, 1886, 12, 1890, 12, 1305, 304, 267, 372, 843, 8, 1258, 12, 1890, 14, 10955, 63, 3600, 8, 344, 430, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 1890, 12, 1011, 1419, 304, 267, 1177, 275, 1890, 14, 981, 63, 3600, 3682, 1419, 9, 267, 372, 843, 14, 504, 63, 344, 8, 1258, 12, 1177, 459, 1304, 1105, 339, 768, 1829, 272, 347, 1305, 8, 277, 304, 267, 372, 291, 14, 9086, 459, 1304, 418, 339, 768, 1829, 272, 347, 1834, 8, 277, 304, 267, 372, 291, 14, 9086, 459, 3491, 418, 339, 768, 1829, 272, 347, 1834, 63, 888, 8, 277, 304, 267, 372, 291, 14, 1258, 14, 10955, 63, 1569, 8, 277, 14, 1569, 9, 339, 768, 1829, 272, 347, 3974, 63, 344, 8, 277, 304, 267, 372, 291, 14, 344, 1491, 709, 61, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 9086, 459, 985, 3488, 17, 2938, 339, 768, 1829, 272, 347, 536, 63, 7395, 63, 1715, 8, 277, 304, 267, 372, 5041, 16, 26738, 17, 5285, 908, 8, 277, 14, 3512, 14, 362, 8, 13837, 63, 10486, 395, 291, 14, 1955, 9, 339, 768, 1829, 272, 347, 1329, 8, 277, 304, 267, 1329, 275, 291, 14, 3512, 14, 362, 8, 13837, 63, 31250, 63, 9190, 9, 267, 340, 440, 1329, 26, 288, 746, 1722, 480, 4076, 469, 16, 93, 1630, 440, 1172, 282, 469, 17, 93, 1768, 1674, 908, 8, 355, 291, 14, 3612, 63, 344, 12, 491, 1217, 2901, 63, 31250, 63, 9190, 430, 267, 372, 1109, 8, 1955, 9, 339, 768, 1829, 272, 347, 8873, 8, 277, 304, 267, 291, 14, 10955, 63, 692, 63, 1397, 63, 3617, 1043, 342, 267, 372, 291, 14, 362, 360, 4491, 5268, 14, 25573, 358, 503, 1052, 339, 768, 1829, 272, 347, 11779, 63, 11875, 63, 5203, 8, 277, 304, 267, 347, 1475, 63, 719, 8, 4239, 12, 4575, 304, 288, 340, 440, 4575, 26, 355, 372, 5726, 288, 372, 5041, 4965, 6583, 16495, 4965, 4313, 93, 5118, 91, 4239, 5285, 908, 8, 355, 5726, 29, 4239, 12, 1011, 3455, 59, 16, 566, 398, 372, 1656, 1987, 904, 8, 908, 63, 719, 2031, 1053, 9, 586, 367, 1242, 315, 3355, 8, 4174, 14, 4611, 8, 277, 14, 5203, 1724, 339, 768, 1829, 272, 347, 3628, 8, 277, 304, 267, 372, 291, 14, 362, 360, 2028, 14, 14016, 358, 503, 1052, 339, 768, 1829, 272, 347, 943, 63, 888, 8, 277, 304, 267, 372, 291, 14, 362, 360, 4965, 2028, 14, 2445, 2028, 358, 503, 488, 339, 768, 1829, 272, 347, 11779, 63, 11875, 63, 929, 8, 277, 304, 267, 340, 291, 14, 374, 63, 5720, 26, 288, 372, 283, 39, 1102, 7, 340, 291, 14, 362, 360, 2223, 14, 39, 1102, 358, 587, 283, 1721, 7, 267, 587, 26, 288, 372, 283, 6699, 450, 83, 7, 450, 291, 14, 362, 360, 2223, 14, 6699, 3034, 358, 339, 768, 1829, 272, 347, 11779, 63, 11875, 63, 1531, 8, 277, 304, 267, 2397, 1403, 275, 291, 14, 362, 360, 2028, 14, 3900, 1403, 358, 503, 942, 267, 2088, 275, 291, 14, 362, 360, 2028, 14, 7874, 358, 503, 942, 267, 372, 283, 1987, 904, 8, 2373, 1403, 435, 2088, 9, 339, 768, 1829, 272, 347, 3734, 8, 277, 304, 267, 372, 1211, 8, 1391, 14, 1294, 480, 11107, 413, 9, 367, 2729, 315, 291, 14, 362, 360, 2028, 14, 7744, 358, 503, 3073, 339, 768, 1829, 272, 347, 365, 63, 5720, 8, 277, 304, 267, 372, 291, 14, 362, 360, 2223, 14, 9602, 358, 339, 347, 664, 8, 277, 12, 790, 304, 267, 408, 1767, 282, 574, 687, 314, 3970, 503, 488, 340, 314, 574, 365, 440, 663, 14, 398, 520, 635, 790, 26, 282, 1059, 1808, 18947, 15843, 367, 6032, 2600, 490, 16807, 267, 408, 267, 291, 14, 10955, 63, 692, 63, 1397, 63, 3617, 1043, 342, 398, 347, 664, 63, 585, 8, 9086, 12, 790, 304, 288, 372, 334, 9086, 503, 13056, 362, 8, 498, 9, 398, 372, 7114, 8, 362, 63, 585, 12, 790, 14, 1294, 5175, 659, 291, 14, 9086, 9, 339, 347, 664, 63, 1832, 63, 719, 8, 277, 12, 1844, 12, 4113, 534, 8815, 735, 267, 1844, 275, 291, 14, 5203, 14, 362, 3647, 83, 3149, 83, 2, 450, 334, 719, 12, 4113, 430, 267, 372, 5310, 4965, 6583, 16495, 4965, 4313, 5469, 908, 3682, 719, 59, 16, 566, 340, 1844, 587, 488, 339, 347, 1343, 8, 277, 12, 1011, 1419, 304, 267, 372, 291, 14, 1258, 14, 928, 8, 277, 14, 344, 12, 1011, 1419, 9, 339, 347, 3631, 8, 277, 12, 1011, 1419, 304, 267, 372, 291, 14, 1258, 14, 2379, 8, 277, 14, 344, 12, 1011, 1419, 9, 339, 347, 14561, 8, 277, 12, 1011, 1419, 304, 267, 372, 291, 14, 1258, 14, 8997, 8 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 3816, 199, 504, 9143, 492, 7114, 199, 199, 504, 1275, 1297, 492, 491, 1217, 2901, 63, 31250, 63, 9190, 12, 491, 1217, 2901, 63, 10486, 421, 199, 533, 15395, 8, 785, 304, 272, 408, 272, 21591, 282, 22067, 3970, 12, 14701, 687, 314, 1072, 402, 272, 9576, 1182, 13577, 22075, 344, 11254, 1001, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1890, 12, 2600, 12, 965, 63, 1235, 287, 63, 3617, 1043, 29, 797, 304, 267, 291, 14, 1258, 275, 1890, 267, 291, 14, 9086, 275, 2600, 267, 291, 14, 1989, 63, 1235, 287, 63, 3617, 1043, 275, 965, 63, 1235, 287, 63, 3617, 1043, 339, 768, 3744, 272, 347, 687, 63, 1190, 8, 1886, 12, 1890, 12, 2600, 12, 1011, 958, 304, 267, 408, 267, 9215, 282, 3970, 909, 687, 314, 1072, 402, 9576, 1182, 13577, 15, 1001, 14, 267, 408, 267, 892, 63, 9086, 275, 469, 288, 283, 1304, 356, 2600, 459, 1304, 995, 288, 283, 3491, 356, 2600, 459, 3491, 995, 288, 283, 985, 356, 7324, 435, 664, 63, 3600, 63, 354, 8, 9086, 395, 267, 789, 267, 372, 843, 8, 1258, 12, 892, 63, 9086, 12, 1011, 958, 9, 339, 768, 3744, 272, 347, 687, 63, 344, 8, 1886, 12, 1890, 12, 1305, 304, 267, 372, 843, 8, 1258, 12, 1890, 14, 10955, 63, 3600, 8, 344, 430, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 1890, 12, 1011, 1419, 304, 267, 1177, 275, 1890, 14, 981, 63, 3600, 3682, 1419, 9, 267, 372, 843, 14, 504, 63, 344, 8, 1258, 12, 1177, 459, 1304, 1105, 339, 768, 1829, 272, 347, 1305, 8, 277, 304, 267, 372, 291, 14, 9086, 459, 1304, 418, 339, 768, 1829, 272, 347, 1834, 8, 277, 304, 267, 372, 291, 14, 9086, 459, 3491, 418, 339, 768, 1829, 272, 347, 1834, 63, 888, 8, 277, 304, 267, 372, 291, 14, 1258, 14, 10955, 63, 1569, 8, 277, 14, 1569, 9, 339, 768, 1829, 272, 347, 3974, 63, 344, 8, 277, 304, 267, 372, 291, 14, 344, 1491, 709, 61, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 14, 9086, 459, 985, 3488, 17, 2938, 339, 768, 1829, 272, 347, 536, 63, 7395, 63, 1715, 8, 277, 304, 267, 372, 5041, 16, 26738, 17, 5285, 908, 8, 277, 14, 3512, 14, 362, 8, 13837, 63, 10486, 395, 291, 14, 1955, 9, 339, 768, 1829, 272, 347, 1329, 8, 277, 304, 267, 1329, 275, 291, 14, 3512, 14, 362, 8, 13837, 63, 31250, 63, 9190, 9, 267, 340, 440, 1329, 26, 288, 746, 1722, 480, 4076, 469, 16, 93, 1630, 440, 1172, 282, 469, 17, 93, 1768, 1674, 908, 8, 355, 291, 14, 3612, 63, 344, 12, 491, 1217, 2901, 63, 31250, 63, 9190, 430, 267, 372, 1109, 8, 1955, 9, 339, 768, 1829, 272, 347, 8873, 8, 277, 304, 267, 291, 14, 10955, 63, 692, 63, 1397, 63, 3617, 1043, 342, 267, 372, 291, 14, 362, 360, 4491, 5268, 14, 25573, 358, 503, 1052, 339, 768, 1829, 272, 347, 11779, 63, 11875, 63, 5203, 8, 277, 304, 267, 347, 1475, 63, 719, 8, 4239, 12, 4575, 304, 288, 340, 440, 4575, 26, 355, 372, 5726, 288, 372, 5041, 4965, 6583, 16495, 4965, 4313, 93, 5118, 91, 4239, 5285, 908, 8, 355, 5726, 29, 4239, 12, 1011, 3455, 59, 16, 566, 398, 372, 1656, 1987, 904, 8, 908, 63, 719, 2031, 1053, 9, 586, 367, 1242, 315, 3355, 8, 4174, 14, 4611, 8, 277, 14, 5203, 1724, 339, 768, 1829, 272, 347, 3628, 8, 277, 304, 267, 372, 291, 14, 362, 360, 2028, 14, 14016, 358, 503, 1052, 339, 768, 1829, 272, 347, 943, 63, 888, 8, 277, 304, 267, 372, 291, 14, 362, 360, 4965, 2028, 14, 2445, 2028, 358, 503, 488, 339, 768, 1829, 272, 347, 11779, 63, 11875, 63, 929, 8, 277, 304, 267, 340, 291, 14, 374, 63, 5720, 26, 288, 372, 283, 39, 1102, 7, 340, 291, 14, 362, 360, 2223, 14, 39, 1102, 358, 587, 283, 1721, 7, 267, 587, 26, 288, 372, 283, 6699, 450, 83, 7, 450, 291, 14, 362, 360, 2223, 14, 6699, 3034, 358, 339, 768, 1829, 272, 347, 11779, 63, 11875, 63, 1531, 8, 277, 304, 267, 2397, 1403, 275, 291, 14, 362, 360, 2028, 14, 3900, 1403, 358, 503, 942, 267, 2088, 275, 291, 14, 362, 360, 2028, 14, 7874, 358, 503, 942, 267, 372, 283, 1987, 904, 8, 2373, 1403, 435, 2088, 9, 339, 768, 1829, 272, 347, 3734, 8, 277, 304, 267, 372, 1211, 8, 1391, 14, 1294, 480, 11107, 413, 9, 367, 2729, 315, 291, 14, 362, 360, 2028, 14, 7744, 358, 503, 3073, 339, 768, 1829, 272, 347, 365, 63, 5720, 8, 277, 304, 267, 372, 291, 14, 362, 360, 2223, 14, 9602, 358, 339, 347, 664, 8, 277, 12, 790, 304, 267, 408, 1767, 282, 574, 687, 314, 3970, 503, 488, 340, 314, 574, 365, 440, 663, 14, 398, 520, 635, 790, 26, 282, 1059, 1808, 18947, 15843, 367, 6032, 2600, 490, 16807, 267, 408, 267, 291, 14, 10955, 63, 692, 63, 1397, 63, 3617, 1043, 342, 398, 347, 664, 63, 585, 8, 9086, 12, 790, 304, 288, 372, 334, 9086, 503, 13056, 362, 8, 498, 9, 398, 372, 7114, 8, 362, 63, 585, 12, 790, 14, 1294, 5175, 659, 291, 14, 9086, 9, 339, 347, 664, 63, 1832, 63, 719, 8, 277, 12, 1844, 12, 4113, 534, 8815, 735, 267, 1844, 275, 291, 14, 5203, 14, 362, 3647, 83, 3149, 83, 2, 450, 334, 719, 12, 4113, 430, 267, 372, 5310, 4965, 6583, 16495, 4965, 4313, 5469, 908, 3682, 719, 59, 16, 566, 340, 1844, 587, 488, 339, 347, 1343, 8, 277, 12, 1011, 1419, 304, 267, 372, 291, 14, 1258, 14, 928, 8, 277, 14, 344,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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 ]
dsapandora/die_hard
diehard.py
1
1608
#!/usr/bin/env python import roslib; roslib.load_manifest('DroneInteractiveEnviroment') import rospy import json import requests from std_msgs.msg import String from geometry_msgs.msg import Twist from ardrone_autonomy.msg import Navdata class DieHard(object): def __init__(self): self.twist = Twist() rospy.init_node('DIEHARD') self.pub = rospy.Publisher('/cmd_vel', Twist, latch=True) rospy.Subscriber('/ardrone/navdata', Navdata, self.update_value) self.twist.linear.x = 0; # our forward speed self.twist.linear.y = 0; self.twist.linear.z = 0; # we can't use these! self.twist.angular.x = 0; self.twist.angular.y = 0; # or these! self.twist.angular.z = 0; def update_value(self, msg): self.value = str(msg.vx) +" "+str(msg.vy)+" "+str(msg.vz) response = requests.get('http://10.100.100.104:5000/am_gonna_die?longitude=%s&latitude=%s&elevation=%s' % (msg.vx, msg.vy, msg.vz)) rospy.loginfo(self.value) value = json.loads(response.text) rospy.loginfo(value) rospy.loginfo("response:"+ str(value['distance'])+" "+str(value['latitude'])+" "+str(value['longitude'])) self.twist.linear.x = float(value['latitude']*float(value['distance'])) self.twist.linear.y = float(value['longitude']*float(value['distance'])) def run(self): r = rospy.Rate(10) while not rospy.is_shutdown(): self.pub.publish(self.twist) r.sleep() if __name__=="__main__": DieHard().run()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 882, 83, 773, 27, 882, 83, 773, 14, 912, 63, 6418, 360, 21733, 368, 23879, 1327, 433, 293, 434, 358, 199, 646, 21848, 199, 646, 2022, 199, 646, 4145, 199, 504, 2418, 63, 13429, 14, 1328, 492, 2624, 221, 199, 504, 3400, 63, 13429, 14, 1328, 492, 377, 87, 631, 199, 504, 601, 5012, 368, 63, 6898, 17293, 14, 1328, 492, 653, 1214, 576, 421, 199, 533, 577, 1873, 16464, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 8122, 631, 275, 377, 87, 631, 342, 267, 21848, 14, 826, 63, 932, 360, 1914, 24948, 7816, 358, 398, 291, 14, 5645, 275, 21848, 14, 27341, 2336, 1760, 63, 1090, 297, 377, 87, 631, 12, 634, 693, 29, 549, 9, 267, 21848, 14, 28638, 2336, 1005, 82, 368, 15, 10927, 576, 297, 653, 1214, 576, 12, 291, 14, 873, 63, 585, 9, 267, 291, 14, 8122, 631, 14, 6676, 14, 88, 275, 378, 27, 7861, 327, 4154, 7568, 8112, 267, 291, 14, 8122, 631, 14, 6676, 14, 89, 275, 378, 27, 4960, 291, 14, 8122, 631, 14, 6676, 14, 90, 275, 378, 27, 258, 327, 781, 883, 1133, 675, 3520, 1, 18418, 291, 14, 8122, 631, 14, 11572, 14, 88, 275, 378, 27, 291, 14, 8122, 631, 14, 11572, 14, 89, 275, 378, 27, 257, 327, 3515, 503, 3520, 1, 267, 291, 14, 8122, 631, 14, 11572, 14, 90, 275, 378, 27, 259, 339, 347, 1678, 63, 585, 8, 277, 12, 1499, 304, 267, 291, 14, 585, 275, 620, 8, 1328, 14, 18843, 9, 435, 2, 7210, 495, 8, 1328, 14, 16091, 18663, 7210, 495, 8, 1328, 14, 31007, 9, 267, 1177, 275, 4145, 14, 362, 360, 1014, 921, 709, 14, 1960, 14, 1960, 14, 6785, 26, 13128, 15, 455, 63, 27719, 3540, 63, 15130, 31, 13803, 2458, 83, 6, 13331, 2458, 83, 6, 32568, 2458, 83, 7, 450, 334, 1328, 14, 18843, 12, 1499, 14, 16091, 12, 1499, 14, 31007, 430, 267, 21848, 14, 793, 815, 8, 277, 14, 585, 9, 267, 574, 221, 275, 2022, 14, 3640, 8, 1310, 14, 505, 9, 267, 21848, 14, 793, 815, 8, 585, 9, 267, 21848, 14, 793, 815, 480, 1310, 5424, 11, 620, 8, 585, 459, 5590, 1105, 5207, 7210, 495, 8, 585, 459, 13331, 1105, 5207, 7210, 495, 8, 585, 459, 13803, 5156, 267, 291, 14, 8122, 631, 14, 6676, 14, 88, 275, 2069, 8, 585, 459, 13331, 20445, 1609, 8, 585, 459, 5590, 5156, 267, 291, 14, 8122, 631, 14, 6676, 14, 89, 275, 2069, 8, 585, 459, 13803, 20445, 1609, 8, 585, 459, 5590, 5156, 268, 2378, 347, 1255, 8, 277, 304, 267, 519, 275, 21848, 14, 6621, 8, 709, 9, 267, 1830, 440, 21848, 14, 374, 63, 8831, 837, 288, 291, 14, 5645, 14, 4763, 8, 277, 14, 8122, 631, 9, 288, 519, 14, 4532, 342, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 199, 198, 1341, 69, 16464, 1252, 1065, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 882, 83, 773, 27, 882, 83, 773, 14, 912, 63, 6418, 360, 21733, 368, 23879, 1327, 433, 293, 434, 358, 199, 646, 21848, 199, 646, 2022, 199, 646, 4145, 199, 504, 2418, 63, 13429, 14, 1328, 492, 2624, 221, 199, 504, 3400, 63, 13429, 14, 1328, 492, 377, 87, 631, 199, 504, 601, 5012, 368, 63, 6898, 17293, 14, 1328, 492, 653, 1214, 576, 421, 199, 533, 577, 1873, 16464, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 8122, 631, 275, 377, 87, 631, 342, 267, 21848, 14, 826, 63, 932, 360, 1914, 24948, 7816, 358, 398, 291, 14, 5645, 275, 21848, 14, 27341, 2336, 1760, 63, 1090, 297, 377, 87, 631, 12, 634, 693, 29, 549, 9, 267, 21848, 14, 28638, 2336, 1005, 82, 368, 15, 10927, 576, 297, 653, 1214, 576, 12, 291, 14, 873, 63, 585, 9, 267, 291, 14, 8122, 631, 14, 6676, 14, 88, 275, 378, 27, 7861, 327, 4154, 7568, 8112, 267, 291, 14, 8122, 631, 14, 6676, 14, 89, 275, 378, 27, 4960, 291, 14, 8122, 631, 14, 6676, 14, 90, 275, 378, 27, 258, 327, 781, 883, 1133, 675, 3520, 1, 18418, 291, 14, 8122, 631, 14, 11572, 14, 88, 275, 378, 27, 291, 14, 8122, 631, 14, 11572, 14, 89, 275, 378, 27, 257, 327, 3515, 503, 3520, 1, 267, 291, 14, 8122, 631, 14, 11572, 14, 90, 275, 378, 27, 259, 339, 347, 1678, 63, 585, 8, 277, 12, 1499, 304, 267, 291, 14, 585, 275, 620, 8, 1328, 14, 18843, 9, 435, 2, 7210, 495, 8, 1328, 14, 16091, 18663, 7210, 495, 8, 1328, 14, 31007, 9, 267, 1177, 275, 4145, 14, 362, 360, 1014, 921, 709, 14, 1960, 14, 1960, 14, 6785, 26, 13128, 15, 455, 63, 27719, 3540, 63, 15130, 31, 13803, 2458, 83, 6, 13331, 2458, 83, 6, 32568, 2458, 83, 7, 450, 334, 1328, 14, 18843, 12, 1499, 14, 16091, 12, 1499, 14, 31007, 430, 267, 21848, 14, 793, 815, 8, 277, 14, 585, 9, 267, 574, 221, 275, 2022, 14, 3640, 8, 1310, 14, 505, 9, 267, 21848, 14, 793, 815, 8, 585, 9, 267, 21848, 14, 793, 815, 480, 1310, 5424, 11, 620, 8, 585, 459, 5590, 1105, 5207, 7210, 495, 8, 585, 459, 13331, 1105, 5207, 7210, 495, 8, 585, 459, 13803, 5156, 267, 291, 14, 8122, 631, 14, 6676, 14, 88, 275, 2069, 8, 585, 459, 13331, 20445, 1609, 8, 585, 459, 5590, 5156, 267, 291, 14, 8122, 631, 14, 6676, 14, 89, 275, 2069, 8, 585, 459, 13803, 20445, 1609, 8, 585, 459, 5590, 5156, 268, 2378, 347, 1255, 8, 277, 304, 267, 519, 275, 21848, 14, 6621, 8, 709, 9, 267, 1830, 440, 21848, 14, 374, 63, 8831, 837, 288, 291, 14, 5645, 14, 4763, 8, 277, 14, 8122, 631, 9, 288, 519, 14, 4532, 342, 199, 199, 692, 636, 354, 363, 11800, 363, 973, 5727, 199, 198, 1341, 69, 16464, 1252, 1065, 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, 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 ]
AndrewPeelMV/Blender2.78c
2.78/scripts/addons/rigify/rigs/pitchipoy/limbs/super_arm.py
2
47129
import bpy, re from ..super_widgets import create_hand_widget from .ui import create_script from .limb_utils import * from mathutils import Vector from ....utils import copy_bone, flip_bone, put_bone, create_cube_widget from ....utils import strip_org, make_deformer_name, create_widget from ....utils import create_circle_widget, create_sphere_widget from ....utils import MetarigError, make_mechanism_name, org from ....utils import create_limb_widget, connected_children_names from rna_prop_ui import rna_idprop_ui_prop_get from ..super_widgets import create_ikarrow_widget from math import trunc extra_script = """ controls = [%s] ctrl = '%s' if is_selected( controls ): layout.prop( pose_bones[ ctrl ], '["%s"]') if '%s' in pose_bones[ctrl].keys(): layout.prop( pose_bones[ ctrl ], '["%s"]', slider = True ) """ class Rig: def __init__(self, obj, bone_name, params): """ Initialize arm rig and key rig properties """ self.obj = obj self.params = params self.org_bones = list( [bone_name] + connected_children_names(obj, bone_name) )[:3] # The basic limb is the first 3 bones self.segments = params.segments self.bbones = params.bbones self.limb_type = params.limb_type self.rot_axis = params.rotation_axis # Assign values to tweak/FK layers props if opted by user if params.tweak_extra_layers: self.tweak_layers = list(params.tweak_layers) else: self.tweak_layers = None if params.fk_extra_layers: self.fk_layers = list(params.fk_layers) else: self.fk_layers = None def create_parent(self): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones name = get_bone_name( strip_org( org_bones[0] ), 'mch', 'parent' ) mch = copy_bone( self.obj, org_bones[0], name ) orient_bone( self, eb[mch], 'y' ) eb[ mch ].length = eb[ org_bones[0] ].length / 4 eb[ mch ].parent = eb[ org_bones[0] ].parent eb[ mch ].roll = 0.0 # Constraints make_constraint( self, mch, { 'constraint' : 'COPY_ROTATION', 'subtarget' : 'root' }) make_constraint( self, mch, { 'constraint' : 'COPY_SCALE', 'subtarget' : 'root' }) # Limb Follow Driver pb = self.obj.pose.bones name = 'FK_limb_follow' pb[ mch ][ name ] = 0.0 prop = rna_idprop_ui_prop_get( pb[ mch ], name, create = True ) prop["min"] = 0.0 prop["max"] = 1.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = name drv = pb[ mch ].constraints[ 0 ].driver_add("influence").driver drv.type = 'AVERAGE' var = drv.variables.new() var.name = name var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = pb[ mch ].path_from_id() + \ '[' + '"' + name + '"' + ']' return mch def create_tweak(self): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones tweaks = {} tweaks['ctrl'] = [] tweaks['mch' ] = [] # Create and parent mch and ctrl tweaks for i,org in enumerate(org_bones): #if (self.limb_type == 'paw'): # idx_stop = len(org_bones) #else: # idx_stop = len(org_bones) - 1 if i < len(org_bones) - 1: # if i < idx_stop: # Create segments if specified for j in range( self.segments ): # MCH name = get_bone_name( strip_org(org), 'mch', 'tweak' ) mch = copy_bone( self.obj, org, name ) # CTRL name = get_bone_name( strip_org(org), 'ctrl', 'tweak' ) ctrl = copy_bone( self.obj, org, name ) eb[ mch ].length /= self.segments eb[ ctrl ].length /= self.segments # If we have more than one segments, place the head of the # 2nd and onwards at the correct position if j > 0: put_bone(self.obj, mch, eb[ tweaks['mch' ][-1] ].tail) put_bone(self.obj, ctrl, eb[ tweaks['ctrl'][-1] ].tail) tweaks['ctrl'] += [ ctrl ] tweaks['mch' ] += [ mch ] # Parenting the tweak ctrls to mchs eb[ mch ].parent = eb[ org ] eb[ ctrl ].parent = eb[ mch ] else: # Last limb bone - is not subdivided name = get_bone_name( strip_org(org), 'mch', 'tweak' ) mch = copy_bone( self.obj, org_bones[i-1], name ) eb[ mch ].length = eb[org].length / 4 put_bone( self.obj, mch, eb[org_bones[i-1]].tail ) ctrl = get_bone_name( strip_org(org), 'ctrl', 'tweak' ) ctrl = copy_bone( self.obj, org, ctrl ) eb[ ctrl ].length = eb[org].length / 2 tweaks['mch'] += [ mch ] tweaks['ctrl'] += [ ctrl ] # Parenting the tweak ctrls to mchs eb[ mch ].parent = eb[ org ] eb[ ctrl ].parent = eb[ mch ] # Scale to reduce widget size and maintain conventions! for mch, ctrl in zip( tweaks['mch'], tweaks['ctrl'] ): eb[ mch ].length /= 4 eb[ ctrl ].length /= 2 # Contraints for i,b in enumerate( tweaks['mch'] ): first = 0 middle = trunc( len( tweaks['mch'] ) / 2 ) last = len( tweaks['mch'] ) - 1 if i == first or i == middle: make_constraint( self, b, { 'constraint' : 'COPY_SCALE', 'subtarget' : 'root' }) elif i != last: targets = [] dt_target_idx = middle factor = 0 if i < middle: targets = [first,middle] else: targets = [middle,last] factor = self.segments dt_target_idx = last # Use copy transforms constraints to position each bone # exactly in the location respective to its index (between # the two edges) make_constraint( self, b, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : tweaks['ctrl'][targets[0]] }) make_constraint( self, b, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : tweaks['ctrl'][targets[1]], 'influence' : (i - factor) / self.segments }) make_constraint( self, b, { 'constraint' : 'DAMPED_TRACK', 'subtarget' : tweaks['ctrl'][ dt_target_idx ], }) # Ctrl bones Locks and Widgets pb = self.obj.pose.bones for t in tweaks['ctrl']: pb[t].lock_rotation = True, False, True pb[t].lock_scale = False, True, False create_sphere_widget(self.obj, t, bone_transform_name=None) if self.tweak_layers: pb[t].bone.layers = self.tweak_layers return tweaks def create_def(self, tweaks): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones def_bones = [] for i,org in enumerate(org_bones): if i < len(org_bones) - 1: # Create segments if specified for j in range( self.segments ): name = get_bone_name( strip_org(org), 'def' ) def_name = copy_bone( self.obj, org, name ) eb[ def_name ].length /= self.segments # If we have more than one segments, place the 2nd and # onwards on the tail of the previous bone if j > 0: put_bone(self.obj, def_name, eb[ def_bones[-1] ].tail) def_bones += [ def_name ] else: name = get_bone_name( strip_org(org), 'def' ) def_name = copy_bone( self.obj, org, name ) def_bones.append( def_name ) # Parent deform bones for i,b in enumerate( def_bones ): if i > 0: # For all bones but the first (which has no parent) eb[b].parent = eb[ def_bones[i-1] ] # to previous eb[b].use_connect = True # Constraint def to tweaks for d,t in zip(def_bones, tweaks): tidx = tweaks.index(t) make_constraint( self, d, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : t }) if tidx != len(tweaks) - 1: make_constraint( self, d, { 'constraint' : 'DAMPED_TRACK', 'subtarget' : tweaks[ tidx + 1 ], }) make_constraint( self, d, { 'constraint' : 'STRETCH_TO', 'subtarget' : tweaks[ tidx + 1 ], }) # Create bbone segments for bone in def_bones[:-1]: self.obj.data.bones[bone].bbone_segments = self.bbones self.obj.data.bones[ def_bones[0] ].bbone_in = 0.0 self.obj.data.bones[ def_bones[-2] ].bbone_out = 0.0 self.obj.data.bones[ def_bones[-1] ].bbone_in = 0.0 self.obj.data.bones[ def_bones[-1] ].bbone_out = 0.0 # Rubber hose drivers pb = self.obj.pose.bones for i,t in enumerate( tweaks[1:-1] ): # Create custom property on tweak bone to control rubber hose name = 'rubber_tweak' if i == trunc( len( tweaks[1:-1] ) / 2 ): pb[t][name] = 0.0 else: pb[t][name] = 1.0 prop = rna_idprop_ui_prop_get( pb[t], name, create=True ) prop["min"] = 0.0 prop["max"] = 2.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = name for j,d in enumerate(def_bones[:-1]): drvs = {} if j != 0: tidx = j drvs[tidx] = self.obj.data.bones[d].driver_add("bbone_in").driver if j != len( def_bones[:-1] ) - 1: tidx = j + 1 drvs[tidx] = self.obj.data.bones[d].driver_add("bbone_out").driver for d in drvs: drv = drvs[d] name = 'rubber_tweak' drv.type = 'AVERAGE' var = drv.variables.new() var.name = name var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = pb[tweaks[d]].path_from_id() + \ '[' + '"' + name + '"' + ']' return def_bones def create_ik(self, parent): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones ctrl = get_bone_name( org_bones[0], 'ctrl', 'ik' ) mch_ik = get_bone_name( org_bones[0], 'mch', 'ik' ) mch_target = get_bone_name( org_bones[0], 'mch', 'ik_target' ) for o, ik in zip( org_bones, [ ctrl, mch_ik, mch_target ] ): bone = copy_bone( self.obj, o, ik ) if org_bones.index(o) == len( org_bones ) - 1: eb[ bone ].length /= 4 # Create MCH Stretch mch_str = copy_bone( self.obj, org_bones[0], get_bone_name( org_bones[0], 'mch', 'ik_stretch' ) ) eb[ mch_str ].tail = eb[ org_bones[-1] ].head # Parenting eb[ ctrl ].parent = eb[ parent ] eb[ mch_str ].parent = eb[ parent ] eb[ mch_ik ].parent = eb[ ctrl ] make_constraint( self, mch_ik, { 'constraint' : 'IK', 'subtarget' : mch_target, 'chain_count' : 2, }) pb = self.obj.pose.bones pb[ mch_ik ].ik_stretch = 0.1 pb[ ctrl ].ik_stretch = 0.1 # IK constraint Rotation locks for axis in ['x','y','z']: if axis != self.rot_axis: setattr( pb[ mch_ik ], 'lock_ik_' + axis, True ) # Locks and Widget pb[ ctrl ].lock_rotation = True, False, True create_ikarrow_widget( self.obj, ctrl, bone_transform_name=None ) return { 'ctrl' : { 'limb' : ctrl }, 'mch_ik' : mch_ik, 'mch_target' : mch_target, 'mch_str' : mch_str } def create_fk(self, parent): org_bones = self.org_bones.copy() bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones ctrls = [] for o in org_bones: bone = copy_bone( self.obj, o, get_bone_name( o, 'ctrl', 'fk' ) ) ctrls.append( bone ) # MCH mch = copy_bone( self.obj, org_bones[-1], get_bone_name( o, 'mch', 'fk' ) ) eb[ mch ].length /= 4 # Parenting eb[ ctrls[0] ].parent = eb[ parent ] eb[ ctrls[1] ].parent = eb[ ctrls[0] ] eb[ ctrls[1] ].use_connect = True eb[ ctrls[2] ].parent = eb[ mch ] eb[ mch ].parent = eb[ ctrls[1] ] eb[ mch ].use_connect = True # Constrain MCH's scale to root make_constraint( self, mch, { 'constraint' : 'COPY_SCALE', 'subtarget' : 'root' }) # Locks and widgets pb = self.obj.pose.bones pb[ ctrls[2] ].lock_location = True, True, True create_limb_widget( self.obj, ctrls[0] ) create_limb_widget( self.obj, ctrls[1] ) create_circle_widget(self.obj, ctrls[2], radius=0.4, head_tail=0.0) for c in ctrls: if self.fk_layers: pb[c].bone.layers = self.fk_layers return { 'ctrl' : ctrls, 'mch' : mch } def org_parenting_and_switch(self, org, ik, fk, parent): bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones # re-parent ORGs in a connected chain for i,o in enumerate(org): if i > 0: eb[o].parent = eb[ org[i-1] ] if i <= len(org)-1: eb[o].use_connect = True bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones pb_parent = pb[ parent ] # Create ik/fk switch property pb_parent['IK/FK'] = 0.0 prop = rna_idprop_ui_prop_get( pb_parent, 'IK/FK', create=True ) prop["min"] = 0.0 prop["max"] = 1.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = 'IK/FK Switch' # Constrain org to IK and FK bones iks = [ ik['ctrl']['limb'] ] iks += [ ik[k] for k in [ 'mch_ik', 'mch_target'] ] for o, i, f in zip( org, iks, fk ): make_constraint( self, o, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : i }) make_constraint( self, o, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : f }) # Add driver to relevant constraint drv = pb[o].constraints[-1].driver_add("influence").driver drv.type = 'AVERAGE' var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = \ pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' def create_arm( self, bones): org_bones = self.org_bones bpy.ops.object.mode_set(mode='EDIT') eb = self.obj.data.edit_bones ctrl = get_bone_name( org_bones[2], 'ctrl', 'ik' ) # Create IK arm control ctrl = copy_bone( self.obj, org_bones[2], ctrl ) # clear parent (so that rigify will parent to root) eb[ ctrl ].parent = None eb[ ctrl ].use_connect = False # Parent eb[ bones['ik']['mch_target'] ].parent = eb[ ctrl ] eb[ bones['ik']['mch_target'] ].use_connect = False # MCH for ik control ctrl_socket = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_socket')) eb[ctrl_socket].tail = eb[ctrl_socket].head + 0.8*(eb[ctrl_socket].tail-eb[ctrl_socket].head) eb[ctrl_socket].parent = None eb[ctrl].parent = eb[ctrl_socket] ctrl_root = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_root')) eb[ctrl_root].tail = eb[ctrl_root].head + 0.7*(eb[ctrl_root].tail-eb[ctrl_root].head) eb[ctrl_root].use_connect = False eb[ctrl_root].parent = eb['root'] if eb[org_bones[0]].parent: arm_parent = eb[org_bones[0]].parent ctrl_parent = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_parent')) eb[ctrl_parent].tail = eb[ctrl_parent].head + 0.6*(eb[ctrl_parent].tail-eb[ctrl_parent].head) eb[ctrl_parent].use_connect = False eb[ctrl_parent].parent = eb[org_bones[0]].parent else: arm_parent = None # Set up constraints # Constrain ik ctrl to root / parent make_constraint( self, ctrl_socket, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : ctrl_root, }) if arm_parent: make_constraint( self, ctrl_socket, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : ctrl_parent, }) # Constrain mch target bone to the ik control and mch stretch make_constraint( self, bones['ik']['mch_target'], { 'constraint' : 'COPY_LOCATION', 'subtarget' : bones['ik']['mch_str'], 'head_tail' : 1.0 }) # Constrain mch ik stretch bone to the ik control make_constraint( self, bones['ik']['mch_str'], { 'constraint' : 'DAMPED_TRACK', 'subtarget' : ctrl, }) make_constraint( self, bones['ik']['mch_str'], { 'constraint' : 'STRETCH_TO', 'subtarget' : ctrl, }) make_constraint( self, bones['ik']['mch_str'], { 'constraint' : 'LIMIT_SCALE', 'use_min_y' : True, 'use_max_y' : True, 'max_y' : 1.05, 'owner_space' : 'LOCAL' }) # Create ik/fk switch property pb = self.obj.pose.bones pb_parent = pb[ bones['parent'] ] # Modify rotation mode for ik and tweak controls pb[bones['ik']['ctrl']['limb']].rotation_mode = 'ZXY' for b in bones['tweak']['ctrl']: pb[b].rotation_mode = 'ZXY' pb_parent['IK_Strertch'] = 1.0 prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) prop["min"] = 0.0 prop["max"] = 1.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = 'IK Stretch' # Add driver to limit scale constraint influence b = bones['ik']['mch_str'] drv = pb[b].constraints[-1].driver_add("influence").driver drv.type = 'SUM' var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = \ pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0] drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 drv_modifier.coefficients[1] = -1.0 # Create hand widget create_hand_widget(self.obj, ctrl, bone_transform_name=None) bones['ik']['ctrl']['terminal'] = [ ctrl ] if arm_parent: bones['ik']['mch_hand'] = [ctrl_socket, ctrl_root, ctrl_parent] else: bones['ik']['mch_hand'] = [ctrl_socket, ctrl_root] return bones def create_drivers(self, bones): bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones ctrl = pb[bones['ik']['mch_hand'][0]] props = [ "IK_follow", "root/parent" ] for prop in props: if prop == 'IK_follow': ctrl[prop]=True rna_prop = rna_idprop_ui_prop_get( ctrl, prop, create=True ) rna_prop["min"] = False rna_prop["max"] = True rna_prop["description"] = prop drv = ctrl.constraints[ 0 ].driver_add("mute").driver drv.type = 'AVERAGE' var = drv.variables.new() var.name = prop var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = \ ctrl.path_from_id() + '['+ '"' + prop + '"' + ']' drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0] drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 drv_modifier.coefficients[1] = -1.0 if len(ctrl.constraints) > 1: drv = ctrl.constraints[ 1 ].driver_add("mute").driver drv.type = 'AVERAGE' var = drv.variables.new() var.name = prop var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = \ ctrl.path_from_id() + '['+ '"' + prop + '"' + ']' drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0] drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 drv_modifier.coefficients[1] = -1.0 elif len(ctrl.constraints) > 1: ctrl[prop]=0.0 rna_prop = rna_idprop_ui_prop_get( ctrl, prop, create=True ) rna_prop["min"] = 0.0 rna_prop["max"] = 1.0 rna_prop["soft_min"] = 0.0 rna_prop["soft_max"] = 1.0 rna_prop["description"] = prop # drv = ctrl.constraints[ 0 ].driver_add("influence").driver # drv.type = 'AVERAGE' # # var = drv.variables.new() # var.name = prop # var.type = "SINGLE_PROP" # var.targets[0].id = self.obj # var.targets[0].data_path = \ # ctrl.path_from_id() + '['+ '"' + prop + '"' + ']' # # drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0] # # drv_modifier.mode = 'POLYNOMIAL' # drv_modifier.poly_order = 1 # drv_modifier.coefficients[0] = 1.0 # drv_modifier.coefficients[1] = -1.0 drv = ctrl.constraints[ 1 ].driver_add("influence").driver drv.type = 'AVERAGE' var = drv.variables.new() var.name = prop var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = \ ctrl.path_from_id() + '['+ '"' + prop + '"' + ']' def generate(self): bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones # Clear parents for org bones for bone in self.org_bones[1:]: eb[bone].use_connect = False eb[bone].parent = None bones = {} # Create mch limb parent bones['parent'] = self.create_parent() bones['tweak'] = self.create_tweak() bones['def'] = self.create_def( bones['tweak']['ctrl'] ) bones['ik'] = self.create_ik( bones['parent'] ) bones['fk'] = self.create_fk( bones['parent'] ) self.org_parenting_and_switch( self.org_bones, bones['ik'], bones['fk']['ctrl'], bones['parent'] ) bones = self.create_arm( bones ) self.create_drivers( bones ) controls = [ bones['ik']['ctrl']['limb'], bones['ik']['ctrl']['terminal'][0] ] # Create UI controls_string = ", ".join(["'" + x + "'" for x in controls]) script = create_script( bones, 'arm' ) script += extra_script % (controls_string, bones['ik']['mch_hand'][0], 'IK_follow', 'root/parent', 'root/parent') return [ script ] def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ items = [ ('x', 'X', ''), ('y', 'Y', ''), ('z', 'Z', '') ] params.rotation_axis = bpy.props.EnumProperty( items = items, name = "Rotation Axis", default = 'x' ) params.segments = bpy.props.IntProperty( name = 'limb segments', default = 2, min = 1, description = 'Number of segments' ) params.bbones = bpy.props.IntProperty( name = 'bbone segments', default = 10, min = 1, description = 'Number of segments' ) # Setting up extra layers for the FK and tweak params.tweak_extra_layers = bpy.props.BoolProperty( name = "tweak_extra_layers", default = True, description = "" ) params.tweak_layers = bpy.props.BoolVectorProperty( size = 32, description = "Layers for the tweak controls to be on", default = tuple( [ i == 1 for i in range(0, 32) ] ) ) # Setting up extra layers for the FK and tweak params.fk_extra_layers = bpy.props.BoolProperty( name = "fk_extra_layers", default = True, description = "" ) params.fk_layers = bpy.props.BoolVectorProperty( size = 32, description = "Layers for the FK controls to be on", default = tuple( [ i == 1 for i in range(0, 32) ] ) ) def parameters_ui(layout, params): """ Create the ui for the rig parameters.""" # r = layout.row() # r.prop(params, "limb_type") r = layout.row() r.prop(params, "rotation_axis") r = layout.row() r.prop(params, "segments") r = layout.row() r.prop(params, "bbones") for layer in [ 'fk', 'tweak' ]: r = layout.row() r.prop(params, layer + "_extra_layers") r.active = params.tweak_extra_layers col = r.column(align=True) row = col.row(align=True) for i in range(8): row.prop(params, layer + "_layers", index=i, toggle=True, text="") row = col.row(align=True) for i in range(16,24): row.prop(params, layer + "_layers", index=i, toggle=True, text="") col = r.column(align=True) row = col.row(align=True) for i in range(8,16): row.prop(params, layer + "_layers", index=i, toggle=True, text="") row = col.row(align=True) for i in range(24,32): row.prop(params, layer + "_layers", index=i, toggle=True, text="") def create_sample(obj): # generated by rigify.utils.write_metarig bpy.ops.object.mode_set(mode='EDIT') arm = obj.data bones = {} for _ in range(28): arm.rigify_layers.add() arm.rigify_layers[5].name = 'Fingers' arm.rigify_layers[5].row = 5 arm.rigify_layers[6].name = 'Fingers (Tweak)' arm.rigify_layers[6].row = 6 arm.rigify_layers[7].name = 'Arm.L (IK)' arm.rigify_layers[7].row = 7 arm.rigify_layers[8].name = 'Arm.L (FK)' arm.rigify_layers[8].row = 8 arm.rigify_layers[9].name = 'Arm.L (Tweak)' arm.rigify_layers[9].row = 9 bone = arm.edit_bones.new('upper_arm.L') bone.head[:] = 0.1953, 0.0267, 1.5846 bone.tail[:] = 0.4424, 0.0885, 1.4491 bone.roll = 2.0724 bone.use_connect = False bones['upper_arm.L'] = bone.name bone = arm.edit_bones.new('forearm.L') bone.head[:] = 0.4424, 0.0885, 1.4491 bone.tail[:] = 0.6594, 0.0492, 1.3061 bone.roll = 2.1535 bone.use_connect = True bone.parent = arm.edit_bones[bones['upper_arm.L']] bones['forearm.L'] = bone.name bone = arm.edit_bones.new('hand.L') bone.head[:] = 0.6594, 0.0492, 1.3061 bone.tail[:] = 0.7234, 0.0412, 1.2585 bone.roll = 2.2103 bone.use_connect = True bone.parent = arm.edit_bones[bones['forearm.L']] bones['hand.L'] = bone.name bone = arm.edit_bones.new('palm.01.L') bone.head[:] = 0.6921, 0.0224, 1.2882 bone.tail[:] = 0.7464, 0.0051, 1.2482 bone.roll = -2.4928 bone.use_connect = False bone.parent = arm.edit_bones[bones['hand.L']] bones['palm.01.L'] = bone.name bone = arm.edit_bones.new('palm.02.L') bone.head[:] = 0.6970, 0.0389, 1.2877 bone.tail[:] = 0.7518, 0.0277, 1.2487 bone.roll = -2.5274 bone.use_connect = False bone.parent = arm.edit_bones[bones['hand.L']] bones['palm.02.L'] = bone.name bone = arm.edit_bones.new('palm.03.L') bone.head[:] = 0.6963, 0.0545, 1.2874 bone.tail[:] = 0.7540, 0.0521, 1.2482 bone.roll = -2.5843 bone.use_connect = False bone.parent = arm.edit_bones[bones['hand.L']] bones['palm.03.L'] = bone.name bone = arm.edit_bones.new('palm.04.L') bone.head[:] = 0.6929, 0.0696, 1.2871 bone.tail[:] = 0.7528, 0.0763, 1.2428 bone.roll = -2.5155 bone.use_connect = False bone.parent = arm.edit_bones[bones['hand.L']] bones['palm.04.L'] = bone.name bone = arm.edit_bones.new('f_index.01.L') bone.head[:] = 0.7464, 0.0051, 1.2482 bone.tail[:] = 0.7718, 0.0013, 1.2112 bone.roll = -2.0315 bone.use_connect = False bone.parent = arm.edit_bones[bones['palm.01.L']] bones['f_index.01.L'] = bone.name bone = arm.edit_bones.new('thumb.01.L') bone.head[:] = 0.6705, 0.0214, 1.2738 bone.tail[:] = 0.6857, 0.0015, 1.2404 bone.roll = -0.1587 bone.use_connect = False bone.parent = arm.edit_bones[bones['palm.01.L']] bones['thumb.01.L'] = bone.name bone = arm.edit_bones.new('f_middle.01.L') bone.head[:] = 0.7518, 0.0277, 1.2487 bone.tail[:] = 0.7762, 0.0234, 1.2058 bone.roll = -2.0067 bone.use_connect = False bone.parent = arm.edit_bones[bones['palm.02.L']] bones['f_middle.01.L'] = bone.name bone = arm.edit_bones.new('f_ring.01.L') bone.head[:] = 0.7540, 0.0521, 1.2482 bone.tail[:] = 0.7715, 0.0499, 1.2070 bone.roll = -2.0082 bone.use_connect = False bone.parent = arm.edit_bones[bones['palm.03.L']] bones['f_ring.01.L'] = bone.name bone = arm.edit_bones.new('f_pinky.01.L') bone.head[:] = 0.7528, 0.0763, 1.2428 bone.tail[:] = 0.7589, 0.0765, 1.2156 bone.roll = -1.9749 bone.use_connect = False bone.parent = arm.edit_bones[bones['palm.04.L']] bones['f_pinky.01.L'] = bone.name bone = arm.edit_bones.new('f_index.02.L') bone.head[:] = 0.7718, 0.0013, 1.2112 bone.tail[:] = 0.7840, -0.0003, 1.1858 bone.roll = -1.8799 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_index.01.L']] bones['f_index.02.L'] = bone.name bone = arm.edit_bones.new('thumb.02.L') bone.head[:] = 0.6857, 0.0015, 1.2404 bone.tail[:] = 0.7056, -0.0057, 1.2145 bone.roll = -0.4798 bone.use_connect = True bone.parent = arm.edit_bones[bones['thumb.01.L']] bones['thumb.02.L'] = bone.name bone = arm.edit_bones.new('f_middle.02.L') bone.head[:] = 0.7762, 0.0234, 1.2058 bone.tail[:] = 0.7851, 0.0218, 1.1749 bone.roll = -1.8283 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_middle.01.L']] bones['f_middle.02.L'] = bone.name bone = arm.edit_bones.new('f_ring.02.L') bone.head[:] = 0.7715, 0.0499, 1.2070 bone.tail[:] = 0.7794, 0.0494, 1.1762 bone.roll = -1.8946 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_ring.01.L']] bones['f_ring.02.L'] = bone.name bone = arm.edit_bones.new('f_pinky.02.L') bone.head[:] = 0.7589, 0.0765, 1.2156 bone.tail[:] = 0.7618, 0.0770, 1.1932 bone.roll = -1.9059 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_pinky.01.L']] bones['f_pinky.02.L'] = bone.name bone = arm.edit_bones.new('f_index.03.L') bone.head[:] = 0.7840, -0.0003, 1.1858 bone.tail[:] = 0.7892, 0.0006, 1.1636 bone.roll = -1.6760 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_index.02.L']] bones['f_index.03.L'] = bone.name bone = arm.edit_bones.new('thumb.03.L') bone.head[:] = 0.7056, -0.0057, 1.2145 bone.tail[:] = 0.7194, -0.0098, 1.1995 bone.roll = -0.5826 bone.use_connect = True bone.parent = arm.edit_bones[bones['thumb.02.L']] bones['thumb.03.L'] = bone.name bone = arm.edit_bones.new('f_middle.03.L') bone.head[:] = 0.7851, 0.0218, 1.1749 bone.tail[:] = 0.7888, 0.0216, 1.1525 bone.roll = -1.7483 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_middle.02.L']] bones['f_middle.03.L'] = bone.name bone = arm.edit_bones.new('f_ring.03.L') bone.head[:] = 0.7794, 0.0494, 1.1762 bone.tail[:] = 0.7781, 0.0498, 1.1577 bone.roll = -1.6582 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_ring.02.L']] bones['f_ring.03.L'] = bone.name bone = arm.edit_bones.new('f_pinky.03.L') bone.head[:] = 0.7618, 0.0770, 1.1932 bone.tail[:] = 0.7611, 0.0772, 1.1782 bone.roll = -1.7639 bone.use_connect = True bone.parent = arm.edit_bones[bones['f_pinky.02.L']] bones['f_pinky.03.L'] = bone.name bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones[bones['upper_arm.L']] pbone.rigify_type = 'pitchipoy.limbs.super_limb' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' try: pbone.rigify_parameters.separate_ik_layers = True except AttributeError: pass try: pbone.rigify_parameters.ik_layers = [False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.separate_hose_layers = True except AttributeError: pass try: pbone.rigify_parameters.hose_layers = [False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.tweak_layers = [False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.fk_layers = [False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass pbone = obj.pose.bones[bones['forearm.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['hand.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['palm.01.L']] pbone.rigify_type = 'palm' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone = obj.pose.bones[bones['palm.02.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone = obj.pose.bones[bones['palm.03.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone = obj.pose.bones[bones['palm.04.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'YXZ' pbone = obj.pose.bones[bones['f_index.01.L']] pbone.rigify_type = 'pitchipoy.simple_tentacle' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' try: pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: pbone.rigify_parameters.extra_layers = [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.tweak_extra_layers = False except AttributeError: pass pbone = obj.pose.bones[bones['thumb.01.L']] pbone.rigify_type = 'pitchipoy.simple_tentacle' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' try: pbone.rigify_parameters.extra_layers = [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: pbone.rigify_parameters.tweak_extra_layers = False except AttributeError: pass pbone = obj.pose.bones[bones['f_middle.01.L']] pbone.rigify_type = 'pitchipoy.simple_tentacle' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' try: pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: pbone.rigify_parameters.extra_layers = [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.tweak_extra_layers = False except AttributeError: pass pbone = obj.pose.bones[bones['f_ring.01.L']] pbone.rigify_type = 'pitchipoy.simple_tentacle' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' try: pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: pbone.rigify_parameters.extra_layers = [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.tweak_extra_layers = False except AttributeError: pass pbone = obj.pose.bones[bones['f_pinky.01.L']] pbone.rigify_type = 'pitchipoy.simple_tentacle' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' try: pbone.rigify_parameters.separate_extra_layers = True except AttributeError: pass try: pbone.rigify_parameters.extra_layers = [False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] except AttributeError: pass try: pbone.rigify_parameters.tweak_extra_layers = False except AttributeError: pass pbone = obj.pose.bones[bones['f_index.02.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['thumb.02.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_middle.02.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_ring.02.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_pinky.02.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_index.03.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['thumb.03.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_middle.03.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_ring.03.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' pbone = obj.pose.bones[bones['f_pinky.03.L']] pbone.rigify_type = '' pbone.lock_location = (False, False, False) pbone.lock_rotation = (False, False, False) pbone.lock_rotation_w = False pbone.lock_scale = (False, False, False) pbone.rotation_mode = 'QUATERNION' bpy.ops.object.mode_set(mode='EDIT') for bone in arm.edit_bones: bone.select = False bone.select_head = False bone.select_tail = False for b in bones: bone = arm.edit_bones[bones[b]] bone.select = True bone.select_head = True bone.select_tail = True arm.edit_bones.active = bone for eb in arm.edit_bones: if ('arm' in eb.name) or ('hand' in eb.name): eb.layers = (False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False) else: eb.layers = (False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False) arm.layers = (False, False, False, False, False, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False) if __name__ == "__main__": create_sample(bpy.context.active_object)
gpl-2.0
[ 646, 20575, 12, 295, 199, 504, 2508, 4792, 63, 8583, 492, 1218, 63, 6868, 63, 3440, 199, 504, 257, 1275, 1907, 3777, 492, 1218, 63, 1579, 199, 504, 257, 1275, 317, 887, 63, 1208, 258, 492, 627, 199, 504, 257, 3473, 1208, 755, 492, 11388, 199, 504, 257, 29222, 1208, 755, 492, 1331, 63, 21134, 12, 18761, 63, 21134, 12, 5324, 63, 21134, 12, 1218, 63, 11477, 63, 3440, 199, 504, 257, 29222, 1208, 755, 492, 6202, 63, 1308, 12, 1852, 63, 318, 269, 2626, 63, 354, 12, 1218, 63, 3440, 199, 504, 257, 29222, 1208, 755, 492, 1218, 63, 11001, 63, 3440, 12, 1218, 63, 14980, 63, 3440, 199, 504, 257, 29222, 1208, 755, 492, 10072, 285, 528, 547, 12, 1852, 63, 278, 11993, 63, 354, 12, 5981, 199, 504, 257, 29222, 1208, 755, 492, 1218, 63, 317, 887, 63, 3440, 12, 8539, 63, 3223, 63, 1247, 199, 504, 257, 519, 3540, 63, 4469, 63, 1907, 258, 492, 519, 3540, 63, 344, 4469, 63, 1907, 63, 4469, 63, 362, 199, 504, 257, 2508, 4792, 63, 8583, 492, 1218, 63, 3258, 7691, 63, 3440, 199, 504, 257, 3473, 3322, 492, 8181, 67, 199, 199, 2911, 63, 1579, 275, 408, 199, 13658, 275, 8978, 83, 61, 199, 12476, 259, 275, 1543, 83, 7, 199, 199, 692, 365, 63, 5511, 8, 13467, 3461, 272, 7054, 14, 4469, 8, 1115, 261, 63, 66, 4548, 59, 15427, 2156, 283, 905, 5, 83, 937, 358, 272, 340, 1543, 83, 7, 315, 1115, 261, 63, 66, 4548, 59, 12476, 1055, 1612, 837, 267, 7054, 14, 4469, 8, 1115, 261, 63, 66, 4548, 59, 15427, 2156, 283, 905, 5, 83, 23793, 31608, 275, 715, 776, 199, 624, 199, 199, 533, 820, 528, 26, 272, 347, 636, 826, 721, 277, 12, 1559, 12, 28120, 63, 354, 12, 1862, 304, 267, 408, 11578, 30701, 8012, 71, 436, 790, 8012, 71, 4382, 408, 267, 291, 14, 1113, 755, 275, 1559, 267, 291, 14, 1162, 259, 275, 1862, 398, 291, 14, 1308, 63, 66, 4548, 275, 769, 8, 288, 359, 21134, 63, 354, 61, 435, 8539, 63, 3223, 63, 1247, 8, 1113, 12, 28120, 63, 354, 9, 288, 776, 1491, 19, 61, 221, 327, 710, 5678, 1212, 887, 365, 314, 1642, 650, 330, 4548, 398, 291, 14, 13879, 221, 275, 1862, 14, 13879, 267, 291, 14, 2501, 4548, 259, 275, 1862, 14, 2501, 4548, 267, 291, 14, 317, 887, 63, 466, 275, 1862, 14, 317, 887, 63, 466, 267, 291, 14, 4571, 63, 3127, 221, 275, 1862, 14, 15362, 63, 3127, 398, 327, 16927, 1338, 370, 32464, 15, 21490, 9393, 10792, 340, 1687, 471, 701, 922, 267, 340, 1862, 14, 84, 10350, 63, 2911, 63, 4359, 26, 288, 291, 14, 84, 10350, 63, 4359, 275, 769, 8, 1162, 14, 84, 10350, 63, 4359, 9, 267, 587, 26, 288, 291, 14, 84, 10350, 63, 4359, 275, 488, 398, 340, 1862, 14, 9010, 63, 2911, 63, 4359, 26, 288, 291, 14, 9010, 63, 4359, 275, 769, 8, 1162, 14, 9010, 63, 4359, 9, 267, 587, 26, 288, 291, 14, 9010, 63, 4359, 275, 488, 339, 347, 1218, 63, 1708, 8, 277, 304, 398, 5981, 63, 66, 4548, 275, 291, 14, 1308, 63, 66, 4548, 398, 20575, 14, 1483, 14, 785, 14, 632, 63, 409, 8, 632, 275, 7, 17929, 358, 267, 26669, 275, 291, 14, 1113, 14, 576, 14, 3773, 63, 66, 4548, 398, 536, 275, 664, 63, 21134, 63, 354, 8, 6202, 63, 1308, 8, 5981, 63, 66, 4548, 59, 16, 61, 2318, 283, 77, 335, 297, 283, 1708, 7, 776, 398, 333, 335, 275, 1331, 63, 21134, 8, 291, 14, 1113, 12, 5981, 63, 66, 4548, 59, 16, 467, 536, 776, 267, 25626, 63, 21134, 8, 291, 12, 26669, 59, 77, 335, 467, 283, 89, 7, 776, 267, 26669, 59, 333, 335, 221, 1055, 1267, 275, 26669, 59, 5981, 63, 66, 4548, 59, 16, 61, 221, 1055, 1267, 1182, 841, 398, 26669, 59, 333, 335, 221, 1055, 1708, 275, 26669, 59, 5981, 63, 66, 4548, 59, 16, 61, 221, 1055, 1708, 398, 26669, 59, 333, 335, 221, 1055, 2827, 275, 378, 14, 16, 398, 327, 25889, 83, 267, 1852, 63, 5631, 8, 291, 12, 333, 335, 12, 469, 288, 283, 5631, 7, 221, 520, 283, 16188, 63, 31075, 2594, 297, 288, 283, 954, 1375, 7, 257, 520, 283, 1231, 7, 267, 3828, 398, 1852, 63, 5631, 8, 291, 12, 333, 335, 12, 469, 288, 283, 5631, 7, 221, 520, 283, 16188, 63, 24333, 297, 288, 283, 954, 1375, 7, 257, 520, 283, 1231, 7, 267, 3828, 398, 327, 24157, 887, 21876, 19447, 267, 10446, 275, 291, 14, 1113, 14, 4070, 14, 66, 4548, 398, 536, 275, 283, 21490, 63, 317, 887, 63, 7207, 7, 398, 10446, 59, 333, 335, 30479, 536, 1622, 275, 378, 14, 16, 267, 5931, 275, 519, 3540, 63, 344, 4469, 63, 1907, 63, 4469, 63, 362, 8, 10446, 59, 333, 335, 2156, 536, 12, 1218, 275, 715, 776, 398, 5931, 905, 827, 937, 260, 275, 378, 14, 16, 267, 5931, 905, 988, 937, 260, 275, 413, 14, 16, 267, 5931, 905, 4617, 63, 827, 937, 259, 275, 378, 14, 16, 267, 5931, 905, 4617, 63, 988, 937, 259, 275, 413, 14, 16, 267, 5931, 905, 1802, 937, 275, 536, 398, 18754, 275, 10446, 59, 333, 335, 221, 1055, 9882, 59, 378, 221, 1055, 3090, 63, 525, 480, 262, 24585, 3471, 3090, 398, 18754, 14, 466, 275, 283, 33, 2111, 2962, 7, 267, 2729, 275, 18754, 14, 3669, 14, 1222, 342, 267, 2729, 14, 354, 275, 536, 267, 2729, 14, 466, 275, 298, 16425, 63, 19926, 2, 267, 2729, 14, 4684, 59, 16, 1055, 344, 275, 291, 14, 1113, 267, 2729, 14, 4684, 59, 16, 1055, 576, 63, 515, 275, 10446, 59, 333, 335, 221, 1055, 515, 63, 504, 63, 344, 342, 435, 971, 3521, 22640, 435, 14788, 435, 536, 435, 14788, 435, 24840, 398, 372, 333, 335, 339, 347, 1218, 63, 84, 10350, 8, 277, 304, 267, 5981, 63, 66, 4548, 275, 291, 14, 1308, 63, 66, 4548, 398, 20575, 14, 1483, 14, 785, 14, 632, 63, 409, 8, 632, 275, 7, 17929, 358, 267, 26669, 275, 291, 14, 1113, 14 ]
[ 20575, 12, 295, 199, 504, 2508, 4792, 63, 8583, 492, 1218, 63, 6868, 63, 3440, 199, 504, 257, 1275, 1907, 3777, 492, 1218, 63, 1579, 199, 504, 257, 1275, 317, 887, 63, 1208, 258, 492, 627, 199, 504, 257, 3473, 1208, 755, 492, 11388, 199, 504, 257, 29222, 1208, 755, 492, 1331, 63, 21134, 12, 18761, 63, 21134, 12, 5324, 63, 21134, 12, 1218, 63, 11477, 63, 3440, 199, 504, 257, 29222, 1208, 755, 492, 6202, 63, 1308, 12, 1852, 63, 318, 269, 2626, 63, 354, 12, 1218, 63, 3440, 199, 504, 257, 29222, 1208, 755, 492, 1218, 63, 11001, 63, 3440, 12, 1218, 63, 14980, 63, 3440, 199, 504, 257, 29222, 1208, 755, 492, 10072, 285, 528, 547, 12, 1852, 63, 278, 11993, 63, 354, 12, 5981, 199, 504, 257, 29222, 1208, 755, 492, 1218, 63, 317, 887, 63, 3440, 12, 8539, 63, 3223, 63, 1247, 199, 504, 257, 519, 3540, 63, 4469, 63, 1907, 258, 492, 519, 3540, 63, 344, 4469, 63, 1907, 63, 4469, 63, 362, 199, 504, 257, 2508, 4792, 63, 8583, 492, 1218, 63, 3258, 7691, 63, 3440, 199, 504, 257, 3473, 3322, 492, 8181, 67, 199, 199, 2911, 63, 1579, 275, 408, 199, 13658, 275, 8978, 83, 61, 199, 12476, 259, 275, 1543, 83, 7, 199, 199, 692, 365, 63, 5511, 8, 13467, 3461, 272, 7054, 14, 4469, 8, 1115, 261, 63, 66, 4548, 59, 15427, 2156, 283, 905, 5, 83, 937, 358, 272, 340, 1543, 83, 7, 315, 1115, 261, 63, 66, 4548, 59, 12476, 1055, 1612, 837, 267, 7054, 14, 4469, 8, 1115, 261, 63, 66, 4548, 59, 15427, 2156, 283, 905, 5, 83, 23793, 31608, 275, 715, 776, 199, 624, 199, 199, 533, 820, 528, 26, 272, 347, 636, 826, 721, 277, 12, 1559, 12, 28120, 63, 354, 12, 1862, 304, 267, 408, 11578, 30701, 8012, 71, 436, 790, 8012, 71, 4382, 408, 267, 291, 14, 1113, 755, 275, 1559, 267, 291, 14, 1162, 259, 275, 1862, 398, 291, 14, 1308, 63, 66, 4548, 275, 769, 8, 288, 359, 21134, 63, 354, 61, 435, 8539, 63, 3223, 63, 1247, 8, 1113, 12, 28120, 63, 354, 9, 288, 776, 1491, 19, 61, 221, 327, 710, 5678, 1212, 887, 365, 314, 1642, 650, 330, 4548, 398, 291, 14, 13879, 221, 275, 1862, 14, 13879, 267, 291, 14, 2501, 4548, 259, 275, 1862, 14, 2501, 4548, 267, 291, 14, 317, 887, 63, 466, 275, 1862, 14, 317, 887, 63, 466, 267, 291, 14, 4571, 63, 3127, 221, 275, 1862, 14, 15362, 63, 3127, 398, 327, 16927, 1338, 370, 32464, 15, 21490, 9393, 10792, 340, 1687, 471, 701, 922, 267, 340, 1862, 14, 84, 10350, 63, 2911, 63, 4359, 26, 288, 291, 14, 84, 10350, 63, 4359, 275, 769, 8, 1162, 14, 84, 10350, 63, 4359, 9, 267, 587, 26, 288, 291, 14, 84, 10350, 63, 4359, 275, 488, 398, 340, 1862, 14, 9010, 63, 2911, 63, 4359, 26, 288, 291, 14, 9010, 63, 4359, 275, 769, 8, 1162, 14, 9010, 63, 4359, 9, 267, 587, 26, 288, 291, 14, 9010, 63, 4359, 275, 488, 339, 347, 1218, 63, 1708, 8, 277, 304, 398, 5981, 63, 66, 4548, 275, 291, 14, 1308, 63, 66, 4548, 398, 20575, 14, 1483, 14, 785, 14, 632, 63, 409, 8, 632, 275, 7, 17929, 358, 267, 26669, 275, 291, 14, 1113, 14, 576, 14, 3773, 63, 66, 4548, 398, 536, 275, 664, 63, 21134, 63, 354, 8, 6202, 63, 1308, 8, 5981, 63, 66, 4548, 59, 16, 61, 2318, 283, 77, 335, 297, 283, 1708, 7, 776, 398, 333, 335, 275, 1331, 63, 21134, 8, 291, 14, 1113, 12, 5981, 63, 66, 4548, 59, 16, 467, 536, 776, 267, 25626, 63, 21134, 8, 291, 12, 26669, 59, 77, 335, 467, 283, 89, 7, 776, 267, 26669, 59, 333, 335, 221, 1055, 1267, 275, 26669, 59, 5981, 63, 66, 4548, 59, 16, 61, 221, 1055, 1267, 1182, 841, 398, 26669, 59, 333, 335, 221, 1055, 1708, 275, 26669, 59, 5981, 63, 66, 4548, 59, 16, 61, 221, 1055, 1708, 398, 26669, 59, 333, 335, 221, 1055, 2827, 275, 378, 14, 16, 398, 327, 25889, 83, 267, 1852, 63, 5631, 8, 291, 12, 333, 335, 12, 469, 288, 283, 5631, 7, 221, 520, 283, 16188, 63, 31075, 2594, 297, 288, 283, 954, 1375, 7, 257, 520, 283, 1231, 7, 267, 3828, 398, 1852, 63, 5631, 8, 291, 12, 333, 335, 12, 469, 288, 283, 5631, 7, 221, 520, 283, 16188, 63, 24333, 297, 288, 283, 954, 1375, 7, 257, 520, 283, 1231, 7, 267, 3828, 398, 327, 24157, 887, 21876, 19447, 267, 10446, 275, 291, 14, 1113, 14, 4070, 14, 66, 4548, 398, 536, 275, 283, 21490, 63, 317, 887, 63, 7207, 7, 398, 10446, 59, 333, 335, 30479, 536, 1622, 275, 378, 14, 16, 267, 5931, 275, 519, 3540, 63, 344, 4469, 63, 1907, 63, 4469, 63, 362, 8, 10446, 59, 333, 335, 2156, 536, 12, 1218, 275, 715, 776, 398, 5931, 905, 827, 937, 260, 275, 378, 14, 16, 267, 5931, 905, 988, 937, 260, 275, 413, 14, 16, 267, 5931, 905, 4617, 63, 827, 937, 259, 275, 378, 14, 16, 267, 5931, 905, 4617, 63, 988, 937, 259, 275, 413, 14, 16, 267, 5931, 905, 1802, 937, 275, 536, 398, 18754, 275, 10446, 59, 333, 335, 221, 1055, 9882, 59, 378, 221, 1055, 3090, 63, 525, 480, 262, 24585, 3471, 3090, 398, 18754, 14, 466, 275, 283, 33, 2111, 2962, 7, 267, 2729, 275, 18754, 14, 3669, 14, 1222, 342, 267, 2729, 14, 354, 275, 536, 267, 2729, 14, 466, 275, 298, 16425, 63, 19926, 2, 267, 2729, 14, 4684, 59, 16, 1055, 344, 275, 291, 14, 1113, 267, 2729, 14, 4684, 59, 16, 1055, 576, 63, 515, 275, 10446, 59, 333, 335, 221, 1055, 515, 63, 504, 63, 344, 342, 435, 971, 3521, 22640, 435, 14788, 435, 536, 435, 14788, 435, 24840, 398, 372, 333, 335, 339, 347, 1218, 63, 84, 10350, 8, 277, 304, 267, 5981, 63, 66, 4548, 275, 291, 14, 1308, 63, 66, 4548, 398, 20575, 14, 1483, 14, 785, 14, 632, 63, 409, 8, 632, 275, 7, 17929, 358, 267, 26669, 275, 291, 14, 1113, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
unnikrishnankgs/va
venv/lib/python3.5/site-packages/werkzeug/script.py
84
11666
# -*- coding: utf-8 -*- r''' werkzeug.script ~~~~~~~~~~~~~~~ .. admonition:: Deprecated Functionality ``werkzeug.script`` is deprecated without replacement functionality. Python's command line support improved greatly with :mod:`argparse` and a bunch of alternative modules. Most of the time you have recurring tasks while writing an application such as starting up an interactive python interpreter with some prefilled imports, starting the development server, initializing the database or something similar. For that purpose werkzeug provides the `werkzeug.script` module which helps you writing such scripts. Basic Usage ----------- The following snippet is roughly the same in every werkzeug script:: #!/usr/bin/env python # -*- coding: utf-8 -*- from werkzeug import script # actions go here if __name__ == '__main__': script.run() Starting this script now does nothing because no actions are defined. An action is a function in the same module starting with ``"action_"`` which takes a number of arguments where every argument has a default. The type of the default value specifies the type of the argument. Arguments can then be passed by position or using ``--name=value`` from the shell. Because a runserver and shell command is pretty common there are two factory functions that create such commands:: def make_app(): from yourapplication import YourApplication return YourApplication(...) action_runserver = script.make_runserver(make_app, use_reloader=True) action_shell = script.make_shell(lambda: {'app': make_app()}) Using The Scripts ----------------- The script from above can be used like this from the shell now: .. sourcecode:: text $ ./manage.py --help $ ./manage.py runserver localhost 8080 --debugger --no-reloader $ ./manage.py runserver -p 4000 $ ./manage.py shell As you can see it's possible to pass parameters as positional arguments or as named parameters, pretty much like Python function calls. :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. ''' from __future__ import print_function import sys import inspect import getopt from warnings import warn from os.path import basename from werkzeug._compat import iteritems argument_types = { bool: 'boolean', str: 'string', int: 'integer', float: 'float' } converters = { 'boolean': lambda x: x.lower() in ('1', 'true', 'yes', 'on'), 'string': str, 'integer': int, 'float': float } def _deprecated(): warn(DeprecationWarning('werkzeug.script is deprecated and ' 'will be removed soon'), stacklevel=2) def run(namespace=None, action_prefix='action_', args=None): """Run the script. Participating actions are looked up in the caller's namespace if no namespace is given, otherwise in the dict provided. Only items that start with action_prefix are processed as actions. If you want to use all items in the namespace provided as actions set action_prefix to an empty string. :param namespace: An optional dict where the functions are looked up in. By default the local namespace of the caller is used. :param action_prefix: The prefix for the functions. Everything else is ignored. :param args: the arguments for the function. If not specified :data:`sys.argv` without the first argument is used. """ _deprecated() if namespace is None: namespace = sys._getframe(1).f_locals actions = find_actions(namespace, action_prefix) if args is None: args = sys.argv[1:] if not args or args[0] in ('-h', '--help'): return print_usage(actions) elif args[0] not in actions: fail('Unknown action \'%s\'' % args[0]) arguments = {} types = {} key_to_arg = {} long_options = [] formatstring = '' func, doc, arg_def = actions[args.pop(0)] for idx, (arg, shortcut, default, option_type) in enumerate(arg_def): real_arg = arg.replace('-', '_') if shortcut: formatstring += shortcut if not isinstance(default, bool): formatstring += ':' key_to_arg['-' + shortcut] = real_arg long_options.append(isinstance(default, bool) and arg or arg + '=') key_to_arg['--' + arg] = real_arg key_to_arg[idx] = real_arg types[real_arg] = option_type arguments[real_arg] = default try: optlist, posargs = getopt.gnu_getopt(args, formatstring, long_options) except getopt.GetoptError as e: fail(str(e)) specified_arguments = set() for key, value in enumerate(posargs): try: arg = key_to_arg[key] except IndexError: fail('Too many parameters') specified_arguments.add(arg) try: arguments[arg] = converters[types[arg]](value) except ValueError: fail('Invalid value for argument %s (%s): %s' % (key, arg, value)) for key, value in optlist: arg = key_to_arg[key] if arg in specified_arguments: fail('Argument \'%s\' is specified twice' % arg) if types[arg] == 'boolean': if arg.startswith('no_'): value = 'no' else: value = 'yes' try: arguments[arg] = converters[types[arg]](value) except ValueError: fail('Invalid value for \'%s\': %s' % (key, value)) newargs = {} for k, v in iteritems(arguments): newargs[k.startswith('no_') and k[3:] or k] = v arguments = newargs return func(**arguments) def fail(message, code=-1): """Fail with an error.""" _deprecated() print('Error: %s' % message, file=sys.stderr) sys.exit(code) def find_actions(namespace, action_prefix): """Find all the actions in the namespace.""" _deprecated() actions = {} for key, value in iteritems(namespace): if key.startswith(action_prefix): actions[key[len(action_prefix):]] = analyse_action(value) return actions def print_usage(actions): """Print the usage information. (Help screen)""" _deprecated() actions = sorted(iteritems(actions)) print('usage: %s <action> [<options>]' % basename(sys.argv[0])) print(' %s --help' % basename(sys.argv[0])) print() print('actions:') for name, (func, doc, arguments) in actions: print(' %s:' % name) for line in doc.splitlines(): print(' %s' % line) if arguments: print() for arg, shortcut, default, argtype in arguments: if isinstance(default, bool): print(' %s' % ( (shortcut and '-%s, ' % shortcut or '') + '--' + arg )) else: print(' %-30s%-10s%s' % ( (shortcut and '-%s, ' % shortcut or '') + '--' + arg, argtype, default )) print() def analyse_action(func): """Analyse a function.""" _deprecated() description = inspect.getdoc(func) or 'undocumented action' arguments = [] args, varargs, kwargs, defaults = inspect.getargspec(func) if varargs or kwargs: raise TypeError('variable length arguments for action not allowed.') if len(args) != len(defaults or ()): raise TypeError('not all arguments have proper definitions') for idx, (arg, definition) in enumerate(zip(args, defaults or ())): if arg.startswith('_'): raise TypeError('arguments may not start with an underscore') if not isinstance(definition, tuple): shortcut = None default = definition else: shortcut, default = definition argument_type = argument_types[type(default)] if isinstance(default, bool) and default is True: arg = 'no-' + arg arguments.append((arg.replace('_', '-'), shortcut, default, argument_type)) return func, description, arguments def make_shell(init_func=None, banner=None, use_ipython=True): """Returns an action callback that spawns a new interactive python shell. :param init_func: an optional initialization function that is called before the shell is started. The return value of this function is the initial namespace. :param banner: the banner that is displayed before the shell. If not specified a generic banner is used instead. :param use_ipython: if set to `True` ipython is used if available. """ _deprecated() if banner is None: banner = 'Interactive Werkzeug Shell' if init_func is None: init_func = dict def action(ipython=use_ipython): """Start a new interactive python session.""" namespace = init_func() if ipython: try: try: from IPython.frontend.terminal.embed import InteractiveShellEmbed sh = InteractiveShellEmbed.instance(banner1=banner) except ImportError: from IPython.Shell import IPShellEmbed sh = IPShellEmbed(banner=banner) except ImportError: pass else: sh(local_ns=namespace) return from code import interact interact(banner, local=namespace) return action def make_runserver(app_factory, hostname='localhost', port=5000, use_reloader=False, use_debugger=False, use_evalex=True, threaded=False, processes=1, static_files=None, extra_files=None, ssl_context=None): """Returns an action callback that spawns a new development server. .. versionadded:: 0.5 `static_files` and `extra_files` was added. ..versionadded:: 0.6.1 `ssl_context` was added. :param app_factory: a function that returns a new WSGI application. :param hostname: the default hostname the server should listen on. :param port: the default port of the server. :param use_reloader: the default setting for the reloader. :param use_evalex: the default setting for the evalex flag of the debugger. :param threaded: the default threading setting. :param processes: the default number of processes to start. :param static_files: optional dict of static files. :param extra_files: optional list of extra files to track for reloading. :param ssl_context: optional SSL context for running server in HTTPS mode. """ _deprecated() def action(hostname=('h', hostname), port=('p', port), reloader=use_reloader, debugger=use_debugger, evalex=use_evalex, threaded=threaded, processes=processes): """Start a new development server.""" from werkzeug.serving import run_simple app = app_factory() run_simple(hostname, port, app, use_reloader=reloader, use_debugger=debugger, use_evalex=evalex, extra_files=extra_files, reloader_interval=1, threaded=threaded, processes=processes, static_files=static_files, ssl_context=ssl_context) return action
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 2344, 272, 10380, 14, 1579, 272, 32202, 23597, 339, 2508, 1503, 31722, 447, 17993, 6801, 6712, 10817, 1124, 17719, 14, 1579, 1040, 365, 5906, 1928, 8343, 9330, 14, 2126, 2018, 1159, 1414, 1004, 2291, 1742, 26429, 27254, 590, 543, 520, 1494, 1705, 18978, 64, 2126, 436, 282, 22219, 402, 13943, 4621, 14, 339, 17536, 402, 314, 900, 1265, 1172, 5344, 5985, 6527, 1830, 3575, 376, 4223, 272, 4066, 465, 6617, 1536, 376, 12777, 2366, 12693, 543, 2005, 876, 17647, 272, 8925, 12, 6617, 314, 16367, 1654, 12, 29141, 314, 3050, 503, 272, 6020, 8545, 14, 339, 2104, 626, 12016, 10380, 6571, 314, 658, 17719, 14, 1579, 64, 859, 1314, 272, 22577, 1265, 3575, 4066, 10554, 14, 2378, 10082, 11028, 272, 3001, 2595, 339, 710, 2569, 17440, 365, 28568, 590, 314, 2011, 315, 4036, 10380, 2884, 447, 398, 327, 1, 15, 2647, 15, 1393, 15, 1813, 2366, 267, 327, 1882, 2803, 26, 2774, 13, 24, 1882, 267, 687, 10380, 492, 2884, 398, 327, 5445, 2621, 2348, 398, 340, 636, 354, 363, 508, 2560, 973, 3706, 288, 2884, 14, 1065, 342, 339, 24175, 642, 2884, 3063, 1630, 6548, 2952, 949, 5445, 787, 3247, 14, 272, 1626, 1595, 365, 282, 805, 315, 314, 2011, 859, 6617, 543, 25916, 1287, 12172, 1040, 272, 1314, 6181, 282, 1329, 402, 2368, 2382, 4036, 1423, 965, 282, 849, 14, 221, 710, 272, 730, 402, 314, 849, 574, 9314, 314, 730, 402, 314, 1423, 14, 339, 7628, 883, 2066, 506, 3032, 701, 3421, 503, 1808, 1124, 306, 354, 29, 585, 1040, 687, 272, 314, 5218, 14, 339, 13821, 282, 1255, 1000, 436, 5218, 1414, 365, 7268, 2863, 2337, 787, 2877, 272, 6434, 3423, 626, 1218, 4066, 3718, 447, 398, 347, 1852, 63, 571, 837, 288, 687, 2195, 3578, 492, 19519, 5039, 288, 372, 19519, 5039, 20186, 398, 1595, 63, 1065, 1000, 275, 2884, 14, 1875, 63, 1065, 1000, 8, 1875, 63, 571, 12, 675, 63, 264, 3422, 29, 549, 9, 267, 1595, 63, 5641, 275, 2884, 14, 1875, 63, 5641, 8, 2734, 26, 791, 571, 356, 1852, 63, 571, 22804, 2378, 11719, 710, 14914, 83, 272, 10652, 13, 339, 710, 2884, 687, 3432, 883, 506, 1202, 2839, 642, 687, 314, 5218, 3063, 26, 339, 2508, 25468, 447, 1318, 398, 2672, 16605, 9053, 14, 647, 1553, 3437, 267, 2672, 16605, 9053, 14, 647, 1255, 1000, 11667, 30220, 1553, 17612, 1553, 889, 13, 264, 3422, 267, 2672, 16605, 9053, 14, 647, 1255, 1000, 446, 80, 31092, 267, 2672, 16605, 9053, 14, 647, 5218, 339, 3709, 1265, 883, 1937, 652, 1159, 3962, 370, 986, 2633, 465, 11333, 2368, 272, 503, 465, 4310, 2633, 12, 7268, 8298, 2839, 2018, 805, 4882, 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, 2344, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 6485, 199, 646, 12733, 199, 504, 3598, 492, 7987, 199, 504, 747, 14, 515, 492, 9593, 199, 504, 10380, 423, 5819, 492, 10849, 421, 199, 2094, 63, 1313, 275, 469, 272, 2155, 26, 755, 283, 4871, 297, 272, 620, 26, 263, 283, 875, 297, 272, 1109, 26, 263, 283, 4115, 297, 272, 2069, 26, 420, 283, 1609, 7, 199, 93, 421, 199, 17911, 275, 469, 272, 283, 4871, 356, 2400, 671, 26, 671, 14, 2325, 342, 315, 661, 17, 297, 283, 2052, 297, 283, 5066, 297, 283, 265, 659, 272, 283, 875, 356, 257, 620, 12, 272, 283, 4115, 356, 221, 1109, 12, 272, 283, 1609, 356, 259, 2069, 199, 93, 421, 199, 318, 485, 6667, 837, 272, 7987, 8, 15561, 360, 17719, 14, 1579, 365, 5906, 436, 283, 1169, 283, 14117, 506, 4829, 18930, 659, 13232, 29, 18, 9, 421, 199, 318, 1255, 8, 3251, 29, 403, 12, 1595, 63, 1861, 534, 1287, 14474, 1249, 29, 403, 304, 272, 408, 2540, 314, 2884, 14, 221, 2235, 10479, 1958, 5445, 787, 21182, 1536, 315, 314, 8025, 1159, 272, 3231, 340, 949, 3231, 365, 1627, 12, 4257, 315, 314, 1211, 2741, 14, 272, 5972, 2974, 626, 1343, 543, 1595, 63, 1861, 787, 7686, 465, 5445, 14, 221, 982, 272, 1265, 2934, 370, 675, 1006, 2974, 315, 314, 3231, 2741, 465, 5445, 663, 272, 1595, 63, 1861, 370, 376, 2701, 1059, 14, 339, 520, 635, 3231, 26, 1626, 2716, 1211, 2382, 314, 3423, 787, 21182, 1536, 315, 14, 1993, 4885, 849, 314, 2257, 3231, 402, 314, 8025, 365, 1202, 14, 272, 520, 635, 1595, 63, 1861, 26, 710, 2403, 367, 314, 3423, 14, 221, 18414, 2127, 587, 2079, 365, 5525, 14, 272, 520, 635, 1249, 26, 314, 2368, 367, 314, 805, 14, 221, 982, 440, 2013, 326, 520, 576, 1705, 1274, 14, 3020, 64, 1928, 314, 1642, 1423, 365, 1202, 14, 272, 408, 272, 485, 6667, 342, 272, 340, 3231, 365, 488, 26, 267, 3231, 275, 984, 423, 20912, 8, 17, 680, 70, 63, 9350, 272, 5445, 275, 2342, 63, 3723, 8, 3251, 12, 1595, 63, 1861, 9, 339, 340, 1249, 365, 488, 26, 267, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 340, 440, 1249, 503, 1249, 59, 16, 61, 315, 12291, 72, 297, 2850, 3437, 735, 267, 372, 870, 63, 3807, 8, 3723, 9, 272, 916, 1249, 59, 16, 61, 440, 315, 5445, 26, 267, 2449, 360, 5912, 1595, 19095, 83, 60, 891, 450, 1249, 59, 16, 566, 339, 2368, 275, 1052, 272, 2943, 275, 1052, 272, 790, 63, 475, 63, 1273, 275, 1052, 272, 1846, 63, 1419, 275, 942, 272, 1475, 875, 275, 2125, 272, 2562, 12, 1382, 12, 1680, 63, 318, 275, 5445, 59, 589, 14, 1935, 8, 16, 1874, 272, 367, 4280, 12, 334, 1273, 12, 17522, 12, 849, 12, 945, 63, 466, 9, 315, 3874, 8, 1273, 63, 318, 304, 267, 3363, 63, 1273, 275, 1680, 14, 1814, 13858, 18962, 267, 340, 17522, 26, 288, 1475, 875, 847, 17522, 288, 340, 440, 1228, 8, 885, 12, 2155, 304, 355, 1475, 875, 847, 10871, 288, 790, 63, 475, 63, 1273, 459, 15668, 435, 17522, 61, 275, 3363, 63, 1273, 267, 1846, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 2344, 272, 10380, 14, 1579, 272, 32202, 23597, 339, 2508, 1503, 31722, 447, 17993, 6801, 6712, 10817, 1124, 17719, 14, 1579, 1040, 365, 5906, 1928, 8343, 9330, 14, 2126, 2018, 1159, 1414, 1004, 2291, 1742, 26429, 27254, 590, 543, 520, 1494, 1705, 18978, 64, 2126, 436, 282, 22219, 402, 13943, 4621, 14, 339, 17536, 402, 314, 900, 1265, 1172, 5344, 5985, 6527, 1830, 3575, 376, 4223, 272, 4066, 465, 6617, 1536, 376, 12777, 2366, 12693, 543, 2005, 876, 17647, 272, 8925, 12, 6617, 314, 16367, 1654, 12, 29141, 314, 3050, 503, 272, 6020, 8545, 14, 339, 2104, 626, 12016, 10380, 6571, 314, 658, 17719, 14, 1579, 64, 859, 1314, 272, 22577, 1265, 3575, 4066, 10554, 14, 2378, 10082, 11028, 272, 3001, 2595, 339, 710, 2569, 17440, 365, 28568, 590, 314, 2011, 315, 4036, 10380, 2884, 447, 398, 327, 1, 15, 2647, 15, 1393, 15, 1813, 2366, 267, 327, 1882, 2803, 26, 2774, 13, 24, 1882, 267, 687, 10380, 492, 2884, 398, 327, 5445, 2621, 2348, 398, 340, 636, 354, 363, 508, 2560, 973, 3706, 288, 2884, 14, 1065, 342, 339, 24175, 642, 2884, 3063, 1630, 6548, 2952, 949, 5445, 787, 3247, 14, 272, 1626, 1595, 365, 282, 805, 315, 314, 2011, 859, 6617, 543, 25916, 1287, 12172, 1040, 272, 1314, 6181, 282, 1329, 402, 2368, 2382, 4036, 1423, 965, 282, 849, 14, 221, 710, 272, 730, 402, 314, 849, 574, 9314, 314, 730, 402, 314, 1423, 14, 339, 7628, 883, 2066, 506, 3032, 701, 3421, 503, 1808, 1124, 306, 354, 29, 585, 1040, 687, 272, 314, 5218, 14, 339, 13821, 282, 1255, 1000, 436, 5218, 1414, 365, 7268, 2863, 2337, 787, 2877, 272, 6434, 3423, 626, 1218, 4066, 3718, 447, 398, 347, 1852, 63, 571, 837, 288, 687, 2195, 3578, 492, 19519, 5039, 288, 372, 19519, 5039, 20186, 398, 1595, 63, 1065, 1000, 275, 2884, 14, 1875, 63, 1065, 1000, 8, 1875, 63, 571, 12, 675, 63, 264, 3422, 29, 549, 9, 267, 1595, 63, 5641, 275, 2884, 14, 1875, 63, 5641, 8, 2734, 26, 791, 571, 356, 1852, 63, 571, 22804, 2378, 11719, 710, 14914, 83, 272, 10652, 13, 339, 710, 2884, 687, 3432, 883, 506, 1202, 2839, 642, 687, 314, 5218, 3063, 26, 339, 2508, 25468, 447, 1318, 398, 2672, 16605, 9053, 14, 647, 1553, 3437, 267, 2672, 16605, 9053, 14, 647, 1255, 1000, 11667, 30220, 1553, 17612, 1553, 889, 13, 264, 3422, 267, 2672, 16605, 9053, 14, 647, 1255, 1000, 446, 80, 31092, 267, 2672, 16605, 9053, 14, 647, 5218, 339, 3709, 1265, 883, 1937, 652, 1159, 3962, 370, 986, 2633, 465, 11333, 2368, 272, 503, 465, 4310, 2633, 12, 7268, 8298, 2839, 2018, 805, 4882, 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, 2344, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 6485, 199, 646, 12733, 199, 504, 3598, 492, 7987, 199, 504, 747, 14, 515, 492, 9593, 199, 504, 10380, 423, 5819, 492, 10849, 421, 199, 2094, 63, 1313, 275, 469, 272, 2155, 26, 755, 283, 4871, 297, 272, 620, 26, 263, 283, 875, 297, 272, 1109, 26, 263, 283, 4115, 297, 272, 2069, 26, 420, 283, 1609, 7, 199, 93, 421, 199, 17911, 275, 469, 272, 283, 4871, 356, 2400, 671, 26, 671, 14, 2325, 342, 315, 661, 17, 297, 283, 2052, 297, 283, 5066, 297, 283, 265, 659, 272, 283, 875, 356, 257, 620, 12, 272, 283, 4115, 356, 221, 1109, 12, 272, 283, 1609, 356, 259, 2069, 199, 93, 421, 199, 318, 485, 6667, 837, 272, 7987, 8, 15561, 360, 17719, 14, 1579, 365, 5906, 436, 283, 1169, 283, 14117, 506, 4829, 18930, 659, 13232, 29, 18, 9, 421, 199, 318, 1255, 8, 3251, 29, 403, 12, 1595, 63, 1861, 534, 1287, 14474, 1249, 29, 403, 304, 272, 408, 2540, 314, 2884, 14, 221, 2235, 10479, 1958, 5445, 787, 21182, 1536, 315, 314, 8025, 1159, 272, 3231, 340, 949, 3231, 365, 1627, 12, 4257, 315, 314, 1211, 2741, 14, 272, 5972, 2974, 626, 1343, 543, 1595, 63, 1861, 787, 7686, 465, 5445, 14, 221, 982, 272, 1265, 2934, 370, 675, 1006, 2974, 315, 314, 3231, 2741, 465, 5445, 663, 272, 1595, 63, 1861, 370, 376, 2701, 1059, 14, 339, 520, 635, 3231, 26, 1626, 2716, 1211, 2382, 314, 3423, 787, 21182, 1536, 315, 14, 1993, 4885, 849, 314, 2257, 3231, 402, 314, 8025, 365, 1202, 14, 272, 520, 635, 1595, 63, 1861, 26, 710, 2403, 367, 314, 3423, 14, 221, 18414, 2127, 587, 2079, 365, 5525, 14, 272, 520, 635, 1249, 26, 314, 2368, 367, 314, 805, 14, 221, 982, 440, 2013, 326, 520, 576, 1705, 1274, 14, 3020, 64, 1928, 314, 1642, 1423, 365, 1202, 14, 272, 408, 272, 485, 6667, 342, 272, 340, 3231, 365, 488, 26, 267, 3231, 275, 984, 423, 20912, 8, 17, 680, 70, 63, 9350, 272, 5445, 275, 2342, 63, 3723, 8, 3251, 12, 1595, 63, 1861, 9, 339, 340, 1249, 365, 488, 26, 267, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 340, 440, 1249, 503, 1249, 59, 16, 61, 315, 12291, 72, 297, 2850, 3437, 735, 267, 372, 870, 63, 3807, 8, 3723, 9, 272, 916, 1249, 59, 16, 61, 440, 315, 5445, 26, 267, 2449, 360, 5912, 1595, 19095, 83, 60, 891, 450, 1249, 59, 16, 566, 339, 2368, 275, 1052, 272, 2943, 275, 1052, 272, 790, 63, 475, 63, 1273, 275, 1052, 272, 1846, 63, 1419, 275, 942, 272, 1475, 875, 275, 2125, 272, 2562, 12, 1382, 12, 1680, 63, 318, 275, 5445, 59, 589, 14, 1935, 8, 16, 1874, 272, 367, 4280, 12, 334, 1273, 12, 17522, 12, 849, 12, 945, 63, 466, 9, 315, 3874, 8, 1273, 63, 318, 304, 267, 3363, 63, 1273, 275, 1680, 14, 1814, 13858, 18962, 267, 340, 17522, 26, 288, 1475, 875, 847, 17522, 288, 340, 440, 1228, 8, 885, 12, 2155, 304, 355, 1475, 875, 847, 10871, 288, 790, 63, 475, 63, 1273, 459, 15668, 435, 17522, 61, 275, 3363, 63, 1273, 267, 1846, 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, 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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 ]
r-icarus/openstack_microserver
openstack_dashboard/openstack/common/rpc/zmq_receiver.py
19
1254
#!/usr/bin/env python # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2011 OpenStack Foundation # # 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 eventlet eventlet.monkey_patch() import contextlib import sys from oslo.config import cfg from openstack_dashboard.openstack.common import log as logging from openstack_dashboard.openstack.common import rpc from openstack_dashboard.openstack.common.rpc import impl_zmq CONF = cfg.CONF CONF.register_opts(rpc.rpc_opts) CONF.register_opts(impl_zmq.zmq_opts) def main(): CONF(sys.argv[1:], project='oslo') logging.setup("oslo") with contextlib.closing(impl_zmq.ZmqProxy(CONF)) as reactor: reactor.consume_in_thread() reactor.wait()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 259, 1898, 7760, 14260, 2752, 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, 21819, 199, 1430, 2723, 14, 20372, 63, 2068, 342, 199, 199, 646, 15502, 199, 646, 984, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 13869, 63, 9743, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 13869, 63, 9743, 14, 8512, 14, 2330, 492, 8985, 199, 504, 13869, 63, 9743, 14, 8512, 14, 2330, 14, 4354, 492, 11512, 63, 21290, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 4354, 14, 4354, 63, 3291, 9, 199, 3103, 14, 2683, 63, 3291, 8, 5472, 63, 21290, 14, 21290, 63, 3291, 9, 421, 199, 318, 2446, 837, 272, 6392, 8, 1274, 14, 3020, 59, 17, 8429, 2199, 534, 736, 320, 358, 272, 2050, 14, 2758, 480, 736, 320, 531, 339, 543, 15502, 14, 11707, 8, 5472, 63, 21290, 14, 58, 8334, 4936, 8, 3103, 430, 465, 9655, 26, 267, 9655, 14, 10235, 63, 262, 63, 2671, 342, 267, 9655, 14, 2573, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 259, 1898, 7760, 14260, 2752, 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, 21819, 199, 1430, 2723, 14, 20372, 63, 2068, 342, 199, 199, 646, 15502, 199, 646, 984, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 13869, 63, 9743, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 13869, 63, 9743, 14, 8512, 14, 2330, 492, 8985, 199, 504, 13869, 63, 9743, 14, 8512, 14, 2330, 14, 4354, 492, 11512, 63, 21290, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 4354, 14, 4354, 63, 3291, 9, 199, 3103, 14, 2683, 63, 3291, 8, 5472, 63, 21290, 14, 21290, 63, 3291, 9, 421, 199, 318, 2446, 837, 272, 6392, 8, 1274, 14, 3020, 59, 17, 8429, 2199, 534, 736, 320, 358, 272, 2050, 14, 2758, 480, 736, 320, 531, 339, 543, 15502, 14, 11707, 8, 5472, 63, 21290, 14, 58, 8334, 4936, 8, 3103, 430, 465, 9655, 26, 267, 9655, 14, 10235, 63, 262, 63, 2671, 342, 267, 9655, 14, 2573, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bmanojlovic/ansible
test/units/module_utils/gcp/test_utils.py
15
1408
#!/usr/bin/env python # -*- coding: utf-8 -*- # (c) 2016, Tom Melendez <tom@supertom.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. import os import sys from ansible.compat.tests import mock, unittest from ansible.module_utils.gcp import (check_min_pkg_version) def build_distribution(version): obj = mock.MagicMock() obj.version = '0.5.0' return obj class GCPUtilsTestCase(unittest.TestCase): @mock.patch("pkg_resources.get_distribution", side_effect=build_distribution) def test_check_minimum_pkg_version(self, mockobj): self.assertTrue(check_min_pkg_version('foobar', '0.4.0')) self.assertTrue(check_min_pkg_version('foobar', '0.5.0')) self.assertFalse(check_min_pkg_version('foobar', '0.6.0')) if __name__ == '__main__': unittest.main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 12, 21644, 3194, 552, 271, 90, 665, 3151, 32, 4792, 3151, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 747, 199, 646, 984, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 1683, 12, 2882, 199, 504, 3242, 14, 578, 63, 1208, 14, 20622, 492, 334, 1074, 63, 827, 63, 4600, 63, 1023, 9, 199, 199, 318, 1900, 63, 4972, 8, 1023, 304, 272, 1559, 275, 1683, 14, 11988, 342, 272, 1559, 14, 1023, 275, 283, 16, 14, 21, 14, 16, 7, 272, 372, 1559, 421, 199, 533, 30902, 7535, 1746, 8, 2796, 14, 1746, 304, 339, 768, 1805, 14, 2068, 480, 4600, 63, 4435, 14, 362, 63, 4972, 401, 5366, 63, 5881, 29, 1506, 63, 4972, 9, 272, 347, 511, 63, 1074, 63, 10700, 63, 4600, 63, 1023, 8, 277, 12, 1683, 1113, 304, 267, 291, 14, 1815, 8, 1074, 63, 827, 63, 4600, 63, 1023, 360, 9664, 297, 283, 16, 14, 20, 14, 16, 1333, 267, 291, 14, 1815, 8, 1074, 63, 827, 63, 4600, 63, 1023, 360, 9664, 297, 283, 16, 14, 21, 14, 16, 1333, 267, 291, 14, 3334, 8, 1074, 63, 827, 63, 4600, 63, 1023, 360, 9664, 297, 283, 16, 14, 22, 14, 16, 1333, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 12, 21644, 3194, 552, 271, 90, 665, 3151, 32, 4792, 3151, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 747, 199, 646, 984, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 1683, 12, 2882, 199, 504, 3242, 14, 578, 63, 1208, 14, 20622, 492, 334, 1074, 63, 827, 63, 4600, 63, 1023, 9, 199, 199, 318, 1900, 63, 4972, 8, 1023, 304, 272, 1559, 275, 1683, 14, 11988, 342, 272, 1559, 14, 1023, 275, 283, 16, 14, 21, 14, 16, 7, 272, 372, 1559, 421, 199, 533, 30902, 7535, 1746, 8, 2796, 14, 1746, 304, 339, 768, 1805, 14, 2068, 480, 4600, 63, 4435, 14, 362, 63, 4972, 401, 5366, 63, 5881, 29, 1506, 63, 4972, 9, 272, 347, 511, 63, 1074, 63, 10700, 63, 4600, 63, 1023, 8, 277, 12, 1683, 1113, 304, 267, 291, 14, 1815, 8, 1074, 63, 827, 63, 4600, 63, 1023, 360, 9664, 297, 283, 16, 14, 20, 14, 16, 1333, 267, 291, 14, 1815, 8, 1074, 63, 827, 63, 4600, 63, 1023, 360, 9664, 297, 283, 16, 14, 21, 14, 16, 1333, 267, 291, 14, 3334, 8, 1074, 63, 827, 63, 4600, 63, 1023, 360, 9664, 297, 283, 16, 14, 22, 14, 16, 1333, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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7.5/lib/python2.7/test/test_md5.py
194
1790
# Testing md5 module import warnings warnings.filterwarnings("ignore", "the md5 module is deprecated.*", DeprecationWarning) import unittest from md5 import md5 from test import test_support def hexstr(s): import string h = string.hexdigits r = '' for c in s: i = ord(c) r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r class MD5_Test(unittest.TestCase): def md5test(self, s, expected): self.assertEqual(hexstr(md5(s).digest()), expected) self.assertEqual(md5(s).hexdigest(), expected) def test_basics(self): eq = self.md5test eq('', 'd41d8cd98f00b204e9800998ecf8427e') eq('a', '0cc175b9c0f1b6a831c399e269772661') eq('abc', '900150983cd24fb0d6963f7d28e17f72') eq('message digest', 'f96b697d7cb7938d525a2f31aaf161d0') eq('abcdefghijklmnopqrstuvwxyz', 'c3fcd3d76192e4007dfb496cca67e13b') eq('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'd174ab98d277d9f5a5611c2c9f419d9f') eq('12345678901234567890123456789012345678901234567890123456789012345678901234567890', '57edf4a22be3c955ac49da2e2107b67a') def test_hexdigest(self): # hexdigest is new with Python 2.0 m = md5('testing the hexdigest method') h = m.hexdigest() self.assertEqual(hexstr(m.digest()), h) def test_large_update(self): aas = 'a' * 64 bees = 'b' * 64 cees = 'c' * 64 m1 = md5() m1.update(aas) m1.update(bees) m1.update(cees) m2 = md5() m2.update(aas + bees + cees) self.assertEqual(m1.digest(), m2.digest()) def test_main(): test_support.run_unittest(MD5_Test) if __name__ == '__main__': test_main()
lgpl-3.0
[ 3, 11940, 6128, 21, 859, 199, 646, 3598, 199, 5451, 14, 23945, 480, 4247, 401, 298, 1589, 6128, 21, 859, 365, 5906, 2795, 401, 717, 13413, 9, 199, 199, 646, 2882, 199, 504, 6128, 21, 492, 6128, 21, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 318, 6318, 495, 8, 83, 304, 272, 492, 1059, 272, 394, 275, 1059, 14, 4097, 7022, 272, 519, 275, 2125, 272, 367, 286, 315, 308, 26, 267, 284, 275, 6206, 8, 67, 9, 267, 519, 275, 519, 435, 394, 7528, 73, 4331, 841, 9, 1253, 378, 6287, 61, 435, 394, 59, 73, 1253, 378, 6287, 61, 272, 372, 519, 199, 199, 533, 15830, 21, 63, 774, 8, 2796, 14, 1746, 304, 339, 347, 6128, 21, 396, 8, 277, 12, 308, 12, 1420, 304, 267, 291, 14, 629, 8, 4097, 495, 8, 1064, 21, 8, 83, 680, 5671, 4000, 1420, 9, 267, 291, 14, 629, 8, 1064, 21, 8, 83, 680, 11453, 1062, 1420, 9, 339, 347, 511, 63, 4316, 83, 8, 277, 304, 267, 3850, 275, 291, 14, 1064, 21, 396, 267, 3850, 8594, 283, 68, 2953, 68, 24, 2866, 2905, 70, 383, 66, 6686, 69, 2905, 383, 13830, 32430, 1349, 1465, 69, 358, 267, 3850, 360, 65, 297, 283, 16, 2055, 10848, 66, 25, 67, 16, 70, 17, 66, 22, 65, 24, 2192, 67, 10936, 69, 12442, 1138, 9969, 17, 358, 267, 3850, 360, 3175, 297, 283, 17518, 1046, 1643, 2658, 2866, 1194, 4675, 16, 68, 1876, 2766, 70, 23, 68, 1651, 69, 1196, 70, 2819, 358, 267, 3850, 360, 1188, 10017, 297, 283, 70, 2534, 66, 19301, 68, 23, 2894, 1965, 1703, 68, 24334, 65, 18, 70, 2192, 31498, 12285, 68, 16, 358, 267, 3850, 360, 23459, 297, 283, 67, 19, 29873, 19, 68, 2114, 5756, 69, 5303, 23, 1587, 66, 18105, 30031, 1822, 69, 969, 66, 358, 267, 3850, 360, 28114, 23459, 11371, 297, 1779, 283, 68, 9892, 371, 2905, 68, 9963, 68, 25, 70, 21, 65, 1367, 845, 67, 18, 67, 25, 70, 25230, 68, 25, 70, 358, 267, 3850, 360, 11272, 25588, 25588, 25588, 11371, 16, 297, 1779, 283, 1641, 27680, 20, 65, 1081, 1235, 19, 67, 32601, 645, 1887, 983, 18, 69, 18, 7555, 66, 1822, 65, 358, 339, 347, 511, 63, 11453, 8, 277, 304, 267, 327, 6318, 5671, 365, 892, 543, 2018, 499, 14, 16, 267, 333, 275, 6128, 21, 360, 4776, 314, 6318, 5671, 1083, 358, 267, 394, 275, 333, 14, 11453, 342, 267, 291, 14, 629, 8, 4097, 495, 8, 77, 14, 5671, 4000, 394, 9, 339, 347, 511, 63, 9629, 63, 873, 8, 277, 304, 267, 282, 305, 275, 283, 65, 7, 627, 5049, 267, 506, 397, 275, 283, 66, 7, 627, 5049, 267, 10142, 397, 275, 283, 67, 7, 627, 5049, 398, 333, 17, 275, 6128, 21, 342, 267, 333, 17, 14, 873, 8, 65, 305, 9, 267, 333, 17, 14, 873, 8, 1235, 397, 9, 267, 333, 17, 14, 873, 8, 301, 397, 9, 398, 333, 18, 275, 6128, 21, 342, 267, 333, 18, 14, 873, 8, 65, 305, 435, 506, 397, 435, 10142, 397, 9, 267, 291, 14, 629, 8, 77, 17, 14, 5671, 1062, 333, 18, 14, 5671, 1012, 199, 199, 318, 511, 63, 973, 837, 272, 511, 63, 4058, 14, 1065, 63, 2796, 8, 5127, 21, 63, 774, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11940, 6128, 21, 859, 199, 646, 3598, 199, 5451, 14, 23945, 480, 4247, 401, 298, 1589, 6128, 21, 859, 365, 5906, 2795, 401, 717, 13413, 9, 199, 199, 646, 2882, 199, 504, 6128, 21, 492, 6128, 21, 199, 504, 511, 492, 511, 63, 4058, 199, 199, 318, 6318, 495, 8, 83, 304, 272, 492, 1059, 272, 394, 275, 1059, 14, 4097, 7022, 272, 519, 275, 2125, 272, 367, 286, 315, 308, 26, 267, 284, 275, 6206, 8, 67, 9, 267, 519, 275, 519, 435, 394, 7528, 73, 4331, 841, 9, 1253, 378, 6287, 61, 435, 394, 59, 73, 1253, 378, 6287, 61, 272, 372, 519, 199, 199, 533, 15830, 21, 63, 774, 8, 2796, 14, 1746, 304, 339, 347, 6128, 21, 396, 8, 277, 12, 308, 12, 1420, 304, 267, 291, 14, 629, 8, 4097, 495, 8, 1064, 21, 8, 83, 680, 5671, 4000, 1420, 9, 267, 291, 14, 629, 8, 1064, 21, 8, 83, 680, 11453, 1062, 1420, 9, 339, 347, 511, 63, 4316, 83, 8, 277, 304, 267, 3850, 275, 291, 14, 1064, 21, 396, 267, 3850, 8594, 283, 68, 2953, 68, 24, 2866, 2905, 70, 383, 66, 6686, 69, 2905, 383, 13830, 32430, 1349, 1465, 69, 358, 267, 3850, 360, 65, 297, 283, 16, 2055, 10848, 66, 25, 67, 16, 70, 17, 66, 22, 65, 24, 2192, 67, 10936, 69, 12442, 1138, 9969, 17, 358, 267, 3850, 360, 3175, 297, 283, 17518, 1046, 1643, 2658, 2866, 1194, 4675, 16, 68, 1876, 2766, 70, 23, 68, 1651, 69, 1196, 70, 2819, 358, 267, 3850, 360, 1188, 10017, 297, 283, 70, 2534, 66, 19301, 68, 23, 2894, 1965, 1703, 68, 24334, 65, 18, 70, 2192, 31498, 12285, 68, 16, 358, 267, 3850, 360, 23459, 297, 283, 67, 19, 29873, 19, 68, 2114, 5756, 69, 5303, 23, 1587, 66, 18105, 30031, 1822, 69, 969, 66, 358, 267, 3850, 360, 28114, 23459, 11371, 297, 1779, 283, 68, 9892, 371, 2905, 68, 9963, 68, 25, 70, 21, 65, 1367, 845, 67, 18, 67, 25, 70, 25230, 68, 25, 70, 358, 267, 3850, 360, 11272, 25588, 25588, 25588, 11371, 16, 297, 1779, 283, 1641, 27680, 20, 65, 1081, 1235, 19, 67, 32601, 645, 1887, 983, 18, 69, 18, 7555, 66, 1822, 65, 358, 339, 347, 511, 63, 11453, 8, 277, 304, 267, 327, 6318, 5671, 365, 892, 543, 2018, 499, 14, 16, 267, 333, 275, 6128, 21, 360, 4776, 314, 6318, 5671, 1083, 358, 267, 394, 275, 333, 14, 11453, 342, 267, 291, 14, 629, 8, 4097, 495, 8, 77, 14, 5671, 4000, 394, 9, 339, 347, 511, 63, 9629, 63, 873, 8, 277, 304, 267, 282, 305, 275, 283, 65, 7, 627, 5049, 267, 506, 397, 275, 283, 66, 7, 627, 5049, 267, 10142, 397, 275, 283, 67, 7, 627, 5049, 398, 333, 17, 275, 6128, 21, 342, 267, 333, 17, 14, 873, 8, 65, 305, 9, 267, 333, 17, 14, 873, 8, 1235, 397, 9, 267, 333, 17, 14, 873, 8, 301, 397, 9, 398, 333, 18, 275, 6128, 21, 342, 267, 333, 18, 14, 873, 8, 65, 305, 435, 506, 397, 435, 10142, 397, 9, 267, 291, 14, 629, 8, 77, 17, 14, 5671, 1062, 333, 18, 14, 5671, 1012, 199, 199, 318, 511, 63, 973, 837, 272, 511, 63, 4058, 14, 1065, 63, 2796, 8, 5127, 21, 63, 774, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 511, 63, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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/heat.py
29
1115
# Copyright (c) 2012-2013, Mark Peek <mark@peek.org> # Copyright (c) 2014, Andy Botting <andy.botting@theguardian.com> # All rights reserved. # # See LICENSE file for full license. from troposphere import AWSObject from troposphere.validators import integer # Due to the strange nature of the OpenStack compatability layer, some values # that should be integers fail to validate and need to be represented as # strings. For this reason, we duplicate the AWS::AutoScaling::AutoScalingGroup # and change these types. class AWSAutoScalingGroup(AWSObject): resource_type = "AWS::AutoScaling::AutoScalingGroup" props = { 'AvailabilityZones': (list, True), 'Cooldown': (integer, False), 'DesiredCapacity': (basestring, False), 'HealthCheckGracePeriod': (integer, False), 'HealthCheckType': (basestring, False), 'LaunchConfigurationName': (basestring, True), 'LoadBalancerNames': (list, False), 'MaxSize': (basestring, True), 'MinSize': (basestring, True), 'Tags': (list, False), 'VPCZoneIdentifier': (list, False), }
bsd-2-clause
[ 3, 1898, 334, 67, 9, 6029, 13, 6965, 12, 7173, 510, 4374, 665, 1657, 32, 13164, 14, 1308, 30, 199, 3, 1898, 334, 67, 9, 6927, 12, 6061, 89, 24896, 1337, 665, 460, 89, 14, 3018, 1337, 32, 1589, 6051, 31186, 14, 957, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 5113, 570, 367, 2615, 4190, 14, 199, 199, 504, 22621, 555, 14980, 492, 10168, 1692, 199, 504, 22621, 555, 14980, 14, 11346, 492, 3000, 421, 199, 3, 25855, 370, 314, 620, 618, 302, 1463, 402, 314, 14260, 1013, 1936, 2012, 4045, 12, 2005, 1338, 199, 3, 626, 1077, 506, 9446, 2449, 370, 4107, 436, 1929, 370, 506, 11159, 465, 199, 3, 3326, 14, 2104, 642, 4499, 12, 781, 9250, 314, 10168, 447, 3358, 26416, 447, 3358, 26416, 2448, 199, 3, 436, 1570, 3520, 2943, 14, 199, 533, 10168, 3358, 26416, 2448, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 3358, 26416, 447, 3358, 26416, 2448, 2, 339, 10792, 275, 469, 267, 283, 26462, 58, 4548, 356, 334, 513, 12, 715, 395, 267, 283, 967, 27898, 356, 334, 4115, 12, 756, 395, 267, 283, 872, 5381, 22688, 356, 334, 17628, 12, 756, 395, 267, 283, 18850, 1799, 5761, 301, 15518, 356, 334, 4115, 12, 756, 395, 267, 283, 18850, 1799, 804, 356, 334, 17628, 12, 756, 395, 267, 283, 18543, 5688, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 27560, 5866, 356, 334, 513, 12, 756, 395, 267, 283, 4261, 2320, 356, 334, 17628, 12, 715, 395, 267, 283, 4649, 2320, 356, 334, 17628, 12, 715, 395, 267, 283, 9440, 356, 334, 513, 12, 756, 395, 267, 283, 54, 4222, 11860, 7544, 356, 334, 513, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 13, 6965, 12, 7173, 510, 4374, 665, 1657, 32, 13164, 14, 1308, 30, 199, 3, 1898, 334, 67, 9, 6927, 12, 6061, 89, 24896, 1337, 665, 460, 89, 14, 3018, 1337, 32, 1589, 6051, 31186, 14, 957, 30, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 1666, 5113, 570, 367, 2615, 4190, 14, 199, 199, 504, 22621, 555, 14980, 492, 10168, 1692, 199, 504, 22621, 555, 14980, 14, 11346, 492, 3000, 421, 199, 3, 25855, 370, 314, 620, 618, 302, 1463, 402, 314, 14260, 1013, 1936, 2012, 4045, 12, 2005, 1338, 199, 3, 626, 1077, 506, 9446, 2449, 370, 4107, 436, 1929, 370, 506, 11159, 465, 199, 3, 3326, 14, 2104, 642, 4499, 12, 781, 9250, 314, 10168, 447, 3358, 26416, 447, 3358, 26416, 2448, 199, 3, 436, 1570, 3520, 2943, 14, 199, 533, 10168, 3358, 26416, 2448, 8, 13226, 1692, 304, 272, 2073, 63, 466, 275, 298, 13226, 447, 3358, 26416, 447, 3358, 26416, 2448, 2, 339, 10792, 275, 469, 267, 283, 26462, 58, 4548, 356, 334, 513, 12, 715, 395, 267, 283, 967, 27898, 356, 334, 4115, 12, 756, 395, 267, 283, 872, 5381, 22688, 356, 334, 17628, 12, 756, 395, 267, 283, 18850, 1799, 5761, 301, 15518, 356, 334, 4115, 12, 756, 395, 267, 283, 18850, 1799, 804, 356, 334, 17628, 12, 756, 395, 267, 283, 18543, 5688, 985, 356, 334, 17628, 12, 715, 395, 267, 283, 27560, 5866, 356, 334, 513, 12, 756, 395, 267, 283, 4261, 2320, 356, 334, 17628, 12, 715, 395, 267, 283, 4649, 2320, 356, 334, 17628, 12, 715, 395, 267, 283, 9440, 356, 334, 513, 12, 756, 395, 267, 283, 54, 4222, 11860, 7544, 356, 334, 513, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
gauthierm/bedrock
tests/functional/firefox/os/test_tv.py
2
1615
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import pytest from pages.firefox.os.tv import TVPage @pytest.mark.sanity @pytest.mark.nondestructive def test_next_previous_buttons(base_url, selenium): page = TVPage(base_url, selenium).open() assert not page.is_previous_enabled screens = page.screens thumbnails = page.thumbnails for i in range(len(screens) - 1): assert screens[i].is_displayed assert thumbnails[i].is_selected page.show_next_screen() assert not page.is_next_enabled for i in range(len(screens) - 1, 0, -1): assert screens[i].is_displayed assert thumbnails[i].is_selected page.show_previous_screen() assert not page.is_previous_enabled assert screens[0].is_displayed assert thumbnails[0].is_selected @pytest.mark.sanity @pytest.mark.nondestructive def test_click_thumbnails(base_url, selenium): page = TVPage(base_url, selenium).open() screens = page.screens thumbnails = page.thumbnails assert screens[0].is_displayed assert thumbnails[0].is_selected for i in range(1, len(thumbnails)): thumbnails[i].click() assert screens[i].is_displayed assert thumbnails[i].is_selected for i in range(len(thumbnails) - 2, -1, -1): thumbnails[i].click() assert screens[i].is_displayed assert thumbnails[i].is_selected assert screens[0].is_displayed assert thumbnails[0].is_selected
mpl-2.0
[ 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 646, 4613, 199, 199, 504, 6497, 14, 15394, 14, 736, 14, 6993, 492, 26990, 3276, 421, 199, 32, 4462, 14, 1657, 14, 21614, 199, 32, 4462, 14, 1657, 14, 2865, 271, 9853, 857, 199, 318, 511, 63, 2184, 63, 6352, 63, 15687, 8, 1095, 63, 633, 12, 19481, 304, 272, 2034, 275, 26990, 3276, 8, 1095, 63, 633, 12, 19481, 680, 1490, 342, 272, 702, 440, 2034, 14, 374, 63, 6352, 63, 3827, 272, 6426, 83, 275, 2034, 14, 5410, 83, 272, 10062, 83, 275, 2034, 14, 8311, 83, 272, 367, 284, 315, 1425, 8, 552, 8, 5410, 83, 9, 446, 413, 304, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 267, 2034, 14, 2384, 63, 2184, 63, 5410, 342, 272, 702, 440, 2034, 14, 374, 63, 2184, 63, 3827, 272, 367, 284, 315, 1425, 8, 552, 8, 5410, 83, 9, 446, 413, 12, 378, 12, 446, 17, 304, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 267, 2034, 14, 2384, 63, 6352, 63, 5410, 342, 272, 702, 440, 2034, 14, 374, 63, 6352, 63, 3827, 272, 702, 6426, 83, 59, 16, 1055, 374, 63, 22283, 272, 702, 10062, 83, 59, 16, 1055, 374, 63, 5511, 421, 199, 32, 4462, 14, 1657, 14, 21614, 199, 32, 4462, 14, 1657, 14, 2865, 271, 9853, 857, 199, 318, 511, 63, 4891, 63, 8311, 83, 8, 1095, 63, 633, 12, 19481, 304, 272, 2034, 275, 26990, 3276, 8, 1095, 63, 633, 12, 19481, 680, 1490, 342, 272, 6426, 83, 275, 2034, 14, 5410, 83, 272, 10062, 83, 275, 2034, 14, 8311, 83, 272, 702, 6426, 83, 59, 16, 1055, 374, 63, 22283, 272, 702, 10062, 83, 59, 16, 1055, 374, 63, 5511, 272, 367, 284, 315, 1425, 8, 17, 12, 822, 8, 8311, 83, 2298, 267, 10062, 83, 59, 73, 1055, 4891, 342, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 272, 367, 284, 315, 1425, 8, 552, 8, 8311, 83, 9, 446, 499, 12, 446, 17, 12, 446, 17, 304, 267, 10062, 83, 59, 73, 1055, 4891, 342, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 272, 702, 6426, 83, 59, 16, 1055, 374, 63, 22283, 272, 702, 10062, 83, 59, 16, 1055, 374, 63, 5511, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 646, 4613, 199, 199, 504, 6497, 14, 15394, 14, 736, 14, 6993, 492, 26990, 3276, 421, 199, 32, 4462, 14, 1657, 14, 21614, 199, 32, 4462, 14, 1657, 14, 2865, 271, 9853, 857, 199, 318, 511, 63, 2184, 63, 6352, 63, 15687, 8, 1095, 63, 633, 12, 19481, 304, 272, 2034, 275, 26990, 3276, 8, 1095, 63, 633, 12, 19481, 680, 1490, 342, 272, 702, 440, 2034, 14, 374, 63, 6352, 63, 3827, 272, 6426, 83, 275, 2034, 14, 5410, 83, 272, 10062, 83, 275, 2034, 14, 8311, 83, 272, 367, 284, 315, 1425, 8, 552, 8, 5410, 83, 9, 446, 413, 304, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 267, 2034, 14, 2384, 63, 2184, 63, 5410, 342, 272, 702, 440, 2034, 14, 374, 63, 2184, 63, 3827, 272, 367, 284, 315, 1425, 8, 552, 8, 5410, 83, 9, 446, 413, 12, 378, 12, 446, 17, 304, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 267, 2034, 14, 2384, 63, 6352, 63, 5410, 342, 272, 702, 440, 2034, 14, 374, 63, 6352, 63, 3827, 272, 702, 6426, 83, 59, 16, 1055, 374, 63, 22283, 272, 702, 10062, 83, 59, 16, 1055, 374, 63, 5511, 421, 199, 32, 4462, 14, 1657, 14, 21614, 199, 32, 4462, 14, 1657, 14, 2865, 271, 9853, 857, 199, 318, 511, 63, 4891, 63, 8311, 83, 8, 1095, 63, 633, 12, 19481, 304, 272, 2034, 275, 26990, 3276, 8, 1095, 63, 633, 12, 19481, 680, 1490, 342, 272, 6426, 83, 275, 2034, 14, 5410, 83, 272, 10062, 83, 275, 2034, 14, 8311, 83, 272, 702, 6426, 83, 59, 16, 1055, 374, 63, 22283, 272, 702, 10062, 83, 59, 16, 1055, 374, 63, 5511, 272, 367, 284, 315, 1425, 8, 17, 12, 822, 8, 8311, 83, 2298, 267, 10062, 83, 59, 73, 1055, 4891, 342, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 272, 367, 284, 315, 1425, 8, 552, 8, 8311, 83, 9, 446, 499, 12, 446, 17, 12, 446, 17, 304, 267, 10062, 83, 59, 73, 1055, 4891, 342, 267, 702, 6426, 83, 59, 73, 1055, 374, 63, 22283, 267, 702, 10062, 83, 59, 73, 1055, 374, 63, 5511, 272, 702, 6426, 83, 59, 16, 1055, 374, 63, 22283, 272, 702, 10062, 83, 59, 16, 1055, 374, 63, 5511, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
mitya57/debian-buildbot
buildbot/test/fake/pbmanager.py
2
1843
# This file is part of Buildbot. Buildbot is free software: you can # redistribute it and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright Buildbot Team Members from twisted.application import service from twisted.internet import defer class FakePBManager(service.MultiService): def __init__(self): service.MultiService.__init__(self) self.setName("fake-pbmanager") self._registrations = [] self._unregistrations = [] def register(self, portstr, username, password, pfactory): if (portstr, username) not in self._registrations: reg = FakeRegistration(self, portstr, username) self._registrations.append((portstr, username, password)) return reg else: raise KeyError("username '%s' is already registered on port %s" % (username, portstr)) def _unregister(self, portstr, username): self._unregistrations.append((portstr, username)) return defer.succeed(None) class FakeRegistration(object): def __init__(self, pbmanager, portstr, username): self._portstr = portstr self._username = username self._pbmanager = pbmanager def unregister(self): self._pbmanager._unregister(self._portstr, self._username)
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 6516, 3018, 11682, 14409, 83, 199, 199, 504, 7390, 14, 3578, 492, 2435, 199, 504, 7390, 14, 4901, 492, 10133, 421, 199, 533, 7777, 13167, 2988, 8, 1364, 14, 3947, 3167, 304, 339, 347, 636, 826, 721, 277, 304, 267, 2435, 14, 3947, 3167, 855, 826, 721, 277, 9, 267, 291, 14, 18347, 480, 3183, 13, 3317, 2609, 531, 267, 291, 423, 29440, 275, 942, 267, 291, 423, 324, 29440, 275, 942, 339, 347, 2274, 8, 277, 12, 1844, 495, 12, 3434, 12, 2505, 12, 299, 3702, 304, 267, 340, 334, 719, 495, 12, 3434, 9, 440, 315, 291, 423, 29440, 26, 288, 1295, 275, 7777, 11757, 8, 277, 12, 1844, 495, 12, 3434, 9, 288, 291, 423, 29440, 14, 740, 1332, 719, 495, 12, 3434, 12, 2505, 430, 288, 372, 1295, 267, 587, 26, 288, 746, 4067, 480, 2473, 1543, 83, 7, 365, 2575, 7264, 641, 1844, 450, 83, 2, 2574, 450, 334, 2473, 12, 1844, 495, 430, 339, 347, 485, 18408, 8, 277, 12, 1844, 495, 12, 3434, 304, 267, 291, 423, 324, 29440, 14, 740, 1332, 719, 495, 12, 3434, 430, 267, 372, 10133, 14, 26622, 8, 403, 9, 421, 199, 533, 7777, 11757, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 10446, 2609, 12, 1844, 495, 12, 3434, 304, 267, 291, 423, 719, 495, 275, 1844, 495, 267, 291, 423, 2473, 275, 3434, 267, 291, 423, 3317, 2609, 275, 10446, 2609, 339, 347, 24369, 8, 277, 304, 267, 291, 423, 3317, 2609, 423, 18408, 8, 277, 423, 719, 495, 12, 291, 423, 2473, 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 ]
[ 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 6516, 3018, 11682, 14409, 83, 199, 199, 504, 7390, 14, 3578, 492, 2435, 199, 504, 7390, 14, 4901, 492, 10133, 421, 199, 533, 7777, 13167, 2988, 8, 1364, 14, 3947, 3167, 304, 339, 347, 636, 826, 721, 277, 304, 267, 2435, 14, 3947, 3167, 855, 826, 721, 277, 9, 267, 291, 14, 18347, 480, 3183, 13, 3317, 2609, 531, 267, 291, 423, 29440, 275, 942, 267, 291, 423, 324, 29440, 275, 942, 339, 347, 2274, 8, 277, 12, 1844, 495, 12, 3434, 12, 2505, 12, 299, 3702, 304, 267, 340, 334, 719, 495, 12, 3434, 9, 440, 315, 291, 423, 29440, 26, 288, 1295, 275, 7777, 11757, 8, 277, 12, 1844, 495, 12, 3434, 9, 288, 291, 423, 29440, 14, 740, 1332, 719, 495, 12, 3434, 12, 2505, 430, 288, 372, 1295, 267, 587, 26, 288, 746, 4067, 480, 2473, 1543, 83, 7, 365, 2575, 7264, 641, 1844, 450, 83, 2, 2574, 450, 334, 2473, 12, 1844, 495, 430, 339, 347, 485, 18408, 8, 277, 12, 1844, 495, 12, 3434, 304, 267, 291, 423, 324, 29440, 14, 740, 1332, 719, 495, 12, 3434, 430, 267, 372, 10133, 14, 26622, 8, 403, 9, 421, 199, 533, 7777, 11757, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 10446, 2609, 12, 1844, 495, 12, 3434, 304, 267, 291, 423, 719, 495, 275, 1844, 495, 267, 291, 423, 2473, 275, 3434, 267, 291, 423, 3317, 2609, 275, 10446, 2609, 339, 347, 24369, 8, 277, 304, 267, 291, 423, 3317, 2609, 423, 18408, 8, 277, 423, 719, 495, 12, 291, 423, 2473, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
paulscottrobson/fred
__old/Processor/process.py
2
2081
# # Process 1801.def # import re def process(txt,opc): txt = txt.replace("@X","{0:x}".format(opc & 15)) txt = txt.replace("@R","{0}".format(opc & 15)) txt = txt.replace("@F","{0:x}".format((opc & 3)+1)) return txt src = open("1801.def","r").readlines() # read file src = [x if x.find("//") < 0 else x[:x.find("//")] for x in src] # delete comments src = [x.replace("\t"," ").strip() for x in src] # spaces and tabs src = [x for x in src if x != ""] # remove blank lines open("_1801_include.h","w").write("\n".join([x[1:] for x in src if x[0] == ':'])) mnemonics = [ None ] * 256 # mnemonics codes = [ None ] * 256 # executable codes. for l in [x for x in src if x[0] != ':']: # for each line. m = re.match('^([0-9A-F\\-]+)\\s*\\"(.*)\\"\s*(.*)$',l) # check it assert m is not None,"Error "+l rg = m.group(1) if len(rg) == 2: # get from/to range rg = rg + "-"+rg for opcode in range(int(rg[:2],16),int(rg[-2:],16)+1): # for each opcode assert mnemonics[opcode] is None mnemonics[opcode] = process(m.group(2),opcode-int(rg[:2],16)).lower() codes[opcode] = process(m.group(3),opcode-int(rg[:2],16)) for i in range(0,256): # fill in mnemonics if mnemonics[i] is None: mnemonics[i] = "byte {0:02x}".format(i) open("_1801_disasm.h","w").write(",".join(['"'+m+'"' for m in mnemonics])) # write out disassembly table h = open("_1801_opcodes.h","w") for i in range(0,256): if codes[i] is not None: h.write("case 0x{0:02x}: // *** {1} ***\n".format(i,mnemonics[i])) h.write(" {0};break;\n".format(codes[i])) h = open("_1801_ports.h","w") for i in range(0,8): h.write("#ifndef INPORT{0}\n".format(i)) h.write("#define INPORT{0}() (0)\n".format(i)) h.write("#endif\n") h.write("#ifndef OUTPORT{0}\n".format(i)) h.write("#define OUTPORT{0}(v) {{}}\n".format(i)) h.write("#endif\n") for i in range(1,5): h.write("#ifndef EFLAG{0}\n".format(i)) h.write("#define EFLAG{0}() (0)\n".format(i)) h.write("#endif\n") h.close()
mit
[ 3, 199, 3, 198, 198, 3498, 6155, 614, 14, 318, 199, 3, 199, 646, 295, 199, 199, 318, 2112, 8, 2424, 12, 411, 67, 304, 199, 198, 2424, 275, 9444, 14, 1814, 25915, 56, 2266, 91, 16, 26, 88, 5469, 908, 8, 411, 67, 1253, 4114, 430, 199, 198, 2424, 275, 9444, 14, 1814, 25915, 50, 2266, 91, 16, 5469, 908, 8, 411, 67, 1253, 4114, 430, 199, 198, 2424, 275, 9444, 14, 1814, 25915, 38, 2266, 91, 16, 26, 88, 5469, 908, 1332, 411, 67, 1253, 650, 6393, 17, 430, 199, 198, 1107, 9444, 199, 199, 2164, 275, 1551, 480, 1085, 614, 14, 318, 2266, 82, 3471, 9684, 342, 24564, 7542, 198, 3, 1586, 570, 199, 2164, 275, 359, 88, 340, 671, 14, 1623, 21816, 531, 665, 378, 587, 671, 1491, 88, 14, 1623, 21816, 11323, 367, 671, 315, 2928, 61, 27997, 198, 3, 3145, 6786, 199, 2164, 275, 359, 88, 14, 1814, 4582, 84, 2266, 298, 680, 1913, 342, 367, 671, 315, 2928, 61, 24564, 198, 198, 3, 7883, 436, 12187, 199, 2164, 275, 359, 88, 367, 671, 315, 2928, 340, 671, 1137, 298, 937, 24564, 27997, 198, 3, 2813, 4596, 2385, 199, 199, 1490, 11008, 1085, 614, 63, 2613, 14, 72, 2266, 87, 3471, 952, 4582, 78, 1674, 904, 779, 88, 59, 17, 2938, 367, 671, 315, 2928, 340, 671, 59, 16, 61, 508, 7596, 5156, 199, 199, 22599, 2106, 2932, 275, 359, 488, 1622, 627, 7633, 24564, 7542, 9622, 198, 3, 18250, 2106, 2932, 199, 6021, 275, 359, 488, 1622, 627, 7633, 24564, 24564, 198, 3, 7286, 9479, 14, 199, 509, 634, 315, 359, 88, 367, 671, 315, 2928, 340, 671, 59, 16, 61, 1137, 7596, 2565, 24564, 9622, 198, 3, 367, 1924, 1004, 14, 199, 198, 77, 275, 295, 14, 1431, 9097, 779, 16, 13, 25, 33, 13, 38, 1103, 13, 11896, 1103, 83, 10, 15022, 8, 12432, 1103, 3212, 83, 5830, 12432, 4268, 76, 9, 7542, 9622, 198, 3, 1104, 652, 199, 198, 479, 333, 365, 440, 488, 4589, 547, 7210, 76, 199, 198, 12430, 275, 333, 14, 923, 8, 17, 9, 199, 198, 692, 822, 8, 12430, 9, 508, 499, 26, 24564, 24564, 198, 3, 664, 687, 15, 475, 1425, 507, 198, 12430, 275, 23136, 435, 3905, 7709, 12430, 199, 198, 509, 10508, 315, 1425, 8, 442, 8, 12430, 1491, 18, 467, 975, 395, 442, 8, 12430, 1988, 18, 8429, 975, 6393, 17, 304, 7542, 9622, 198, 3, 367, 1924, 10508, 507, 198, 479, 18250, 2106, 2932, 59, 14325, 61, 365, 488, 507, 198, 22599, 2106, 2932, 59, 14325, 61, 275, 2112, 8, 77, 14, 923, 8, 18, 395, 14325, 13, 442, 8, 12430, 1491, 18, 467, 975, 4992, 2325, 342, 507, 198, 6021, 59, 14325, 61, 275, 2112, 8, 77, 14, 923, 8, 19, 395, 14325, 13, 442, 8, 12430, 1491, 18, 467, 975, 430, 199, 199, 509, 284, 315, 1425, 8, 16, 12, 3912, 304, 24564, 24564, 198, 3, 5554, 315, 18250, 2106, 2932, 199, 198, 692, 18250, 2106, 2932, 59, 73, 61, 365, 488, 26, 507, 198, 22599, 2106, 2932, 59, 73, 61, 275, 298, 4414, 469, 16, 26, 996, 88, 5469, 908, 8, 73, 9, 199, 199, 1490, 11008, 1085, 614, 63, 2297, 11374, 14, 72, 2266, 87, 3471, 952, 11854, 1674, 904, 2941, 4507, 11, 77, 11, 30385, 367, 333, 315, 18250, 2106, 2932, 2459, 9622, 198, 3, 2218, 734, 2153, 17828, 1817, 199, 199, 72, 275, 1551, 11008, 1085, 614, 63, 22022, 14, 72, 2266, 87, 531, 199, 509, 284, 315, 1425, 8, 16, 12, 3912, 304, 199, 198, 692, 9479, 59, 73, 61, 365, 440, 488, 26, 507, 198, 72, 14, 952, 480, 2546, 378, 88, 91, 16, 26, 996, 88, 9160, 5001, 19688, 469, 17, 93, 1011, 7590, 78, 1674, 908, 8, 73, 12, 22599, 2106, 2932, 59, 73, 2459, 507, 198, 72, 14, 952, 480, 259, 469, 16, 12084, 4785, 3779, 78, 1674, 908, 8, 6021, 59, 73, 2459, 199, 199, 72, 275, 1551, 11008, 1085, 614, 63, 5203, 14, 72, 2266, 87, 531, 199, 509, 284, 315, 1425, 8, 16, 12, 24, 304, 199, 198, 72, 14, 952, 10064, 27708, 1621, 3657, 91, 16, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 4640, 1621, 3657, 91, 16, 93, 342, 334, 16, 2862, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 13739, 60, 78, 531, 199, 198, 72, 14, 952, 10064, 27708, 5738, 3657, 91, 16, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 4640, 5738, 3657, 91, 16, 22999, 86, 9, 469, 2440, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 13739, 60, 78, 531, 199, 509, 284, 315, 1425, 8, 17, 12, 21, 304, 199, 198, 72, 14, 952, 10064, 27708, 662, 3719, 91, 16, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 4640, 662, 3719, 91, 16, 93, 342, 334, 16, 2862, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 13739, 60, 78, 531, 199, 72, 14, 1600, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 198, 198, 3498, 6155, 614, 14, 318, 199, 3, 199, 646, 295, 199, 199, 318, 2112, 8, 2424, 12, 411, 67, 304, 199, 198, 2424, 275, 9444, 14, 1814, 25915, 56, 2266, 91, 16, 26, 88, 5469, 908, 8, 411, 67, 1253, 4114, 430, 199, 198, 2424, 275, 9444, 14, 1814, 25915, 50, 2266, 91, 16, 5469, 908, 8, 411, 67, 1253, 4114, 430, 199, 198, 2424, 275, 9444, 14, 1814, 25915, 38, 2266, 91, 16, 26, 88, 5469, 908, 1332, 411, 67, 1253, 650, 6393, 17, 430, 199, 198, 1107, 9444, 199, 199, 2164, 275, 1551, 480, 1085, 614, 14, 318, 2266, 82, 3471, 9684, 342, 24564, 7542, 198, 3, 1586, 570, 199, 2164, 275, 359, 88, 340, 671, 14, 1623, 21816, 531, 665, 378, 587, 671, 1491, 88, 14, 1623, 21816, 11323, 367, 671, 315, 2928, 61, 27997, 198, 3, 3145, 6786, 199, 2164, 275, 359, 88, 14, 1814, 4582, 84, 2266, 298, 680, 1913, 342, 367, 671, 315, 2928, 61, 24564, 198, 198, 3, 7883, 436, 12187, 199, 2164, 275, 359, 88, 367, 671, 315, 2928, 340, 671, 1137, 298, 937, 24564, 27997, 198, 3, 2813, 4596, 2385, 199, 199, 1490, 11008, 1085, 614, 63, 2613, 14, 72, 2266, 87, 3471, 952, 4582, 78, 1674, 904, 779, 88, 59, 17, 2938, 367, 671, 315, 2928, 340, 671, 59, 16, 61, 508, 7596, 5156, 199, 199, 22599, 2106, 2932, 275, 359, 488, 1622, 627, 7633, 24564, 7542, 9622, 198, 3, 18250, 2106, 2932, 199, 6021, 275, 359, 488, 1622, 627, 7633, 24564, 24564, 198, 3, 7286, 9479, 14, 199, 509, 634, 315, 359, 88, 367, 671, 315, 2928, 340, 671, 59, 16, 61, 1137, 7596, 2565, 24564, 9622, 198, 3, 367, 1924, 1004, 14, 199, 198, 77, 275, 295, 14, 1431, 9097, 779, 16, 13, 25, 33, 13, 38, 1103, 13, 11896, 1103, 83, 10, 15022, 8, 12432, 1103, 3212, 83, 5830, 12432, 4268, 76, 9, 7542, 9622, 198, 3, 1104, 652, 199, 198, 479, 333, 365, 440, 488, 4589, 547, 7210, 76, 199, 198, 12430, 275, 333, 14, 923, 8, 17, 9, 199, 198, 692, 822, 8, 12430, 9, 508, 499, 26, 24564, 24564, 198, 3, 664, 687, 15, 475, 1425, 507, 198, 12430, 275, 23136, 435, 3905, 7709, 12430, 199, 198, 509, 10508, 315, 1425, 8, 442, 8, 12430, 1491, 18, 467, 975, 395, 442, 8, 12430, 1988, 18, 8429, 975, 6393, 17, 304, 7542, 9622, 198, 3, 367, 1924, 10508, 507, 198, 479, 18250, 2106, 2932, 59, 14325, 61, 365, 488, 507, 198, 22599, 2106, 2932, 59, 14325, 61, 275, 2112, 8, 77, 14, 923, 8, 18, 395, 14325, 13, 442, 8, 12430, 1491, 18, 467, 975, 4992, 2325, 342, 507, 198, 6021, 59, 14325, 61, 275, 2112, 8, 77, 14, 923, 8, 19, 395, 14325, 13, 442, 8, 12430, 1491, 18, 467, 975, 430, 199, 199, 509, 284, 315, 1425, 8, 16, 12, 3912, 304, 24564, 24564, 198, 3, 5554, 315, 18250, 2106, 2932, 199, 198, 692, 18250, 2106, 2932, 59, 73, 61, 365, 488, 26, 507, 198, 22599, 2106, 2932, 59, 73, 61, 275, 298, 4414, 469, 16, 26, 996, 88, 5469, 908, 8, 73, 9, 199, 199, 1490, 11008, 1085, 614, 63, 2297, 11374, 14, 72, 2266, 87, 3471, 952, 11854, 1674, 904, 2941, 4507, 11, 77, 11, 30385, 367, 333, 315, 18250, 2106, 2932, 2459, 9622, 198, 3, 2218, 734, 2153, 17828, 1817, 199, 199, 72, 275, 1551, 11008, 1085, 614, 63, 22022, 14, 72, 2266, 87, 531, 199, 509, 284, 315, 1425, 8, 16, 12, 3912, 304, 199, 198, 692, 9479, 59, 73, 61, 365, 440, 488, 26, 507, 198, 72, 14, 952, 480, 2546, 378, 88, 91, 16, 26, 996, 88, 9160, 5001, 19688, 469, 17, 93, 1011, 7590, 78, 1674, 908, 8, 73, 12, 22599, 2106, 2932, 59, 73, 2459, 507, 198, 72, 14, 952, 480, 259, 469, 16, 12084, 4785, 3779, 78, 1674, 908, 8, 6021, 59, 73, 2459, 199, 199, 72, 275, 1551, 11008, 1085, 614, 63, 5203, 14, 72, 2266, 87, 531, 199, 509, 284, 315, 1425, 8, 16, 12, 24, 304, 199, 198, 72, 14, 952, 10064, 27708, 1621, 3657, 91, 16, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 4640, 1621, 3657, 91, 16, 93, 342, 334, 16, 2862, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 13739, 60, 78, 531, 199, 198, 72, 14, 952, 10064, 27708, 5738, 3657, 91, 16, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 4640, 5738, 3657, 91, 16, 22999, 86, 9, 469, 2440, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 13739, 60, 78, 531, 199, 509, 284, 315, 1425, 8, 17, 12, 21, 304, 199, 198, 72, 14, 952, 10064, 27708, 662, 3719, 91, 16, 4988, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 4640, 662, 3719, 91, 16, 93, 342, 334, 16, 2862, 78, 1674, 908, 8, 73, 430, 199, 198, 72, 14, 952, 10064, 13739, 60, 78, 531, 199, 72, 14, 1600, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nuncjo/odoo
addons/l10n_mx/__openerp__.py
379
2559
# -*- encoding: utf-8 -*- ########################################################################### # Module Writen to OpenERP, Open Source Management Solution # All Rights Reserved ###############Credits###################################################### # Coded by: Alejandro Negrin anegrin@vauxoo.com, # Planified by: Alejandro Negrin, Humberto Arocha, Moises Lopez # Finance by: Vauxoo. # Audited by: Humberto Arocha (hbto@vauxoo.com) y Moises Lopez (moylop260@vauxoo.com) ############################################################################# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ############################################################################## { "name" : "Mexico - Accounting", "version" : "2.0", "author" : "Vauxoo", "category" : "Localization/Account Charts", "description": """ Minimal accounting configuration for Mexico. ============================================ This Chart of account is a minimal proposal to be able to use OoB the accounting feature of Openerp. This doesn't pretend be all the localization for MX it is just the minimal data required to start from 0 in mexican localization. This modules and its content is updated frequently by openerp-mexico team. With this module you will have: - Minimal chart of account tested in production eviroments. - Minimal chart of taxes, to comply with SAT_ requirements. .. SAT: http://www.sat.gob.mx/ """, "depends" : ["account", "base_vat", "account_chart", ], "demo_xml" : [], "data" : ["data/account_tax_code.xml", "data/account_chart.xml", "data/account_tax.xml", "data/l10n_chart_mx_wizard.xml"], "active": False, "installable": True, "certificate": False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3949, 5680, 199, 3, 259, 5673, 12859, 724, 370, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 2900, 5924, 5702, 199, 516, 14776, 5482, 15256, 22529, 3726, 199, 3, 259, 5495, 68, 701, 26, 6832, 74, 460, 293, 5612, 2587, 262, 376, 69, 2587, 262, 32, 3042, 2521, 1534, 14, 957, 12, 199, 3, 259, 32427, 4541, 701, 26, 6832, 74, 460, 293, 5612, 2587, 262, 12, 869, 884, 475, 437, 293, 9518, 12, 3930, 1388, 3835, 321, 90, 199, 3, 259, 11711, 554, 701, 26, 812, 10962, 1534, 14, 199, 3, 259, 437, 14525, 471, 701, 26, 869, 884, 475, 437, 293, 9518, 334, 16168, 475, 32, 3042, 2521, 1534, 14, 957, 9, 612, 3930, 1388, 3835, 321, 90, 334, 573, 89, 18630, 13085, 32, 3042, 2521, 1534, 14, 957, 9, 199, 31635, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 4605, 199, 199, 91, 272, 298, 354, 2, 520, 298, 45, 476, 12802, 446, 9973, 316, 401, 272, 298, 1023, 2, 520, 298, 18, 14, 16, 401, 272, 298, 2502, 2, 520, 298, 54, 10962, 1534, 401, 272, 298, 3710, 2, 520, 298, 5339, 2072, 15, 6009, 24874, 83, 401, 272, 298, 1802, 582, 408, 199, 4649, 7265, 24772, 2897, 367, 603, 476, 12802, 14, 199, 2486, 5769, 199, 199, 2765, 24874, 402, 2933, 365, 282, 13460, 28315, 370, 506, 7688, 370, 675, 593, 79, 34, 314, 221, 199, 21609, 3878, 402, 9319, 4457, 14, 199, 199, 2765, 3181, 1133, 27830, 506, 1006, 314, 2257, 2072, 367, 603, 56, 652, 365, 2951, 314, 13460, 221, 199, 576, 1415, 370, 1343, 687, 378, 315, 562, 88, 530, 290, 2257, 2072, 14, 199, 199, 2765, 4621, 436, 2399, 1564, 365, 4588, 28914, 590, 701, 5166, 13, 278, 30077, 8099, 14, 199, 199, 3007, 642, 859, 1265, 911, 1172, 26, 421, 446, 10195, 7265, 10943, 402, 2933, 12470, 315, 9920, 24656, 293, 1470, 14, 199, 446, 10195, 7265, 10943, 402, 21139, 12, 370, 1013, 590, 543, 428, 619, 63, 9760, 14, 199, 199, 703, 428, 619, 26, 1455, 921, 1544, 14, 14997, 14, 1939, 66, 14, 9457, 15, 272, 10327, 272, 298, 8912, 2, 520, 2097, 2048, 401, 20169, 298, 1095, 63, 16305, 401, 20169, 298, 2048, 63, 9019, 401, 326, 2156, 272, 298, 8768, 63, 1652, 2, 520, 990, 272, 298, 576, 2, 520, 2097, 576, 15, 2048, 63, 5530, 63, 600, 14, 1652, 401, 9326, 490, 298, 576, 15, 2048, 63, 9019, 14, 1652, 401, 490, 298, 576, 15, 2048, 63, 5530, 14, 1652, 401, 490, 298, 576, 15, 76, 709, 78, 63, 9019, 63, 9457, 63, 9819, 14, 1652, 2255, 272, 298, 2682, 582, 756, 12, 272, 298, 21762, 582, 715, 12, 272, 298, 6999, 582, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3949, 5680, 199, 3, 259, 5673, 12859, 724, 370, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 2900, 5924, 5702, 199, 516, 14776, 5482, 15256, 22529, 3726, 199, 3, 259, 5495, 68, 701, 26, 6832, 74, 460, 293, 5612, 2587, 262, 376, 69, 2587, 262, 32, 3042, 2521, 1534, 14, 957, 12, 199, 3, 259, 32427, 4541, 701, 26, 6832, 74, 460, 293, 5612, 2587, 262, 12, 869, 884, 475, 437, 293, 9518, 12, 3930, 1388, 3835, 321, 90, 199, 3, 259, 11711, 554, 701, 26, 812, 10962, 1534, 14, 199, 3, 259, 437, 14525, 471, 701, 26, 869, 884, 475, 437, 293, 9518, 334, 16168, 475, 32, 3042, 2521, 1534, 14, 957, 9, 612, 3930, 1388, 3835, 321, 90, 334, 573, 89, 18630, 13085, 32, 3042, 2521, 1534, 14, 957, 9, 199, 31635, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 4605, 199, 199, 91, 272, 298, 354, 2, 520, 298, 45, 476, 12802, 446, 9973, 316, 401, 272, 298, 1023, 2, 520, 298, 18, 14, 16, 401, 272, 298, 2502, 2, 520, 298, 54, 10962, 1534, 401, 272, 298, 3710, 2, 520, 298, 5339, 2072, 15, 6009, 24874, 83, 401, 272, 298, 1802, 582, 408, 199, 4649, 7265, 24772, 2897, 367, 603, 476, 12802, 14, 199, 2486, 5769, 199, 199, 2765, 24874, 402, 2933, 365, 282, 13460, 28315, 370, 506, 7688, 370, 675, 593, 79, 34, 314, 221, 199, 21609, 3878, 402, 9319, 4457, 14, 199, 199, 2765, 3181, 1133, 27830, 506, 1006, 314, 2257, 2072, 367, 603, 56, 652, 365, 2951, 314, 13460, 221, 199, 576, 1415, 370, 1343, 687, 378, 315, 562, 88, 530, 290, 2257, 2072, 14, 199, 199, 2765, 4621, 436, 2399, 1564, 365, 4588, 28914, 590, 701, 5166, 13, 278, 30077, 8099, 14, 199, 199, 3007, 642, 859, 1265, 911, 1172, 26, 421, 446, 10195, 7265, 10943, 402, 2933, 12470, 315, 9920, 24656, 293, 1470, 14, 199, 446, 10195, 7265, 10943, 402, 21139, 12, 370, 1013, 590, 543, 428, 619, 63, 9760, 14, 199, 199, 703, 428, 619, 26, 1455, 921, 1544, 14, 14997, 14, 1939, 66, 14, 9457, 15, 272, 10327, 272, 298, 8912, 2, 520, 2097, 2048, 401, 20169, 298, 1095, 63, 16305, 401, 20169, 298, 2048, 63, 9019, 401, 326, 2156, 272, 298, 8768, 63, 1652, 2, 520, 990, 272, 298, 576, 2, 520, 2097, 576, 15, 2048, 63, 5530, 63, 600, 14, 1652, 401, 9326, 490, 298, 576, 15, 2048, 63, 9019, 14, 1652, 401, 490, 298, 576, 15, 2048, 63, 5530, 14, 1652, 401, 490, 298, 576, 15, 76, 709, 78, 63, 9019, 63, 9457, 63, 9819, 14, 1652, 2255, 272, 298, 2682, 582, 756, 12, 272, 298, 21762, 582, 715, 12, 272, 298, 6999, 582, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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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 ]
caphrim007/ansible
lib/ansible/modules/storage/netapp/na_ontap_net_port.py
6
8182
#!/usr/bin/python # (c) 2018, NetApp, Inc # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = """ module: na_ontap_net_port short_description: Manage NetApp ONTAP network ports. extends_documentation_fragment: - netapp.na_ontap version_added: '2.6' author: NetApp Ansible Team (ng-ansibleteam@netapp.com) description: - Modify a Ontap network port. options: state: description: - Whether the specified net port should exist or not. choices: ['present'] default: present node: description: - Specifies the name of node. required: true port: description: - Specifies the name of port. required: true mtu: description: - Specifies the maximum transmission unit (MTU) reported by the port. autonegotiate_admin: description: - Enables or disables Ethernet auto-negotiation of speed, duplex and flow control. duplex_admin: description: - Specifies the user preferred duplex setting of the port. - Valid values auto, half, full speed_admin: description: - Specifies the user preferred speed setting of the port. flowcontrol_admin: description: - Specifies the user preferred flow control setting of the port. ipspace: description: - Specifies the port's associated IPspace name. - The 'Cluster' ipspace is reserved for cluster ports. """ EXAMPLES = """ - name: Modify Net Port na_ontap_net_port: state=present username={{ netapp_username }} password={{ netapp_password }} hostname={{ netapp_hostname }} node={{ Vsim server name }} port=e0d autonegotiate_admin=true """ RETURN = """ """ from ansible.module_utils.basic import AnsibleModule import ansible.module_utils.netapp as netapp_utils HAS_NETAPP_LIB = netapp_utils.has_netapp_lib() class NetAppOntapNetPort(object): """ Modify a Net port """ def __init__(self): """ Initialize the Ontap Net Port Class """ self.argument_spec = netapp_utils.na_ontap_host_argument_spec() self.argument_spec.update(dict( state=dict(required=False, choices=['present'], default='present'), node=dict(required=True, type="str"), port=dict(required=True, type="str"), mtu=dict(required=False, type="str", default=None), autonegotiate_admin=dict(required=False, type="str", default=None), duplex_admin=dict(required=False, type="str", default=None), speed_admin=dict(required=False, type="str", default=None), flowcontrol_admin=dict(required=False, type="str", default=None), ipspace=dict(required=False, type="str", default=None), )) self.module = AnsibleModule( argument_spec=self.argument_spec, supports_check_mode=True ) p = self.module.params # set up state variables self.state = p['state'] self.node = p['node'] self.port = p['port'] # the following option are optional, but at least one need to be set self.mtu = p['mtu'] self.autonegotiate_admin = p["autonegotiate_admin"] self.duplex_admin = p["duplex_admin"] self.speed_admin = p["speed_admin"] self.flowcontrol_admin = p["flowcontrol_admin"] if HAS_NETAPP_LIB is False: self.module.fail_json( msg="the python NetApp-Lib module is required") else: self.server = netapp_utils.setup_na_ontap_zapi(module=self.module) return def get_net_port(self): """ Return details about the net port :return: Details about the net port. None if not found. :rtype: dict """ net_port_info = netapp_utils.zapi.NaElement('net-port-get-iter') net_port_attributes = netapp_utils.zapi.NaElement('net-port-info') net_port_attributes.add_new_child('node', self.node) net_port_attributes.add_new_child('port', self.port) query = netapp_utils.zapi.NaElement('query') query.add_child_elem(net_port_attributes) net_port_info.add_child_elem(query) result = self.server.invoke_successfully(net_port_info, True) return_value = None if result.get_child_by_name('num-records') and \ int(result.get_child_content('num-records')) >= 1: net_port_attributes = result.get_child_by_name('attributes-list').\ get_child_by_name('net-port-info') return_value = { 'node': net_port_attributes.get_child_content('node'), 'port': net_port_attributes.get_child_content('port'), 'mtu': net_port_attributes.get_child_content('mtu'), 'autonegotiate_admin': net_port_attributes.get_child_content( 'is-administrative-auto-negotiate'), 'duplex_admin': net_port_attributes.get_child_content( 'administrative-duplex'), 'speed_admin': net_port_attributes.get_child_content( 'administrative-speed'), 'flowcontrol_admin': net_port_attributes.get_child_content( 'administrative-flowcontrol'), } return return_value def modify_net_port(self): """ Modify a port """ port_obj = netapp_utils.zapi.NaElement('net-port-modify') port_obj.add_new_child("node", self.node) port_obj.add_new_child("port", self.port) # The following options are optional. # We will only call them if they are not set to None if self.mtu: port_obj.add_new_child("mtu", self.mtu) if self.autonegotiate_admin: port_obj.add_new_child( "is-administrative-auto-negotiate", self.autonegotiate_admin) if self.duplex_admin: port_obj.add_new_child("administrative-duplex", self.duplex_admin) if self.speed_admin: port_obj.add_new_child("administrative-speed", self.speed_admin) if self.flowcontrol_admin: port_obj.add_new_child( "administrative-flowcontrol", self.flowcontrol_admin) self.server.invoke_successfully(port_obj, True) def apply(self): """ Run Module based on play book """ changed = False net_port_exists = False results = netapp_utils.get_cserver(self.server) cserver = netapp_utils.setup_na_ontap_zapi( module=self.module, vserver=results) netapp_utils.ems_log_event("na_ontap_net_port", cserver) net_port_details = self.get_net_port() if net_port_details: net_port_exists = True if self.state == 'present': if (self.mtu and self.mtu != net_port_details['mtu']) or \ (self.autonegotiate_admin and self.autonegotiate_admin != net_port_details['autonegotiate_admin']) or \ (self.duplex_admin and self.duplex_admin != net_port_details['duplex_admin']) or \ (self.speed_admin and self.speed_admin != net_port_details['speed_admin']) or \ (self.flowcontrol_admin and self.flowcontrol_admin != net_port_details['flowcontrol_admin']): changed = True if changed: if self.module.check_mode: pass else: if self.state == 'present': if net_port_exists: self.modify_net_port() self.module.exit_json(changed=changed) def main(): """ Create the NetApp Ontap Net Port Object and modify it """ obj = NetAppOntapNetPort() obj.apply() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 408, 199, 578, 26, 11802, 63, 1888, 439, 63, 846, 63, 719, 199, 3612, 63, 1802, 26, 14944, 28076, 5258, 52, 1282, 2784, 8873, 14, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 3540, 63, 1888, 439, 199, 1023, 63, 3270, 26, 283, 18, 14, 22, 7, 199, 2502, 26, 28076, 2622, 11682, 334, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 9, 199, 1802, 26, 199, 13, 22520, 282, 593, 343, 439, 2784, 1844, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 272, 446, 7480, 314, 2013, 1851, 1844, 1077, 2187, 503, 440, 14, 272, 3415, 26, 788, 1881, 418, 272, 849, 26, 3451, 523, 1031, 26, 272, 1369, 26, 272, 446, 11015, 314, 536, 402, 1031, 14, 272, 1415, 26, 2549, 523, 1844, 26, 272, 1369, 26, 272, 446, 11015, 314, 536, 402, 1844, 14, 272, 1415, 26, 2549, 523, 28270, 26, 272, 1369, 26, 272, 446, 11015, 314, 5696, 1752, 2250, 4137, 334, 5747, 53, 9, 14581, 701, 314, 1844, 14, 523, 6384, 368, 14727, 323, 63, 2113, 26, 272, 1369, 26, 272, 446, 3447, 5921, 503, 28421, 26125, 2599, 13, 21961, 425, 402, 8112, 12, 489, 366, 26646, 436, 6369, 3304, 14, 523, 366, 26646, 63, 2113, 26, 272, 1369, 26, 272, 446, 11015, 314, 922, 14388, 366, 26646, 4260, 402, 314, 1844, 14, 272, 446, 4821, 1338, 2599, 12, 12995, 12, 2615, 523, 8112, 63, 2113, 26, 272, 1369, 26, 272, 446, 11015, 314, 922, 14388, 8112, 4260, 402, 314, 1844, 14, 523, 6369, 2785, 63, 2113, 26, 272, 1369, 26, 272, 446, 11015, 314, 922, 14388, 6369, 3304, 4260, 402, 314, 1844, 14, 523, 15017, 1142, 26, 272, 1369, 26, 272, 446, 11015, 314, 1844, 1159, 4568, 3531, 2638, 536, 14, 272, 446, 710, 283, 9581, 7, 15017, 1142, 365, 4644, 367, 4350, 8873, 14, 199, 624, 199, 199, 8918, 275, 408, 272, 446, 536, 26, 22520, 5365, 10977, 489, 11802, 63, 1888, 439, 63, 846, 63, 719, 26, 267, 1174, 29, 1881, 267, 3434, 3126, 91, 15742, 63, 2473, 3586, 267, 2505, 3126, 91, 15742, 63, 2060, 3586, 267, 6246, 3126, 91, 15742, 63, 4269, 3586, 267, 1031, 3126, 91, 812, 5206, 1654, 536, 3586, 267, 1844, 29, 69, 16, 68, 267, 6384, 368, 14727, 323, 63, 2113, 29, 2052, 199, 624, 199, 199, 9677, 275, 408, 199, 199, 624, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 646, 3242, 14, 578, 63, 1208, 14, 25830, 465, 15742, 63, 1208, 199, 199, 13533, 63, 7278, 7121, 63, 5617, 275, 15742, 63, 1208, 14, 1989, 63, 25830, 63, 773, 342, 421, 199, 533, 28076, 47, 343, 439, 2480, 4313, 8, 785, 304, 272, 408, 267, 22520, 282, 5365, 1844, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 408, 288, 11578, 314, 593, 343, 439, 5365, 10977, 8089, 267, 408, 267, 291, 14, 2094, 63, 1650, 275, 15742, 63, 1208, 14, 3540, 63, 1888, 439, 63, 1102, 63, 2094, 63, 1650, 342, 267, 291, 14, 2094, 63, 1650, 14, 873, 8, 807, 8, 288, 1174, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 995, 849, 534, 1881, 659, 288, 1031, 29, 807, 8, 2427, 29, 549, 12, 730, 628, 495, 1288, 288, 1844, 29, 807, 8, 2427, 29, 549, 12, 730, 628, 495, 1288, 288, 28270, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 6384, 368, 14727, 323, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 366, 26646, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 8112, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 6369, 2785, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 15017, 1142, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 267, 5082, 398, 291, 14, 578, 275, 6953, 8, 288, 1423, 63, 1650, 29, 277, 14, 2094, 63, 1650, 12, 288, 5171, 63, 1074, 63, 632, 29, 549, 267, 776, 398, 299, 275, 291, 14, 578, 14, 1162, 398, 327, 663, 1536, 1174, 2860, 267, 291, 14, 929, 275, 299, 459, 929, 418, 267, 291, 14, 932, 275, 299, 459, 932, 418, 267, 291, 14, 719, 275, 299, 459, 719, 418, 267, 327, 314, 2569, 945, 787, 2716, 12, 1325, 737, 5210, 1373, 1929, 370, 506, 663, 267, 291, 14, 17696, 275, 299, 459, 17696, 418, 267, 291, 14, 6898, 368, 14727, 323, 63, 2113, 275, 299, 905, 6898, 368, 14727, 323, 63, 2113, 937, 267, 291, 14, 68, 26646, 63, 2113, 275, 299, 905, 68, 26646, 63, 2113, 937, 267, 291, 14, 7625, 63, 2113, 275, 299, 905, 7625, 63, 2113, 937, 267, 291, 14, 1659, 2785, 63, 2113, 275, 299, 905, 1659, 2785, 63, 2113, 937, 398, 340, 7509, 63, 7278, 7121, 63, 5617, 365, 756, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 355, 1499, 628, 1589, 2366, 28076, 13, 4728, 859, 365, 1415, 531, 267, 587, 26, 288, 291, 14, 1000, 275, 15742, 63, 1208, 14, 2758, 63, 3540, 63, 1888, 439, 63, 21059, 8, 578, 29, 277, 14, 578, 9, 267, 372, 339, 347, 664, 63, 846, 63, 719, 8, 277, 304, 267, 408, 267, 1432, 2436, 3595, 314, 1851, 1844, 398, 520, 1107, 26, 15621, 3595, 314, 1851 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 334, 67, 9, 14894, 12, 28076, 12, 3277, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 408, 199, 578, 26, 11802, 63, 1888, 439, 63, 846, 63, 719, 199, 3612, 63, 1802, 26, 14944, 28076, 5258, 52, 1282, 2784, 8873, 14, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 15742, 14, 3540, 63, 1888, 439, 199, 1023, 63, 3270, 26, 283, 18, 14, 22, 7, 199, 2502, 26, 28076, 2622, 11682, 334, 2753, 13, 4853, 5969, 32, 25830, 14, 957, 9, 199, 1802, 26, 199, 13, 22520, 282, 593, 343, 439, 2784, 1844, 14, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 272, 446, 7480, 314, 2013, 1851, 1844, 1077, 2187, 503, 440, 14, 272, 3415, 26, 788, 1881, 418, 272, 849, 26, 3451, 523, 1031, 26, 272, 1369, 26, 272, 446, 11015, 314, 536, 402, 1031, 14, 272, 1415, 26, 2549, 523, 1844, 26, 272, 1369, 26, 272, 446, 11015, 314, 536, 402, 1844, 14, 272, 1415, 26, 2549, 523, 28270, 26, 272, 1369, 26, 272, 446, 11015, 314, 5696, 1752, 2250, 4137, 334, 5747, 53, 9, 14581, 701, 314, 1844, 14, 523, 6384, 368, 14727, 323, 63, 2113, 26, 272, 1369, 26, 272, 446, 3447, 5921, 503, 28421, 26125, 2599, 13, 21961, 425, 402, 8112, 12, 489, 366, 26646, 436, 6369, 3304, 14, 523, 366, 26646, 63, 2113, 26, 272, 1369, 26, 272, 446, 11015, 314, 922, 14388, 366, 26646, 4260, 402, 314, 1844, 14, 272, 446, 4821, 1338, 2599, 12, 12995, 12, 2615, 523, 8112, 63, 2113, 26, 272, 1369, 26, 272, 446, 11015, 314, 922, 14388, 8112, 4260, 402, 314, 1844, 14, 523, 6369, 2785, 63, 2113, 26, 272, 1369, 26, 272, 446, 11015, 314, 922, 14388, 6369, 3304, 4260, 402, 314, 1844, 14, 523, 15017, 1142, 26, 272, 1369, 26, 272, 446, 11015, 314, 1844, 1159, 4568, 3531, 2638, 536, 14, 272, 446, 710, 283, 9581, 7, 15017, 1142, 365, 4644, 367, 4350, 8873, 14, 199, 624, 199, 199, 8918, 275, 408, 272, 446, 536, 26, 22520, 5365, 10977, 489, 11802, 63, 1888, 439, 63, 846, 63, 719, 26, 267, 1174, 29, 1881, 267, 3434, 3126, 91, 15742, 63, 2473, 3586, 267, 2505, 3126, 91, 15742, 63, 2060, 3586, 267, 6246, 3126, 91, 15742, 63, 4269, 3586, 267, 1031, 3126, 91, 812, 5206, 1654, 536, 3586, 267, 1844, 29, 69, 16, 68, 267, 6384, 368, 14727, 323, 63, 2113, 29, 2052, 199, 624, 199, 199, 9677, 275, 408, 199, 199, 624, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 646, 3242, 14, 578, 63, 1208, 14, 25830, 465, 15742, 63, 1208, 199, 199, 13533, 63, 7278, 7121, 63, 5617, 275, 15742, 63, 1208, 14, 1989, 63, 25830, 63, 773, 342, 421, 199, 533, 28076, 47, 343, 439, 2480, 4313, 8, 785, 304, 272, 408, 267, 22520, 282, 5365, 1844, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 408, 288, 11578, 314, 593, 343, 439, 5365, 10977, 8089, 267, 408, 267, 291, 14, 2094, 63, 1650, 275, 15742, 63, 1208, 14, 3540, 63, 1888, 439, 63, 1102, 63, 2094, 63, 1650, 342, 267, 291, 14, 2094, 63, 1650, 14, 873, 8, 807, 8, 288, 1174, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 995, 849, 534, 1881, 659, 288, 1031, 29, 807, 8, 2427, 29, 549, 12, 730, 628, 495, 1288, 288, 1844, 29, 807, 8, 2427, 29, 549, 12, 730, 628, 495, 1288, 288, 28270, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 6384, 368, 14727, 323, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 366, 26646, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 8112, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 6369, 2785, 63, 2113, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 288, 15017, 1142, 29, 807, 8, 2427, 29, 797, 12, 730, 628, 495, 401, 849, 29, 403, 395, 267, 5082, 398, 291, 14, 578, 275, 6953, 8, 288, 1423, 63, 1650, 29, 277, 14, 2094, 63, 1650, 12, 288, 5171, 63, 1074, 63, 632, 29, 549, 267, 776, 398, 299, 275, 291, 14, 578, 14, 1162, 398, 327, 663, 1536, 1174, 2860, 267, 291, 14, 929, 275, 299, 459, 929, 418, 267, 291, 14, 932, 275, 299, 459, 932, 418, 267, 291, 14, 719, 275, 299, 459, 719, 418, 267, 327, 314, 2569, 945, 787, 2716, 12, 1325, 737, 5210, 1373, 1929, 370, 506, 663, 267, 291, 14, 17696, 275, 299, 459, 17696, 418, 267, 291, 14, 6898, 368, 14727, 323, 63, 2113, 275, 299, 905, 6898, 368, 14727, 323, 63, 2113, 937, 267, 291, 14, 68, 26646, 63, 2113, 275, 299, 905, 68, 26646, 63, 2113, 937, 267, 291, 14, 7625, 63, 2113, 275, 299, 905, 7625, 63, 2113, 937, 267, 291, 14, 1659, 2785, 63, 2113, 275, 299, 905, 1659, 2785, 63, 2113, 937, 398, 340, 7509, 63, 7278, 7121, 63, 5617, 365, 756, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 355, 1499, 628, 1589, 2366, 28076, 13, 4728, 859, 365, 1415, 531, 267, 587, 26, 288, 291, 14, 1000, 275, 15742, 63, 1208, 14, 2758, 63, 3540, 63, 1888, 439, 63, 21059, 8, 578, 29, 277, 14, 578, 9, 267, 372, 339, 347, 664, 63, 846, 63, 719, 8, 277, 304, 267, 408, 267, 1432, 2436, 3595, 314, 1851, 1844, 398, 520, 1107, 26, 15621, 3595, 314, 1851, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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