repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
admiralspark/NetSpark-Scripts
Example_Scripts/Cisco/auditQOS.py
1
2040
#Global imports from netmiko import ConnectHandler from datetime import datetime import csv, os.path #Local imports import credentials # Begin timing the script start_time = datetime.now() # Define the primary function (to be moved to a separate module some day...) def nc(username, password, secret, customer): with open(customer, mode='r') as csvfile: reader = csv.DictReader(csvfile) # Now iterate through every row in the CSVfile and make dictionaries for row in reader: hostname = row['SysName'] device_type = row['device_type'] ip = row['IP_Address'] switch = { 'device_type': device_type, 'ip': ip, 'username': USERNAME, 'password': PASSWORD, 'secret': SECRET, 'verbose': False, } # This is your connection handler for commands from here on out net_connect = ConnectHandler(**switch) # Insert your commands here net_connect.enable() # or maybe send configuration stuff with # net_connect.send_config_set(username cisco priv 15 pass cisco) connect_return = net_connect.send_command("sh mls qos") # Now make it pretty print("\n\n>>>>>>>>> Device {0} <<<<<<<<<".format(hostname)) print(connect_return) print("\n>>>>>>>>> End <<<<<<<<<") # Disconnect from this session net_connect.disconnect() # Grab the Customer name to search CUSTOMER = input('Customer name: ') + ".csv" # Flesh out these variables using the credentials.cred_csv module USERNAME, PASSWORD, SECRET = credentials.cred_csv() # Give it a command: # command_string = "write mem" # can be passed to nc... # Run the primary function in this program nc(USERNAME, PASSWORD, SECRET, CUSTOMER) end_time = datetime.now() # How long did it run? total_time = end_time - start_time print("\nTotal time for script: \n" + str(total_time))
gpl-3.0
[ 3, 7025, 8925, 199, 504, 1851, 2664, 7697, 492, 15175, 2461, 199, 504, 2197, 492, 2197, 199, 646, 7392, 12, 747, 14, 515, 199, 3, 5339, 8925, 199, 646, 6235, 199, 199, 3, 25754, 20542, 314, 2884, 199, 928, 63, 521, 275, 2197, 14, 2131, 342, 199, 199, 3, 13930, 314, 5062, 805, 334, 475, 506, 12155, 370, 282, 7396, 859, 2005, 5382, 11965, 199, 318, 12698, 8, 2473, 12, 2505, 12, 7565, 12, 15229, 304, 272, 543, 1551, 8, 10178, 12, 818, 534, 82, 358, 465, 7392, 493, 26, 267, 7002, 275, 7392, 14, 2141, 5929, 8, 4737, 493, 9, 267, 327, 7356, 13974, 4012, 4036, 1962, 315, 314, 14689, 493, 436, 1852, 11196, 267, 367, 1962, 315, 7002, 26, 288, 6246, 275, 1962, 459, 11319, 985, 418, 288, 2243, 63, 466, 275, 1962, 459, 1782, 63, 466, 418, 288, 3384, 275, 1962, 459, 1772, 63, 1476, 418, 288, 6258, 275, 469, 355, 283, 1782, 63, 466, 356, 2243, 63, 466, 12, 355, 283, 711, 356, 3384, 12, 355, 283, 2473, 356, 13044, 2339, 12, 355, 283, 2060, 356, 21705, 5172, 12, 355, 283, 4731, 356, 5795, 11771, 12, 355, 283, 3832, 356, 756, 12, 288, 789, 288, 327, 961, 365, 2195, 1950, 3016, 367, 3718, 687, 2348, 641, 734, 288, 1851, 63, 2242, 275, 15175, 2461, 3682, 5656, 9, 288, 327, 15496, 2195, 3718, 2348, 288, 1851, 63, 2242, 14, 4296, 342, 288, 327, 503, 11703, 3222, 2897, 8292, 543, 288, 327, 1851, 63, 2242, 14, 2254, 63, 888, 63, 409, 8, 2473, 286, 10081, 16254, 4114, 986, 286, 10081, 9, 288, 4907, 63, 1107, 275, 1851, 63, 2242, 14, 2254, 63, 1531, 480, 609, 333, 478, 19384, 531, 288, 327, 7356, 1852, 652, 7268, 288, 870, 4582, 78, 60, 78, 28375, 1140, 6071, 12272, 469, 16, 93, 5213, 31275, 8999, 28, 1674, 908, 8, 4269, 430, 288, 870, 8, 2242, 63, 1107, 9, 288, 870, 4582, 78, 28375, 1140, 6071, 9599, 5213, 31275, 8999, 28, 531, 288, 327, 5289, 2242, 687, 642, 2351, 288, 1851, 63, 2242, 14, 10673, 342, 199, 199, 3, 29225, 314, 22397, 536, 370, 2754, 199, 20519, 540, 275, 1324, 360, 17025, 536, 26, 5320, 435, 3680, 4737, 2, 199, 3, 481, 274, 609, 734, 3520, 2860, 1808, 314, 6235, 14, 18639, 63, 4737, 859, 199, 11958, 12, 21705, 5172, 12, 5795, 11771, 275, 6235, 14, 18639, 63, 4737, 342, 199, 3, 25495, 652, 282, 1414, 26, 199, 3, 1414, 63, 875, 275, 298, 952, 7573, 2, 327, 883, 506, 3032, 370, 12698, 1396, 199, 3, 3378, 314, 5062, 805, 315, 642, 2240, 199, 7966, 8, 11958, 12, 21705, 5172, 12, 5795, 11771, 12, 445, 7698, 7474, 540, 9, 421, 199, 500, 63, 521, 275, 2197, 14, 2131, 342, 199, 3, 7494, 1846, 8103, 652, 1255, 31, 199, 2923, 63, 521, 275, 1284, 63, 521, 446, 1343, 63, 521, 199, 1361, 4582, 78, 7316, 900, 367, 2884, 26, 971, 78, 2, 435, 620, 8, 2923, 63, 521, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7025, 8925, 199, 504, 1851, 2664, 7697, 492, 15175, 2461, 199, 504, 2197, 492, 2197, 199, 646, 7392, 12, 747, 14, 515, 199, 3, 5339, 8925, 199, 646, 6235, 199, 199, 3, 25754, 20542, 314, 2884, 199, 928, 63, 521, 275, 2197, 14, 2131, 342, 199, 199, 3, 13930, 314, 5062, 805, 334, 475, 506, 12155, 370, 282, 7396, 859, 2005, 5382, 11965, 199, 318, 12698, 8, 2473, 12, 2505, 12, 7565, 12, 15229, 304, 272, 543, 1551, 8, 10178, 12, 818, 534, 82, 358, 465, 7392, 493, 26, 267, 7002, 275, 7392, 14, 2141, 5929, 8, 4737, 493, 9, 267, 327, 7356, 13974, 4012, 4036, 1962, 315, 314, 14689, 493, 436, 1852, 11196, 267, 367, 1962, 315, 7002, 26, 288, 6246, 275, 1962, 459, 11319, 985, 418, 288, 2243, 63, 466, 275, 1962, 459, 1782, 63, 466, 418, 288, 3384, 275, 1962, 459, 1772, 63, 1476, 418, 288, 6258, 275, 469, 355, 283, 1782, 63, 466, 356, 2243, 63, 466, 12, 355, 283, 711, 356, 3384, 12, 355, 283, 2473, 356, 13044, 2339, 12, 355, 283, 2060, 356, 21705, 5172, 12, 355, 283, 4731, 356, 5795, 11771, 12, 355, 283, 3832, 356, 756, 12, 288, 789, 288, 327, 961, 365, 2195, 1950, 3016, 367, 3718, 687, 2348, 641, 734, 288, 1851, 63, 2242, 275, 15175, 2461, 3682, 5656, 9, 288, 327, 15496, 2195, 3718, 2348, 288, 1851, 63, 2242, 14, 4296, 342, 288, 327, 503, 11703, 3222, 2897, 8292, 543, 288, 327, 1851, 63, 2242, 14, 2254, 63, 888, 63, 409, 8, 2473, 286, 10081, 16254, 4114, 986, 286, 10081, 9, 288, 4907, 63, 1107, 275, 1851, 63, 2242, 14, 2254, 63, 1531, 480, 609, 333, 478, 19384, 531, 288, 327, 7356, 1852, 652, 7268, 288, 870, 4582, 78, 60, 78, 28375, 1140, 6071, 12272, 469, 16, 93, 5213, 31275, 8999, 28, 1674, 908, 8, 4269, 430, 288, 870, 8, 2242, 63, 1107, 9, 288, 870, 4582, 78, 28375, 1140, 6071, 9599, 5213, 31275, 8999, 28, 531, 288, 327, 5289, 2242, 687, 642, 2351, 288, 1851, 63, 2242, 14, 10673, 342, 199, 199, 3, 29225, 314, 22397, 536, 370, 2754, 199, 20519, 540, 275, 1324, 360, 17025, 536, 26, 5320, 435, 3680, 4737, 2, 199, 3, 481, 274, 609, 734, 3520, 2860, 1808, 314, 6235, 14, 18639, 63, 4737, 859, 199, 11958, 12, 21705, 5172, 12, 5795, 11771, 275, 6235, 14, 18639, 63, 4737, 342, 199, 3, 25495, 652, 282, 1414, 26, 199, 3, 1414, 63, 875, 275, 298, 952, 7573, 2, 327, 883, 506, 3032, 370, 12698, 1396, 199, 3, 3378, 314, 5062, 805, 315, 642, 2240, 199, 7966, 8, 11958, 12, 21705, 5172, 12, 5795, 11771, 12, 445, 7698, 7474, 540, 9, 421, 199, 500, 63, 521, 275, 2197, 14, 2131, 342, 199, 3, 7494, 1846, 8103, 652, 1255, 31, 199, 2923, 63, 521, 275, 1284, 63, 521, 446, 1343, 63, 521, 199, 1361, 4582, 78, 7316, 900, 367, 2884, 26, 971, 78, 2, 435, 620, 8, 2923, 63, 521, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TheWardoctor/Wardoctors-repo
script.stargate.guide/resources/playwith/playwith.py
1
2975
import sys import xbmc,xbmcaddon,xbmcvfs import sqlite3 from subprocess import Popen import datetime,time # from vpnapi import VPNAPI channel = sys.argv[1] start = sys.argv[2] ADDON = xbmcaddon.Addon(id='script.stargate.guide') def adapt_datetime(ts): # http://docs.python.org/2/library/sqlite3.html#registering-an-adapter-callable return time.mktime(ts.timetuple()) def convert_datetime(ts): try: return datetime.datetime.fromtimestamp(float(ts)) except ValueError: return None sqlite3.register_adapter(datetime.datetime, adapt_datetime) sqlite3.register_converter('timestamp', convert_datetime) path = xbmc.translatePath('special://profile/addon_data/script.stargate.guide/source.db') try: conn = sqlite3.connect(path, detect_types=sqlite3.PARSE_DECLTYPES) conn.row_factory = sqlite3.Row except Exception as detail: xbmc.log("EXCEPTION: (script.stargate.guide) %s" % detail, xbmc.LOGERROR) # Get the Program Info from the database c = conn.cursor() startDate = datetime.datetime.fromtimestamp(float(start)) c.execute('SELECT DISTINCT * FROM programs WHERE channel=? AND start_date = ?', [channel,startDate]) for row in c: title = row["title"] endDate = row["end_date"] duration = endDate - startDate before = int(ADDON.getSetting('autoplaywiths.before')) after = int(ADDON.getSetting('autoplaywiths.after')) extra = (before + after) * 60 #TODO start from now seconds = duration.seconds + extra if seconds > (3600*4): seconds = 3600*4 break # Find the channel's stream url c.execute('SELECT stream_url FROM custom_stream_url WHERE channel=?', [channel]) row = c.fetchone() url = "" if row: url = row[0] if not url: quit() # Uncomment this if you want to use VPN Mgr filtering. Need to import VPNAPI.py # else: # if ADDON.getSetting('vpnmgr.connect') == "true": # vpndefault = False # if ADDON.getSetting('vpnmgr.default') == "true": # vpndefault = True # api = VPNAPI() # if url[0:9] == 'plugin://': # api.filterAndSwitch(url, 0, vpndefault, True) # else: # if vpndefault: api.defaultVPN(True) # Find the actual url used to play the stream #core = "dummy" #xbmc.executebuiltin('PlayWith(%s)' % core) player = xbmc.Player() player.play(url) count = 30 url = "" while count: count = count - 1 time.sleep(1) if player.isPlaying(): url = player.getPlayingFile() break player.stop() # Play with your own preferred player and paths if url: name = "%s = %s = %s" % (start,channel,title) name = name.encode("cp1252") filename = xbmc.translatePath("special://temp/%s.ts" % name) #filename = "/storage/recordings/%s.ts" % name ffmpeg = r"c:\utils\ffmpeg.exe" #WINDOWS #ffmpeg = r"/usr/bin/ffmpeg" #LIBREELEC cmd = [ffmpeg, "-y", "-i", url, "-c", "copy", "-t", str(seconds), filename] #p = Popen(cmd,shell=True) p = Popen(cmd,shell=False)
apache-2.0
[ 646, 984, 199, 646, 11709, 12, 21382, 9291, 12, 1774, 77, 5107, 2319, 199, 646, 11723, 19, 199, 504, 3873, 492, 13995, 199, 646, 2197, 12, 521, 199, 3, 687, 15978, 1246, 492, 29057, 3735, 199, 199, 2775, 275, 984, 14, 3020, 59, 17, 61, 199, 928, 275, 984, 14, 3020, 59, 18, 61, 199, 199, 9732, 615, 275, 11709, 9291, 14, 19654, 8, 344, 534, 1579, 14, 270, 1273, 323, 14, 17348, 358, 199, 199, 318, 19520, 63, 2083, 8, 1086, 304, 272, 327, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 10659, 19, 14, 1360, 3, 2683, 316, 13, 290, 13, 10394, 13, 8296, 272, 372, 900, 14, 23456, 8, 1086, 14, 22309, 1012, 199, 199, 318, 3957, 63, 2083, 8, 1086, 304, 272, 862, 26, 267, 372, 2197, 14, 2083, 14, 18531, 8, 1609, 8, 1086, 430, 272, 871, 1722, 26, 267, 372, 488, 199, 199, 10659, 19, 14, 2683, 63, 10394, 8, 2083, 14, 2083, 12, 19520, 63, 2083, 9, 199, 10659, 19, 14, 2683, 63, 11256, 360, 3954, 297, 3957, 63, 2083, 9, 199, 515, 275, 11709, 14, 5275, 2042, 360, 6664, 921, 2913, 15, 9291, 63, 576, 15, 1579, 14, 270, 1273, 323, 14, 17348, 15, 1365, 14, 697, 358, 199, 893, 26, 272, 2557, 275, 11723, 19, 14, 2242, 8, 515, 12, 9696, 63, 1313, 29, 10659, 19, 14, 23354, 63, 27402, 7893, 9, 272, 2557, 14, 1143, 63, 3702, 275, 11723, 19, 14, 5810, 199, 2590, 2186, 465, 10093, 26, 272, 11709, 14, 793, 480, 15375, 26, 334, 1579, 14, 270, 1273, 323, 14, 17348, 9, 221, 450, 83, 2, 450, 10093, 12, 11709, 14, 4947, 3170, 9, 199, 199, 3, 2372, 314, 18841, 10332, 687, 314, 3050, 199, 67, 275, 2557, 14, 3937, 342, 199, 928, 2506, 275, 2197, 14, 2083, 14, 18531, 8, 1609, 8, 928, 430, 199, 67, 14, 2526, 360, 4859, 28424, 28437, 627, 4442, 18572, 6038, 3623, 18048, 2401, 1343, 63, 602, 275, 5805, 297, 359, 2775, 12, 928, 2506, 566, 199, 509, 1962, 315, 286, 26, 272, 2538, 275, 1962, 905, 1213, 937, 272, 1284, 2506, 275, 1962, 905, 500, 63, 602, 937, 272, 7373, 275, 1284, 2506, 446, 1343, 2506, 272, 2544, 275, 1109, 8, 9732, 615, 14, 30008, 360, 29582, 817, 1045, 83, 14, 5182, 1333, 272, 2410, 275, 1109, 8, 9732, 615, 14, 30008, 360, 29582, 817, 1045, 83, 14, 4399, 1333, 272, 2402, 275, 334, 5182, 435, 2410, 9, 627, 5212, 272, 327, 11768, 1343, 687, 3063, 272, 4696, 275, 7373, 14, 4515, 435, 2402, 272, 340, 4696, 690, 334, 11035, 10, 20, 304, 267, 4696, 275, 15751, 10, 20, 272, 2059, 199, 199, 3, 6668, 314, 3623, 1159, 2547, 1166, 199, 67, 14, 2526, 360, 4859, 2547, 63, 633, 4442, 3537, 63, 1745, 63, 633, 6038, 3623, 29, 7044, 359, 2775, 566, 199, 1143, 275, 286, 14, 11591, 342, 199, 633, 275, 3087, 199, 692, 1962, 26, 272, 1166, 275, 1962, 59, 16, 61, 199, 692, 440, 1166, 26, 272, 17242, 342, 199, 3, 1910, 3349, 642, 340, 1265, 2934, 370, 675, 29057, 603, 2587, 14545, 14, 221, 14012, 370, 492, 29057, 3735, 14, 647, 199, 3, 587, 26, 199, 3, 259, 340, 21380, 615, 14, 30008, 360, 9702, 7755, 14, 2242, 358, 508, 298, 2052, 582, 199, 3, 263, 15978, 885, 275, 756, 199, 3, 263, 340, 21380, 615, 14, 30008, 360, 9702, 7755, 14, 885, 358, 508, 298, 2052, 582, 199, 3, 3322, 15978, 885, 275, 715, 199, 3, 263, 2986, 275, 29057, 3735, 342, 199, 3, 263, 340, 1166, 59, 16, 26, 25, 61, 508, 283, 2718, 921, 356, 199, 3, 3322, 2986, 14, 1541, 3325, 10167, 8, 633, 12, 378, 12, 15978, 885, 12, 715, 9, 199, 3, 263, 587, 26, 199, 3, 3322, 340, 15978, 885, 26, 2986, 14, 885, 54, 9060, 8, 549, 9, 199, 199, 3, 6668, 314, 3503, 1166, 1202, 370, 5232, 314, 2547, 199, 3, 1018, 275, 298, 5869, 2, 199, 3, 21382, 14, 2526, 5351, 360, 9651, 3007, 4042, 83, 3171, 450, 6170, 9, 199, 6147, 275, 11709, 14, 10921, 342, 199, 6147, 14, 2802, 8, 633, 9, 199, 835, 275, 4233, 199, 633, 275, 3087, 199, 6710, 2338, 26, 272, 2338, 275, 2338, 446, 413, 272, 900, 14, 4532, 8, 17, 9, 272, 340, 7748, 14, 374, 29975, 837, 267, 1166, 275, 7748, 14, 362, 29975, 1173, 342, 267, 2059, 199, 6147, 14, 2379, 342, 199, 199, 3, 16527, 543, 2195, 5705, 14388, 7748, 436, 3792, 199, 692, 1166, 26, 272, 536, 275, 2071, 83, 275, 450, 83, 275, 450, 83, 2, 450, 334, 928, 12, 2775, 12, 1213, 9, 272, 536, 275, 536, 14, 2143, 480, 1850, 19364, 531, 272, 1788, 275, 11709, 14, 5275, 2042, 480, 6664, 921, 808, 3149, 83, 14, 1086, 2, 450, 536, 9, 272, 327, 1501, 275, 3286, 3494, 15, 3059, 780, 3149, 83, 14, 1086, 2, 450, 536, 272, 16328, 16801, 275, 519, 2, 67, 3427, 1208, 60, 27648, 14, 5803, 2, 327, 20509, 272, 327, 27648, 275, 519, 15313, 2647, 15, 1393, 15, 27648, 2, 327, 5617, 5271, 906, 35, 272, 2088, 275, 359, 27648, 12, 3905, 89, 401, 3905, 73, 401, 1166, 12, 3905, 67, 401, 298, 1574, 401, 3905, 84, 401, 620, 8, 4515, 395, 1788, 61, 272, 327, 80, 275, 13995, 8, 1760, 12, 5641, 29, 549, 9, 272, 299, 275, 13995, 8, 1760, 12, 5641, 29, 797, 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 ]
[ 984, 199, 646, 11709, 12, 21382, 9291, 12, 1774, 77, 5107, 2319, 199, 646, 11723, 19, 199, 504, 3873, 492, 13995, 199, 646, 2197, 12, 521, 199, 3, 687, 15978, 1246, 492, 29057, 3735, 199, 199, 2775, 275, 984, 14, 3020, 59, 17, 61, 199, 928, 275, 984, 14, 3020, 59, 18, 61, 199, 199, 9732, 615, 275, 11709, 9291, 14, 19654, 8, 344, 534, 1579, 14, 270, 1273, 323, 14, 17348, 358, 199, 199, 318, 19520, 63, 2083, 8, 1086, 304, 272, 327, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 10659, 19, 14, 1360, 3, 2683, 316, 13, 290, 13, 10394, 13, 8296, 272, 372, 900, 14, 23456, 8, 1086, 14, 22309, 1012, 199, 199, 318, 3957, 63, 2083, 8, 1086, 304, 272, 862, 26, 267, 372, 2197, 14, 2083, 14, 18531, 8, 1609, 8, 1086, 430, 272, 871, 1722, 26, 267, 372, 488, 199, 199, 10659, 19, 14, 2683, 63, 10394, 8, 2083, 14, 2083, 12, 19520, 63, 2083, 9, 199, 10659, 19, 14, 2683, 63, 11256, 360, 3954, 297, 3957, 63, 2083, 9, 199, 515, 275, 11709, 14, 5275, 2042, 360, 6664, 921, 2913, 15, 9291, 63, 576, 15, 1579, 14, 270, 1273, 323, 14, 17348, 15, 1365, 14, 697, 358, 199, 893, 26, 272, 2557, 275, 11723, 19, 14, 2242, 8, 515, 12, 9696, 63, 1313, 29, 10659, 19, 14, 23354, 63, 27402, 7893, 9, 272, 2557, 14, 1143, 63, 3702, 275, 11723, 19, 14, 5810, 199, 2590, 2186, 465, 10093, 26, 272, 11709, 14, 793, 480, 15375, 26, 334, 1579, 14, 270, 1273, 323, 14, 17348, 9, 221, 450, 83, 2, 450, 10093, 12, 11709, 14, 4947, 3170, 9, 199, 199, 3, 2372, 314, 18841, 10332, 687, 314, 3050, 199, 67, 275, 2557, 14, 3937, 342, 199, 928, 2506, 275, 2197, 14, 2083, 14, 18531, 8, 1609, 8, 928, 430, 199, 67, 14, 2526, 360, 4859, 28424, 28437, 627, 4442, 18572, 6038, 3623, 18048, 2401, 1343, 63, 602, 275, 5805, 297, 359, 2775, 12, 928, 2506, 566, 199, 509, 1962, 315, 286, 26, 272, 2538, 275, 1962, 905, 1213, 937, 272, 1284, 2506, 275, 1962, 905, 500, 63, 602, 937, 272, 7373, 275, 1284, 2506, 446, 1343, 2506, 272, 2544, 275, 1109, 8, 9732, 615, 14, 30008, 360, 29582, 817, 1045, 83, 14, 5182, 1333, 272, 2410, 275, 1109, 8, 9732, 615, 14, 30008, 360, 29582, 817, 1045, 83, 14, 4399, 1333, 272, 2402, 275, 334, 5182, 435, 2410, 9, 627, 5212, 272, 327, 11768, 1343, 687, 3063, 272, 4696, 275, 7373, 14, 4515, 435, 2402, 272, 340, 4696, 690, 334, 11035, 10, 20, 304, 267, 4696, 275, 15751, 10, 20, 272, 2059, 199, 199, 3, 6668, 314, 3623, 1159, 2547, 1166, 199, 67, 14, 2526, 360, 4859, 2547, 63, 633, 4442, 3537, 63, 1745, 63, 633, 6038, 3623, 29, 7044, 359, 2775, 566, 199, 1143, 275, 286, 14, 11591, 342, 199, 633, 275, 3087, 199, 692, 1962, 26, 272, 1166, 275, 1962, 59, 16, 61, 199, 692, 440, 1166, 26, 272, 17242, 342, 199, 3, 1910, 3349, 642, 340, 1265, 2934, 370, 675, 29057, 603, 2587, 14545, 14, 221, 14012, 370, 492, 29057, 3735, 14, 647, 199, 3, 587, 26, 199, 3, 259, 340, 21380, 615, 14, 30008, 360, 9702, 7755, 14, 2242, 358, 508, 298, 2052, 582, 199, 3, 263, 15978, 885, 275, 756, 199, 3, 263, 340, 21380, 615, 14, 30008, 360, 9702, 7755, 14, 885, 358, 508, 298, 2052, 582, 199, 3, 3322, 15978, 885, 275, 715, 199, 3, 263, 2986, 275, 29057, 3735, 342, 199, 3, 263, 340, 1166, 59, 16, 26, 25, 61, 508, 283, 2718, 921, 356, 199, 3, 3322, 2986, 14, 1541, 3325, 10167, 8, 633, 12, 378, 12, 15978, 885, 12, 715, 9, 199, 3, 263, 587, 26, 199, 3, 3322, 340, 15978, 885, 26, 2986, 14, 885, 54, 9060, 8, 549, 9, 199, 199, 3, 6668, 314, 3503, 1166, 1202, 370, 5232, 314, 2547, 199, 3, 1018, 275, 298, 5869, 2, 199, 3, 21382, 14, 2526, 5351, 360, 9651, 3007, 4042, 83, 3171, 450, 6170, 9, 199, 6147, 275, 11709, 14, 10921, 342, 199, 6147, 14, 2802, 8, 633, 9, 199, 835, 275, 4233, 199, 633, 275, 3087, 199, 6710, 2338, 26, 272, 2338, 275, 2338, 446, 413, 272, 900, 14, 4532, 8, 17, 9, 272, 340, 7748, 14, 374, 29975, 837, 267, 1166, 275, 7748, 14, 362, 29975, 1173, 342, 267, 2059, 199, 6147, 14, 2379, 342, 199, 199, 3, 16527, 543, 2195, 5705, 14388, 7748, 436, 3792, 199, 692, 1166, 26, 272, 536, 275, 2071, 83, 275, 450, 83, 275, 450, 83, 2, 450, 334, 928, 12, 2775, 12, 1213, 9, 272, 536, 275, 536, 14, 2143, 480, 1850, 19364, 531, 272, 1788, 275, 11709, 14, 5275, 2042, 480, 6664, 921, 808, 3149, 83, 14, 1086, 2, 450, 536, 9, 272, 327, 1501, 275, 3286, 3494, 15, 3059, 780, 3149, 83, 14, 1086, 2, 450, 536, 272, 16328, 16801, 275, 519, 2, 67, 3427, 1208, 60, 27648, 14, 5803, 2, 327, 20509, 272, 327, 27648, 275, 519, 15313, 2647, 15, 1393, 15, 27648, 2, 327, 5617, 5271, 906, 35, 272, 2088, 275, 359, 27648, 12, 3905, 89, 401, 3905, 73, 401, 1166, 12, 3905, 67, 401, 298, 1574, 401, 3905, 84, 401, 620, 8, 4515, 395, 1788, 61, 272, 327, 80, 275, 13995, 8, 1760, 12, 5641, 29, 549, 9, 272, 299, 275, 13995, 8, 1760, 12, 5641, 29, 797, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Kazade/NeHe-Website
google_appengine/lib/django_1_2/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, 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,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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 ]
partofthething/home-assistant
homeassistant/components/dweet/sensor.py
21
3239
"""Support for showing values from Dweet.io.""" from datetime import timedelta import json import logging import dweepy import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_DEVICE, CONF_NAME, CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, ) import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Dweet.io Sensor" SCAN_INTERVAL = timedelta(minutes=1) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_DEVICE): cv.string, vol.Required(CONF_VALUE_TEMPLATE): cv.template, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string, } ) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dweet sensor.""" name = config.get(CONF_NAME) device = config.get(CONF_DEVICE) value_template = config.get(CONF_VALUE_TEMPLATE) unit = config.get(CONF_UNIT_OF_MEASUREMENT) if value_template is not None: value_template.hass = hass try: content = json.dumps(dweepy.get_latest_dweet_for(device)[0]["content"]) except dweepy.DweepyError: _LOGGER.error("Device/thing %s could not be found", device) return if value_template.render_with_possible_json_value(content) == "": _LOGGER.error("%s was not found", value_template) return dweet = DweetData(device) add_entities([DweetSensor(hass, dweet, name, value_template, unit)], True) class DweetSensor(Entity): """Representation of a Dweet sensor.""" def __init__(self, hass, dweet, name, value_template, unit_of_measurement): """Initialize the sensor.""" self.hass = hass self.dweet = dweet self._name = name self._value_template = value_template self._state = None self._unit_of_measurement = unit_of_measurement @property def name(self): """Return the name of the sensor.""" return self._name @property def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit_of_measurement @property def state(self): """Return the state.""" return self._state def update(self): """Get the latest data from REST API.""" self.dweet.update() if self.dweet.data is None: self._state = None else: values = json.dumps(self.dweet.data[0]["content"]) self._state = self._value_template.render_with_possible_json_value( values, None ) class DweetData: """The class for handling the data retrieval.""" def __init__(self, device): """Initialize the sensor.""" self._device = device self.data = None def update(self): """Get the latest data from Dweet.io.""" try: self.data = dweepy.get_latest_dweet_for(self._device) except dweepy.DweepyError: _LOGGER.warning("Device %s doesn't contain any data", self._device) self.data = None
mit
[ 624, 11532, 367, 21207, 1338, 687, 577, 11554, 14, 2308, 1041, 199, 504, 2197, 492, 6871, 199, 646, 2022, 199, 646, 2050, 199, 199, 646, 17594, 1024, 647, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 8956, 492, 21966, 63, 10926, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 10555, 12, 272, 6392, 63, 2339, 12, 272, 6392, 63, 15505, 63, 3359, 63, 31097, 3942, 4479, 12, 272, 6392, 63, 7041, 63, 7433, 12, 199, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3472, 63, 2339, 275, 298, 36, 11554, 14, 2308, 18474, 2, 199, 199, 24078, 63, 17359, 275, 6871, 8, 10430, 29, 17, 9, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 10555, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 7041, 63, 7433, 304, 6277, 14, 1160, 12, 267, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 15505, 63, 3359, 63, 31097, 3942, 4479, 304, 6277, 14, 875, 12, 272, 789, 199, 9, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 577, 11554, 8778, 1041, 272, 536, 275, 1101, 14, 362, 8, 3103, 63, 2339, 9, 272, 2243, 275, 1101, 14, 362, 8, 3103, 63, 10555, 9, 272, 574, 63, 1160, 275, 1101, 14, 362, 8, 3103, 63, 7041, 63, 7433, 9, 272, 4137, 275, 1101, 14, 362, 8, 3103, 63, 15505, 63, 3359, 63, 31097, 3942, 4479, 9, 272, 340, 574, 63, 1160, 365, 440, 488, 26, 267, 574, 63, 1160, 14, 5387, 275, 6298, 339, 862, 26, 267, 1564, 275, 2022, 14, 4180, 8, 10772, 1024, 647, 14, 362, 63, 7410, 63, 68, 11554, 63, 509, 8, 1782, 2788, 16, 7541, 1317, 3135, 272, 871, 17594, 1024, 647, 14, 36, 25515, 647, 547, 26, 267, 485, 10186, 14, 705, 480, 2510, 15, 2127, 450, 83, 4293, 440, 506, 1911, 401, 2243, 9, 267, 372, 339, 340, 574, 63, 1160, 14, 3352, 63, 1045, 63, 13893, 63, 1001, 63, 585, 8, 1317, 9, 508, 10812, 267, 485, 10186, 14, 705, 3647, 83, 1990, 440, 1911, 401, 574, 63, 1160, 9, 267, 372, 339, 366, 11554, 275, 577, 11554, 1451, 8, 1782, 9, 339, 1050, 63, 8327, 779, 36, 11554, 10160, 8, 5387, 12, 366, 11554, 12, 536, 12, 574, 63, 1160, 12, 4137, 4360, 715, 9, 421, 199, 533, 577, 11554, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 577, 11554, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 6298, 12, 366, 11554, 12, 536, 12, 574, 63, 1160, 12, 4137, 63, 1618, 63, 17912, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 14, 5387, 275, 6298, 267, 291, 14, 68, 11554, 275, 366, 11554, 267, 291, 423, 354, 275, 536, 267, 291, 423, 585, 63, 1160, 275, 574, 63, 1160, 267, 291, 423, 929, 275, 488, 267, 291, 423, 3248, 63, 1618, 63, 17912, 275, 4137, 63, 1618, 63, 17912, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 4137, 63, 1618, 63, 17912, 8, 277, 304, 267, 408, 1767, 314, 4137, 314, 574, 365, 19147, 315, 1041, 267, 372, 291, 423, 3248, 63, 1618, 63, 17912, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 1041, 267, 372, 291, 423, 929, 339, 347, 1678, 8, 277, 304, 267, 408, 1002, 314, 8839, 666, 687, 14880, 3261, 1041, 267, 291, 14, 68, 11554, 14, 873, 342, 398, 340, 291, 14, 68, 11554, 14, 576, 365, 488, 26, 288, 291, 423, 929, 275, 488, 267, 587, 26, 288, 1338, 275, 2022, 14, 4180, 8, 277, 14, 68, 11554, 14, 576, 59, 16, 7541, 1317, 3135, 288, 291, 423, 929, 275, 291, 423, 585, 63, 1160, 14, 3352, 63, 1045, 63, 13893, 63, 1001, 63, 585, 8, 355, 1338, 12, 488, 288, 776, 421, 199, 533, 577, 11554, 1451, 26, 272, 408, 1918, 1021, 367, 7252, 314, 666, 27157, 1041, 339, 347, 636, 826, 721, 277, 12, 2243, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 423, 1782, 275, 2243, 267, 291, 14, 576, 275, 488, 339, 347, 1678, 8, 277, 304, 267, 408, 1002, 314, 8839, 666, 687, 577, 11554, 14, 2308, 1041, 267, 862, 26, 288, 291, 14, 576, 275, 17594, 1024, 647, 14, 362, 63, 7410, 63, 68, 11554, 63, 509, 8, 277, 423, 1782, 9, 267, 871, 17594, 1024, 647, 14, 36, 25515, 647, 547, 26, 288, 485, 10186, 14, 3764, 480, 2510, 450, 83, 3181, 1133, 1395, 1263, 666, 401, 291, 423, 1782, 9, 288, 291, 14, 576, 275, 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 ]
[ 11532, 367, 21207, 1338, 687, 577, 11554, 14, 2308, 1041, 199, 504, 2197, 492, 6871, 199, 646, 2022, 199, 646, 2050, 199, 199, 646, 17594, 1024, 647, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 4608, 14, 8956, 492, 21966, 63, 10926, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 10555, 12, 272, 6392, 63, 2339, 12, 272, 6392, 63, 15505, 63, 3359, 63, 31097, 3942, 4479, 12, 272, 6392, 63, 7041, 63, 7433, 12, 199, 9, 199, 646, 8846, 14, 7546, 14, 888, 63, 6136, 465, 6277, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3472, 63, 2339, 275, 298, 36, 11554, 14, 2308, 18474, 2, 199, 199, 24078, 63, 17359, 275, 6871, 8, 10430, 29, 17, 9, 199, 199, 17805, 63, 10926, 275, 21966, 63, 10926, 14, 2880, 8, 272, 469, 267, 5236, 14, 8030, 8, 3103, 63, 10555, 304, 6277, 14, 875, 12, 267, 5236, 14, 8030, 8, 3103, 63, 7041, 63, 7433, 304, 6277, 14, 1160, 12, 267, 5236, 14, 7012, 8, 3103, 63, 2339, 12, 849, 29, 3472, 63, 2339, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 3103, 63, 15505, 63, 3359, 63, 31097, 3942, 4479, 304, 6277, 14, 875, 12, 272, 789, 199, 9, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 8327, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 577, 11554, 8778, 1041, 272, 536, 275, 1101, 14, 362, 8, 3103, 63, 2339, 9, 272, 2243, 275, 1101, 14, 362, 8, 3103, 63, 10555, 9, 272, 574, 63, 1160, 275, 1101, 14, 362, 8, 3103, 63, 7041, 63, 7433, 9, 272, 4137, 275, 1101, 14, 362, 8, 3103, 63, 15505, 63, 3359, 63, 31097, 3942, 4479, 9, 272, 340, 574, 63, 1160, 365, 440, 488, 26, 267, 574, 63, 1160, 14, 5387, 275, 6298, 339, 862, 26, 267, 1564, 275, 2022, 14, 4180, 8, 10772, 1024, 647, 14, 362, 63, 7410, 63, 68, 11554, 63, 509, 8, 1782, 2788, 16, 7541, 1317, 3135, 272, 871, 17594, 1024, 647, 14, 36, 25515, 647, 547, 26, 267, 485, 10186, 14, 705, 480, 2510, 15, 2127, 450, 83, 4293, 440, 506, 1911, 401, 2243, 9, 267, 372, 339, 340, 574, 63, 1160, 14, 3352, 63, 1045, 63, 13893, 63, 1001, 63, 585, 8, 1317, 9, 508, 10812, 267, 485, 10186, 14, 705, 3647, 83, 1990, 440, 1911, 401, 574, 63, 1160, 9, 267, 372, 339, 366, 11554, 275, 577, 11554, 1451, 8, 1782, 9, 339, 1050, 63, 8327, 779, 36, 11554, 10160, 8, 5387, 12, 366, 11554, 12, 536, 12, 574, 63, 1160, 12, 4137, 4360, 715, 9, 421, 199, 533, 577, 11554, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 577, 11554, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 6298, 12, 366, 11554, 12, 536, 12, 574, 63, 1160, 12, 4137, 63, 1618, 63, 17912, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 14, 5387, 275, 6298, 267, 291, 14, 68, 11554, 275, 366, 11554, 267, 291, 423, 354, 275, 536, 267, 291, 423, 585, 63, 1160, 275, 574, 63, 1160, 267, 291, 423, 929, 275, 488, 267, 291, 423, 3248, 63, 1618, 63, 17912, 275, 4137, 63, 1618, 63, 17912, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 4137, 63, 1618, 63, 17912, 8, 277, 304, 267, 408, 1767, 314, 4137, 314, 574, 365, 19147, 315, 1041, 267, 372, 291, 423, 3248, 63, 1618, 63, 17912, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 1041, 267, 372, 291, 423, 929, 339, 347, 1678, 8, 277, 304, 267, 408, 1002, 314, 8839, 666, 687, 14880, 3261, 1041, 267, 291, 14, 68, 11554, 14, 873, 342, 398, 340, 291, 14, 68, 11554, 14, 576, 365, 488, 26, 288, 291, 423, 929, 275, 488, 267, 587, 26, 288, 1338, 275, 2022, 14, 4180, 8, 277, 14, 68, 11554, 14, 576, 59, 16, 7541, 1317, 3135, 288, 291, 423, 929, 275, 291, 423, 585, 63, 1160, 14, 3352, 63, 1045, 63, 13893, 63, 1001, 63, 585, 8, 355, 1338, 12, 488, 288, 776, 421, 199, 533, 577, 11554, 1451, 26, 272, 408, 1918, 1021, 367, 7252, 314, 666, 27157, 1041, 339, 347, 636, 826, 721, 277, 12, 2243, 304, 267, 408, 9345, 314, 8778, 1041, 267, 291, 423, 1782, 275, 2243, 267, 291, 14, 576, 275, 488, 339, 347, 1678, 8, 277, 304, 267, 408, 1002, 314, 8839, 666, 687, 577, 11554, 14, 2308, 1041, 267, 862, 26, 288, 291, 14, 576, 275, 17594, 1024, 647, 14, 362, 63, 7410, 63, 68, 11554, 63, 509, 8, 277, 423, 1782, 9, 267, 871, 17594, 1024, 647, 14, 36, 25515, 647, 547, 26, 288, 485, 10186, 14, 3764, 480, 2510, 450, 83, 3181, 1133, 1395, 1263, 666, 401, 291, 423, 1782, 9, 288, 291, 14, 576, 275, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pk-sam/crosswalk-test-suite
usecase/usecase-wrt-auto-tests/samples/ApkBuildAnyLocation/absolutePath.py
2
2850
#!/usr/bin/env python # # Copyright (c) 2015 Intel Corporation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of works must retain the original copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the original 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 Intel Corporation nor the names of its contributors # may be used to endorse or promote products derived from this work without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "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 INTEL CORPORATION 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: # Hongjuan, Wang<hongjuanx.wang@intel.com> import unittest import os import sys import commands import shutil import comm class TestPackertoolsFunctions(unittest.TestCase): def test_absolutePath_hostApp(self): comm.setUp() cmd = "python %smake_apk.py --package=org.xwalk.example --name=example --arch=%s --mode=%s --app-url=https://crosswalk-project.org/" % \ (comm.Pck_Tools, comm.ARCH, comm.MODE) print os.getcwd() comm.gen_pkg(cmd, self) def test_absolutePath_manifest(self): comm.setUp() manifestPath = comm.ConstPath + "/res/manifest.json" cmd = "python %smake_apk.py --package=org.xwalk.example --arch=%s --mode=%s --manifest=%s" % \ (comm.Pck_Tools, comm.ARCH, comm.MODE, manifestPath) os.chdir(comm.ConstPath + '/../../tools') print os.getcwd() comm.gen_pkg(cmd, self) def test_absolutePath_package(self): comm.setUp() appRoot = comm.ConstPath + "/res/" cmd = "python %smake_apk.py --package=org.xwalk.example --name=example --arch=%s --mode=%s --app-root=%s --app-local-path=index.html" % \ (comm.Pck_Tools, comm.ARCH, comm.MODE, appRoot) os.chdir(comm.ConstPath + '/../../tools/crosswalk') print os.getcwd() comm.gen_pkg(cmd, self) if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 67, 9, 6900, 20619, 11098, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 627, 6823, 402, 5419, 1471, 8074, 314, 3379, 4248, 4245, 12, 642, 199, 3, 257, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3379, 4248, 199, 3, 257, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 257, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 627, 11443, 314, 536, 402, 20619, 11098, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 257, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 1736, 1928, 199, 3, 257, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 16429, 2901, 27072, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 16429, 2901, 27072, 6262, 7024, 2381, 1821, 8703, 12, 199, 3, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 199, 3, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 199, 3, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 199, 3, 260, 869, 951, 74, 7856, 12, 644, 621, 28, 72, 951, 74, 7856, 88, 14, 87, 621, 32, 22264, 14, 957, 30, 199, 199, 646, 2882, 199, 646, 747, 199, 646, 984, 199, 646, 3718, 199, 646, 5145, 199, 646, 1923, 199, 199, 533, 1379, 2305, 281, 2537, 13967, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 6116, 2042, 63, 1102, 2640, 8, 277, 304, 489, 1923, 14, 5996, 342, 489, 2088, 275, 298, 1548, 450, 83, 1875, 63, 23582, 14, 647, 1553, 2491, 29, 1308, 14, 88, 7757, 14, 2694, 1553, 354, 29, 2694, 1553, 1047, 2458, 83, 1553, 632, 2458, 83, 1553, 571, 13, 633, 29, 2859, 921, 7925, 7757, 13, 1715, 14, 1308, 6687, 450, 971, 288, 334, 1404, 14, 48, 346, 63, 11654, 12, 1923, 14, 7762, 12, 1923, 14, 6963, 9, 489, 870, 747, 14, 9458, 342, 489, 1923, 14, 2268, 63, 4600, 8, 1760, 12, 291, 9, 819, 347, 511, 63, 6116, 2042, 63, 6418, 8, 277, 304, 489, 1923, 14, 5996, 342, 489, 7712, 2042, 275, 1923, 14, 6361, 2042, 435, 3286, 470, 15, 6418, 14, 1001, 2, 489, 2088, 275, 298, 1548, 450, 83, 1875, 63, 23582, 14, 647, 1553, 2491, 29, 1308, 14, 88, 7757, 14, 2694, 1553, 1047, 2458, 83, 1553, 632, 2458, 83, 1553, 6418, 2458, 83, 2, 450, 971, 288, 334, 1404, 14, 48, 346, 63, 11654, 12, 1923, 14, 7762, 12, 1923, 14, 6963, 12, 7712, 2042, 9, 489, 747, 14, 8563, 8, 1404, 14, 6361, 2042, 435, 1994, 9707, 2537, 358, 489, 870, 747, 14, 9458, 342, 489, 1923, 14, 2268, 63, 4600, 8, 1760, 12, 291, 9, 819, 347, 511, 63, 6116, 2042, 63, 2491, 8, 277, 304, 489, 1923, 14, 5996, 342, 489, 1145, 6405, 275, 1923, 14, 6361, 2042, 435, 3286, 470, 6687, 489, 2088, 275, 298, 1548, 450, 83, 1875, 63, 23582, 14, 647, 1553, 2491, 29, 1308, 14, 88, 7757, 14, 2694, 1553, 354, 29, 2694, 1553, 1047, 2458, 83, 1553, 632, 2458, 83, 1553, 571, 13, 1231, 2458, 83, 1553, 571, 13, 1832, 13, 515, 29, 1080, 14, 1360, 2, 450, 971, 288, 334, 1404, 14, 48, 346, 63, 11654, 12, 1923, 14, 7762, 12, 1923, 14, 6963, 12, 1145, 6405, 9, 489, 747, 14, 8563, 8, 1404, 14, 6361, 2042, 435, 1994, 9707, 2537, 15, 7925, 7757, 358, 489, 870, 747, 14, 9458, 342, 489, 1923, 14, 2268, 63, 4600, 8, 1760, 12, 291, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 23855, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 67, 9, 6900, 20619, 11098, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 627, 6823, 402, 5419, 1471, 8074, 314, 3379, 4248, 4245, 12, 642, 199, 3, 257, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3379, 4248, 199, 3, 257, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 257, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 627, 11443, 314, 536, 402, 20619, 11098, 6590, 314, 1561, 402, 2399, 8417, 199, 3, 257, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 1736, 1928, 199, 3, 257, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 16429, 2901, 27072, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 199, 3, 9315, 9706, 14, 1621, 4825, 6461, 7000, 16429, 2901, 27072, 6262, 7024, 2381, 1821, 8703, 12, 199, 3, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 199, 3, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 199, 3, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 199, 3, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 3, 199, 3, 6642, 26, 199, 3, 260, 869, 951, 74, 7856, 12, 644, 621, 28, 72, 951, 74, 7856, 88, 14, 87, 621, 32, 22264, 14, 957, 30, 199, 199, 646, 2882, 199, 646, 747, 199, 646, 984, 199, 646, 3718, 199, 646, 5145, 199, 646, 1923, 199, 199, 533, 1379, 2305, 281, 2537, 13967, 8, 2796, 14, 1746, 304, 523, 347, 511, 63, 6116, 2042, 63, 1102, 2640, 8, 277, 304, 489, 1923, 14, 5996, 342, 489, 2088, 275, 298, 1548, 450, 83, 1875, 63, 23582, 14, 647, 1553, 2491, 29, 1308, 14, 88, 7757, 14, 2694, 1553, 354, 29, 2694, 1553, 1047, 2458, 83, 1553, 632, 2458, 83, 1553, 571, 13, 633, 29, 2859, 921, 7925, 7757, 13, 1715, 14, 1308, 6687, 450, 971, 288, 334, 1404, 14, 48, 346, 63, 11654, 12, 1923, 14, 7762, 12, 1923, 14, 6963, 9, 489, 870, 747, 14, 9458, 342, 489, 1923, 14, 2268, 63, 4600, 8, 1760, 12, 291, 9, 819, 347, 511, 63, 6116, 2042, 63, 6418, 8, 277, 304, 489, 1923, 14, 5996, 342, 489, 7712, 2042, 275, 1923, 14, 6361, 2042, 435, 3286, 470, 15, 6418, 14, 1001, 2, 489, 2088, 275, 298, 1548, 450, 83, 1875, 63, 23582, 14, 647, 1553, 2491, 29, 1308, 14, 88, 7757, 14, 2694, 1553, 1047, 2458, 83, 1553, 632, 2458, 83, 1553, 6418, 2458, 83, 2, 450, 971, 288, 334, 1404, 14, 48, 346, 63, 11654, 12, 1923, 14, 7762, 12, 1923, 14, 6963, 12, 7712, 2042, 9, 489, 747, 14, 8563, 8, 1404, 14, 6361, 2042, 435, 1994, 9707, 2537, 358, 489, 870, 747, 14, 9458, 342, 489, 1923, 14, 2268, 63, 4600, 8, 1760, 12, 291, 9, 819, 347, 511, 63, 6116, 2042, 63, 2491, 8, 277, 304, 489, 1923, 14, 5996, 342, 489, 1145, 6405, 275, 1923, 14, 6361, 2042, 435, 3286, 470, 6687, 489, 2088, 275, 298, 1548, 450, 83, 1875, 63, 23582, 14, 647, 1553, 2491, 29, 1308, 14, 88, 7757, 14, 2694, 1553, 354, 29, 2694, 1553, 1047, 2458, 83, 1553, 632, 2458, 83, 1553, 571, 13, 1231, 2458, 83, 1553, 571, 13, 1832, 13, 515, 29, 1080, 14, 1360, 2, 450, 971, 288, 334, 1404, 14, 48, 346, 63, 11654, 12, 1923, 14, 7762, 12, 1923, 14, 6963, 12, 1145, 6405, 9, 489, 747, 14, 8563, 8, 1404, 14, 6361, 2042, 435, 1994, 9707, 2537, 15, 7925, 7757, 358, 489, 870, 747, 14, 9458, 342, 489, 1923, 14, 2268, 63, 4600, 8, 1760, 12, 291, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 23855, 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, 0 ]
[ 1, 1, 1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DEVSimPy-plugin-SIG-viewer
ExtendedFrame.py
1
9957
# -*- coding: utf-8 -*- #import wxversion #wxversion.select('2.8.11') import wx import os import sys import wx.combo import wx.lib.agw.foldpanelbar as fpb _ = wx.GetTranslation def GetCollapsedIconData(): return \ '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ \x00\x01\x8eIDAT8\x8d\xa5\x93-n\xe4@\x10\x85?g\x03\n6lh)\xc4\xd2\x12\xc3\x81\ \xd6\xa2I\x90\x154\xb9\x81\x8f1G\xc8\x11\x16\x86\xcd\xa0\x99F\xb3A\x91\xa1\ \xc9J&\x96L"5lX\xcc\x0bl\xf7v\xb2\x7fZ\xa5\x98\xebU\xbdz\xf5\\\x9deW\x9f\xf8\ H\\\xbfO|{y\x9dT\x15P\x04\x01\x01UPUD\x84\xdb/7YZ\x9f\xa5\n\xce\x97aRU\x8a\ \xdc`\xacA\x00\x04P\xf0!0\xf6\x81\xa0\xf0p\xff9\xfb\x85\xe0|\x19&T)K\x8b\x18\ \xf9\xa3\xe4\xbe\xf3\x8c^#\xc9\xd5\n\xa8*\xc5?\x9a\x01\x8a\xd2b\r\x1cN\xc3\ \x14\t\xce\x97a\xb2F0Ks\xd58\xaa\xc6\xc5\xa6\xf7\xdfya\xe7\xbdR\x13M2\xf9\ \xf9qKQ\x1fi\xf6-\x00~T\xfac\x1dq#\x82,\xe5q\x05\x91D\xba@\xefj\xba1\xf0\xdc\ zzW\xcff&\xb8,\x89\xa8@Q\xd6\xaaf\xdfRm,\xee\xb1BDxr#\xae\xf5|\xddo\xd6\xe2H\ \x18\x15\x84\xa0q@]\xe54\x8d\xa3\xedf\x05M\xe3\xd8Uy\xc4\x15\x8d\xf5\xd7\x8b\ ~\x82\x0fh\x0e"\xb0\xad,\xee\xb8c\xbb\x18\xe7\x8e;6\xa5\x89\x04\xde\xff\x1c\ \x16\xef\xe0p\xfa>\x19\x11\xca\x8d\x8d\xe0\x93\x1b\x01\xd8m\xf3(;x\xa5\xef=\ \xb7w\xf3\x1d$\x7f\xc1\xe0\xbd\xa7\xeb\xa0(,"Kc\x12\xc1+\xfd\xe8\tI\xee\xed)\ \xbf\xbcN\xc1{D\x04k\x05#\x12\xfd\xf2a\xde[\x81\x87\xbb\xdf\x9cr\x1a\x87\xd3\ 0)\xba>\x83\xd5\xb97o\xe0\xaf\x04\xff\x13?\x00\xd2\xfb\xa9`z\xac\x80w\x00\ \x00\x00\x00IEND\xaeB`\x82' def GetCollapsedIconBitmap(): return wx.BitmapFromImage(GetCollapsedIconImage()) def GetCollapsedIconImage(): import cStringIO stream = cStringIO.StringIO(GetCollapsedIconData()) return wx.ImageFromStream(stream) #---------------------------------------------------------------------- def GetExpandedIconData(): return \ '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ \x00\x01\x9fIDAT8\x8d\x95\x93\xa1\x8e\xdc0\x14EO\xb2\xc4\xd0\xd2\x12\xb7(mI\ \xa4%V\xd1lQT4[4-\x9a\xfe\xc1\xc2|\xc6\xc2~BY\x83:A3E\xd3\xa0*\xa4\xd2\x90H!\ \x95\x0c\r\r\x1fK\x81g\xb2\x99\x84\xb4\x0fY\xd6\xbb\xc7\xf7>=\'Iz\xc3\xbcv\ \xfbn\xb8\x9c\x15 \xe7\xf3\xc7\x0fw\xc9\xbc7\x99\x03\x0e\xfbn0\x99F+\x85R\ \x80RH\x10\x82\x08\xde\x05\x1ef\x90+\xc0\xe1\xd8\ryn\xd0Z-\\A\xb4\xd2\xf7\ \x9e\xfbwoF\xc8\x088\x1c\xbbae\xb3\xe8y&\x9a\xdf\xf5\xbd\xe7\xfem\x84\xa4\ \x97\xccYf\x16\x8d\xdb\xb2a]\xfeX\x18\xc9s\xc3\xe1\x18\xe7\x94\x12cb\xcc\xb5\ \xfa\xb1l8\xf5\x01\xe7\x84\xc7\xb2Y@\xb2\xcc0\x02\xb4\x9a\x88%\xbe\xdc\xb4\ \x9e\xb6Zs\xaa74\xadg[6\x88<\xb7]\xc6\x14\x1dL\x86\xe6\x83\xa0\x81\xba\xda\ \x10\x02x/\xd4\xd5\x06\r\x840!\x9c\x1fM\x92\xf4\x86\x9f\xbf\xfe\x0c\xd6\x9ae\ \xd6u\x8d \xf4\xf5\x165\x9b\x8f\x04\xe1\xc5\xcb\xdb$\x05\x90\xa97@\x04lQas\ \xcd*7\x14\xdb\x9aY\xcb\xb8\\\xe9E\x10|\xbc\xf2^\xb0E\x85\xc95_\x9f\n\xaa/\ \x05\x10\x81\xce\xc9\xa8\xf6><G\xd8\xed\xbbA)X\xd9\x0c\x01\x9a\xc6Q\x14\xd9h\ [\x04\xda\xd6c\xadFkE\xf0\xc2\xab\xd7\xb7\xc9\x08\x00\xf8\xf6\xbd\x1b\x8cQ\ \xd8|\xb9\x0f\xd3\x9a\x8a\xc7\x08\x00\x9f?\xdd%\xde\x07\xda\x93\xc3{\x19C\ \x8a\x9c\x03\x0b8\x17\xe8\x9d\xbf\x02.>\x13\xc0n\xff{PJ\xc5\xfdP\x11""<\xbc\ \xff\x87\xdf\xf8\xbf\xf5\x17FF\xaf\x8f\x8b\xd3\xe6K\x00\x00\x00\x00IEND\xaeB\ `\x82' def GetExpandedIconBitmap(): return wx.BitmapFromImage(GetExpandedIconImage()) def GetExpandedIconImage(): import cStringIO stream = cStringIO.StringIO(GetExpandedIconData()) return wx.ImageFromStream(stream) class Extended(wx.Frame): def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=(700,400), style=wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, id, title, pos, size, style) self._flags = 0 self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP) self.statusbar.SetStatusWidths([-4, -3]) self.statusbar.SetStatusText("", 0) self.statusbar.SetStatusText("", 1) self._leftWindow1 = wx.SashLayoutWindow(self, 101, wx.DefaultPosition, wx.Size(200, 1000), wx.NO_BORDER | wx.SW_3D | wx.CLIP_CHILDREN) self._leftWindow1.SetDefaultSize(wx.Size(220, 1000)) self._leftWindow1.SetOrientation(wx.LAYOUT_VERTICAL) self._leftWindow1.SetAlignment(wx.LAYOUT_LEFT) self._leftWindow1.SetSashVisible(wx.SASH_RIGHT, True) self._leftWindow1.SetExtraBorderSize(10) self._pnl = 0 ###------------------------------------------------------------------------------------ self.remainingSpace = self.CreateRemainingSpace() self.ReCreateFoldPanel(0) def OnSize(self, event): wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) event.Skip() def OnFoldPanelBarDrag(self, event): if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE: return if event.GetId() == self.ID_WINDOW_LEFT1: self._leftWindow1.SetDefaultSize(wx.Size(event.GetDragRect().width, 1000)) # Leaves bits of itself behind sometimes wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace) self.remainingSpace.Refresh() event.Skip() def CreateRemainingSpace(self): """ Default right panel """ panel = wx.Panel(self, -1, style=wx.SUNKEN_BORDER) wx.StaticText(panel, -1, "Use your imagination for what kinds of things to put in this window...", (15,30)) return panel def ReCreateFoldPanel(self, fpb_flags): # delete earlier panel self._leftWindow1.DestroyChildren() # recreate the foldpanelbar self._pnl = fpb.FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition, wx.Size(-1,-1), agwStyle=fpb_flags) Images = wx.ImageList(16,16) Images.Add(GetExpandedIconBitmap()) Images.Add(GetCollapsedIconBitmap()) item = self._pnl.AddFoldPanel(_("Options"), collapsed=False, foldIcons=Images) self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Some options..."), fpb.FPB_ALIGN_WIDTH, 5, 20) self._leftWindow1.SizeWindows() def OnCollapseMe(self, event): for i in range(0, self._pnl.GetCount()): item = self._pnl.GetFoldPanel(i) self._pnl.Collapse(item) def OnExpandMe(self, event): col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), self._bslider1.GetValue()) col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), self._bslider2.GetValue()) style = fpb.CaptionBarStyle() style.SetFirstColour(col1) style.SetSecondColour(col2) counter = 0 for items in self.radiocontrols: if items.GetValue(): break counter = counter + 1 if counter == 0: mystyle = fpb.CAPTIONBAR_GRADIENT_V elif counter == 1: mystyle = fpb.CAPTIONBAR_GRADIENT_H elif counter == 2: mystyle = fpb.CAPTIONBAR_SINGLE elif counter == 3: mystyle = fpb.CAPTIONBAR_RECTANGLE else: mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE style.SetCaptionStyle(mystyle) self._pnl.ApplyCaptionStyleAll(style) def OnSlideColour(self, event): col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), self._bslider1.GetValue()) col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), self._bslider2.GetValue()) style = fpb.CaptionBarStyle() counter = 0 for items in self.radiocontrols: if items.GetValue(): break counter = counter + 1 if counter == 0: mystyle = fpb.CAPTIONBAR_GRADIENT_V elif counter == 1: mystyle = fpb.CAPTIONBAR_GRADIENT_H elif counter == 2: mystyle = fpb.CAPTIONBAR_SINGLE elif counter == 3: mystyle = fpb.CAPTIONBAR_RECTANGLE else: mystyle = fpb.CAPTIONBAR_FILLED_RECTANGLE style.SetFirstColour(col1) style.SetSecondColour(col2) style.SetCaptionStyle(mystyle) item = self._pnl.GetFoldPanel(0) self._pnl.ApplyCaptionStyle(item, style) def OnStyleChange(self, event): style = fpb.CaptionBarStyle() eventid = event.GetId() if eventid == self.ID_USE_HGRADIENT: style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_H) elif eventid == self.ID_USE_VGRADIENT: style.SetCaptionStyle(fpb.CAPTIONBAR_GRADIENT_V) elif eventid == self.ID_USE_SINGLE: style.SetCaptionStyle(fpb.CAPTIONBAR_SINGLE) elif eventid == self.ID_USE_RECTANGLE: style.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE) elif eventid == self.ID_USE_FILLED_RECTANGLE: style.SetCaptionStyle(fpb.CAPTIONBAR_FILLED_RECTANGLE) else: raise "ERROR: Undefined Style Selected For CaptionBar: " + repr(eventid) col1 = wx.Colour(self._rslider1.GetValue(), self._gslider1.GetValue(), self._bslider1.GetValue()) col2 = wx.Colour(self._rslider2.GetValue(), self._gslider2.GetValue(), self._bslider2.GetValue()) style.SetFirstColour(col1) style.SetSecondColour(col2) if self._single.GetValue(): item = self._pnl.GetFoldPanel(1) self._pnl.ApplyCaptionStyle(item, style) else: self._pnl.ApplyCaptionStyleAll(style) if __name__ == '__main__': app = wx.PySimpleApp() frame = Extended(None, title="FoldPanelBar Extended Demo") frame.Show() app.MainLoop()
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 646, 4818, 1023, 199, 3, 6323, 1023, 14, 2416, 360, 18, 14, 24, 14, 845, 358, 199, 199, 646, 4818, 199, 646, 747, 199, 646, 984, 199, 199, 646, 4818, 14, 12650, 199, 199, 646, 4818, 14, 773, 14, 643, 87, 14, 14011, 7885, 1700, 465, 289, 3317, 199, 199, 63, 275, 4818, 14, 1002, 18483, 199, 199, 318, 2372, 2001, 9982, 8954, 1451, 837, 272, 372, 971, 199, 1154, 88, 1407, 24454, 60, 82, 60, 78, 60, 88, 17, 65, 60, 78, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 82, 19824, 4564, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 709, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 709, 60, 88, 2036, 60, 88, 1690, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 17, 70, 60, 1949, 19, 60, 3581, 65, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 966, 83, 11970, 60, 88, 2036, 60, 88, 2036, 60, 88, 2036, 60, 88, 2036, 6113, 88, 2036, 68, 60, 88, 1299, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 614, 60, 88, 24, 69, 998, 619, 24, 60, 88, 24, 68, 60, 1800, 21, 60, 88, 3129, 13, 78, 60, 1845, 20, 32, 60, 88, 709, 60, 88, 2426, 31, 71, 60, 88, 1644, 60, 78, 22, 25514, 2862, 1812, 20, 60, 2207, 18, 60, 88, 713, 60, 1812, 19, 60, 88, 2835, 60, 199, 60, 2207, 22, 60, 1800, 18, 41, 60, 88, 2710, 60, 88, 10478, 60, 1774, 25, 60, 88, 2835, 60, 88, 24, 70, 17, 39, 60, 1812, 24, 60, 88, 845, 60, 88, 975, 60, 88, 1184, 60, 10879, 60, 1800, 16, 60, 88, 1020, 38, 60, 1774, 19, 33, 60, 88, 3328, 60, 1800, 17, 60, 199, 60, 1812, 25, 42, 28103, 88, 2534, 44, 2, 21, 76, 56, 60, 11022, 60, 88, 16, 3345, 60, 1949, 23, 86, 60, 1774, 18, 60, 88, 23, 70, 58, 60, 1800, 21, 60, 88, 2905, 60, 10145, 53, 60, 9826, 90, 60, 1949, 21, 9780, 88, 25, 271, 55, 60, 88, 25, 70, 60, 1949, 24, 60, 199, 40, 9780, 9566, 47, 92, 91, 89, 60, 88, 25, 19772, 60, 88, 1046, 48, 60, 88, 966, 60, 88, 614, 60, 88, 614, 2160, 3383, 60, 88, 1349, 60, 10719, 15, 23, 26184, 60, 88, 25, 70, 60, 1800, 21, 60, 78, 60, 10489, 60, 88, 2576, 65, 9500, 60, 88, 24, 65, 60, 199, 60, 10550, 25502, 10104, 33, 60, 88, 383, 60, 88, 966, 48, 60, 1949, 16, 1, 16, 60, 1949, 22, 60, 88, 2835, 60, 1800, 16, 60, 1949, 16, 80, 60, 3581, 25, 60, 10272, 60, 88, 2426, 60, 1845, 16, 6113, 88, 1167, 6, 52, 9, 43, 60, 88, 24, 66, 60, 88, 1085, 60, 199, 60, 1949, 25, 60, 1800, 19, 60, 1845, 20, 60, 9957, 60, 1949, 19, 60, 88, 24, 67, 62, 20262, 1812, 25, 60, 2207, 21, 60, 78, 60, 1800, 24, 7590, 1812, 21, 8995, 88, 25, 65, 60, 88, 614, 60, 88, 24, 65, 60, 2207, 18, 66, 60, 82, 60, 88, 17, 67, 46, 60, 1812, 19, 60, 199, 60, 88, 1079, 60, 84, 60, 10489, 60, 88, 2576, 65, 60, 1774, 18, 38, 16, 43, 83, 60, 2207, 2010, 60, 10117, 60, 1812, 22, 60, 1812, 21, 60, 1800, 22, 60, 1949, 23, 60, 2207, 1399, 65, 60, 1845, 23, 60, 9826, 50, 60, 88, 969, 45, 18, 60, 1949, 25, 60, 199, 60, 1949, 25, 81, 24817, 60, 88, 17, 329, 60, 1949, 22, 2696, 88, 383, 94, 52, 60, 1949, 645, 60, 88, 17, 27073, 20262, 88, 2564, 4202, 1845, 21, 81, 60, 88, 1717, 60, 88, 3328, 36, 60, 10539, 32, 60, 9532, 74, 60, 10539, 17, 60, 1949, 16, 60, 10550, 60, 199, 4348, 55, 60, 1812, 556, 28103, 1774, 24, 4202, 88, 1407, 60, 1800, 24, 32, 49, 60, 2207, 22, 60, 1800, 2756, 60, 10418, 31330, 4202, 11127, 60, 1774, 17, 11156, 15775, 20262, 10183, 60, 1949, 21, 6113, 11110, 79, 60, 2207, 22, 60, 1845, 18, 40, 60, 199, 60, 88, 1085, 60, 88, 1046, 60, 88, 1349, 60, 1800, 16, 81, 32, 7272, 1845, 1477, 60, 88, 24, 68, 60, 1800, 19, 60, 7887, 70, 60, 88, 1717, 45, 60, 1845, 19, 60, 2207, 24, 53, 89, 60, 1812, 20, 60, 88, 1046, 60, 88, 24, 68, 60, 1949, 21, 60, 2207, 23, 60, 88, 24, 66, 60, 199, 94, 60, 88, 2564, 60, 88, 16, 12853, 60, 88, 16, 69, 3212, 1774, 16, 60, 10135, 4202, 11127, 60, 1774, 24, 67, 60, 9932, 60, 88, 1085, 60, 1845, 23, 60, 88, 24, 69, 27, 22, 60, 1800, 21, 60, 88, 1407, 60, 88, 966, 60, 10745, 60, 3581, 60, 88, 17, 67, 60, 199, 60, 88, 975, 60, 9532, 60, 1845, 16, 80, 60, 10500, 3072, 88, 1167, 60, 88, 845, 60, 10768, 60, 88, 24, 68, 60, 88, 24, 68, 60, 1845, 16, 60, 88, 3129, 60, 88, 17, 66, 60, 88, 614, 60, 2207, 24, 77, 60, 1949, 19, 8, 27, 88, 60, 1800, 21, 60, 9532, 9529, 199, 60, 1774, 23, 87, 60, 1949, 19, 60, 88, 17, 68, 16827, 88, 23, 70, 60, 1812, 17, 60, 1845, 16, 60, 9826, 60, 1800, 23, 60, 10145, 60, 1800, 16, 8, 4589, 43, 67, 60, 88, 713, 60, 1812, 17, 7896, 11208, 60, 1845, 24, 60, 84, 41, 60, 11127, 60, 7887, 2862, 199, 60, 9566, 60, 10323, 46, 60, 1812, 17, 91, 36, 60, 88, 966, 75, 60, 88, 1717, 20262, 88, 713, 60, 11208, 60, 1949, 18, 65, 60, 10745, 7023, 88, 2835, 60, 88, 1555, 60, 9932, 60, 10418, 60, 88, 25, 1556, 60, 88, 17, 65, 60, 88, 1555, 60, 2207, 19, 60, 199, 16, 2862, 10539, 3072, 88, 2658, 60, 2207, 21, 60, 1774, 2576, 79, 60, 1845, 16, 60, 10850, 60, 88, 966, 60, 3581, 60, 88, 969, 8995, 88, 383, 60, 2207, 18, 60, 10272, 60, 1800 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 646, 4818, 1023, 199, 3, 6323, 1023, 14, 2416, 360, 18, 14, 24, 14, 845, 358, 199, 199, 646, 4818, 199, 646, 747, 199, 646, 984, 199, 199, 646, 4818, 14, 12650, 199, 199, 646, 4818, 14, 773, 14, 643, 87, 14, 14011, 7885, 1700, 465, 289, 3317, 199, 199, 63, 275, 4818, 14, 1002, 18483, 199, 199, 318, 2372, 2001, 9982, 8954, 1451, 837, 272, 372, 971, 199, 1154, 88, 1407, 24454, 60, 82, 60, 78, 60, 88, 17, 65, 60, 78, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 82, 19824, 4564, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 709, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 709, 60, 88, 2036, 60, 88, 1690, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 17, 70, 60, 1949, 19, 60, 3581, 65, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 966, 83, 11970, 60, 88, 2036, 60, 88, 2036, 60, 88, 2036, 60, 88, 2036, 6113, 88, 2036, 68, 60, 88, 1299, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 614, 60, 88, 24, 69, 998, 619, 24, 60, 88, 24, 68, 60, 1800, 21, 60, 88, 3129, 13, 78, 60, 1845, 20, 32, 60, 88, 709, 60, 88, 2426, 31, 71, 60, 88, 1644, 60, 78, 22, 25514, 2862, 1812, 20, 60, 2207, 18, 60, 88, 713, 60, 1812, 19, 60, 88, 2835, 60, 199, 60, 2207, 22, 60, 1800, 18, 41, 60, 88, 2710, 60, 88, 10478, 60, 1774, 25, 60, 88, 2835, 60, 88, 24, 70, 17, 39, 60, 1812, 24, 60, 88, 845, 60, 88, 975, 60, 88, 1184, 60, 10879, 60, 1800, 16, 60, 88, 1020, 38, 60, 1774, 19, 33, 60, 88, 3328, 60, 1800, 17, 60, 199, 60, 1812, 25, 42, 28103, 88, 2534, 44, 2, 21, 76, 56, 60, 11022, 60, 88, 16, 3345, 60, 1949, 23, 86, 60, 1774, 18, 60, 88, 23, 70, 58, 60, 1800, 21, 60, 88, 2905, 60, 10145, 53, 60, 9826, 90, 60, 1949, 21, 9780, 88, 25, 271, 55, 60, 88, 25, 70, 60, 1949, 24, 60, 199, 40, 9780, 9566, 47, 92, 91, 89, 60, 88, 25, 19772, 60, 88, 1046, 48, 60, 88, 966, 60, 88, 614, 60, 88, 614, 2160, 3383, 60, 88, 1349, 60, 10719, 15, 23, 26184, 60, 88, 25, 70, 60, 1800, 21, 60, 78, 60, 10489, 60, 88, 2576, 65, 9500, 60, 88, 24, 65, 60, 199, 60, 10550, 25502, 10104, 33, 60, 88, 383, 60, 88, 966, 48, 60, 1949, 16, 1, 16, 60, 1949, 22, 60, 88, 2835, 60, 1800, 16, 60, 1949, 16, 80, 60, 3581, 25, 60, 10272, 60, 88, 2426, 60, 1845, 16, 6113, 88, 1167, 6, 52, 9, 43, 60, 88, 24, 66, 60, 88, 1085, 60, 199, 60, 1949, 25, 60, 1800, 19, 60, 1845, 20, 60, 9957, 60, 1949, 19, 60, 88, 24, 67, 62, 20262, 1812, 25, 60, 2207, 21, 60, 78, 60, 1800, 24, 7590, 1812, 21, 8995, 88, 25, 65, 60, 88, 614, 60, 88, 24, 65, 60, 2207, 18, 66, 60, 82, 60, 88, 17, 67, 46, 60, 1812, 19, 60, 199, 60, 88, 1079, 60, 84, 60, 10489, 60, 88, 2576, 65, 60, 1774, 18, 38, 16, 43, 83, 60, 2207, 2010, 60, 10117, 60, 1812, 22, 60, 1812, 21, 60, 1800, 22, 60, 1949, 23, 60, 2207, 1399, 65, 60, 1845, 23, 60, 9826, 50, 60, 88, 969, 45, 18, 60, 1949, 25, 60, 199, 60, 1949, 25, 81, 24817, 60, 88, 17, 329, 60, 1949, 22, 2696, 88, 383, 94, 52, 60, 1949, 645, 60, 88, 17, 27073, 20262, 88, 2564, 4202, 1845, 21, 81, 60, 88, 1717, 60, 88, 3328, 36, 60, 10539, 32, 60, 9532, 74, 60, 10539, 17, 60, 1949, 16, 60, 10550, 60, 199, 4348, 55, 60, 1812, 556, 28103, 1774, 24, 4202, 88, 1407, 60, 1800, 24, 32, 49, 60, 2207, 22, 60, 1800, 2756, 60, 10418, 31330, 4202, 11127, 60, 1774, 17, 11156, 15775, 20262, 10183, 60, 1949, 21, 6113, 11110, 79, 60, 2207, 22, 60, 1845, 18, 40, 60, 199, 60, 88, 1085, 60, 88, 1046, 60, 88, 1349, 60, 1800, 16, 81, 32, 7272, 1845, 1477, 60, 88, 24, 68, 60, 1800, 19, 60, 7887, 70, 60, 88, 1717, 45, 60, 1845, 19, 60, 2207, 24, 53, 89, 60, 1812, 20, 60, 88, 1046, 60, 88, 24, 68, 60, 1949, 21, 60, 2207, 23, 60, 88, 24, 66, 60, 199, 94, 60, 88, 2564, 60, 88, 16, 12853, 60, 88, 16, 69, 3212, 1774, 16, 60, 10135, 4202, 11127, 60, 1774, 24, 67, 60, 9932, 60, 88, 1085, 60, 1845, 23, 60, 88, 24, 69, 27, 22, 60, 1800, 21, 60, 88, 1407, 60, 88, 966, 60, 10745, 60, 3581, 60, 88, 17, 67, 60, 199, 60, 88, 975, 60, 9532, 60, 1845, 16, 80, 60, 10500, 3072, 88, 1167, 60, 88, 845, 60, 10768, 60, 88, 24, 68, 60, 88, 24, 68, 60, 1845, 16, 60, 88, 3129, 60, 88, 17, 66, 60, 88, 614, 60, 2207, 24, 77, 60, 1949, 19, 8, 27, 88, 60, 1800, 21, 60, 9532, 9529, 199, 60, 1774, 23, 87, 60, 1949, 19, 60, 88, 17, 68, 16827, 88, 23, 70, 60, 1812, 17, 60, 1845, 16, 60, 9826, 60, 1800, 23, 60, 10145, 60, 1800, 16, 8, 4589, 43, 67, 60, 88, 713, 60, 1812, 17, 7896, 11208, 60, 1845, 24, 60, 84, 41, 60, 11127, 60, 7887, 2862, 199, 60, 9566, 60, 10323, 46, 60, 1812, 17, 91, 36, 60, 88, 966, 75, 60, 88, 1717, 20262, 88, 713, 60, 11208, 60, 1949, 18, 65, 60, 10745, 7023, 88, 2835, 60, 88, 1555, 60, 9932, 60, 10418, 60, 88, 25, 1556, 60, 88, 17, 65, 60, 88, 1555, 60, 2207, 19, 60, 199, 16, 2862, 10539, 3072, 88, 2658, 60, 2207, 21, 60, 1774, 2576, 79, 60, 1845, 16, 60, 10850, 60, 88, 966, 60, 3581, 60, 88, 969, 8995, 88, 383, 60, 2207, 18, 60, 10272, 60, 1800, 0 ]
[ 1, 1, 1,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ansible
lib/ansible/utils/module_docs_fragments/ipa.py
27
2627
# Copyright (c) 2017-18, Ansible Project # Copyright (c) 2017-18, Abhijeet Kasurde (akasurde@redhat.com) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) class ModuleDocFragment(object): # Parameters for FreeIPA/IPA modules DOCUMENTATION = ''' options: ipa_port: description: - Port of FreeIPA / IPA server. - If the value is not specified in the task, the value of environment variable C(IPA_PORT) will be used instead. - If both the environment variable C(IPA_PORT) and the value are not specified in the task, then default value is set. - 'Environment variable fallback mechanism is added in version 2.5.' default: 443 ipa_host: description: - IP or hostname of IPA server. - If the value is not specified in the task, the value of environment variable C(IPA_HOST) will be used instead. - If both the environment variable C(IPA_HOST) and the value are not specified in the task, then default value is set. - 'Environment variable fallback mechanism is added in version 2.5.' default: ipa.example.com ipa_user: description: - Administrative account used on IPA server. - If the value is not specified in the task, the value of environment variable C(IPA_USER) will be used instead. - If both the environment variable C(IPA_USER) and the value are not specified in the task, then default value is set. - 'Environment variable fallback mechanism is added in version 2.5.' default: admin ipa_pass: description: - Password of administrative user. - If the value is not specified in the task, the value of environment variable C(IPA_PASS) will be used instead. - If both the environment variable C(IPA_PASS) and the value are not specified in the task, then default value is set. - 'Environment variable fallback mechanism is added in version 2.5.' required: true ipa_prot: description: - Protocol used by IPA server. - If the value is not specified in the task, the value of environment variable C(IPA_PROT) will be used instead. - If both the environment variable C(IPA_PROT) and the value are not specified in the task, then default value is set. - 'Environment variable fallback mechanism is added in version 2.5.' default: https choices: ["http", "https"] validate_certs: description: - This only applies if C(ipa_prot) is I(https). - If set to C(no), the SSL certificates will not be validated. - This should only set to C(no) used on personally controlled sites using self-signed certificates. default: true '''
gpl-3.0
[ 3, 1898, 334, 67, 9, 9708, 13, 1085, 12, 2622, 7290, 199, 3, 1898, 334, 67, 9, 9708, 13, 1085, 12, 8351, 5812, 6532, 386, 1804, 305, 300, 271, 334, 1151, 305, 300, 271, 32, 17164, 14, 957, 9, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 272, 327, 3897, 367, 2868, 1772, 33, 15, 1772, 33, 4621, 272, 29970, 2594, 275, 1449, 199, 1419, 26, 523, 18210, 63, 719, 26, 272, 1369, 26, 272, 446, 10977, 402, 2868, 1772, 33, 1182, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 3657, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 3657, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 23865, 523, 18210, 63, 1102, 26, 272, 1369, 26, 272, 446, 3531, 503, 6246, 402, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 5449, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 5449, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 18210, 14, 2694, 14, 957, 523, 18210, 63, 751, 26, 272, 1369, 26, 272, 446, 9516, 25124, 2933, 1202, 641, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 3791, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 3791, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 4628, 523, 18210, 63, 1529, 26, 272, 1369, 26, 272, 446, 13635, 402, 4628, 25124, 922, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 6909, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 6909, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 1415, 26, 2549, 523, 18210, 63, 2745, 26, 272, 1369, 26, 272, 446, 11557, 1202, 701, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 21998, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 21998, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 4178, 272, 3415, 26, 2097, 1014, 401, 298, 2859, 937, 523, 4107, 63, 8356, 26, 272, 1369, 26, 272, 446, 961, 1454, 12966, 340, 445, 8, 20014, 63, 2745, 9, 365, 473, 8, 2859, 680, 272, 446, 982, 663, 370, 445, 8, 889, 395, 314, 7799, 14512, 911, 440, 506, 16468, 14, 272, 446, 961, 1077, 1454, 663, 370, 445, 8, 889, 9, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 272, 849, 26, 2549, 199, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 9708, 13, 1085, 12, 2622, 7290, 199, 3, 1898, 334, 67, 9, 9708, 13, 1085, 12, 8351, 5812, 6532, 386, 1804, 305, 300, 271, 334, 1151, 305, 300, 271, 32, 17164, 14, 957, 9, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 272, 327, 3897, 367, 2868, 1772, 33, 15, 1772, 33, 4621, 272, 29970, 2594, 275, 1449, 199, 1419, 26, 523, 18210, 63, 719, 26, 272, 1369, 26, 272, 446, 10977, 402, 2868, 1772, 33, 1182, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 3657, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 3657, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 23865, 523, 18210, 63, 1102, 26, 272, 1369, 26, 272, 446, 3531, 503, 6246, 402, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 5449, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 5449, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 18210, 14, 2694, 14, 957, 523, 18210, 63, 751, 26, 272, 1369, 26, 272, 446, 9516, 25124, 2933, 1202, 641, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 3791, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 3791, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 4628, 523, 18210, 63, 1529, 26, 272, 1369, 26, 272, 446, 13635, 402, 4628, 25124, 922, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 6909, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 6909, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 1415, 26, 2549, 523, 18210, 63, 2745, 26, 272, 1369, 26, 272, 446, 11557, 1202, 701, 3531, 33, 1654, 14, 272, 446, 982, 314, 574, 365, 440, 2013, 315, 314, 2120, 12, 314, 574, 402, 3734, 1750, 445, 8, 1772, 33, 63, 21998, 9, 911, 506, 1202, 3140, 14, 272, 446, 982, 3865, 314, 3734, 1750, 445, 8, 1772, 33, 63, 21998, 9, 436, 314, 574, 787, 440, 2013, 315, 314, 2120, 12, 2066, 849, 574, 365, 663, 14, 272, 446, 283, 8263, 1750, 9567, 14729, 365, 3483, 315, 1015, 499, 14, 21, 3530, 272, 849, 26, 4178, 272, 3415, 26, 2097, 1014, 401, 298, 2859, 937, 523, 4107, 63, 8356, 26, 272, 1369, 26, 272, 446, 961, 1454, 12966, 340, 445, 8, 20014, 63, 2745, 9, 365, 473, 8, 2859, 680, 272, 446, 982, 663, 370, 445, 8, 889, 395, 314, 7799, 14512, 911, 440, 506, 16468, 14, 272, 446, 961, 1077, 1454, 663, 370, 445, 8, 889, 9, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 272, 849, 26, 2549, 199, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
openhatch/oh-mainline
vendor/packages/Django/django/contrib/gis/tests/inspectapp/tests.py
134
5128
from __future__ import absolute_import import os from django.db import connections from django.test import TestCase from django.contrib.gis.gdal import Driver from django.contrib.gis.geometry.test_data import TEST_DATA from django.contrib.gis.utils.ogrinspect import ogrinspect from .models import AllOGRFields class OGRInspectTest(TestCase): def test_poly(self): shp_file = os.path.join(TEST_DATA, 'test_poly', 'test_poly.shp') model_def = ogrinspect(shp_file, 'MyModel') expected = [ '# This is an auto-generated Django model module created by ogrinspect.', 'from django.contrib.gis.db import models', '', 'class MyModel(models.Model):', ' float = models.FloatField()', ' int = models.FloatField()', ' str = models.CharField(max_length=80)', ' geom = models.PolygonField(srid=-1)', ' objects = models.GeoManager()', ] self.assertEqual(model_def, '\n'.join(expected)) def test_date_field(self): shp_file = os.path.join(TEST_DATA, 'cities', 'cities.shp') model_def = ogrinspect(shp_file, 'City') expected = [ '# This is an auto-generated Django model module created by ogrinspect.', 'from django.contrib.gis.db import models', '', 'class City(models.Model):', ' name = models.CharField(max_length=80)', ' population = models.FloatField()', ' density = models.FloatField()', ' created = models.DateField()', ' geom = models.PointField(srid=-1)', ' objects = models.GeoManager()', ] self.assertEqual(model_def, '\n'.join(expected)) def test_time_field(self): # Only possible to test this on PostGIS at the momemnt. MySQL # complains about permissions, and SpatiaLite/Oracle are # insanely difficult to get support compiled in for in GDAL. if not connections['default'].ops.postgis: return # Getting the database identifier used by OGR, if None returned # GDAL does not have the support compiled in. ogr_db = get_ogr_db_string() if not ogr_db: return # writing shapefules via GDAL currently does not support writing OGRTime # fields, so we need to actually use a database model_def = ogrinspect(ogr_db, 'Measurement', layer_key=AllOGRFields._meta.db_table, decimal=['f_decimal']) self.assertTrue(model_def.startswith( '# This is an auto-generated Django model module created by ogrinspect.\n' 'from django.contrib.gis.db import models\n' '\n' 'class Measurement(models.Model):\n' )) # The ordering of model fields might vary depending on several factors (version of GDAL, etc.) self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def) self.assertIn(' f_int = models.IntegerField()', model_def) self.assertIn(' f_datetime = models.DateTimeField()', model_def) self.assertIn(' f_time = models.TimeField()', model_def) self.assertIn(' f_float = models.FloatField()', model_def) self.assertIn(' f_char = models.CharField(max_length=10)', model_def) self.assertIn(' f_date = models.DateField()', model_def) self.assertTrue(model_def.endswith( ' geom = models.PolygonField()\n' ' objects = models.GeoManager()' )) def get_ogr_db_string(): # Construct the DB string that GDAL will use to inspect the database. # GDAL will create its own connection to the database, so we re-use the # connection settings from the Django test. This approach is a bit fragile # and cannot work on any other database other than PostgreSQL at the moment. db = connections.databases['default'] # Map from the django backend into the OGR driver name and database identifier # http://www.gdal.org/ogr/ogr_formats.html # # TODO: Support Oracle (OCI), MySQL, and SpatiaLite. drivers = { 'django.contrib.gis.db.backends.postgis': ('PostgreSQL', 'PG'), } drv_name, db_str = drivers[db['ENGINE']] # Ensure that GDAL library has driver support for the database. try: Driver(drv_name) except: return None # Build the params of the OGR database connection string # TODO: connection strings are database-dependent, thus if # we ever test other backends, this will need to change. params = ["dbname='%s'" % db['NAME']] def add(key, template): value = db.get(key, None) # Don't add the parameter if it is not in django's settings if value: params.append(template % value) add('HOST', "host='%s'") add('PORT', "port='%s'") add('USER', "user='%s'") add('PASSWORD', "password='%s'") return '%s:%s' % (db_str, ' '.join(params))
agpl-3.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 697, 492, 6947, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 492, 19447, 199, 504, 1639, 14, 2828, 14, 5668, 14, 7660, 14, 396, 63, 576, 492, 7393, 63, 3998, 199, 504, 1639, 14, 2828, 14, 5668, 14, 1208, 14, 14945, 10955, 492, 20713, 10955, 199, 199, 504, 1275, 992, 492, 2900, 17275, 7304, 421, 199, 533, 10904, 13962, 1764, 774, 8, 1746, 304, 272, 347, 511, 63, 6023, 8, 277, 304, 267, 1033, 80, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2864, 63, 3998, 12, 283, 396, 63, 6023, 297, 283, 396, 63, 6023, 14, 17299, 358, 267, 1402, 63, 318, 275, 20713, 10955, 8, 17299, 63, 493, 12, 283, 5713, 1685, 358, 398, 1420, 275, 359, 288, 3943, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2737, 701, 20713, 10955, 3130, 288, 283, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 297, 288, 3260, 288, 283, 533, 4932, 1685, 8, 992, 14, 1685, 304, 297, 288, 283, 259, 2069, 275, 1709, 14, 13019, 19633, 288, 283, 259, 1109, 275, 1709, 14, 13019, 19633, 288, 283, 259, 620, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1257, 3196, 288, 283, 259, 9671, 275, 1709, 14, 12367, 792, 8, 10498, 4022, 17, 3196, 288, 283, 259, 2251, 275, 1709, 14, 10748, 2988, 19633, 267, 1622, 398, 291, 14, 629, 8, 1238, 63, 318, 12, 1557, 78, 1370, 904, 8, 2062, 430, 339, 347, 511, 63, 602, 63, 698, 8, 277, 304, 267, 1033, 80, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2864, 63, 3998, 12, 283, 18207, 297, 283, 18207, 14, 17299, 358, 267, 1402, 63, 318, 275, 20713, 10955, 8, 17299, 63, 493, 12, 283, 17024, 358, 398, 1420, 275, 359, 288, 3943, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2737, 701, 20713, 10955, 3130, 288, 283, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 297, 288, 3260, 288, 283, 533, 14753, 8, 992, 14, 1685, 304, 297, 288, 283, 259, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1257, 3196, 288, 283, 259, 16423, 275, 1709, 14, 13019, 19633, 288, 283, 259, 13650, 275, 1709, 14, 13019, 19633, 288, 283, 259, 2737, 275, 1709, 14, 14071, 19633, 288, 283, 259, 9671, 275, 1709, 14, 3428, 792, 8, 10498, 4022, 17, 3196, 288, 283, 259, 2251, 275, 1709, 14, 10748, 2988, 19633, 267, 1622, 398, 291, 14, 629, 8, 1238, 63, 318, 12, 1557, 78, 1370, 904, 8, 2062, 430, 339, 347, 511, 63, 521, 63, 698, 8, 277, 304, 267, 327, 5972, 3962, 370, 511, 642, 641, 20929, 737, 314, 1303, 5286, 343, 14, 221, 11200, 267, 327, 32493, 3617, 3595, 3443, 12, 436, 25177, 15, 21202, 787, 267, 327, 5261, 4822, 89, 29870, 370, 664, 2291, 10311, 315, 367, 315, 15801, 14, 267, 340, 440, 6947, 459, 885, 2278, 1483, 14, 1932, 5668, 26, 288, 372, 398, 327, 20703, 314, 3050, 5148, 1202, 701, 10904, 12, 340, 488, 2138, 267, 327, 15801, 1630, 440, 1172, 314, 2291, 10311, 315, 14, 267, 20713, 63, 697, 275, 664, 63, 14945, 63, 697, 63, 875, 342, 267, 340, 440, 20713, 63, 697, 26, 288, 372, 398, 327, 3575, 2215, 70, 443, 83, 4799, 15801, 5544, 1630, 440, 2291, 3575, 10904, 1366, 267, 327, 1504, 12, 880, 781, 1929, 370, 5965, 675, 282, 3050, 267, 1402, 63, 318, 275, 20713, 10955, 8, 14945, 63, 697, 12, 283, 18611, 434, 297, 3044, 4045, 63, 498, 29, 2422, 17275, 7304, 423, 2024, 14, 697, 63, 1224, 12, 3044, 6107, 2968, 70, 63, 6355, 1105, 398, 291, 14, 1815, 8, 1238, 63, 318, 14, 2460, 8, 288, 3943, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2737, 701, 20713, 10955, 3134, 78, 7, 288, 283, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 60, 78, 7, 288, 1557, 78, 7, 288, 283, 533, 22933, 434, 8, 992, 14, 1685, 17211, 78, 7, 267, 5082, 398, 327, 710, 7794, 402, 1402, 1504, 5594, 17083, 10298, 641, 9978, 17704, 334, 1023, 402, 15801, 12, 5423, 4959, 267, 291, 14, 4080, 360, 259, 289, 63, 6355, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 16, 12, 6107, 63, 10696, 29, 16, 3196, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 442, 275, 1709, 14, 3901, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 2083, 275, 1709, 14, 4626, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 521, 275, 1709, 14, 27115, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 1609, 275, 1709, 14, 13019, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 1560, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 3196, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 602, 275, 1709, 14, 14071, 19633, 1402, 63, 318, 9, 398, 291, 14, 1815, 8, 1238, 63, 318, 14, 4130, 8, 288, 283, 259, 9671, 275, 1709, 14, 12367, 792, 17158, 78, 7, 288, 283, 259, 2251, 275, 1709, 14, 10748, 2988, 11716, 267, 5082, 421, 199, 318, 664, 63, 14945, 63, 697, 63, 875, 837, 272, 327, 9215, 314, 6249, 1059, 626, 15801, 911, 675, 370, 6485, 314, 3050, 14, 272, 327, 15801, 911, 1218, 2399, 5705, 1950, 370, 314, 3050, 12, 880, 781, 295, 13, 1180, 314, 272, 327, 1950, 2202, 687, 314, 5634, 511, 14, 221, 961, 18140, 365, 282, 4546, 11101, 441, 272, 327, 436, 3913, 1736, 641, 1263, 1163, 3050, 1163, 2419, 20175, 737, 314, 12427, 14, 272, 1592, 275, 6947, 14, 17439, 459, 885, 418, 339, 327, 9672, 687, 314, 1639, 4865, 1901, 314, 10904, 5253, 536, 436, 3050, 5148, 272, 327, 1455, 921, 1544, 14, 11600, 14, 1308, 15, 14945, 15, 14945, 63, 6321, 14, 1360, 272, 327, 272, 327, 3254, 26, 12502, 15309, 334, 47, 3553, 395, 11200, 12, 436, 25177, 14, 272, 19016, 275, 469, 267, 283, 1176, 14 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 697, 492, 6947, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 492, 19447, 199, 504, 1639, 14, 2828, 14, 5668, 14, 7660, 14, 396, 63, 576, 492, 7393, 63, 3998, 199, 504, 1639, 14, 2828, 14, 5668, 14, 1208, 14, 14945, 10955, 492, 20713, 10955, 199, 199, 504, 1275, 992, 492, 2900, 17275, 7304, 421, 199, 533, 10904, 13962, 1764, 774, 8, 1746, 304, 272, 347, 511, 63, 6023, 8, 277, 304, 267, 1033, 80, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2864, 63, 3998, 12, 283, 396, 63, 6023, 297, 283, 396, 63, 6023, 14, 17299, 358, 267, 1402, 63, 318, 275, 20713, 10955, 8, 17299, 63, 493, 12, 283, 5713, 1685, 358, 398, 1420, 275, 359, 288, 3943, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2737, 701, 20713, 10955, 3130, 288, 283, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 297, 288, 3260, 288, 283, 533, 4932, 1685, 8, 992, 14, 1685, 304, 297, 288, 283, 259, 2069, 275, 1709, 14, 13019, 19633, 288, 283, 259, 1109, 275, 1709, 14, 13019, 19633, 288, 283, 259, 620, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1257, 3196, 288, 283, 259, 9671, 275, 1709, 14, 12367, 792, 8, 10498, 4022, 17, 3196, 288, 283, 259, 2251, 275, 1709, 14, 10748, 2988, 19633, 267, 1622, 398, 291, 14, 629, 8, 1238, 63, 318, 12, 1557, 78, 1370, 904, 8, 2062, 430, 339, 347, 511, 63, 602, 63, 698, 8, 277, 304, 267, 1033, 80, 63, 493, 275, 747, 14, 515, 14, 904, 8, 2864, 63, 3998, 12, 283, 18207, 297, 283, 18207, 14, 17299, 358, 267, 1402, 63, 318, 275, 20713, 10955, 8, 17299, 63, 493, 12, 283, 17024, 358, 398, 1420, 275, 359, 288, 3943, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2737, 701, 20713, 10955, 3130, 288, 283, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 297, 288, 3260, 288, 283, 533, 14753, 8, 992, 14, 1685, 304, 297, 288, 283, 259, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1257, 3196, 288, 283, 259, 16423, 275, 1709, 14, 13019, 19633, 288, 283, 259, 13650, 275, 1709, 14, 13019, 19633, 288, 283, 259, 2737, 275, 1709, 14, 14071, 19633, 288, 283, 259, 9671, 275, 1709, 14, 3428, 792, 8, 10498, 4022, 17, 3196, 288, 283, 259, 2251, 275, 1709, 14, 10748, 2988, 19633, 267, 1622, 398, 291, 14, 629, 8, 1238, 63, 318, 12, 1557, 78, 1370, 904, 8, 2062, 430, 339, 347, 511, 63, 521, 63, 698, 8, 277, 304, 267, 327, 5972, 3962, 370, 511, 642, 641, 20929, 737, 314, 1303, 5286, 343, 14, 221, 11200, 267, 327, 32493, 3617, 3595, 3443, 12, 436, 25177, 15, 21202, 787, 267, 327, 5261, 4822, 89, 29870, 370, 664, 2291, 10311, 315, 367, 315, 15801, 14, 267, 340, 440, 6947, 459, 885, 2278, 1483, 14, 1932, 5668, 26, 288, 372, 398, 327, 20703, 314, 3050, 5148, 1202, 701, 10904, 12, 340, 488, 2138, 267, 327, 15801, 1630, 440, 1172, 314, 2291, 10311, 315, 14, 267, 20713, 63, 697, 275, 664, 63, 14945, 63, 697, 63, 875, 342, 267, 340, 440, 20713, 63, 697, 26, 288, 372, 398, 327, 3575, 2215, 70, 443, 83, 4799, 15801, 5544, 1630, 440, 2291, 3575, 10904, 1366, 267, 327, 1504, 12, 880, 781, 1929, 370, 5965, 675, 282, 3050, 267, 1402, 63, 318, 275, 20713, 10955, 8, 14945, 63, 697, 12, 283, 18611, 434, 297, 3044, 4045, 63, 498, 29, 2422, 17275, 7304, 423, 2024, 14, 697, 63, 1224, 12, 3044, 6107, 2968, 70, 63, 6355, 1105, 398, 291, 14, 1815, 8, 1238, 63, 318, 14, 2460, 8, 288, 3943, 961, 365, 376, 2599, 13, 10176, 5634, 1402, 859, 2737, 701, 20713, 10955, 3134, 78, 7, 288, 283, 504, 1639, 14, 2828, 14, 5668, 14, 697, 492, 1709, 60, 78, 7, 288, 1557, 78, 7, 288, 283, 533, 22933, 434, 8, 992, 14, 1685, 17211, 78, 7, 267, 5082, 398, 327, 710, 7794, 402, 1402, 1504, 5594, 17083, 10298, 641, 9978, 17704, 334, 1023, 402, 15801, 12, 5423, 4959, 267, 291, 14, 4080, 360, 259, 289, 63, 6355, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 16, 12, 6107, 63, 10696, 29, 16, 3196, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 442, 275, 1709, 14, 3901, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 2083, 275, 1709, 14, 4626, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 521, 275, 1709, 14, 27115, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 1609, 275, 1709, 14, 13019, 19633, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 1560, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 3196, 1402, 63, 318, 9, 267, 291, 14, 4080, 360, 259, 289, 63, 602, 275, 1709, 14, 14071, 19633, 1402, 63, 318, 9, 398, 291, 14, 1815, 8, 1238, 63, 318, 14, 4130, 8, 288, 283, 259, 9671, 275, 1709, 14, 12367, 792, 17158, 78, 7, 288, 283, 259, 2251, 275, 1709, 14, 10748, 2988, 11716, 267, 5082, 421, 199, 318, 664, 63, 14945, 63, 697, 63, 875, 837, 272, 327, 9215, 314, 6249, 1059, 626, 15801, 911, 675, 370, 6485, 314, 3050, 14, 272, 327, 15801, 911, 1218, 2399, 5705, 1950, 370, 314, 3050, 12, 880, 781, 295, 13, 1180, 314, 272, 327, 1950, 2202, 687, 314, 5634, 511, 14, 221, 961, 18140, 365, 282, 4546, 11101, 441, 272, 327, 436, 3913, 1736, 641, 1263, 1163, 3050, 1163, 2419, 20175, 737, 314, 12427, 14, 272, 1592, 275, 6947, 14, 17439, 459, 885, 418, 339, 327, 9672, 687, 314, 1639, 4865, 1901, 314, 10904, 5253, 536, 436, 3050, 5148, 272, 327, 1455, 921, 1544, 14, 11600, 14, 1308, 15, 14945, 15, 14945, 63, 6321, 14, 1360, 272, 327, 272, 327, 3254, 26, 12502, 15309, 334, 47, 3553, 395, 11200, 12, 436, 25177, 14, 272, 19016, 275, 469, 267, 283, 1176, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
phimpme/generator
Phimpme/site-packages/requests/packages/charade/utf8prober.py
205
2728
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from . import constants from .charsetprober import CharSetProber from .codingstatemachine import CodingStateMachine from .mbcssm import UTF8SMModel ONE_CHAR_PROB = 0.5 class UTF8Prober(CharSetProber): def __init__(self): CharSetProber.__init__(self) self._mCodingSM = CodingStateMachine(UTF8SMModel) self.reset() def reset(self): CharSetProber.reset(self) self._mCodingSM.reset() self._mNumOfMBChar = 0 def get_charset_name(self): return "utf-8" def feed(self, aBuf): for c in aBuf: codingState = self._mCodingSM.next_state(c) if codingState == constants.eError: self._mState = constants.eNotMe break elif codingState == constants.eItsMe: self._mState = constants.eFoundIt break elif codingState == constants.eStart: if self._mCodingSM.get_current_charlen() >= 2: self._mNumOfMBChar += 1 if self.get_state() == constants.eDetecting: if self.get_confidence() > constants.SHORTCUT_THRESHOLD: self._mState = constants.eFoundIt return self.get_state() def get_confidence(self): unlike = 0.99 if self._mNumOfMBChar < 6: for i in range(0, self._mNumOfMBChar): unlike = unlike * ONE_CHAR_PROB return 1.0 - unlike else: return unlike
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 202, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 202, 199, 3, 202, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 202, 199, 3, 20433, 18686, 11098, 14, 202, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 202, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 202, 199, 3, 202, 199, 3, 17636, 8, 83, 304, 202, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 202, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 202, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 202, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 202, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 202, 199, 3, 11315, 13, 10067, 221, 8217, 202, 199, 19054, 7729, 5113, 8068, 21186, 2999, 199, 504, 1275, 492, 5262, 202, 199, 504, 1275, 6043, 19903, 492, 31727, 202, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 202, 199, 504, 1275, 887, 3919, 77, 492, 9094, 24, 25335, 2999, 199, 4817, 63, 5901, 63, 30533, 275, 378, 14, 21, 8065, 199, 533, 9094, 24, 8029, 8, 15159, 304, 1128, 347, 636, 826, 721, 277, 304, 1039, 31727, 855, 826, 721, 277, 9, 1039, 291, 423, 29633, 275, 30539, 8, 6610, 24, 25335, 9, 1039, 291, 14, 3958, 342, 2958, 347, 5305, 8, 277, 304, 1039, 31727, 14, 3958, 8, 277, 9, 1039, 291, 423, 29633, 14, 3958, 342, 1039, 291, 423, 77, 5667, 3466, 4567, 1610, 275, 378, 2958, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 1039, 372, 298, 1624, 13, 24, 2, 2958, 347, 4733, 8, 277, 12, 17407, 304, 1039, 367, 286, 315, 17407, 26, 1675, 2803, 2223, 275, 291, 423, 29633, 14, 2184, 63, 929, 8, 67, 9, 1675, 340, 2803, 2223, 508, 5262, 14, 6259, 26, 2628, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 2628, 2059, 1675, 916, 2803, 2223, 508, 5262, 14, 13241, 26, 2628, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 2628, 2059, 1675, 916, 2803, 2223, 508, 5262, 14, 11724, 26, 2628, 340, 291, 423, 29633, 14, 362, 63, 1818, 63, 1560, 552, 342, 2356, 499, 26, 4906, 291, 423, 77, 5667, 3466, 4567, 1610, 847, 413, 4341, 340, 291, 14, 362, 63, 929, 342, 508, 5262, 14, 69, 20064, 316, 26, 1675, 340, 291, 14, 362, 63, 13969, 342, 690, 5262, 14, 13003, 24678, 63, 19307, 26, 2628, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 4341, 372, 291, 14, 362, 63, 929, 342, 2958, 347, 664, 63, 13969, 8, 277, 304, 1039, 29750, 275, 378, 14, 1020, 1039, 340, 291, 423, 77, 5667, 3466, 4567, 1610, 665, 1227, 26, 1675, 367, 284, 315, 1425, 8, 16, 12, 291, 423, 77, 5667, 3466, 4567, 1610, 304, 2628, 29750, 275, 29750, 627, 13051, 63, 5901, 63, 30533, 1675, 372, 413, 14, 16, 446, 29750, 1039, 587, 26, 1675, 372, 29750, 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 ]
[ 16427, 5113, 8068, 11945, 202, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 202, 199, 3, 202, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 202, 199, 3, 20433, 18686, 11098, 14, 202, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 202, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 202, 199, 3, 202, 199, 3, 17636, 8, 83, 304, 202, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 202, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 202, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 202, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 202, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 202, 199, 3, 11315, 13, 10067, 221, 8217, 202, 199, 19054, 7729, 5113, 8068, 21186, 2999, 199, 504, 1275, 492, 5262, 202, 199, 504, 1275, 6043, 19903, 492, 31727, 202, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 202, 199, 504, 1275, 887, 3919, 77, 492, 9094, 24, 25335, 2999, 199, 4817, 63, 5901, 63, 30533, 275, 378, 14, 21, 8065, 199, 533, 9094, 24, 8029, 8, 15159, 304, 1128, 347, 636, 826, 721, 277, 304, 1039, 31727, 855, 826, 721, 277, 9, 1039, 291, 423, 29633, 275, 30539, 8, 6610, 24, 25335, 9, 1039, 291, 14, 3958, 342, 2958, 347, 5305, 8, 277, 304, 1039, 31727, 14, 3958, 8, 277, 9, 1039, 291, 423, 29633, 14, 3958, 342, 1039, 291, 423, 77, 5667, 3466, 4567, 1610, 275, 378, 2958, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 1039, 372, 298, 1624, 13, 24, 2, 2958, 347, 4733, 8, 277, 12, 17407, 304, 1039, 367, 286, 315, 17407, 26, 1675, 2803, 2223, 275, 291, 423, 29633, 14, 2184, 63, 929, 8, 67, 9, 1675, 340, 2803, 2223, 508, 5262, 14, 6259, 26, 2628, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 2628, 2059, 1675, 916, 2803, 2223, 508, 5262, 14, 13241, 26, 2628, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 2628, 2059, 1675, 916, 2803, 2223, 508, 5262, 14, 11724, 26, 2628, 340, 291, 423, 29633, 14, 362, 63, 1818, 63, 1560, 552, 342, 2356, 499, 26, 4906, 291, 423, 77, 5667, 3466, 4567, 1610, 847, 413, 4341, 340, 291, 14, 362, 63, 929, 342, 508, 5262, 14, 69, 20064, 316, 26, 1675, 340, 291, 14, 362, 63, 13969, 342, 690, 5262, 14, 13003, 24678, 63, 19307, 26, 2628, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 4341, 372, 291, 14, 362, 63, 929, 342, 2958, 347, 664, 63, 13969, 8, 277, 304, 1039, 29750, 275, 378, 14, 1020, 1039, 340, 291, 423, 77, 5667, 3466, 4567, 1610, 665, 1227, 26, 1675, 367, 284, 315, 1425, 8, 16, 12, 291, 423, 77, 5667, 3466, 4567, 1610, 304, 2628, 29750, 275, 29750, 627, 13051, 63, 5901, 63, 30533, 1675, 372, 413, 14, 16, 446, 29750, 1039, 587, 26, 1675, 372, 29750, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ajoaoff/django
tests/generic_views/test_base.py
269
19854
from __future__ import unicode_literals import time import unittest from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import resolve from django.http import HttpResponse from django.test import RequestFactory, SimpleTestCase, override_settings from django.test.utils import require_jinja2 from django.views.generic import RedirectView, TemplateView, View from . import views class SimpleView(View): """ A simple view with a docstring. """ def get(self, request): return HttpResponse('This is a simple view') class SimplePostView(SimpleView): post = SimpleView.get class PostOnlyView(View): def post(self, request): return HttpResponse('This view only accepts POST') class CustomizableView(SimpleView): parameter = {} def decorator(view): view.is_decorated = True return view class DecoratedDispatchView(SimpleView): @decorator def dispatch(self, request, *args, **kwargs): return super(DecoratedDispatchView, self).dispatch(request, *args, **kwargs) class AboutTemplateView(TemplateView): def get(self, request): return self.render_to_response({}) def get_template_names(self): return ['generic_views/about.html'] class AboutTemplateAttributeView(TemplateView): template_name = 'generic_views/about.html' def get(self, request): return self.render_to_response(context={}) class InstanceView(View): def get(self, request): return self class ViewTest(unittest.TestCase): rf = RequestFactory() def _assert_simple(self, response): self.assertEqual(response.status_code, 200) self.assertEqual(response.content, b'This is a simple view') def test_no_init_kwargs(self): """ Test that a view can't be accidentally instantiated before deployment """ try: SimpleView(key='value').as_view() self.fail('Should not be able to instantiate a view') except AttributeError: pass def test_no_init_args(self): """ Test that a view can't be accidentally instantiated before deployment """ try: SimpleView.as_view('value') self.fail('Should not be able to use non-keyword arguments instantiating a view') except TypeError: pass def test_pathological_http_method(self): """ The edge case of a http request that spoofs an existing method name is caught. """ self.assertEqual(SimpleView.as_view()( self.rf.get('/', REQUEST_METHOD='DISPATCH') ).status_code, 405) def test_get_only(self): """ Test a view which only allows GET doesn't allow other methods. """ self._assert_simple(SimpleView.as_view()(self.rf.get('/'))) self.assertEqual(SimpleView.as_view()(self.rf.post('/')).status_code, 405) self.assertEqual(SimpleView.as_view()( self.rf.get('/', REQUEST_METHOD='FAKE') ).status_code, 405) def test_get_and_head(self): """ Test a view which supplies a GET method also responds correctly to HEAD. """ self._assert_simple(SimpleView.as_view()(self.rf.get('/'))) response = SimpleView.as_view()(self.rf.head('/')) self.assertEqual(response.status_code, 200) def test_head_no_get(self): """ Test a view which supplies no GET method responds to HEAD with HTTP 405. """ response = PostOnlyView.as_view()(self.rf.head('/')) self.assertEqual(response.status_code, 405) def test_get_and_post(self): """ Test a view which only allows both GET and POST. """ self._assert_simple(SimplePostView.as_view()(self.rf.get('/'))) self._assert_simple(SimplePostView.as_view()(self.rf.post('/'))) self.assertEqual(SimplePostView.as_view()( self.rf.get('/', REQUEST_METHOD='FAKE') ).status_code, 405) def test_invalid_keyword_argument(self): """ Test that view arguments must be predefined on the class and can't be named like a HTTP method. """ # Check each of the allowed method names for method in SimpleView.http_method_names: kwargs = dict(((method, "value"),)) self.assertRaises(TypeError, SimpleView.as_view, **kwargs) # Check the case view argument is ok if predefined on the class... CustomizableView.as_view(parameter="value") # ...but raises errors otherwise. self.assertRaises(TypeError, CustomizableView.as_view, foobar="value") def test_calling_more_than_once(self): """ Test a view can only be called once. """ request = self.rf.get('/') view = InstanceView.as_view() self.assertNotEqual(view(request), view(request)) def test_class_attributes(self): """ Test that the callable returned from as_view() has proper docstring, name and module. """ self.assertEqual(SimpleView.__doc__, SimpleView.as_view().__doc__) self.assertEqual(SimpleView.__name__, SimpleView.as_view().__name__) self.assertEqual(SimpleView.__module__, SimpleView.as_view().__module__) def test_dispatch_decoration(self): """ Test that attributes set by decorators on the dispatch method are also present on the closure. """ self.assertTrue(DecoratedDispatchView.as_view().is_decorated) def test_options(self): """ Test that views respond to HTTP OPTIONS requests with an Allow header appropriate for the methods implemented by the view class. """ request = self.rf.options('/') view = SimpleView.as_view() response = view(request) self.assertEqual(200, response.status_code) self.assertTrue(response['Allow']) def test_options_for_get_view(self): """ Test that a view implementing GET allows GET and HEAD. """ request = self.rf.options('/') view = SimpleView.as_view() response = view(request) self._assert_allows(response, 'GET', 'HEAD') def test_options_for_get_and_post_view(self): """ Test that a view implementing GET and POST allows GET, HEAD, and POST. """ request = self.rf.options('/') view = SimplePostView.as_view() response = view(request) self._assert_allows(response, 'GET', 'HEAD', 'POST') def test_options_for_post_view(self): """ Test that a view implementing POST allows POST. """ request = self.rf.options('/') view = PostOnlyView.as_view() response = view(request) self._assert_allows(response, 'POST') def _assert_allows(self, response, *expected_methods): "Assert allowed HTTP methods reported in the Allow response header" response_allows = set(response['Allow'].split(', ')) self.assertEqual(set(expected_methods + ('OPTIONS',)), response_allows) def test_args_kwargs_request_on_self(self): """ Test a view only has args, kwargs & request once `as_view` has been called. """ bare_view = InstanceView() view = InstanceView.as_view()(self.rf.get('/')) for attribute in ('args', 'kwargs', 'request'): self.assertNotIn(attribute, dir(bare_view)) self.assertIn(attribute, dir(view)) def test_direct_instantiation(self): """ It should be possible to use the view by directly instantiating it without going through .as_view() (#21564). """ view = PostOnlyView() response = view.dispatch(self.rf.head('/')) self.assertEqual(response.status_code, 405) @override_settings(ROOT_URLCONF='generic_views.urls') class TemplateViewTest(SimpleTestCase): rf = RequestFactory() def _assert_about(self, response): response.render() self.assertEqual(response.status_code, 200) self.assertContains(response, '<h1>About</h1>') def test_get(self): """ Test a view that simply renders a template on GET """ self._assert_about(AboutTemplateView.as_view()(self.rf.get('/about/'))) def test_head(self): """ Test a TemplateView responds correctly to HEAD """ response = AboutTemplateView.as_view()(self.rf.head('/about/')) self.assertEqual(response.status_code, 200) def test_get_template_attribute(self): """ Test a view that renders a template on GET with the template name as an attribute on the class. """ self._assert_about(AboutTemplateAttributeView.as_view()(self.rf.get('/about/'))) def test_get_generic_template(self): """ Test a completely generic view that renders a template on GET with the template name as an argument at instantiation. """ self._assert_about(TemplateView.as_view(template_name='generic_views/about.html')(self.rf.get('/about/'))) def test_template_name_required(self): """ A template view must provide a template name. """ self.assertRaises(ImproperlyConfigured, self.client.get, '/template/no_template/') @require_jinja2 def test_template_engine(self): """ A template view may provide a template engine. """ request = self.rf.get('/using/') view = TemplateView.as_view(template_name='generic_views/using.html') self.assertEqual(view(request).render().content, b'DTL\n') view = TemplateView.as_view(template_name='generic_views/using.html', template_engine='django') self.assertEqual(view(request).render().content, b'DTL\n') view = TemplateView.as_view(template_name='generic_views/using.html', template_engine='jinja2') self.assertEqual(view(request).render().content, b'Jinja2\n') def test_template_params(self): """ A generic template view passes kwargs as context. """ response = self.client.get('/template/simple/bar/') self.assertEqual(response.status_code, 200) self.assertEqual(response.context['foo'], 'bar') self.assertIsInstance(response.context['view'], View) def test_extra_template_params(self): """ A template view can be customized to return extra context. """ response = self.client.get('/template/custom/bar/') self.assertEqual(response.status_code, 200) self.assertEqual(response.context['foo'], 'bar') self.assertEqual(response.context['key'], 'value') self.assertIsInstance(response.context['view'], View) def test_cached_views(self): """ A template view can be cached """ response = self.client.get('/template/cached/bar/') self.assertEqual(response.status_code, 200) time.sleep(1.0) response2 = self.client.get('/template/cached/bar/') self.assertEqual(response2.status_code, 200) self.assertEqual(response.content, response2.content) time.sleep(2.0) # Let the cache expire and test again response2 = self.client.get('/template/cached/bar/') self.assertEqual(response2.status_code, 200) self.assertNotEqual(response.content, response2.content) def test_content_type(self): response = self.client.get('/template/content_type/') self.assertEqual(response['Content-Type'], 'text/plain') def test_resolve_view(self): match = resolve('/template/content_type/') self.assertIs(match.func.view_class, TemplateView) self.assertEqual(match.func.view_initkwargs['content_type'], 'text/plain') def test_resolve_login_required_view(self): match = resolve('/template/login_required/') self.assertIs(match.func.view_class, TemplateView) @override_settings(ROOT_URLCONF='generic_views.urls') class RedirectViewTest(SimpleTestCase): rf = RequestFactory() def test_no_url(self): "Without any configuration, returns HTTP 410 GONE" response = RedirectView.as_view()(self.rf.get('/foo/')) self.assertEqual(response.status_code, 410) def test_default_redirect(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.get('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_permanent_redirect(self): "Permanent redirects are an option" response = RedirectView.as_view(url='/bar/', permanent=True)(self.rf.get('/foo/')) self.assertEqual(response.status_code, 301) self.assertEqual(response.url, '/bar/') def test_temporary_redirect(self): "Temporary redirects are an option" response = RedirectView.as_view(url='/bar/', permanent=False)(self.rf.get('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_include_args(self): "GET arguments can be included in the redirected URL" response = RedirectView.as_view(url='/bar/')(self.rf.get('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') response = RedirectView.as_view(url='/bar/', query_string=True)(self.rf.get('/foo/?pork=spam')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/?pork=spam') def test_include_urlencoded_args(self): "GET arguments can be URL-encoded when included in the redirected URL" response = RedirectView.as_view(url='/bar/', query_string=True)( self.rf.get('/foo/?unicode=%E2%9C%93')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/?unicode=%E2%9C%93') def test_parameter_substitution(self): "Redirection URLs can be parameterized" response = RedirectView.as_view(url='/bar/%(object_id)d/')(self.rf.get('/foo/42/'), object_id=42) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/42/') def test_named_url_pattern(self): "Named pattern parameter should reverse to the matching pattern" response = RedirectView.as_view(pattern_name='artist_detail')(self.rf.get('/foo/'), pk=1) self.assertEqual(response.status_code, 302) self.assertEqual(response['Location'], '/detail/artist/1/') def test_named_url_pattern_using_args(self): response = RedirectView.as_view(pattern_name='artist_detail')(self.rf.get('/foo/'), 1) self.assertEqual(response.status_code, 302) self.assertEqual(response['Location'], '/detail/artist/1/') def test_wrong_named_url_pattern(self): "A wrong pattern name returns 410 GONE" response = RedirectView.as_view(pattern_name='wrong.pattern_name')(self.rf.get('/foo/')) self.assertEqual(response.status_code, 410) def test_redirect_POST(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.post('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_redirect_HEAD(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.head('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_redirect_OPTIONS(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.options('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_redirect_PUT(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.put('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_redirect_PATCH(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.patch('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_redirect_DELETE(self): "Default is a temporary redirect" response = RedirectView.as_view(url='/bar/')(self.rf.delete('/foo/')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, '/bar/') def test_redirect_when_meta_contains_no_query_string(self): "regression for #16705" # we can't use self.rf.get because it always sets QUERY_STRING response = RedirectView.as_view(url='/bar/')(self.rf.request(PATH_INFO='/foo/')) self.assertEqual(response.status_code, 302) def test_direct_instantiation(self): """ It should be possible to use the view without going through .as_view() (#21564). """ view = RedirectView() response = view.dispatch(self.rf.head('/foo/')) self.assertEqual(response.status_code, 410) class GetContextDataTest(unittest.TestCase): def test_get_context_data_super(self): test_view = views.CustomContextView() context = test_view.get_context_data(kwarg_test='kwarg_value') # the test_name key is inserted by the test classes parent self.assertIn('test_name', context) self.assertEqual(context['kwarg_test'], 'kwarg_value') self.assertEqual(context['custom_key'], 'custom_value') # test that kwarg overrides values assigned higher up context = test_view.get_context_data(test_name='test_value') self.assertEqual(context['test_name'], 'test_value') def test_object_at_custom_name_in_context_data(self): # Checks 'pony' key presence in dict returned by get_context_date test_view = views.CustomSingleObjectView() test_view.context_object_name = 'pony' context = test_view.get_context_data() self.assertEqual(context['pony'], test_view.object) def test_object_in_get_context_data(self): # Checks 'object' key presence in dict returned by get_context_date #20234 test_view = views.CustomSingleObjectView() context = test_view.get_context_data() self.assertEqual(context['object'], test_view.object) class UseMultipleObjectMixinTest(unittest.TestCase): rf = RequestFactory() def test_use_queryset_from_view(self): test_view = views.CustomMultipleObjectMixinView() test_view.get(self.rf.get('/')) # Don't pass queryset as argument context = test_view.get_context_data() self.assertEqual(context['object_list'], test_view.queryset) def test_overwrite_queryset(self): test_view = views.CustomMultipleObjectMixinView() test_view.get(self.rf.get('/')) queryset = [{'name': 'Lennon'}, {'name': 'Ono'}] self.assertNotEqual(test_view.queryset, queryset) # Overwrite the view's queryset with queryset from kwarg context = test_view.get_context_data(object_list=queryset) self.assertEqual(context['object_list'], queryset) class SingleObjectTemplateResponseMixinTest(unittest.TestCase): def test_template_mixin_without_template(self): """ We want to makes sure that if you use a template mixin, but forget the template, it still tells you it's ImproperlyConfigured instead of TemplateDoesNotExist. """ view = views.TemplateResponseWithoutTemplate() self.assertRaises(ImproperlyConfigured, view.get_template_names)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 900, 199, 646, 2882, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 7512, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 396, 492, 18638, 12, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 4409, 63, 12264, 18, 199, 504, 1639, 14, 4196, 14, 6767, 492, 18532, 2768, 12, 5458, 2768, 12, 10935, 199, 199, 504, 1275, 492, 6858, 421, 199, 533, 5870, 2768, 8, 2768, 304, 272, 408, 272, 437, 3486, 2455, 543, 282, 9214, 14, 272, 408, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 6183, 360, 2765, 365, 282, 3486, 2455, 358, 421, 199, 533, 5870, 6564, 2768, 8, 3184, 2768, 304, 272, 2963, 275, 5870, 2768, 14, 362, 421, 199, 533, 7711, 5903, 2768, 8, 2768, 304, 272, 347, 2963, 8, 277, 12, 1056, 304, 267, 372, 6183, 360, 2765, 2455, 1454, 11479, 8761, 358, 421, 199, 533, 8388, 14065, 2768, 8, 3184, 2768, 304, 272, 2725, 275, 1052, 421, 199, 318, 7531, 8, 1345, 304, 272, 2455, 14, 374, 63, 29299, 275, 715, 272, 372, 2455, 421, 199, 533, 13966, 269, 972, 20628, 2768, 8, 3184, 2768, 304, 339, 768, 11547, 272, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 1613, 8, 8584, 269, 972, 20628, 2768, 12, 291, 680, 6052, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 533, 25225, 4231, 2768, 8, 4231, 2768, 304, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 14079, 339, 347, 664, 63, 1160, 63, 1247, 8, 277, 304, 267, 372, 788, 6767, 63, 4196, 15, 10254, 14, 1360, 418, 421, 199, 533, 25225, 4231, 1646, 2768, 8, 4231, 2768, 304, 272, 1978, 63, 354, 275, 283, 6767, 63, 4196, 15, 10254, 14, 1360, 7, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 1100, 21146, 421, 199, 533, 10066, 2768, 8, 2768, 304, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 291, 421, 199, 533, 10935, 774, 8, 2796, 14, 1746, 304, 272, 17781, 275, 18638, 342, 339, 347, 485, 479, 63, 4129, 8, 277, 12, 1177, 304, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 2765, 365, 282, 3486, 2455, 358, 339, 347, 511, 63, 889, 63, 826, 63, 958, 8, 277, 304, 267, 408, 267, 1379, 626, 282, 2455, 883, 1133, 506, 24634, 1183, 17544, 2544, 14295, 267, 408, 267, 862, 26, 288, 5870, 2768, 8, 498, 534, 585, 1959, 305, 63, 1345, 342, 288, 291, 14, 1633, 360, 11408, 440, 506, 7688, 370, 17321, 282, 2455, 358, 267, 871, 4281, 26, 288, 986, 339, 347, 511, 63, 889, 63, 826, 63, 589, 8, 277, 304, 267, 408, 267, 1379, 626, 282, 2455, 883, 1133, 506, 24634, 1183, 17544, 2544, 14295, 267, 408, 267, 862, 26, 288, 5870, 2768, 14, 305, 63, 1345, 360, 585, 358, 288, 291, 14, 1633, 360, 11408, 440, 506, 7688, 370, 675, 2222, 13, 6691, 2368, 9034, 1958, 282, 2455, 358, 267, 871, 3146, 26, 288, 986, 339, 347, 511, 63, 515, 79, 7954, 63, 1014, 63, 765, 8, 277, 304, 267, 408, 267, 710, 6275, 1930, 402, 282, 1455, 1056, 626, 25664, 14105, 376, 3411, 1083, 536, 365, 15604, 14, 267, 408, 267, 291, 14, 629, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 288, 291, 14, 3941, 14, 362, 10998, 31325, 63, 9977, 534, 32550, 358, 267, 7092, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 362, 63, 2118, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 1454, 6127, 9576, 3181, 1133, 2040, 1163, 3102, 14, 267, 408, 267, 291, 423, 479, 63, 4129, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 362, 2336, 7058, 267, 291, 14, 629, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 1932, 7825, 680, 1205, 63, 600, 12, 25766, 9, 267, 291, 14, 629, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 288, 291, 14, 3941, 14, 362, 10998, 31325, 63, 9977, 534, 14623, 358, 267, 7092, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 362, 63, 460, 63, 2993, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 4973, 6528, 282, 9576, 1083, 2597, 9163, 795, 6657, 370, 13053, 14, 267, 408, 267, 291, 423, 479, 63, 4129, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 362, 2336, 7058, 267, 1177, 275, 5870, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 2993, 28684, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 339, 347, 511, 63, 2993, 63, 889, 63, 362, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 4973, 6528, 949, 9576, 1083, 9163, 795, 370, 13053, 543, 3101, 25766, 14, 267, 408, 267, 1177, 275, 7711, 5903, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 2993, 28684, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 362, 63, 460, 63, 1932, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 1454, 6127, 3865, 9576, 436, 8761, 14, 267, 408, 267, 291, 423, 479, 63, 4129, 8, 3184, 6564, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 362, 2336, 7058, 267, 291, 423, 479, 63, 4129, 8, 3184, 6564, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 1932, 2336, 7058, 267, 291, 14, 629, 8, 3184, 6564, 2768, 14, 305, 63, 1345, 24851, 288, 291, 14, 3941, 14, 362, 10998, 31325, 63, 9977, 534, 14623, 358, 267, 7092, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 3197, 63, 6691, 63, 2094, 8, 277, 304, 267, 408, 267, 1379, 626, 2455, 2368, 1471, 506, 27684, 641, 314, 1021, 436, 883, 1133, 267, 506, 4310, 2839, 282, 3101, 1083, 14, 267, 408, 267, 327, 2670, 1924 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 900, 199, 646, 2882, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 7512, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 396, 492, 18638, 12, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 4409, 63, 12264, 18, 199, 504, 1639, 14, 4196, 14, 6767, 492, 18532, 2768, 12, 5458, 2768, 12, 10935, 199, 199, 504, 1275, 492, 6858, 421, 199, 533, 5870, 2768, 8, 2768, 304, 272, 408, 272, 437, 3486, 2455, 543, 282, 9214, 14, 272, 408, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 6183, 360, 2765, 365, 282, 3486, 2455, 358, 421, 199, 533, 5870, 6564, 2768, 8, 3184, 2768, 304, 272, 2963, 275, 5870, 2768, 14, 362, 421, 199, 533, 7711, 5903, 2768, 8, 2768, 304, 272, 347, 2963, 8, 277, 12, 1056, 304, 267, 372, 6183, 360, 2765, 2455, 1454, 11479, 8761, 358, 421, 199, 533, 8388, 14065, 2768, 8, 3184, 2768, 304, 272, 2725, 275, 1052, 421, 199, 318, 7531, 8, 1345, 304, 272, 2455, 14, 374, 63, 29299, 275, 715, 272, 372, 2455, 421, 199, 533, 13966, 269, 972, 20628, 2768, 8, 3184, 2768, 304, 339, 768, 11547, 272, 347, 7634, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 1613, 8, 8584, 269, 972, 20628, 2768, 12, 291, 680, 6052, 8, 1069, 12, 627, 589, 12, 1011, 958, 9, 421, 199, 533, 25225, 4231, 2768, 8, 4231, 2768, 304, 272, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 14079, 339, 347, 664, 63, 1160, 63, 1247, 8, 277, 304, 267, 372, 788, 6767, 63, 4196, 15, 10254, 14, 1360, 418, 421, 199, 533, 25225, 4231, 1646, 2768, 8, 4231, 2768, 304, 272, 1978, 63, 354, 275, 283, 6767, 63, 4196, 15, 10254, 14, 1360, 7, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 291, 14, 3352, 63, 475, 63, 1310, 8, 1100, 21146, 421, 199, 533, 10066, 2768, 8, 2768, 304, 339, 347, 664, 8, 277, 12, 1056, 304, 267, 372, 291, 421, 199, 533, 10935, 774, 8, 2796, 14, 1746, 304, 272, 17781, 275, 18638, 342, 339, 347, 485, 479, 63, 4129, 8, 277, 12, 1177, 304, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 12, 330, 7, 2765, 365, 282, 3486, 2455, 358, 339, 347, 511, 63, 889, 63, 826, 63, 958, 8, 277, 304, 267, 408, 267, 1379, 626, 282, 2455, 883, 1133, 506, 24634, 1183, 17544, 2544, 14295, 267, 408, 267, 862, 26, 288, 5870, 2768, 8, 498, 534, 585, 1959, 305, 63, 1345, 342, 288, 291, 14, 1633, 360, 11408, 440, 506, 7688, 370, 17321, 282, 2455, 358, 267, 871, 4281, 26, 288, 986, 339, 347, 511, 63, 889, 63, 826, 63, 589, 8, 277, 304, 267, 408, 267, 1379, 626, 282, 2455, 883, 1133, 506, 24634, 1183, 17544, 2544, 14295, 267, 408, 267, 862, 26, 288, 5870, 2768, 14, 305, 63, 1345, 360, 585, 358, 288, 291, 14, 1633, 360, 11408, 440, 506, 7688, 370, 675, 2222, 13, 6691, 2368, 9034, 1958, 282, 2455, 358, 267, 871, 3146, 26, 288, 986, 339, 347, 511, 63, 515, 79, 7954, 63, 1014, 63, 765, 8, 277, 304, 267, 408, 267, 710, 6275, 1930, 402, 282, 1455, 1056, 626, 25664, 14105, 376, 3411, 1083, 536, 365, 15604, 14, 267, 408, 267, 291, 14, 629, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 288, 291, 14, 3941, 14, 362, 10998, 31325, 63, 9977, 534, 32550, 358, 267, 7092, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 362, 63, 2118, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 1454, 6127, 9576, 3181, 1133, 2040, 1163, 3102, 14, 267, 408, 267, 291, 423, 479, 63, 4129, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 362, 2336, 7058, 267, 291, 14, 629, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 1932, 7825, 680, 1205, 63, 600, 12, 25766, 9, 267, 291, 14, 629, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 288, 291, 14, 3941, 14, 362, 10998, 31325, 63, 9977, 534, 14623, 358, 267, 7092, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 362, 63, 460, 63, 2993, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 4973, 6528, 282, 9576, 1083, 2597, 9163, 795, 6657, 370, 13053, 14, 267, 408, 267, 291, 423, 479, 63, 4129, 8, 3184, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 362, 2336, 7058, 267, 1177, 275, 5870, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 2993, 28684, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 339, 347, 511, 63, 2993, 63, 889, 63, 362, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 4973, 6528, 949, 9576, 1083, 9163, 795, 370, 13053, 543, 3101, 25766, 14, 267, 408, 267, 1177, 275, 7711, 5903, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 2993, 28684, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 362, 63, 460, 63, 1932, 8, 277, 304, 267, 408, 267, 1379, 282, 2455, 1314, 1454, 6127, 3865, 9576, 436, 8761, 14, 267, 408, 267, 291, 423, 479, 63, 4129, 8, 3184, 6564, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 362, 2336, 7058, 267, 291, 423, 479, 63, 4129, 8, 3184, 6564, 2768, 14, 305, 63, 1345, 24851, 277, 14, 3941, 14, 1932, 2336, 7058, 267, 291, 14, 629, 8, 3184, 6564, 2768, 14, 305, 63, 1345, 24851, 288, 291, 14, 3941, 14, 362, 10998, 31325, 63, 9977, 534, 14623, 358, 267, 7092, 1205, 63, 600, 12, 25766, 9, 339, 347, 511, 63, 3197, 63, 6691, 63, 2094, 8, 277, 304, 267, 408, 267, 1379, 626, 2455, 2368, 1471, 506, 27684, 641, 314, 1021, 436, 883, 1133, 267, 506, 4310, 2839, 282, 3101, 1083, 14, 267, 408, 267, 327, 2670, 1924, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
malisal/bfdpie
tests/bfdpie_test.py
1
14822
import unittest from bfdpie import * class Test(unittest.TestCase): def test_large_vma(self): b = Binary() # 32-bit limit test dis1 = b.disassemble(b"\x90", ARCH_I686, 0x80000000) dis2 = b.disassemble(b"\x90", ARCH_X86_64, 0x80000000) self.assertTrue(dis1[0].vma >= 0) self.assertTrue(dis2[0].vma >= 0) # 64-bit limit test dis3 = b.disassemble(b"\x90", ARCH_I686, 0x8000000000000000) dis4 = b.disassemble(b"\x90", ARCH_X86_64, 0x8000000000000000) self.assertTrue(dis3[0].vma >= 0) self.assertTrue(dis4[0].vma >= 0) def test_arch_i686(self): # 8048579: 89 e5 mov %esp,%ebp # 804857b: 53 push %ebx # 804857c: bb 4c 96 04 08 mov $0x804964c,%ebx # 8048581: 52 push %edx b = Binary() dis = b.disassemble( b"\x89\xe5" + b"\x53" + b"\xbb\x4c\x96\x04\x08" + b"\x52" ,arch=ARCH_I686 ) self.assertTrue(str(dis[0]) == "mov ebp,esp") self.assertTrue(str(dis[1]) == "push ebx") self.assertTrue(str(dis[2]) == "mov ebx,0x804964c") self.assertTrue(str(dis[3]) == "push edx") def test_arch_x86_64(self): # 4006aa: ba 00 04 00 00 mov $0x400,%edx # 4006af: 48 89 c6 mov %rax,%rsi # 4006b2: bf 00 00 00 00 mov $0x0,%edi # 4006b7: b8 00 00 00 00 mov $0x0,%eax b = Binary() dis = b.disassemble( b"\xba\x00\x04\x00\x00" + b"\x48\x89\xc6" + b"\xbf\x00\x00\x00\x00" + b"\xb8\x00\x00\x00\x00", ARCH_X86_64 ) self.assertTrue(str(dis[0]) == "mov edx,0x400") self.assertTrue(str(dis[1]) == "mov rsi,rax") self.assertTrue(str(dis[2]) == "mov edi,0x0") self.assertTrue(str(dis[3]) == "mov eax,0x0") def test_arch_armel(self): # 84c0: e92d4800 push {fp, lr} # 84c4: e28db004 add fp, sp, #4 # 84c8: e24dd020 sub sp, sp, #32 # 84cc: e24b3024 sub r3, fp, #36 ; 0x24 b = Binary() dis = b.disassemble( b"\x00\x48\x2d\xe9" + b"\x04\xb0\x8d\xe2" + b"\x20\xd0\x4d\xe2" + b"\x24\x30\x4b\xe2", ARCH_ARMEL ) self.assertTrue(str(dis[0]) == "push {fp, lr}") self.assertTrue(str(dis[1]) == "add fp, sp, #4") self.assertTrue(str(dis[2]) == "sub sp, sp, #32") self.assertTrue(str(dis[3]) == "sub r3, fp, #36 ; 0x24") def test_arch_armel_thumb(self): # 84ce: db00 lsls r3, r3, #3 # 84d0: 0020 movs r0, #0 # 84d2: 111c adds r1, r2, #0 # 84d4: 1a1c adds r2, r3, #0 b = Binary() dis = b.disassemble( b"\xdb\x00" + b"\x00\x20" + b"\x11\x1c" + b"\x1a\x1c", ARCH_ARMEL_THUMB ) self.assertTrue(str(dis[0]) == "lsls r3, r3, #3") self.assertTrue(str(dis[1]) == "movs r0, #0") self.assertTrue(str(dis[2]) == "adds r1, r2, #0") self.assertTrue(str(dis[3]) == "adds r2, r3, #0") def test_arch_armeb(self): # 84c0: e92d4800 push {fp, lr} # 84c4: e28db004 add fp, sp, #4 # 84c8: e24dd020 sub sp, sp, #32 # 84cc: e24b3024 sub r3, fp, #36 ; 0x24 b = Binary() dis = b.disassemble( b"\xe9\x2d\x48\x00" + b"\xe2\x8d\xb0\x04" + b"\xe2\x4d\xd0\x20" + b"\xe2\x4b\x30\x24", ARCH_ARMEB ) self.assertTrue(str(dis[0]) == "push {fp, lr}") self.assertTrue(str(dis[1]) == "add fp, sp, #4") self.assertTrue(str(dis[2]) == "sub sp, sp, #32") self.assertTrue(str(dis[3]) == "sub r3, fp, #36 ; 0x24") def test_arch_armeb_thumb(self): # 84ce: 00db lsls r3, r3, #3 # 84d0: 2000 movs r0, #0 # 84d2: 1c11 adds r1, r2, #0 # 84d4: 1c1a adds r2, r3, #0 b = Binary() dis = b.disassemble( b"\x00\xdb" + b"\x20\x00" + b"\x1c\x11" + b"\x1c\x1a", ARCH_ARMEB_THUMB ) self.assertTrue(str(dis[0]) == "lsls r3, r3, #3") self.assertTrue(str(dis[1]) == "movs r0, #0") self.assertTrue(str(dis[2]) == "adds r1, r2, #0") self.assertTrue(str(dis[3]) == "adds r2, r3, #0") def test_arch_mips(self): # 4009d8: 8fbf001c lw ra,28(sp) # 4009dc: 00000000 nop # 4009e0: 03e00008 jr ra # 4009e4: 27bd0020 addiu sp,sp,32 b = Binary() dis = b.disassemble( b"\x8f\xbf\x00\x1c" + b"\x00\x00\x00\x00" + b"\x03\xe0\x00\x08" + b"\x27\xbd\x00\x20", ARCH_MIPS ) self.assertTrue(str(dis[0]) == "lw ra,28(sp)") self.assertTrue(str(dis[1]) == "nop") self.assertTrue(str(dis[2]) == "jr ra") self.assertTrue(str(dis[3]) == "addiu sp,sp,32") def test_arch_mipsel(self): # 4009d8: 1c00bf8f lw ra,28(sp) # 4009dc: 00000000 nop # 4009e0: 0800e003 jr ra # 4009e4: 2000bd27 addiu sp,sp,32 b = Binary() dis = b.disassemble( b"\x1c\x00\xbf\x8f" + b"\x00\x00\x00\x00" + b"\x08\x00\xe0\x03" + b"\x20\x00\xbd\x27", ARCH_MIPSEL ) self.assertTrue(str(dis[0]) == "lw ra,28(sp)") self.assertTrue(str(dis[1]) == "nop") self.assertTrue(str(dis[2]) == "jr ra") self.assertTrue(str(dis[3]) == "addiu sp,sp,32") def test_arch_mips64(self): # 120000918: 3c1c0002 lui gp,0x2 # 12000091c: 279c843c addiu gp,gp,-31684 # 120000920: 039fe02d daddu gp,gp,ra # 120000924: df998068 ld t9,-32664(gp) b = Binary() dis = b.disassemble( b"\x3c\x1c\x00\x02" + b"\x27\x9c\x84\x3c" + b"\x03\x9f\xe0\x2d" + b"\xdf\x99\x80\x68", ARCH_MIPS64 ) self.assertTrue(str(dis[0]) == "lui gp,0x2") self.assertTrue(str(dis[1]) == "addiu gp,gp,-31684") self.assertTrue(str(dis[2]) == "daddu gp,gp,ra") self.assertTrue(str(dis[3]) == "ld t9,-32664(gp)") def test_arch_mips64el(self): # 120000918: 02001c3c lui gp,0x2 # 12000091c: 3c849c27 addiu gp,gp,-31684 # 120000920: 2de09f03 daddu gp,gp,ra # 120000924: 688099df ld t9,-32664(gp) b = Binary() dis = b.disassemble( b"\x02\x00\x1c\x3c" + b"\x3c\x84\x9c\x27" + b"\x2d\xe0\x9f\x03" + b"\x68\x80\x99\xdf", ARCH_MIPS64EL ) self.assertTrue(str(dis[0]) == "lui gp,0x2") self.assertTrue(str(dis[1]) == "addiu gp,gp,-31684") self.assertTrue(str(dis[2]) == "daddu gp,gp,ra") self.assertTrue(str(dis[3]) == "ld t9,-32664(gp)") def test_arch_ppc32(self): # 1000058c: 80 01 00 14 lwz r0,20(r1) # 10000590: 38 21 00 10 addi r1,r1,16 # 10000594: 7c 08 03 a6 mtlr r0 # 10000598: 4e 80 00 20 blr b = Binary() dis = b.disassemble( b"\x80\x01\x00\x14" + b"\x38\x21\x00\x10" + b"\x7c\x08\x03\xa6" + b"\x4e\x80\x00\x20", ARCH_PPC32 ) self.assertTrue(str(dis[0]) == "lwz r0,20(r1)") self.assertTrue(str(dis[1]) == "addi r1,r1,16") self.assertTrue(str(dis[2]) == "mtlr r0") self.assertTrue(str(dis[3]) == "blr") def test_arch_ppc64(self): # 100007d4: 38 21 00 70 addi r1,r1,112 # 100007d8: e8 01 00 10 ld r0,16(r1) # 100007dc: 7c 08 03 a6 mtlr r0 # 100007e0: 4e 80 00 20 blr b = Binary() dis = b.disassemble( b"\x38\x21\x00\x70" + b"\xe8\x01\x00\x10" + b"\x7c\x08\x03\xa6" + b"\x4e\x80\x00\x20", ARCH_PPC64 ) self.assertTrue(str(dis[0]) == "addi r1,r1,112") self.assertTrue(str(dis[1]) == "ld r0,16(r1)") self.assertTrue(str(dis[2]) == "mtlr r0") self.assertTrue(str(dis[3]) == "blr") def test_arch_sparc(self): # 105e4: 9d e3 bf 98 save %sp, -104, %sp # 105ec: 01 00 00 00 nop # 105f0: 81 c7 e0 08 ret # 105f4: 81 e8 00 00 restore b = Binary() dis = b.disassemble( b"\x9d\xe3\xbf\x98" + b"\x01\x00\x00\x00" + b"\x81\xc7\xe0\x08" + b"\x81\xe8\x00\x00", ARCH_SPARC ) self.assertTrue(str(dis[0]) == "save %sp, -104, %sp") self.assertTrue(str(dis[1]) == "nop") self.assertTrue(str(dis[2]) == "ret") self.assertTrue(str(dis[3]) == "restore") def test_arch_sparc64(self): # 1007a0: 9f c0 40 00 call %g1 # 1007a4: ba 07 7f f8 add %i5, -8, %i5 # 1007a8: c2 5f 40 00 ldx [ %i5 ], %g1 # 1007ac: 80 a0 7f ff cmp %g1, -1 b = Binary() dis = b.disassemble( b"\x9f\xc0\x40\x00" + b"\xba\x07\x7f\xf8" + b"\xc2\x5f\x40\x00" + b"\x80\xa0\x7f\xff", ARCH_SPARC64 ) self.assertTrue(str(dis[0]) == "call %g1") self.assertTrue(str(dis[1]) == "add %i5, -8, %i5") self.assertTrue(str(dis[2]) == "ldx [ %i5 ], %g1") self.assertTrue(str(dis[3]) == "cmp %g1, -1") def test_arch_sh4(self): # 400618: 26 4f lds.l @r15+,pr # 40061a: 0b 00 rts # 40061c: f6 68 mov.l @r15+,r8 # 40061e: 09 00 nop b = Binary() dis = b.disassemble( b"\x26\x4f" + b"\x0b\x00" + b"\xf6\x68" + b"\x09\x00", ARCH_SH4 ) self.assertTrue(str(dis[0]) == "lds.l @r15+,pr") self.assertTrue(str(dis[1]) == "rts") self.assertTrue(str(dis[2]) == "mov.l @r15+,r8") self.assertTrue(str(dis[3]) == "nop") def test_arch_sh4eb(self): # 400618: 4f 26 lds.l @r15+,pr # 40061a: 00 0b rts # 40061c: 68 f6 mov.l @r15+,r8 # 40061e: 00 09 nop b = Binary() dis = b.disassemble( b"\x4f\x26" + b"\x00\x0b" + b"\x68\xf6" + b"\x00\x09", ARCH_SH4EB ) self.assertTrue(str(dis[0]) == "lds.l @r15+,pr") self.assertTrue(str(dis[1]) == "rts") self.assertTrue(str(dis[2]) == "mov.l @r15+,r8") self.assertTrue(str(dis[3]) == "nop") def test_arch_aarch64(self): # 400624: a9bf7bfd stp x29, x30, [sp,#-16]! # 400628: 910003fd mov x29, sp # 40062c: a8c17bfd ldp x29, x30, [sp],#16 # 400630: d65f03c0 ret b = Binary() dis = b.disassemble( b"\xfd\x7b\xbf\xa9" + b"\xfd\x03\x00\x91" + b"\xfd\x7b\xc1\xa8" + b"\xc0\x03\x5f\xd6", ARCH_AARCH64 ) self.assertTrue(str(dis[0]) == "stp x29, x30, [sp,#-16]!") self.assertTrue(str(dis[1]) == "mov x29, sp") self.assertTrue(str(dis[2]) == "ldp x29, x30, [sp],#16") self.assertTrue(str(dis[3]) == "ret") def test_arch_alpha(self): # 1200007e8: 3e 15 c2 43 subq sp,0x10,sp # 1200007ec: 00 00 5e b7 stq ra,0(sp) # 1200007f0: 08 00 be b7 stq gp,8(sp) # 1200007f4: 00 00 fe 2f unop b = Binary() dis = b.disassemble( b"\x3e\x15\xc2\x43" + b"\x00\x00\x5e\xb7" + b"\x08\x00\xbe\xb7" + b"\x00\x00\xfe\x2f", ARCH_ALPHA ) self.assertTrue(str(dis[0]) == "subq sp,0x10,sp") self.assertTrue(str(dis[1]) == "stq ra,0(sp)") self.assertTrue(str(dis[2]) == "stq gp,8(sp)") self.assertTrue(str(dis[3]) == "unop") def test_arch_crisv32(self): # 80610: 6e0e move.d [$sp+],$r0 # 80612: 31b6 move $r1,$srp # 80614: 6e1e move.d [$sp+],$r1 # 80616: f0b9 ret b = Binary() dis = b.disassemble( b"\x6e\x0e" + b"\x31\xb6" + b"\x6e\x1e" + b"\xf0\xb9", ARCH_CRISV32 ) self.assertTrue(str(dis[0]) == "move.d [$sp+],$r0") self.assertTrue(str(dis[1]) == "move $r1,$srp") self.assertTrue(str(dis[2]) == "move.d [$sp+],$r1") self.assertTrue(str(dis[3]) == "ret") def test_arch_s390x(self): # 80000724: e3 40 f1 10 00 04 lg %r4,272(%r15) # 8000072a: eb cf f1 00 00 04 lmg %r12,%r15,256(%r15) # 80000730: 07 f4 br %r4 # 80000732: 07 07 nopr %r7 b = Binary() dis = b.disassemble( b"\xe3\x40\xf1\x10\x00\x04" + b"\xeb\xcf\xf1\x00\x00\x04" + b"\x07\xf4" + b"\x07\x07", ARCH_S390X ) self.assertTrue(str(dis[0]) == "lg %r4,272(%r15)") self.assertTrue(str(dis[1]) == "lmg %r12,%r15,256(%r15)") self.assertTrue(str(dis[2]) == "br %r4") self.assertTrue(str(dis[3]) == "nopr %r7") def test_arch_microblaze(self): # 10000628: 3021ffe0 addik r1, r1, -32 # 1000062c: fa81001c swi r20, r1, 28 # 10000630: f9e10000 swi r15, r1, 0 # 10000634: 96808000 mfs r20, rpc b = Binary() dis = b.disassemble( b"\x30\x21\xff\xe0" + b"\xfa\x81\x00\x1c" + b"\xf9\xe1\x00\x00" + b"\x96\x80\x80\x00", ARCH_MICROBLAZE ) self.assertTrue(str(dis[0]) == "addik r1, r1, -32") self.assertTrue(str(dis[1]) == "swi r20, r1, 28") self.assertTrue(str(dis[2]) == "swi r15, r1, 0") self.assertTrue(str(dis[3]) == "mfs r20, rpc") def test_arch_microblazeel(self): # 10000628: e03021ff addik r1, r1, -32 # 1000062c: 1cfa8100 swi r20, r1, 28 # 10000630: 00f9e100 swi r15, r1, 0 # 10000634: 00968080 mfs r20, rpc b = Binary() dis = b.disassemble( b"\xe0\xff\x21\x30" + b"\x1c\x00\x81\xfa" + b"\x00\x00\xe1\xf9" + b"\x00\x80\x80\x96", ARCH_MICROBLAZEEL ) self.assertTrue(str(dis[0]) == "addik r1, r1, -32") self.assertTrue(str(dis[1]) == "swi r20, r1, 28") self.assertTrue(str(dis[2]) == "swi r15, r1, 0") self.assertTrue(str(dis[3]) == "mfs r20, rpc") def test_loading(self): b = Binary() self.assertTrue(b.file_type == "elf") self.assertTrue(str(b.arch) == "Arch<name:X86_64, bits:64, little_endian:1>") if __name__ == "__main__": unittest.main()
mit
[ 646, 2882, 199, 504, 330, 2592, 9890, 492, 627, 199, 199, 533, 1379, 8, 2796, 14, 1746, 304, 2043, 347, 511, 63, 9629, 63, 86, 391, 8, 277, 304, 489, 330, 275, 14161, 342, 2541, 327, 4337, 13, 2075, 2304, 511, 489, 2153, 17, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 41, 10253, 12, 378, 88, 24, 9084, 9, 489, 2153, 18, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 56, 1184, 63, 772, 12, 378, 88, 24, 9084, 9, 2541, 291, 14, 1815, 8, 2297, 17, 59, 16, 1055, 86, 391, 2356, 378, 9, 489, 291, 14, 1815, 8, 2297, 18, 59, 16, 1055, 86, 391, 2356, 378, 9, 2541, 327, 5049, 13, 2075, 2304, 511, 489, 2153, 19, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 41, 10253, 12, 378, 88, 24, 3607, 9084, 9, 489, 2153, 20, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 56, 1184, 63, 772, 12, 378, 88, 24, 3607, 9084, 9, 2541, 291, 14, 1815, 8, 2297, 19, 59, 16, 1055, 86, 391, 2356, 378, 9, 489, 291, 14, 1815, 8, 2297, 20, 59, 16, 1055, 86, 391, 2356, 378, 9, 8410, 347, 511, 63, 1047, 63, 73, 10253, 8, 277, 304, 489, 327, 1695, 9941, 14003, 26, 257, 17838, 325, 21, 7861, 26524, 259, 450, 397, 80, 8719, 2871, 80, 489, 327, 1695, 9941, 1641, 66, 26, 257, 13564, 10473, 6675, 257, 450, 2871, 88, 489, 327, 1695, 9941, 1641, 67, 26, 257, 14027, 841, 67, 15580, 28527, 19363, 3515, 26524, 259, 2672, 16, 88, 24, 12809, 772, 67, 8719, 2871, 88, 489, 327, 1695, 9941, 18844, 26, 257, 14589, 10473, 6675, 257, 450, 8268, 2541, 330, 275, 14161, 342, 489, 2153, 275, 330, 14, 2297, 21263, 8, 268, 330, 3212, 88, 1407, 60, 1845, 21, 2, 435, 268, 330, 3212, 88, 2481, 2, 435, 268, 330, 3212, 9932, 60, 88, 20, 67, 60, 88, 2534, 60, 88, 966, 60, 88, 2036, 2, 435, 268, 330, 3212, 88, 2528, 2, 268, 2360, 1047, 29, 7762, 63, 41, 10253, 489, 776, 2541, 291, 14, 1815, 8, 495, 8, 2297, 59, 16, 566, 508, 298, 14469, 325, 10913, 12, 397, 80, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 17, 566, 508, 298, 5335, 325, 13691, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 18, 566, 508, 298, 14469, 325, 13691, 12, 16, 88, 24, 12809, 772, 67, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 19, 566, 508, 298, 5335, 22435, 531, 8410, 347, 511, 63, 1047, 63, 88, 1184, 63, 772, 8, 277, 304, 489, 327, 221, 841, 8010, 2158, 26, 257, 19325, 8733, 28527, 8733, 8733, 3515, 26524, 259, 2672, 16, 88, 5303, 8719, 8268, 489, 327, 221, 841, 8010, 2756, 26, 257, 9615, 17838, 286, 22, 4483, 26524, 259, 450, 14495, 8719, 82, 338, 489, 327, 221, 841, 8010, 66, 18, 26, 257, 18839, 8733, 8733, 8733, 8733, 3515, 26524, 259, 2672, 16, 88, 16, 8719, 6297, 489, 327, 221, 841, 8010, 66, 23, 26, 257, 330, 24, 8733, 8733, 8733, 8733, 3515, 26524, 259, 2672, 16, 88, 16, 8719, 32156, 2541, 330, 275, 14161, 342, 489, 2153, 275, 330, 14, 2297, 21263, 8, 268, 330, 3212, 10539, 60, 88, 383, 60, 88, 966, 60, 88, 383, 60, 88, 383, 2, 435, 268, 330, 3212, 88, 2006, 60, 88, 1407, 60, 1812, 22, 2, 435, 268, 330, 3212, 9566, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 2, 435, 268, 330, 3212, 1774, 24, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 401, 268, 4160, 1244, 63, 56, 1184, 63, 772, 489, 776, 2541, 291, 14, 1815, 8, 495, 8, 2297, 59, 16, 566, 508, 298, 14469, 22435, 12, 16, 88, 5303, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 17, 566, 508, 298, 14469, 519, 338, 12, 14495, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 18, 566, 508, 298, 14469, 7860, 12, 16, 88, 16, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 19, 566, 508, 298, 14469, 325, 1219, 12, 16, 88, 16, 531, 8410, 347, 511, 63, 1047, 63, 285, 26908, 8, 277, 304, 489, 327, 259, 8264, 67, 16, 26, 257, 325, 2942, 68, 2006, 383, 259, 6675, 221, 469, 3997, 12, 13645, 93, 489, 327, 259, 8264, 67, 20, 26, 257, 325, 1651, 697, 7979, 259, 1050, 257, 4090, 12, 2249, 12, 327, 20, 489, 327, 259, 8264, 67, 24, 26, 257, 325, 1194, 617, 10173, 259, 1007, 257, 2249, 12, 2249, 12, 327, 708, 489, 327, 259, 8264, 2055, 26, 257, 325, 1194, 66, 19, 5284, 259, 1007, 257, 519, 19, 12, 4090, 12, 327, 1344, 257, 8700, 378, 88, 1194, 2541, 330, 275, 14161, 342, 489, 2153, 275, 330, 14, 2297, 21263, 8, 268, 330, 3212, 88, 383, 60, 88, 2006, 60, 88, 18, 68, 60, 1845, 25, 2, 435, 268, 330, 3212, 88, 966, 60, 1774, 16, 60, 88, 24, 68, 60, 1845, 18, 2, 435, 268, 330, 3212, 88, 1165, 60, 2207, 16, 60, 88, 20, 68, 60, 1845, 18, 2, 435, 268, 330, 3212, 88, 1194, 60, 88, 1216, 60, 88, 20, 66, 60, 1845, 18, 401, 268, 4160, 1244, 63, 12482, 2901, 489, 776, 2541, 291, 14, 1815, 8, 495, 8, 2297, 59, 16, 566, 508, 298, 5335, 469, 3997, 12, 13645, 15412, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 17, 566, 508, 298, 525, 4090, 12, 2249, 12, 327, 20, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 18, 566, 508, 298, 954, 2249, 12, 2249, 12, 327, 708, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 19, 566, 508, 298, 954, 519, 19, 12, 4090, 12, 327, 1344, 8700, 378, 88, 1194, 531, 8410, 347, 511, 63, 1047, 63, 285, 26908, 63, 16534, 8, 277, 304, 489, 327, 259, 8264, 301, 26, 257, 1592, 383, 260, 9100, 478, 257, 519, 19, 12, 519, 19, 12, 327, 19, 489 ]
[ 2882, 199, 504, 330, 2592, 9890, 492, 627, 199, 199, 533, 1379, 8, 2796, 14, 1746, 304, 2043, 347, 511, 63, 9629, 63, 86, 391, 8, 277, 304, 489, 330, 275, 14161, 342, 2541, 327, 4337, 13, 2075, 2304, 511, 489, 2153, 17, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 41, 10253, 12, 378, 88, 24, 9084, 9, 489, 2153, 18, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 56, 1184, 63, 772, 12, 378, 88, 24, 9084, 9, 2541, 291, 14, 1815, 8, 2297, 17, 59, 16, 1055, 86, 391, 2356, 378, 9, 489, 291, 14, 1815, 8, 2297, 18, 59, 16, 1055, 86, 391, 2356, 378, 9, 2541, 327, 5049, 13, 2075, 2304, 511, 489, 2153, 19, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 41, 10253, 12, 378, 88, 24, 3607, 9084, 9, 489, 2153, 20, 275, 330, 14, 2297, 21263, 8, 66, 3212, 88, 2710, 401, 4160, 1244, 63, 56, 1184, 63, 772, 12, 378, 88, 24, 3607, 9084, 9, 2541, 291, 14, 1815, 8, 2297, 19, 59, 16, 1055, 86, 391, 2356, 378, 9, 489, 291, 14, 1815, 8, 2297, 20, 59, 16, 1055, 86, 391, 2356, 378, 9, 8410, 347, 511, 63, 1047, 63, 73, 10253, 8, 277, 304, 489, 327, 1695, 9941, 14003, 26, 257, 17838, 325, 21, 7861, 26524, 259, 450, 397, 80, 8719, 2871, 80, 489, 327, 1695, 9941, 1641, 66, 26, 257, 13564, 10473, 6675, 257, 450, 2871, 88, 489, 327, 1695, 9941, 1641, 67, 26, 257, 14027, 841, 67, 15580, 28527, 19363, 3515, 26524, 259, 2672, 16, 88, 24, 12809, 772, 67, 8719, 2871, 88, 489, 327, 1695, 9941, 18844, 26, 257, 14589, 10473, 6675, 257, 450, 8268, 2541, 330, 275, 14161, 342, 489, 2153, 275, 330, 14, 2297, 21263, 8, 268, 330, 3212, 88, 1407, 60, 1845, 21, 2, 435, 268, 330, 3212, 88, 2481, 2, 435, 268, 330, 3212, 9932, 60, 88, 20, 67, 60, 88, 2534, 60, 88, 966, 60, 88, 2036, 2, 435, 268, 330, 3212, 88, 2528, 2, 268, 2360, 1047, 29, 7762, 63, 41, 10253, 489, 776, 2541, 291, 14, 1815, 8, 495, 8, 2297, 59, 16, 566, 508, 298, 14469, 325, 10913, 12, 397, 80, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 17, 566, 508, 298, 5335, 325, 13691, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 18, 566, 508, 298, 14469, 325, 13691, 12, 16, 88, 24, 12809, 772, 67, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 19, 566, 508, 298, 5335, 22435, 531, 8410, 347, 511, 63, 1047, 63, 88, 1184, 63, 772, 8, 277, 304, 489, 327, 221, 841, 8010, 2158, 26, 257, 19325, 8733, 28527, 8733, 8733, 3515, 26524, 259, 2672, 16, 88, 5303, 8719, 8268, 489, 327, 221, 841, 8010, 2756, 26, 257, 9615, 17838, 286, 22, 4483, 26524, 259, 450, 14495, 8719, 82, 338, 489, 327, 221, 841, 8010, 66, 18, 26, 257, 18839, 8733, 8733, 8733, 8733, 3515, 26524, 259, 2672, 16, 88, 16, 8719, 6297, 489, 327, 221, 841, 8010, 66, 23, 26, 257, 330, 24, 8733, 8733, 8733, 8733, 3515, 26524, 259, 2672, 16, 88, 16, 8719, 32156, 2541, 330, 275, 14161, 342, 489, 2153, 275, 330, 14, 2297, 21263, 8, 268, 330, 3212, 10539, 60, 88, 383, 60, 88, 966, 60, 88, 383, 60, 88, 383, 2, 435, 268, 330, 3212, 88, 2006, 60, 88, 1407, 60, 1812, 22, 2, 435, 268, 330, 3212, 9566, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 2, 435, 268, 330, 3212, 1774, 24, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 383, 401, 268, 4160, 1244, 63, 56, 1184, 63, 772, 489, 776, 2541, 291, 14, 1815, 8, 495, 8, 2297, 59, 16, 566, 508, 298, 14469, 22435, 12, 16, 88, 5303, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 17, 566, 508, 298, 14469, 519, 338, 12, 14495, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 18, 566, 508, 298, 14469, 7860, 12, 16, 88, 16, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 19, 566, 508, 298, 14469, 325, 1219, 12, 16, 88, 16, 531, 8410, 347, 511, 63, 1047, 63, 285, 26908, 8, 277, 304, 489, 327, 259, 8264, 67, 16, 26, 257, 325, 2942, 68, 2006, 383, 259, 6675, 221, 469, 3997, 12, 13645, 93, 489, 327, 259, 8264, 67, 20, 26, 257, 325, 1651, 697, 7979, 259, 1050, 257, 4090, 12, 2249, 12, 327, 20, 489, 327, 259, 8264, 67, 24, 26, 257, 325, 1194, 617, 10173, 259, 1007, 257, 2249, 12, 2249, 12, 327, 708, 489, 327, 259, 8264, 2055, 26, 257, 325, 1194, 66, 19, 5284, 259, 1007, 257, 519, 19, 12, 4090, 12, 327, 1344, 257, 8700, 378, 88, 1194, 2541, 330, 275, 14161, 342, 489, 2153, 275, 330, 14, 2297, 21263, 8, 268, 330, 3212, 88, 383, 60, 88, 2006, 60, 88, 18, 68, 60, 1845, 25, 2, 435, 268, 330, 3212, 88, 966, 60, 1774, 16, 60, 88, 24, 68, 60, 1845, 18, 2, 435, 268, 330, 3212, 88, 1165, 60, 2207, 16, 60, 88, 20, 68, 60, 1845, 18, 2, 435, 268, 330, 3212, 88, 1194, 60, 88, 1216, 60, 88, 20, 66, 60, 1845, 18, 401, 268, 4160, 1244, 63, 12482, 2901, 489, 776, 2541, 291, 14, 1815, 8, 495, 8, 2297, 59, 16, 566, 508, 298, 5335, 469, 3997, 12, 13645, 15412, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 17, 566, 508, 298, 525, 4090, 12, 2249, 12, 327, 20, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 18, 566, 508, 298, 954, 2249, 12, 2249, 12, 327, 708, 531, 489, 291, 14, 1815, 8, 495, 8, 2297, 59, 19, 566, 508, 298, 954, 519, 19, 12, 4090, 12, 327, 1344, 8700, 378, 88, 1194, 531, 8410, 347, 511, 63, 1047, 63, 285, 26908, 63, 16534, 8, 277, 304, 489, 327, 259, 8264, 301, 26, 257, 1592, 383, 260, 9100, 478, 257, 519, 19, 12, 519, 19, 12, 327, 19, 489, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dingdong-io/brackets.beautify.io
thirdparty/js-beautify/python/cssbeautifier/tests/test.py
1
20342
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest import cssbeautifier class CSSBeautifierTest(unittest.TestCase): def resetOptions(self): false = False true = True self.options = cssbeautifier.default_options() self.options.indent_size = 1 self.options.indent_char = '\t' self.options.selector_separator_newline = true self.options.end_with_newline = false self.options.newline_between_rules = false def testGenerated(self): self.resetOptions() test_fragment = self.decodesto t = self.decodesto false = False true = True self.options.indent_size = 1 self.options.indent_char = '\t' self.options.selector_separator_newline = true self.options.end_with_newline = false self.options.newline_between_rules = false # End With Newline - (eof = "\n") self.options.end_with_newline = true test_fragment('', '\n') test_fragment(' .tabs{}', ' .tabs {}\n') test_fragment(' \n\n.tabs{}\n\n\n\n', ' .tabs {}\n') test_fragment('\n') # End With Newline - (eof = "") self.options.end_with_newline = false test_fragment('') test_fragment(' .tabs{}', ' .tabs {}') test_fragment(' \n\n.tabs{}\n\n\n\n', ' .tabs {}') test_fragment('\n', '') # Empty braces t('.tabs{}', '.tabs {}') t('.tabs { }', '.tabs {}') t('.tabs { }', '.tabs {}') t('.tabs \n{\n \n }', '.tabs {}') # t('#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity = 90);\n}', '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity=90);\n}') # Selector Separator - (separator = " ", separator1 = " ") self.options.selector_separator_newline = false self.options.selector_separator = " " t('#bla, #foo{color:green}', '#bla, #foo {\n\tcolor: green\n}') t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') t('@media print {.tab,.bat{}}', '@media print {\n\t.tab, .bat {}\n}') t('#bla, #foo{color:black}', '#bla, #foo {\n\tcolor: black\n}') t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child, a:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}') # Selector Separator - (separator = " ", separator1 = " ") self.options.selector_separator_newline = false self.options.selector_separator = " " t('#bla, #foo{color:green}', '#bla, #foo {\n\tcolor: green\n}') t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') t('@media print {.tab,.bat{}}', '@media print {\n\t.tab, .bat {}\n}') t('#bla, #foo{color:black}', '#bla, #foo {\n\tcolor: black\n}') t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child, a:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}') # Selector Separator - (separator = "\n", separator1 = "\n\t") self.options.selector_separator_newline = true self.options.selector_separator = " " t('#bla, #foo{color:green}', '#bla,\n#foo {\n\tcolor: green\n}') t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') t('@media print {.tab,.bat{}}', '@media print {\n\t.tab,\n\t.bat {}\n}') t('#bla, #foo{color:black}', '#bla,\n#foo {\n\tcolor: black\n}') t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child,\n\tdiv:hover {\n\t\tcolor: black;\n\t}\n}') # Selector Separator - (separator = "\n", separator1 = "\n\t") self.options.selector_separator_newline = true self.options.selector_separator = " " t('#bla, #foo{color:green}', '#bla,\n#foo {\n\tcolor: green\n}') t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') t('@media print {.tab,.bat{}}', '@media print {\n\t.tab,\n\t.bat {}\n}') t('#bla, #foo{color:black}', '#bla,\n#foo {\n\tcolor: black\n}') t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child,\n\tdiv:hover {\n\t\tcolor: black;\n\t}\n}') # Newline Between Rules - (separator = "\n") self.options.newline_between_rules = true t('.div {}\n.span {}', '.div {}\n\n.span {}') t('.div{}\n \n.span{}', '.div {}\n\n.span {}') t('.div {} \n \n.span { } \n', '.div {}\n\n.span {}') t('.div {\n \n} \n .span {\n } ', '.div {}\n\n.span {}') t('.selector1 {\n\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n}\n.div{height:15px;}', '.selector1 {\n\tmargin: 0;\n\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n}\n\n.div {\n\theight: 15px;\n}') t('.tabs{width:10px;//end of line comment\nheight:10px;//another\n}\n.div{height:15px;}', '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px; //another\n}\n\n.div {\n\theight: 15px;\n}') t('#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div{height:15px;}', '#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n\n.div {\n\theight: 15px;\n}') t('@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div{height:15px;}', '@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n\n.div {\n\theight: 15px;\n}') t('@font-face {\n\tfont-family: "Bitstream Vera Serif Bold";\n\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n}\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: "Helvetica Neue"\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}', '@font-face {\n\tfont-family: "Bitstream Vera Serif Bold";\n\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n}\n\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: "Helvetica Neue"\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}') t('a:first-child{color:red;div:first-child{color:black;}}\n.div{height:15px;}', 'a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}\n\n.div {\n\theight: 15px;\n}') t('a:first-child{color:red;div:not(.peq){color:black;}}\n.div{height:15px;}', 'a:first-child {\n\tcolor: red;\n\tdiv:not(.peq) {\n\t\tcolor: black;\n\t}\n}\n\n.div {\n\theight: 15px;\n}') # Newline Between Rules - (separator = "") self.options.newline_between_rules = false t('.div {}\n.span {}') t('.div{}\n \n.span{}', '.div {}\n.span {}') t('.div {} \n \n.span { } \n', '.div {}\n.span {}') t('.div {\n \n} \n .span {\n } ', '.div {}\n.span {}') t('.selector1 {\n\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n}\n.div{height:15px;}', '.selector1 {\n\tmargin: 0;\n\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n}\n.div {\n\theight: 15px;\n}') t('.tabs{width:10px;//end of line comment\nheight:10px;//another\n}\n.div{height:15px;}', '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px; //another\n}\n.div {\n\theight: 15px;\n}') t('#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div{height:15px;}', '#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div {\n\theight: 15px;\n}') t('@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div{height:15px;}', '@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: "Bitstream Vera Serif Bold";\n\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n\t}\n}\n.div {\n\theight: 15px;\n}') t('@font-face {\n\tfont-family: "Bitstream Vera Serif Bold";\n\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n}\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: "Helvetica Neue"\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}') t('a:first-child{color:red;div:first-child{color:black;}}\n.div{height:15px;}', 'a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}\n.div {\n\theight: 15px;\n}') t('a:first-child{color:red;div:not(.peq){color:black;}}\n.div{height:15px;}', 'a:first-child {\n\tcolor: red;\n\tdiv:not(.peq) {\n\t\tcolor: black;\n\t}\n}\n.div {\n\theight: 15px;\n}') # Functions braces t('.tabs(){}', '.tabs() {}') t('.tabs (){}', '.tabs () {}') t('.tabs (pa, pa(1,2)), .cols { }', '.tabs (pa, pa(1, 2)),\n.cols {}') t('.tabs(pa, pa(1,2)), .cols { }', '.tabs(pa, pa(1, 2)),\n.cols {}') t('.tabs ( ) { }', '.tabs () {}') t('.tabs( ) { }', '.tabs() {}') t('.tabs (t, t2) \n{\n key: val(p1 ,p2); \n }', '.tabs (t, t2) {\n\tkey: val(p1, p2);\n}') t('.box-shadow(@shadow: 0 1px 3px rgba(0, 0, 0, .25)) {\n\t-webkit-box-shadow: @shadow;\n\t-moz-box-shadow: @shadow;\n\tbox-shadow: @shadow;\n}') # Comments t('/* test */') t('.tabs{/* test */}', '.tabs {\n\t/* test */\n}') t('.tabs{/* test */}', '.tabs {\n\t/* test */\n}') t('/* header */.tabs {}', '/* header */\n\n.tabs {}') t('.tabs {\n/* non-header */\nwidth:10px;}', '.tabs {\n\t/* non-header */\n\twidth: 10px;\n}') t('/* header') t('// comment') t('.selector1 {\n\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n}', '.selector1 {\n\tmargin: 0;\n\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n}') # single line comment support (less/sass) t('.tabs{\n// comment\nwidth:10px;\n}', '.tabs {\n\t// comment\n\twidth: 10px;\n}') t('.tabs{// comment\nwidth:10px;\n}', '.tabs {\n\t// comment\n\twidth: 10px;\n}') t('//comment\n.tabs{width:10px;}', '//comment\n.tabs {\n\twidth: 10px;\n}') t('.tabs{//comment\n//2nd single line comment\nwidth:10px;}', '.tabs {\n\t//comment\n\t//2nd single line comment\n\twidth: 10px;\n}') t('.tabs{width:10px;//end of line comment\n}', '.tabs {\n\twidth: 10px; //end of line comment\n}') t('.tabs{width:10px;//end of line comment\nheight:10px;}', '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px;\n}') t('.tabs{width:10px;//end of line comment\nheight:10px;//another\n}', '.tabs {\n\twidth: 10px; //end of line comment\n\theight: 10px; //another\n}') # Psuedo-classes vs Variables t('@page :first {}') # Assume the colon goes with the @name. If we're in LESS, this is required regardless of the at-string. t('@page:first {}', '@page: first {}') t('@page: first {}') # SASS/SCSS # Basic Interpolation t('p {\n\t$font-size: 12px;\n\t$line-height: 30px;\n\tfont: #{$font-size}/#{$line-height};\n}') t('p.#{$name} {}') t( '@mixin itemPropertiesCoverItem($items, $margin) {\n' + '\twidth: calc((100% - ((#{$items} - 1) * #{$margin}rem)) / #{$items});\n' + '\tmargin: 1.6rem #{$margin}rem 1.6rem 0;\n' + '}') # def testNewline(self): self.resetOptions() t = self.decodesto self.options.end_with_newline = True t("", "\n") t("\n", "\n") t(".tabs{}\n", ".tabs {}\n") t(".tabs{}", ".tabs {}\n") def testBasics(self): self.resetOptions() t = self.decodesto t("", "") t("\n", "") t(".tabs{}\n", ".tabs {}") t(".tabs{}", ".tabs {}") t(".tabs{color:red}", ".tabs {\n\tcolor: red\n}") t(".tabs{color:rgb(255, 255, 0)}", ".tabs {\n\tcolor: rgb(255, 255, 0)\n}") t(".tabs{background:url('back.jpg')}", ".tabs {\n\tbackground: url('back.jpg')\n}") t("#bla, #foo{color:red}", "#bla,\n#foo {\n\tcolor: red\n}") t("@media print {.tab{}}", "@media print {\n\t.tab {}\n}") t("@media print {.tab{background-image:url(foo@2x.png)}}", "@media print {\n\t.tab {\n\t\tbackground-image: url(foo@2x.png)\n\t}\n}") t("a:before {\n" + "\tcontent: 'a{color:black;}\"\"\\'\\'\"\\n\\n\\na{color:black}\';\n" + "}"); # may not eat the space before "[" t('html.js [data-custom="123"] {\n\topacity: 1.00;\n}') t('html.js *[data-custom="123"] {\n\topacity: 1.00;\n}') # lead-in whitespace determines base-indent. # lead-in newlines are stripped. t("\n\na, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}") t(" a, img {padding: 0.2px}", " a,\n img {\n \tpadding: 0.2px\n }") t(" \t \na, img {padding: 0.2px}", " \t a,\n \t img {\n \t \tpadding: 0.2px\n \t }") t("\n\n a, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}") def testSeperateSelectors(self): self.resetOptions() t = self.decodesto t("#bla, #foo{color:red}", "#bla,\n#foo {\n\tcolor: red\n}") t("a, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}") def testBlockNesting(self): self.resetOptions() t = self.decodesto t("#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: 'Bitstream Vera Serif Bold';\n\t\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n\t}\n}") t("@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: 'Bitstream Vera Serif Bold';\n\t\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n\t}\n}") # @font-face { # font-family: 'Bitstream Vera Serif Bold'; # src: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf'); # } # @media screen { # #foo:hover { # background-image: url(foo.png); # } # @media screen and (min-device-pixel-ratio: 2) { # @font-face { # font-family: 'Helvetica Neue' # } # #foo:hover { # background-image: url(foo@2x.png); # } # } # } t("@font-face {\n\tfont-family: 'Bitstream Vera Serif Bold';\n\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n}\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: 'Helvetica Neue'\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}") def testOptions(self): self.resetOptions() self.options.indent_size = 2 self.options.indent_char = ' ' self.options.selector_separator_newline = False t = self.decodesto # pseudo-classes and pseudo-elements t("#foo:hover {\n background-image: url(foo@2x.png)\n}") t("#foo *:hover {\n color: purple\n}") t("::selection {\n color: #ff0000;\n}") # TODO: don't break nested pseduo-classes t("@media screen {.tab,.bat:hover {color:red}}", "@media screen {\n .tab, .bat:hover {\n color: red\n }\n}") # particular edge case with braces and semicolons inside tags that allows custom text t( "a:not(\"foobar\\\";{}omg\"){\ncontent: 'example\\';{} text';\ncontent: \"example\\\";{} text\";}", "a:not(\"foobar\\\";{}omg\") {\n content: 'example\\';{} text';\n content: \"example\\\";{} text\";\n}") def testLessCss(self): self.resetOptions() t = self.decodesto t('.well{ \n @well-bg:@bg-color;@well-fg:@fg-color;}','.well {\n\t@well-bg: @bg-color;\n\t@well-fg: @fg-color;\n}') t('.well {&.active {\nbox-shadow: 0 1px 1px @border-color, 1px 0 1px @border-color;}}', '.well {\n' + '\t&.active {\n' + '\t\tbox-shadow: 0 1px 1px @border-color, 1px 0 1px @border-color;\n' + '\t}\n' + '}') t('a {\n' + '\tcolor: blue;\n' + '\t&:hover {\n' + '\t\tcolor: green;\n' + '\t}\n' + '\t& & &&&.active {\n' + '\t\tcolor: green;\n' + '\t}\n' + '}') # Not sure if this is sensible # but I believe it is correct to not remove the space in "&: hover". t('a {\n' + '\t&: hover {\n' + '\t\tcolor: green;\n' + '\t}\n' + '}'); # import t('@import "test";'); # don't break nested pseudo-classes t("a:first-child{color:red;div:first-child{color:black;}}", "a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); # handle SASS/LESS parent reference t("div{&:first-letter {text-transform: uppercase;}}", "div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); # nested modifiers (&:hover etc) t(".tabs{&:hover{width:10px;}}", ".tabs {\n\t&:hover {\n\t\twidth: 10px;\n\t}\n}") t(".tabs{&.big{width:10px;}}", ".tabs {\n\t&.big {\n\t\twidth: 10px;\n\t}\n}") t(".tabs{&>big{width:10px;}}", ".tabs {\n\t&>big {\n\t\twidth: 10px;\n\t}\n}") t(".tabs{&+.big{width:10px;}}", ".tabs {\n\t&+.big {\n\t\twidth: 10px;\n\t}\n}") # nested rules t(".tabs{.child{width:10px;}}", ".tabs {\n\t.child {\n\t\twidth: 10px;\n\t}\n}") # variables t("@myvar:10px;.tabs{width:10px;}", "@myvar: 10px;\n.tabs {\n\twidth: 10px;\n}") t("@myvar:10px; .tabs{width:10px;}", "@myvar: 10px;\n.tabs {\n\twidth: 10px;\n}") def decodesto(self, input, expectation=None): if expectation == None: expectation = input self.assertMultiLineEqual( cssbeautifier.beautify(input, self.options), expectation) # if the expected is different from input, run it again # expected output should be unchanged when run twice. if not expectation != input: self.assertMultiLineEqual( cssbeautifier.beautify(expectation, self.options), expectation) # Everywhere we do newlines, they should be replaced with opts.eol self.options.eol = '\r\\n'; expectation = expectation.replace('\n', '\r\n') self.assertMultiLineEqual( cssbeautifier.beautify(input, self.options), expectation) input = input.replace('\n', '\r\n') self.assertMultiLineEqual( cssbeautifier.beautify(input, self.options), expectation) self.options.eol = '\n' if __name__ == '__main__': unittest.main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 2882, 199, 646, 11431, 30745, 935, 3895, 421, 199, 533, 15750, 3655, 65, 935, 3895, 774, 8, 2796, 14, 1746, 304, 339, 347, 5305, 4558, 8, 277, 304, 267, 3055, 275, 756, 267, 2549, 275, 715, 267, 291, 14, 1419, 275, 11431, 30745, 935, 3895, 14, 885, 63, 1419, 342, 267, 291, 14, 1419, 14, 3724, 63, 890, 275, 413, 267, 291, 14, 1419, 14, 3724, 63, 1560, 275, 1557, 84, 7, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 2549, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 12210, 63, 13007, 63, 4423, 275, 3055, 339, 347, 511, 12706, 8, 277, 304, 267, 291, 14, 3958, 4558, 342, 267, 511, 63, 7677, 275, 291, 14, 2708, 14308, 267, 307, 275, 291, 14, 2708, 14308, 398, 3055, 275, 756, 267, 2549, 275, 715, 398, 291, 14, 1419, 14, 3724, 63, 890, 275, 413, 267, 291, 14, 1419, 14, 3724, 63, 1560, 275, 1557, 84, 7, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 2549, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 12210, 63, 13007, 63, 4423, 275, 3055, 398, 327, 9599, 8777, 7053, 604, 446, 334, 11670, 275, 1867, 78, 531, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 2549, 267, 511, 63, 7677, 8594, 1557, 78, 358, 267, 511, 63, 7677, 360, 257, 1275, 8741, 2440, 297, 283, 257, 1275, 8741, 22902, 78, 358, 267, 511, 63, 7677, 360, 257, 971, 78, 60, 78, 14, 8741, 24423, 78, 60, 78, 60, 78, 60, 78, 297, 283, 257, 1275, 8741, 22902, 78, 358, 267, 511, 63, 7677, 2258, 78, 358, 398, 327, 9599, 8777, 7053, 604, 446, 334, 11670, 275, 6899, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 3055, 267, 511, 63, 7677, 8355, 267, 511, 63, 7677, 360, 257, 1275, 8741, 2440, 297, 283, 257, 1275, 8741, 1052, 358, 267, 511, 63, 7677, 360, 257, 971, 78, 60, 78, 14, 8741, 24423, 78, 60, 78, 60, 78, 60, 78, 297, 283, 257, 1275, 8741, 1052, 358, 267, 511, 63, 7677, 2258, 78, 297, 4074, 398, 327, 9630, 27158, 267, 307, 5175, 8741, 2440, 297, 1987, 8741, 1052, 358, 267, 307, 5175, 8741, 469, 789, 297, 1987, 8741, 1052, 358, 267, 307, 5175, 8741, 259, 469, 259, 789, 297, 1987, 8741, 1052, 358, 267, 307, 5175, 8741, 259, 971, 78, 12911, 78, 259, 971, 78, 221, 789, 297, 1987, 8741, 1052, 358, 398, 327, 267, 307, 7863, 67, 1977, 31099, 9459, 78, 60, 84, 7451, 26, 1166, 8, 4782, 15, 18534, 14, 4524, 9, 11982, 378, 378, 3779, 78, 60, 475, 6192, 26, 378, 14, 25, 3779, 78, 60, 84, 1541, 26, 5131, 8, 21861, 275, 9137, 6152, 78, 7293, 3943, 67, 1977, 31099, 9459, 78, 60, 84, 7451, 26, 1166, 8, 4782, 15, 18534, 14, 4524, 9, 11982, 378, 378, 3779, 78, 60, 475, 6192, 26, 378, 14, 25, 3779, 78, 60, 84, 1541, 26, 5131, 8, 21861, 29, 2710, 6152, 78, 12216, 398, 327, 3240, 3283, 27504, 707, 446, 334, 9896, 275, 298, 3872, 9432, 17, 275, 298, 6099, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 6662, 63, 9896, 275, 298, 298, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 7731, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12431, 60, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 22902, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 18485, 13475, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 12, 1275, 13475, 22902, 78, 12216, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 8399, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12136, 60, 78, 12216, 267, 307, 360, 65, 26, 2246, 13, 1739, 12, 65, 26, 2246, 13, 1739, 91, 2326, 26, 581, 27, 3015, 26, 2246, 13, 1739, 12, 3015, 26, 22797, 91, 2326, 26, 8399, 27, 29223, 283, 65, 26, 2246, 13, 1739, 12, 282, 26, 2246, 13, 1739, 9459, 78, 60, 84, 2326, 26, 8992, 3779, 78, 60, 84, 3015, 26, 2246, 13, 1739, 12, 9073, 26, 22797, 9459, 78, 60, 84, 60, 84, 2326, 26, 12136, 3779, 78, 60, 84, 4988, 78, 12216, 398, 327, 3240, 3283, 27504, 707, 446, 334, 9896, 275, 298, 3872, 9432, 17, 275, 298, 6099, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 6662, 63, 9896, 275, 298, 221, 298, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 7731, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12431, 60, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 22902, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 18485, 13475, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 12, 1275, 13475, 22902, 78, 12216, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 8399, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12136, 60, 78, 12216, 267, 307, 360, 65, 26, 2246, 13, 1739, 12, 65, 26, 2246, 13, 1739, 91, 2326, 26, 581, 27, 3015, 26, 2246, 13, 1739, 12, 3015, 26, 22797, 91, 2326, 26, 8399, 27, 29223, 283, 65, 26, 2246, 13, 1739, 12, 282, 26, 2246, 13, 1739, 9459, 78, 60, 84, 2326, 26, 8992, 3779, 78, 60, 84, 3015, 26, 2246, 13, 1739, 12, 9073, 26, 22797, 9459, 78, 60, 84, 60, 84, 2326, 26, 12136, 3779, 78, 60, 84, 4988, 78, 12216, 398, 327, 3240, 3283, 27504, 707, 446, 334, 9896, 275, 1867, 78, 401, 9432, 17, 275, 1867, 78, 60, 84, 531, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 2549, 267, 291, 14, 1419, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 2882, 199, 646, 11431, 30745, 935, 3895, 421, 199, 533, 15750, 3655, 65, 935, 3895, 774, 8, 2796, 14, 1746, 304, 339, 347, 5305, 4558, 8, 277, 304, 267, 3055, 275, 756, 267, 2549, 275, 715, 267, 291, 14, 1419, 275, 11431, 30745, 935, 3895, 14, 885, 63, 1419, 342, 267, 291, 14, 1419, 14, 3724, 63, 890, 275, 413, 267, 291, 14, 1419, 14, 3724, 63, 1560, 275, 1557, 84, 7, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 2549, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 12210, 63, 13007, 63, 4423, 275, 3055, 339, 347, 511, 12706, 8, 277, 304, 267, 291, 14, 3958, 4558, 342, 267, 511, 63, 7677, 275, 291, 14, 2708, 14308, 267, 307, 275, 291, 14, 2708, 14308, 398, 3055, 275, 756, 267, 2549, 275, 715, 398, 291, 14, 1419, 14, 3724, 63, 890, 275, 413, 267, 291, 14, 1419, 14, 3724, 63, 1560, 275, 1557, 84, 7, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 2549, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 12210, 63, 13007, 63, 4423, 275, 3055, 398, 327, 9599, 8777, 7053, 604, 446, 334, 11670, 275, 1867, 78, 531, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 2549, 267, 511, 63, 7677, 8594, 1557, 78, 358, 267, 511, 63, 7677, 360, 257, 1275, 8741, 2440, 297, 283, 257, 1275, 8741, 22902, 78, 358, 267, 511, 63, 7677, 360, 257, 971, 78, 60, 78, 14, 8741, 24423, 78, 60, 78, 60, 78, 60, 78, 297, 283, 257, 1275, 8741, 22902, 78, 358, 267, 511, 63, 7677, 2258, 78, 358, 398, 327, 9599, 8777, 7053, 604, 446, 334, 11670, 275, 6899, 267, 291, 14, 1419, 14, 500, 63, 1045, 63, 12210, 275, 3055, 267, 511, 63, 7677, 8355, 267, 511, 63, 7677, 360, 257, 1275, 8741, 2440, 297, 283, 257, 1275, 8741, 1052, 358, 267, 511, 63, 7677, 360, 257, 971, 78, 60, 78, 14, 8741, 24423, 78, 60, 78, 60, 78, 60, 78, 297, 283, 257, 1275, 8741, 1052, 358, 267, 511, 63, 7677, 2258, 78, 297, 4074, 398, 327, 9630, 27158, 267, 307, 5175, 8741, 2440, 297, 1987, 8741, 1052, 358, 267, 307, 5175, 8741, 469, 789, 297, 1987, 8741, 1052, 358, 267, 307, 5175, 8741, 259, 469, 259, 789, 297, 1987, 8741, 1052, 358, 267, 307, 5175, 8741, 259, 971, 78, 12911, 78, 259, 971, 78, 221, 789, 297, 1987, 8741, 1052, 358, 398, 327, 267, 307, 7863, 67, 1977, 31099, 9459, 78, 60, 84, 7451, 26, 1166, 8, 4782, 15, 18534, 14, 4524, 9, 11982, 378, 378, 3779, 78, 60, 475, 6192, 26, 378, 14, 25, 3779, 78, 60, 84, 1541, 26, 5131, 8, 21861, 275, 9137, 6152, 78, 7293, 3943, 67, 1977, 31099, 9459, 78, 60, 84, 7451, 26, 1166, 8, 4782, 15, 18534, 14, 4524, 9, 11982, 378, 378, 3779, 78, 60, 475, 6192, 26, 378, 14, 25, 3779, 78, 60, 84, 1541, 26, 5131, 8, 21861, 29, 2710, 6152, 78, 12216, 398, 327, 3240, 3283, 27504, 707, 446, 334, 9896, 275, 298, 3872, 9432, 17, 275, 298, 6099, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 6662, 63, 9896, 275, 298, 298, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 7731, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12431, 60, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 22902, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 18485, 13475, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 12, 1275, 13475, 22902, 78, 12216, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 8399, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12136, 60, 78, 12216, 267, 307, 360, 65, 26, 2246, 13, 1739, 12, 65, 26, 2246, 13, 1739, 91, 2326, 26, 581, 27, 3015, 26, 2246, 13, 1739, 12, 3015, 26, 22797, 91, 2326, 26, 8399, 27, 29223, 283, 65, 26, 2246, 13, 1739, 12, 282, 26, 2246, 13, 1739, 9459, 78, 60, 84, 2326, 26, 8992, 3779, 78, 60, 84, 3015, 26, 2246, 13, 1739, 12, 9073, 26, 22797, 9459, 78, 60, 84, 60, 84, 2326, 26, 12136, 3779, 78, 60, 84, 4988, 78, 12216, 398, 327, 3240, 3283, 27504, 707, 446, 334, 9896, 275, 298, 3872, 9432, 17, 275, 298, 6099, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 3055, 267, 291, 14, 1419, 14, 6662, 63, 9896, 275, 298, 221, 298, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 7731, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12431, 60, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 22902, 78, 12216, 267, 307, 16591, 4603, 870, 469, 14, 2902, 18485, 13475, 2440, 7293, 10267, 4603, 870, 9459, 78, 60, 84, 14, 2902, 12, 1275, 13475, 22902, 78, 12216, 267, 307, 7863, 21244, 12, 327, 1421, 91, 2326, 26, 8399, 7293, 3943, 21244, 12, 327, 1421, 9459, 78, 60, 84, 2326, 26, 12136, 60, 78, 12216, 267, 307, 360, 65, 26, 2246, 13, 1739, 12, 65, 26, 2246, 13, 1739, 91, 2326, 26, 581, 27, 3015, 26, 2246, 13, 1739, 12, 3015, 26, 22797, 91, 2326, 26, 8399, 27, 29223, 283, 65, 26, 2246, 13, 1739, 12, 282, 26, 2246, 13, 1739, 9459, 78, 60, 84, 2326, 26, 8992, 3779, 78, 60, 84, 3015, 26, 2246, 13, 1739, 12, 9073, 26, 22797, 9459, 78, 60, 84, 60, 84, 2326, 26, 12136, 3779, 78, 60, 84, 4988, 78, 12216, 398, 327, 3240, 3283, 27504, 707, 446, 334, 9896, 275, 1867, 78, 401, 9432, 17, 275, 1867, 78, 60, 84, 531, 267, 291, 14, 1419, 14, 6662, 63, 9896, 63, 12210, 275, 2549, 267, 291, 14, 1419, 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,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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 ]
bcheung92/Paperproject
gem5/tests/configs/memtest-filter.py
23
3208
# Copyright (c) 2006-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: Ron Dreslinski import m5 from m5.objects import * m5.util.addToPath('../configs/common') from Caches import * #MAX CORES IS 8 with the fals sharing method nb_cores = 8 cpus = [ MemTest() for i in xrange(nb_cores) ] # system simulated system = System(cpu = cpus, physmem = SimpleMemory(), membus = SystemXBar(width=16, snoop_filter = SnoopFilter())) # Dummy voltage domain for all our clock domains system.voltage_domain = VoltageDomain() system.clk_domain = SrcClockDomain(clock = '1GHz', voltage_domain = system.voltage_domain) # Create a seperate clock domain for components that should run at # CPUs frequency system.cpu_clk_domain = SrcClockDomain(clock = '2GHz', voltage_domain = system.voltage_domain) system.toL2Bus = L2XBar(clk_domain = system.cpu_clk_domain, snoop_filter = SnoopFilter()) system.l2c = L2Cache(clk_domain = system.cpu_clk_domain, size='64kB', assoc=8) system.l2c.cpu_side = system.toL2Bus.master # connect l2c to membus system.l2c.mem_side = system.membus.slave # add L1 caches for cpu in cpus: # All cpus are associated with cpu_clk_domain cpu.clk_domain = system.cpu_clk_domain cpu.l1c = L1Cache(size = '32kB', assoc = 4) cpu.l1c.cpu_side = cpu.port cpu.l1c.mem_side = system.toL2Bus.slave system.system_port = system.membus.slave # connect memory to membus system.physmem.port = system.membus.master # ----------------------- # run simulation # ----------------------- root = Root( full_system = False, system = system ) root.system.mem_mode = 'timing'
mit
[ 3, 1898, 334, 67, 9, 8315, 13, 9488, 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, 32472, 577, 470, 472, 10728, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 77, 21, 14, 1974, 14, 525, 1378, 2042, 24592, 7532, 15, 2330, 358, 199, 504, 445, 1225, 397, 492, 627, 199, 199, 3, 4283, 18886, 654, 2281, 1695, 543, 314, 289, 2551, 26994, 1083, 199, 4994, 63, 4630, 275, 1695, 199, 8896, 275, 359, 30465, 774, 342, 367, 284, 315, 4945, 8, 4994, 63, 4630, 9, 1622, 199, 199, 3, 2656, 4389, 8097, 199, 2253, 275, 6187, 8, 3541, 275, 24174, 12, 355, 3945, 588, 5286, 275, 5870, 8628, 1062, 355, 7573, 5610, 275, 6187, 56, 5281, 8, 2063, 29, 975, 12, 308, 12921, 63, 1541, 275, 428, 12921, 4131, 4059, 199, 3, 9762, 29943, 2881, 367, 1006, 4154, 12516, 14006, 199, 2253, 14, 27543, 63, 2261, 275, 16171, 15028, 7705, 342, 199, 2253, 14, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 17, 39, 13026, 297, 3521, 29943, 63, 2261, 275, 2656, 14, 27543, 63, 2261, 9, 199, 199, 3, 2790, 282, 542, 529, 323, 12516, 2881, 367, 7323, 626, 1077, 1255, 737, 199, 3, 28504, 9857, 199, 2253, 14, 3541, 63, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 18, 39, 13026, 297, 4318, 29943, 63, 2261, 275, 2656, 14, 27543, 63, 2261, 9, 199, 199, 2253, 14, 475, 44, 18, 12106, 275, 491, 18, 56, 5281, 8, 429, 75, 63, 2261, 275, 2656, 14, 3541, 63, 429, 75, 63, 2261, 12, 717, 308, 12921, 63, 1541, 275, 428, 12921, 4131, 1012, 199, 2253, 14, 76, 18, 67, 275, 491, 18, 4437, 8, 429, 75, 63, 2261, 275, 2656, 14, 3541, 63, 429, 75, 63, 2261, 12, 1568, 534, 772, 75, 34, 297, 22149, 29, 24, 9, 199, 2253, 14, 76, 18, 67, 14, 3541, 63, 2441, 275, 2656, 14, 475, 44, 18, 12106, 14, 4133, 199, 199, 3, 4907, 634, 18, 67, 370, 7573, 5610, 199, 2253, 14, 76, 18, 67, 14, 5286, 63, 2441, 275, 2656, 14, 5286, 5610, 14, 12384, 199, 199, 3, 1050, 491, 17, 18014, 199, 509, 5033, 315, 24174, 26, 272, 327, 2900, 24174, 787, 4568, 543, 5033, 63, 429, 75, 63, 2261, 272, 5033, 14, 429, 75, 63, 2261, 275, 2656, 14, 3541, 63, 429, 75, 63, 2261, 272, 5033, 14, 76, 17, 67, 275, 491, 17, 4437, 8, 890, 275, 283, 708, 75, 34, 297, 22149, 275, 841, 9, 272, 5033, 14, 76, 17, 67, 14, 3541, 63, 2441, 275, 5033, 14, 719, 272, 5033, 14, 76, 17, 67, 14, 5286, 63, 2441, 275, 2656, 14, 475, 44, 18, 12106, 14, 12384, 199, 199, 2253, 14, 2253, 63, 719, 275, 2656, 14, 5286, 5610, 14, 12384, 199, 199, 3, 4907, 4402, 370, 7573, 5610, 199, 2253, 14, 26827, 5286, 14, 719, 275, 2656, 14, 5286, 5610, 14, 4133, 421, 199, 3, 10652, 12797, 199, 3, 1255, 17625, 199, 3, 10652, 12797, 199, 199, 1231, 275, 12826, 8, 2615, 63, 2253, 275, 756, 12, 2656, 275, 2656, 776, 199, 1231, 14, 2253, 14, 5286, 63, 632, 275, 283, 14639, 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 ]
[ 1898, 334, 67, 9, 8315, 13, 9488, 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, 32472, 577, 470, 472, 10728, 199, 199, 646, 333, 21, 199, 504, 333, 21, 14, 1462, 492, 627, 199, 77, 21, 14, 1974, 14, 525, 1378, 2042, 24592, 7532, 15, 2330, 358, 199, 504, 445, 1225, 397, 492, 627, 199, 199, 3, 4283, 18886, 654, 2281, 1695, 543, 314, 289, 2551, 26994, 1083, 199, 4994, 63, 4630, 275, 1695, 199, 8896, 275, 359, 30465, 774, 342, 367, 284, 315, 4945, 8, 4994, 63, 4630, 9, 1622, 199, 199, 3, 2656, 4389, 8097, 199, 2253, 275, 6187, 8, 3541, 275, 24174, 12, 355, 3945, 588, 5286, 275, 5870, 8628, 1062, 355, 7573, 5610, 275, 6187, 56, 5281, 8, 2063, 29, 975, 12, 308, 12921, 63, 1541, 275, 428, 12921, 4131, 4059, 199, 3, 9762, 29943, 2881, 367, 1006, 4154, 12516, 14006, 199, 2253, 14, 27543, 63, 2261, 275, 16171, 15028, 7705, 342, 199, 2253, 14, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 17, 39, 13026, 297, 3521, 29943, 63, 2261, 275, 2656, 14, 27543, 63, 2261, 9, 199, 199, 3, 2790, 282, 542, 529, 323, 12516, 2881, 367, 7323, 626, 1077, 1255, 737, 199, 3, 28504, 9857, 199, 2253, 14, 3541, 63, 429, 75, 63, 2261, 275, 428, 1195, 17387, 7705, 8, 9597, 275, 283, 18, 39, 13026, 297, 4318, 29943, 63, 2261, 275, 2656, 14, 27543, 63, 2261, 9, 199, 199, 2253, 14, 475, 44, 18, 12106, 275, 491, 18, 56, 5281, 8, 429, 75, 63, 2261, 275, 2656, 14, 3541, 63, 429, 75, 63, 2261, 12, 717, 308, 12921, 63, 1541, 275, 428, 12921, 4131, 1012, 199, 2253, 14, 76, 18, 67, 275, 491, 18, 4437, 8, 429, 75, 63, 2261, 275, 2656, 14, 3541, 63, 429, 75, 63, 2261, 12, 1568, 534, 772, 75, 34, 297, 22149, 29, 24, 9, 199, 2253, 14, 76, 18, 67, 14, 3541, 63, 2441, 275, 2656, 14, 475, 44, 18, 12106, 14, 4133, 199, 199, 3, 4907, 634, 18, 67, 370, 7573, 5610, 199, 2253, 14, 76, 18, 67, 14, 5286, 63, 2441, 275, 2656, 14, 5286, 5610, 14, 12384, 199, 199, 3, 1050, 491, 17, 18014, 199, 509, 5033, 315, 24174, 26, 272, 327, 2900, 24174, 787, 4568, 543, 5033, 63, 429, 75, 63, 2261, 272, 5033, 14, 429, 75, 63, 2261, 275, 2656, 14, 3541, 63, 429, 75, 63, 2261, 272, 5033, 14, 76, 17, 67, 275, 491, 17, 4437, 8, 890, 275, 283, 708, 75, 34, 297, 22149, 275, 841, 9, 272, 5033, 14, 76, 17, 67, 14, 3541, 63, 2441, 275, 5033, 14, 719, 272, 5033, 14, 76, 17, 67, 14, 5286, 63, 2441, 275, 2656, 14, 475, 44, 18, 12106, 14, 12384, 199, 199, 2253, 14, 2253, 63, 719, 275, 2656, 14, 5286, 5610, 14, 12384, 199, 199, 3, 4907, 4402, 370, 7573, 5610, 199, 2253, 14, 26827, 5286, 14, 719, 275, 2656, 14, 5286, 5610, 14, 4133, 421, 199, 3, 10652, 12797, 199, 3, 1255, 17625, 199, 3, 10652, 12797, 199, 199, 1231, 275, 12826, 8, 2615, 63, 2253, 275, 756, 12, 2656, 275, 2656, 776, 199, 1231, 14, 2253, 14, 5286, 63, 632, 275, 283, 14639, 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, 0 ]
[ 1, 1, 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ss/splitencoder
splitencoder/splitter.py
1
4258
#!/usr/bin/env python # # splitencoder # # Copyright (C) 2015 Samsung Electronics. All rights reserved. # Author: Thiago Santos <thiagoss@osg.samsung.com> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301, USA. # import sys import gi gi.require_version('Gst', '1.0') from gi.repository import GObject, Gst import utils def on_message(bus, message, udata): pipeline, loop = udata if message.type == Gst.MessageType.EOS: pipeline.set_state(Gst.State.NULL) loop.quit() elif message.type == Gst.MessageType.ERROR: print message.parse_error() pipeline.set_state(Gst.State.NULL) loop.quit() return True def on_autoplug_factories(element, pad, caps, udata): factories = Gst.ElementFactory.list_get_elements(Gst.ELEMENT_FACTORY_TYPE_DEMUXER | Gst.ELEMENT_FACTORY_TYPE_PARSER, Gst.Rank.MARGINAL) factories = Gst.ElementFactory.list_filter(factories, caps, Gst.PadDirection.SINK, caps.is_fixed()) if len(factories) == 0: #TODO check if this is indeed a parsed type and not some unhandled format (missing elements) return None return factories def on_autoplug_continue(element, pad, caps, udata): s = caps.get_structure(0) if s.has_field('parsed'): if s.get_value('parsed') == True: return False if s.has_field('framed'): if s.get_value('framed') == True: return False return True def on_pad_added(element, pad, udata): pipeline, splitmuxsink = udata other_pad = None # Can't use 'get_compatible_pad' because splitmuxsink pad templates # are all ANY so it will always match the first if utils.caps_is_video(pad.get_current_caps()): klass = type(splitmuxsink) tmpl = klass.get_pad_template('video') other_pad = splitmuxsink.request_pad(tmpl, None, None) elif utils.caps_is_audio(pad.get_current_caps()): klass = type(splitmuxsink) tmpl = klass.get_pad_template('audio_%u') other_pad = splitmuxsink.request_pad(tmpl, None, None) else: caps = pad.get_current_caps() print 'leaving pad %s unlinked - "%s"' % (pad.get_name(), caps.to_string() if caps else 'no caps') if other_pad: queue = Gst.ElementFactory.make('queue') pipeline.add(queue) queue.sync_state_with_parent() pad.link(queue.get_static_pad('sink')) queue.get_static_pad('src').link(other_pad) def split(input_uri, output_dir): Gst.init() loop = GObject.MainLoop() pipeline = Gst.Pipeline() uridecodebin = Gst.ElementFactory.make('uridecodebin') splitmuxsink = Gst.ElementFactory.make('splitmuxsink') pipeline.add(uridecodebin) pipeline.add(splitmuxsink) uridecodebin.set_property('uri', input_uri) uridecodebin.connect('autoplug-factories', on_autoplug_factories, None) uridecodebin.connect('autoplug-continue', on_autoplug_continue, None) uridecodebin.connect('pad-added', on_pad_added, (pipeline, splitmuxsink)) # TODO fix mp4mux to properly segment files splitmuxsink.set_property('muxer', Gst.ElementFactory.make('matroskamux')) splitmuxsink.set_property('location', output_dir + '/' + 'segment_%09d.mkv') splitmuxsink.set_property('max-size-time', 10000000000) #10s segments bus = pipeline.get_bus() bus.add_watch(0, on_message, (pipeline, loop)) pipeline.set_state(Gst.State.PLAYING) loop.run() if __name__ == '__main__': Gst.init() input_uri = sys.argv[1] output_dir = sys.argv[2] #TODO validate args split(input_uri, output_dir)
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 2249, 317, 724, 2693, 199, 3, 199, 3, 1898, 334, 35, 9, 6900, 428, 19470, 10335, 662, 16728, 2932, 14, 2900, 4481, 4644, 14, 199, 3, 257, 6529, 26, 3868, 73, 14315, 29359, 14543, 665, 273, 73, 14315, 385, 32, 21593, 14, 83, 19470, 10335, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 646, 984, 199, 199, 646, 18895, 199, 6153, 14, 4365, 63, 1023, 360, 39, 270, 297, 283, 17, 14, 16, 358, 199, 504, 18895, 14, 8421, 492, 31264, 12, 598, 270, 199, 199, 646, 3778, 199, 199, 318, 641, 63, 1188, 8, 5610, 12, 1245, 12, 399, 576, 304, 272, 7679, 12, 4438, 275, 399, 576, 339, 340, 1245, 14, 466, 508, 598, 270, 14, 12091, 14, 37, 3100, 26, 267, 7679, 14, 409, 63, 929, 8, 39, 270, 14, 2223, 14, 8084, 9, 267, 4438, 14, 10589, 342, 272, 916, 1245, 14, 466, 508, 598, 270, 14, 12091, 14, 3170, 26, 267, 870, 1245, 14, 1122, 63, 705, 342, 267, 7679, 14, 409, 63, 929, 8, 39, 270, 14, 2223, 14, 8084, 9, 267, 4438, 14, 10589, 342, 339, 372, 715, 199, 199, 318, 641, 63, 29582, 32047, 63, 15406, 8, 2108, 12, 6567, 12, 22053, 12, 399, 576, 304, 272, 22115, 275, 598, 270, 14, 2162, 2927, 14, 513, 63, 362, 63, 5527, 8, 39, 270, 14, 12535, 63, 18164, 5347, 63, 2711, 63, 1093, 45, 14272, 540, 1204, 598, 270, 14, 12535, 63, 18164, 5347, 63, 2711, 63, 26078, 12, 598, 270, 14, 19486, 14, 45, 11611, 13384, 9, 272, 22115, 275, 598, 270, 14, 2162, 2927, 14, 513, 63, 1541, 8, 15406, 12, 22053, 12, 598, 270, 14, 18584, 17015, 14, 51, 12394, 12, 22053, 14, 374, 63, 5964, 1012, 339, 340, 822, 8, 15406, 9, 508, 378, 26, 267, 327, 11768, 1104, 340, 642, 365, 31043, 379, 282, 4565, 730, 436, 440, 2005, 23090, 1475, 334, 4752, 4008, 9, 267, 372, 488, 339, 372, 22115, 199, 199, 318, 641, 63, 29582, 32047, 63, 6958, 8, 2108, 12, 6567, 12, 22053, 12, 399, 576, 304, 272, 308, 275, 22053, 14, 362, 63, 6976, 8, 16, 9, 272, 340, 308, 14, 1989, 63, 698, 360, 6751, 735, 267, 340, 308, 14, 362, 63, 585, 360, 6751, 358, 508, 715, 26, 288, 372, 756, 272, 340, 308, 14, 1989, 63, 698, 360, 1943, 68, 735, 267, 340, 308, 14, 362, 63, 585, 360, 1943, 68, 358, 508, 715, 26, 288, 372, 756, 339, 372, 715, 199, 199, 318, 641, 63, 6226, 63, 3270, 8, 2108, 12, 6567, 12, 399, 576, 304, 272, 7679, 12, 3715, 20521, 11279, 275, 399, 576, 272, 1163, 63, 6226, 275, 488, 339, 327, 6855, 1133, 675, 283, 362, 63, 6490, 63, 6226, 7, 2952, 3715, 20521, 11279, 6567, 7009, 272, 327, 787, 1006, 1821, 880, 652, 911, 3544, 1336, 314, 1642, 272, 340, 3778, 14, 12029, 63, 374, 63, 3722, 8, 6226, 14, 362, 63, 1818, 63, 12029, 5109, 267, 8531, 275, 730, 8, 1294, 20521, 11279, 9, 267, 9675, 275, 8531, 14, 362, 63, 6226, 63, 1160, 360, 3722, 358, 267, 1163, 63, 6226, 275, 3715, 20521, 11279, 14, 1069, 63, 6226, 8, 11510, 12, 488, 12, 488, 9, 272, 916, 3778, 14, 12029, 63, 374, 63, 8130, 8, 6226, 14, 362, 63, 1818, 63, 12029, 5109, 267, 8531, 275, 730, 8, 1294, 20521, 11279, 9, 267, 9675, 275, 8531, 14, 362, 63, 6226, 63, 1160, 360, 8130, 4970, 85, 358, 267, 1163, 63, 6226, 275, 3715, 20521, 11279, 14, 1069, 63, 6226, 8, 11510, 12, 488, 12, 488, 9, 272, 587, 26, 267, 22053, 275, 6567, 14, 362, 63, 1818, 63, 12029, 342, 267, 870, 283, 274, 5519, 6567, 450, 83, 625, 12751, 446, 2071, 83, 4507, 450, 334, 6226, 14, 362, 63, 354, 1062, 22053, 14, 475, 63, 875, 342, 340, 22053, 587, 283, 889, 22053, 358, 339, 340, 1163, 63, 6226, 26, 267, 4126, 275, 598, 270, 14, 2162, 2927, 14, 1875, 360, 1825, 358, 267, 7679, 14, 525, 8, 1825, 9, 267, 4126, 14, 5186, 63, 929, 63, 1045, 63, 1708, 342, 267, 6567, 14, 1073, 8, 1825, 14, 362, 63, 1986, 63, 6226, 360, 11279, 1333, 267, 4126, 14, 362, 63, 1986, 63, 6226, 360, 2164, 1959, 1073, 8, 1848, 63, 6226, 9, 199, 199, 318, 3715, 8, 1210, 63, 2302, 12, 1072, 63, 694, 304, 272, 598, 270, 14, 826, 342, 272, 4438, 275, 31264, 14, 6756, 7382, 342, 339, 7679, 275, 598, 270, 14, 17562, 342, 272, 5108, 2708, 1393, 275, 598, 270, 14, 2162, 2927, 14, 1875, 360, 2302, 2708, 1393, 358, 272, 3715, 20521, 11279, 275, 598, 270, 14, 2162, 2927, 14, 1875, 360, 1294, 20521, 11279, 358, 272, 7679, 14, 525, 8, 2302, 2708, 1393, 9, 272, 7679, 14, 525, 8, 1294, 20521, 11279, 9, 339, 5108, 2708, 1393, 14, 409, 63, 1829, 360, 2302, 297, 1324, 63, 2302, 9, 272, 5108, 2708, 1393, 14, 2242, 360, 29582, 32047, 13, 15406, 297, 641, 63, 29582, 32047, 63, 15406, 12, 488, 9, 272, 5108, 2708, 1393, 14, 2242, 360, 29582, 32047, 13, 6958, 297 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 2249, 317, 724, 2693, 199, 3, 199, 3, 1898, 334, 35, 9, 6900, 428, 19470, 10335, 662, 16728, 2932, 14, 2900, 4481, 4644, 14, 199, 3, 257, 6529, 26, 3868, 73, 14315, 29359, 14543, 665, 273, 73, 14315, 385, 32, 21593, 14, 83, 19470, 10335, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 646, 984, 199, 199, 646, 18895, 199, 6153, 14, 4365, 63, 1023, 360, 39, 270, 297, 283, 17, 14, 16, 358, 199, 504, 18895, 14, 8421, 492, 31264, 12, 598, 270, 199, 199, 646, 3778, 199, 199, 318, 641, 63, 1188, 8, 5610, 12, 1245, 12, 399, 576, 304, 272, 7679, 12, 4438, 275, 399, 576, 339, 340, 1245, 14, 466, 508, 598, 270, 14, 12091, 14, 37, 3100, 26, 267, 7679, 14, 409, 63, 929, 8, 39, 270, 14, 2223, 14, 8084, 9, 267, 4438, 14, 10589, 342, 272, 916, 1245, 14, 466, 508, 598, 270, 14, 12091, 14, 3170, 26, 267, 870, 1245, 14, 1122, 63, 705, 342, 267, 7679, 14, 409, 63, 929, 8, 39, 270, 14, 2223, 14, 8084, 9, 267, 4438, 14, 10589, 342, 339, 372, 715, 199, 199, 318, 641, 63, 29582, 32047, 63, 15406, 8, 2108, 12, 6567, 12, 22053, 12, 399, 576, 304, 272, 22115, 275, 598, 270, 14, 2162, 2927, 14, 513, 63, 362, 63, 5527, 8, 39, 270, 14, 12535, 63, 18164, 5347, 63, 2711, 63, 1093, 45, 14272, 540, 1204, 598, 270, 14, 12535, 63, 18164, 5347, 63, 2711, 63, 26078, 12, 598, 270, 14, 19486, 14, 45, 11611, 13384, 9, 272, 22115, 275, 598, 270, 14, 2162, 2927, 14, 513, 63, 1541, 8, 15406, 12, 22053, 12, 598, 270, 14, 18584, 17015, 14, 51, 12394, 12, 22053, 14, 374, 63, 5964, 1012, 339, 340, 822, 8, 15406, 9, 508, 378, 26, 267, 327, 11768, 1104, 340, 642, 365, 31043, 379, 282, 4565, 730, 436, 440, 2005, 23090, 1475, 334, 4752, 4008, 9, 267, 372, 488, 339, 372, 22115, 199, 199, 318, 641, 63, 29582, 32047, 63, 6958, 8, 2108, 12, 6567, 12, 22053, 12, 399, 576, 304, 272, 308, 275, 22053, 14, 362, 63, 6976, 8, 16, 9, 272, 340, 308, 14, 1989, 63, 698, 360, 6751, 735, 267, 340, 308, 14, 362, 63, 585, 360, 6751, 358, 508, 715, 26, 288, 372, 756, 272, 340, 308, 14, 1989, 63, 698, 360, 1943, 68, 735, 267, 340, 308, 14, 362, 63, 585, 360, 1943, 68, 358, 508, 715, 26, 288, 372, 756, 339, 372, 715, 199, 199, 318, 641, 63, 6226, 63, 3270, 8, 2108, 12, 6567, 12, 399, 576, 304, 272, 7679, 12, 3715, 20521, 11279, 275, 399, 576, 272, 1163, 63, 6226, 275, 488, 339, 327, 6855, 1133, 675, 283, 362, 63, 6490, 63, 6226, 7, 2952, 3715, 20521, 11279, 6567, 7009, 272, 327, 787, 1006, 1821, 880, 652, 911, 3544, 1336, 314, 1642, 272, 340, 3778, 14, 12029, 63, 374, 63, 3722, 8, 6226, 14, 362, 63, 1818, 63, 12029, 5109, 267, 8531, 275, 730, 8, 1294, 20521, 11279, 9, 267, 9675, 275, 8531, 14, 362, 63, 6226, 63, 1160, 360, 3722, 358, 267, 1163, 63, 6226, 275, 3715, 20521, 11279, 14, 1069, 63, 6226, 8, 11510, 12, 488, 12, 488, 9, 272, 916, 3778, 14, 12029, 63, 374, 63, 8130, 8, 6226, 14, 362, 63, 1818, 63, 12029, 5109, 267, 8531, 275, 730, 8, 1294, 20521, 11279, 9, 267, 9675, 275, 8531, 14, 362, 63, 6226, 63, 1160, 360, 8130, 4970, 85, 358, 267, 1163, 63, 6226, 275, 3715, 20521, 11279, 14, 1069, 63, 6226, 8, 11510, 12, 488, 12, 488, 9, 272, 587, 26, 267, 22053, 275, 6567, 14, 362, 63, 1818, 63, 12029, 342, 267, 870, 283, 274, 5519, 6567, 450, 83, 625, 12751, 446, 2071, 83, 4507, 450, 334, 6226, 14, 362, 63, 354, 1062, 22053, 14, 475, 63, 875, 342, 340, 22053, 587, 283, 889, 22053, 358, 339, 340, 1163, 63, 6226, 26, 267, 4126, 275, 598, 270, 14, 2162, 2927, 14, 1875, 360, 1825, 358, 267, 7679, 14, 525, 8, 1825, 9, 267, 4126, 14, 5186, 63, 929, 63, 1045, 63, 1708, 342, 267, 6567, 14, 1073, 8, 1825, 14, 362, 63, 1986, 63, 6226, 360, 11279, 1333, 267, 4126, 14, 362, 63, 1986, 63, 6226, 360, 2164, 1959, 1073, 8, 1848, 63, 6226, 9, 199, 199, 318, 3715, 8, 1210, 63, 2302, 12, 1072, 63, 694, 304, 272, 598, 270, 14, 826, 342, 272, 4438, 275, 31264, 14, 6756, 7382, 342, 339, 7679, 275, 598, 270, 14, 17562, 342, 272, 5108, 2708, 1393, 275, 598, 270, 14, 2162, 2927, 14, 1875, 360, 2302, 2708, 1393, 358, 272, 3715, 20521, 11279, 275, 598, 270, 14, 2162, 2927, 14, 1875, 360, 1294, 20521, 11279, 358, 272, 7679, 14, 525, 8, 2302, 2708, 1393, 9, 272, 7679, 14, 525, 8, 1294, 20521, 11279, 9, 339, 5108, 2708, 1393, 14, 409, 63, 1829, 360, 2302, 297, 1324, 63, 2302, 9, 272, 5108, 2708, 1393, 14, 2242, 360, 29582, 32047, 13, 15406, 297, 641, 63, 29582, 32047, 63, 15406, 12, 488, 9, 272, 5108, 2708, 1393, 14, 2242, 360, 29582, 32047, 13, 6958, 297, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
aio-libs/aiohttp_session
tests/test_nacl_storage.py
1
9303
import asyncio import json import time from typing import Any, Dict, MutableMapping, Optional, cast import nacl.secret import nacl.utils import pytest from aiohttp import web from aiohttp.test_utils import TestClient from aiohttp.web_middlewares import _Handler from nacl.encoding import Base64Encoder from aiohttp_session import Session, get_session, new_session, session_middleware from aiohttp_session.nacl_storage import NaClCookieStorage from .typedefs import AiohttpClient def test_invalid_key() -> None: with pytest.raises(ValueError): NaClCookieStorage(b'123') # short key def make_cookie( client: TestClient, secretbox: nacl.secret.SecretBox, data: Dict[str, Any] ) -> None: session_data = { 'session': data, 'created': int(time.time()) } cookie_data = json.dumps(session_data).encode('utf-8') nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE) data = secretbox.encrypt(cookie_data, nonce, encoder=Base64Encoder).decode('utf-8') # Ignoring type until aiohttp#4252 is released client.session.cookie_jar.update_cookies( {'AIOHTTP_SESSION': data} # type: ignore ) def create_app( handler: _Handler, key: bytes, max_age: Optional[int] = None ) -> web.Application: middleware = session_middleware(NaClCookieStorage(key, max_age=max_age)) app = web.Application(middlewares=[middleware]) app.router.add_route('GET', '/', handler) return app def decrypt(secretbox: nacl.secret.SecretBox, cookie_value: str) -> Any: assert type(cookie_value) == str return json.loads( secretbox.decrypt(cookie_value.encode('utf-8'), encoder=Base64Encoder).decode('utf-8') ) @pytest.fixture def secretbox(key: bytes) -> nacl.secret.SecretBox: # type: ignore[misc] # No nacl types return nacl.secret.SecretBox(key) @pytest.fixture def key() -> bytes: return nacl.utils.random(nacl.secret.SecretBox.KEY_SIZE) # type: ignore[no-any-return] async def test_create_new_session( aiohttp_client: AiohttpClient, secretbox: nacl.secret.SecretBox, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) assert isinstance(session, Session) assert session.new assert not session._changed assert cast(MutableMapping[str, Any], {}) == session return web.Response(body=b'OK') client = await aiohttp_client(create_app(handler, key)) resp = await client.get('/') assert resp.status == 200 async def test_load_existing_session( aiohttp_client: AiohttpClient, secretbox: nacl.secret.SecretBox, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) assert isinstance(session, Session) assert not session.new assert not session._changed assert cast(MutableMapping[str, Any], {'a': 1, 'b': 12}) == session return web.Response(body=b'OK') client = await aiohttp_client(create_app(handler, key)) make_cookie(client, secretbox, {'a': 1, 'b': 12}) resp = await client.get('/') assert resp.status == 200 async def test_change_session( aiohttp_client: AiohttpClient, secretbox: nacl.secret.SecretBox, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) session['c'] = 3 return web.Response(body=b'OK') client = await aiohttp_client(create_app(handler, key)) make_cookie(client, secretbox, {'a': 1, 'b': 2}) resp = await client.get('/') assert resp.status == 200 morsel = resp.cookies['AIOHTTP_SESSION'] cookie_data = decrypt(secretbox, morsel.value) assert 'session' in cookie_data assert 'a' in cookie_data['session'] assert 'b' in cookie_data['session'] assert 'c' in cookie_data['session'] assert 'created' in cookie_data assert cookie_data['session']['a'] == 1 assert cookie_data['session']['b'] == 2 assert cookie_data['session']['c'] == 3 assert morsel['httponly'] assert '/' == morsel['path'] async def test_del_cookie_on_session_invalidation( aiohttp_client: AiohttpClient, secretbox: nacl.secret.SecretBox, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) session.invalidate() return web.Response(body=b'OK') client = await aiohttp_client(create_app(handler, key)) make_cookie(client, secretbox, {'a': 1, 'b': 2}) resp = await client.get('/') assert resp.status == 200 morsel = resp.cookies['AIOHTTP_SESSION'] assert '' == morsel.value assert not morsel['httponly'] assert morsel['path'] == '/' async def test_nacl_session_fixation( aiohttp_client: AiohttpClient, secretbox: nacl.secret.SecretBox, key: bytes ) -> None: async def login(request: web.Request) -> web.StreamResponse: session = await get_session(request) session['k'] = 'v' return web.Response() async def logout(request: web.Request) -> web.StreamResponse: session = await get_session(request) session.invalidate() return web.Response() app = create_app(login, key) app.router.add_route('DELETE', '/', logout) client = await aiohttp_client(app) resp = await client.get('/') assert 'AIOHTTP_SESSION' in resp.cookies evil_cookie = resp.cookies['AIOHTTP_SESSION'].value resp = await client.delete('/') assert resp.cookies['AIOHTTP_SESSION'].value == "" # Ignoring type until aiohttp#4252 is released client.session.cookie_jar.update_cookies( {'AIOHTTP_SESSION': evil_cookie} # type: ignore ) resp = await client.get('/') assert resp.cookies['AIOHTTP_SESSION'].value != evil_cookie async def test_load_session_dont_load_expired_session( aiohttp_client: AiohttpClient, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) exp_param = request.rel_url.query.get('exp', None) if exp_param is None: session['a'] = 1 session['b'] = 2 else: assert cast(MutableMapping[str, Any], {}) == session return web.Response(body=b'OK') client = await aiohttp_client( create_app(handler, key, 2) ) resp = await client.get('/') assert resp.status == 200 await asyncio.sleep(5) resp = await client.get('/?exp=yes') assert resp.status == 200 async def test_load_corrupted_session( aiohttp_client: AiohttpClient, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) assert isinstance(session, Session) assert session.new assert cast(MutableMapping[str, Any], {}) == session return web.Response(body=b'OK') client = await aiohttp_client(create_app(handler, key)) # Ignoring type until aiohttp#4252 is released client.session.cookie_jar.update_cookies( {'AIOHTTP_SESSION': 'bad key'} # type: ignore ) resp = await client.get('/') assert resp.status == 200 async def test_load_session_different_key( aiohttp_client: AiohttpClient, key: bytes ) -> None: async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) assert isinstance(session, Session) assert session.new assert cast(MutableMapping[str, Any], {}) == session return web.Response(body=b'OK') client = await aiohttp_client(create_app(handler, key)) # create another box with another key key = nacl.utils.random(nacl.secret.SecretBox.KEY_SIZE) secretbox = nacl.secret.SecretBox(key) make_cookie(client, secretbox, {'a': 1, 'b': 12}) resp = await client.get('/') assert resp.status == 200 async def test_load_expired_session( aiohttp_client: AiohttpClient, key: bytes ) -> None: MAX_AGE = 2 async def login(request: web.Request) -> web.StreamResponse: session = await new_session(request) session['created'] = int(time.time()) return web.Response() async def handler(request: web.Request) -> web.StreamResponse: session = await get_session(request) created = session.get('created', None) if not session.new else None text = '' if created is not None and (time.time() - created) > MAX_AGE: text += 'WARNING!' return web.Response(text=text) app = create_app(handler, key, max_age=MAX_AGE) app.router.add_route('POST', '/', login) client = await aiohttp_client(app) resp = await client.post('/') assert 'AIOHTTP_SESSION' in resp.cookies cookie = resp.cookies['AIOHTTP_SESSION'].value await asyncio.sleep(MAX_AGE + 1) # Ignoring type until aiohttp#4252 is released client.session.cookie_jar.update_cookies( {'AIOHTTP_SESSION': cookie} # type: ignore ) resp = await client.get('/') body = await resp.text() assert body == ''
apache-2.0
[ 646, 16195, 199, 646, 2022, 199, 646, 900, 199, 504, 14090, 492, 6184, 12, 7448, 12, 29396, 12, 4879, 12, 9106, 199, 199, 646, 302, 5853, 14, 4731, 199, 646, 302, 5853, 14, 1208, 199, 646, 4613, 199, 504, 30274, 492, 3330, 199, 504, 30274, 14, 396, 63, 1208, 492, 1379, 3041, 199, 504, 30274, 14, 2520, 63, 14885, 758, 470, 492, 485, 2461, 199, 504, 302, 5853, 14, 2991, 492, 3523, 772, 6679, 199, 199, 504, 30274, 63, 1730, 492, 8596, 12, 664, 63, 1730, 12, 892, 63, 1730, 12, 2351, 63, 5754, 199, 504, 30274, 63, 1730, 14, 7745, 63, 3494, 492, 11290, 1968, 7810, 6408, 199, 504, 1275, 466, 8710, 492, 437, 24134, 3041, 421, 199, 318, 511, 63, 3197, 63, 498, 342, 1035, 488, 26, 272, 543, 4613, 14, 3536, 8, 3393, 304, 267, 11290, 1968, 7810, 6408, 8, 66, 7, 4288, 358, 221, 327, 3974, 790, 421, 199, 318, 1852, 63, 5306, 8, 272, 1890, 26, 1379, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 666, 26, 7448, 59, 495, 12, 6184, 61, 199, 9, 1035, 488, 26, 272, 2351, 63, 576, 275, 469, 267, 283, 1730, 356, 666, 12, 267, 283, 3966, 356, 1109, 8, 521, 14, 521, 1012, 272, 789, 339, 5494, 63, 576, 275, 2022, 14, 4180, 8, 1730, 63, 576, 680, 2143, 360, 1624, 13, 24, 358, 272, 13711, 275, 302, 5853, 14, 1208, 14, 2355, 8, 7745, 14, 4731, 14, 13790, 3532, 14, 13887, 2089, 63, 4305, 9, 272, 666, 275, 7565, 1977, 14, 11929, 8, 5306, 63, 576, 12, 13711, 12, 2490, 10295, 29, 1563, 772, 6679, 680, 2708, 360, 1624, 13, 24, 358, 339, 327, 20489, 6854, 730, 5133, 30274, 3, 20, 6390, 365, 14286, 272, 1890, 14, 1730, 14, 5306, 63, 7338, 14, 873, 63, 7792, 8, 267, 791, 33, 2090, 2856, 63, 12763, 356, 666, 93, 221, 327, 730, 26, 3686, 272, 776, 421, 199, 318, 1218, 63, 571, 8, 272, 3016, 26, 485, 2461, 12, 272, 790, 26, 2783, 12, 272, 1390, 63, 474, 26, 4879, 59, 442, 61, 275, 488, 199, 9, 1035, 3330, 14, 5039, 26, 272, 10816, 275, 2351, 63, 5754, 8, 8565, 1968, 7810, 6408, 8, 498, 12, 1390, 63, 474, 29, 988, 63, 474, 430, 272, 1145, 275, 3330, 14, 5039, 8, 14885, 758, 470, 1524, 5754, 566, 272, 1145, 14, 4995, 14, 525, 63, 4449, 360, 2970, 297, 17220, 3016, 9, 272, 372, 1145, 421, 199, 318, 20090, 8, 4731, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 5494, 63, 585, 26, 620, 9, 1035, 6184, 26, 272, 702, 730, 8, 5306, 63, 585, 9, 508, 620, 272, 372, 2022, 14, 3640, 8, 267, 7565, 1977, 14, 15682, 8, 5306, 63, 585, 14, 2143, 360, 1624, 13, 24, 659, 2079, 10295, 29, 1563, 772, 6679, 680, 2708, 360, 1624, 13, 24, 358, 272, 776, 421, 199, 32, 4462, 14, 5997, 199, 318, 7565, 1977, 8, 498, 26, 2783, 9, 1035, 302, 5853, 14, 4731, 14, 13790, 3532, 26, 221, 327, 730, 26, 3686, 59, 9923, 61, 221, 327, 3091, 302, 5853, 2943, 272, 372, 302, 5853, 14, 4731, 14, 13790, 3532, 8, 498, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 790, 342, 1035, 2783, 26, 272, 372, 302, 5853, 14, 1208, 14, 2355, 8, 7745, 14, 4731, 14, 13790, 3532, 14, 3078, 63, 4305, 9, 221, 327, 730, 26, 3686, 59, 889, 13, 1629, 13, 1107, 61, 421, 199, 4146, 347, 511, 63, 981, 63, 1222, 63, 1730, 8, 272, 30274, 63, 1258, 26, 437, 24134, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 790, 26, 2783, 199, 9, 1035, 488, 26, 339, 5316, 347, 3016, 8, 1069, 26, 3330, 14, 2017, 9, 1035, 3330, 14, 3296, 2364, 26, 267, 2351, 275, 5517, 664, 63, 1730, 8, 1069, 9, 267, 702, 1228, 8, 1730, 12, 8596, 9, 267, 702, 2351, 14, 1222, 267, 702, 440, 2351, 423, 2489, 267, 702, 9106, 8, 17707, 7674, 59, 495, 12, 6184, 467, 5009, 508, 2351, 267, 372, 3330, 14, 2364, 8, 2030, 29, 66, 7, 3593, 358, 339, 1890, 275, 5517, 30274, 63, 1258, 8, 981, 63, 571, 8, 2232, 12, 790, 430, 272, 3085, 275, 5517, 1890, 14, 362, 7825, 272, 702, 3085, 14, 1205, 508, 1926, 421, 199, 4146, 347, 511, 63, 912, 63, 5952, 63, 1730, 8, 272, 30274, 63, 1258, 26, 437, 24134, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 790, 26, 2783, 199, 9, 1035, 488, 26, 339, 5316, 347, 3016, 8, 1069, 26, 3330, 14, 2017, 9, 1035, 3330, 14, 3296, 2364, 26, 267, 2351, 275, 5517, 664, 63, 1730, 8, 1069, 9, 267, 702, 1228, 8, 1730, 12, 8596, 9, 267, 702, 440, 2351, 14, 1222, 267, 702, 440, 2351, 423, 2489, 267, 702, 9106, 8, 17707, 7674, 59, 495, 12, 6184, 467, 791, 65, 356, 413, 12, 283, 66, 356, 3144, 1552, 508, 2351, 267, 372, 3330, 14, 2364, 8, 2030, 29, 66, 7, 3593, 358, 339, 1890, 275, 5517, 30274, 63, 1258, 8, 981, 63, 571, 8, 2232, 12, 790, 430, 272, 1852, 63, 5306, 8, 1258, 12, 7565, 1977, 12, 791, 65, 356, 413, 12, 283, 66, 356, 3144, 1552, 272, 3085, 275, 5517, 1890, 14, 362, 7825, 272, 702, 3085, 14, 1205, 508, 1926, 421, 199, 4146, 347, 511, 63, 1461, 63, 1730, 8, 272, 30274, 63, 1258, 26, 437, 24134, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 790, 26, 2783, 199, 9, 1035, 488, 26, 339, 5316, 347, 3016, 8, 1069, 26, 3330, 14, 2017, 9, 1035, 3330, 14, 3296, 2364, 26, 267, 2351, 275, 5517, 664, 63, 1730, 8, 1069, 9, 267, 2351, 459, 67, 418, 275, 650, 267, 372, 3330, 14, 2364, 8, 2030, 29, 66, 7, 3593, 358, 339, 1890, 275, 5517, 30274, 63, 1258, 8, 981, 63, 571, 8, 2232, 12, 790, 430, 272, 1852, 63, 5306, 8, 1258, 12, 7565, 1977, 12, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1552, 272, 3085, 275 ]
[ 16195, 199, 646, 2022, 199, 646, 900, 199, 504, 14090, 492, 6184, 12, 7448, 12, 29396, 12, 4879, 12, 9106, 199, 199, 646, 302, 5853, 14, 4731, 199, 646, 302, 5853, 14, 1208, 199, 646, 4613, 199, 504, 30274, 492, 3330, 199, 504, 30274, 14, 396, 63, 1208, 492, 1379, 3041, 199, 504, 30274, 14, 2520, 63, 14885, 758, 470, 492, 485, 2461, 199, 504, 302, 5853, 14, 2991, 492, 3523, 772, 6679, 199, 199, 504, 30274, 63, 1730, 492, 8596, 12, 664, 63, 1730, 12, 892, 63, 1730, 12, 2351, 63, 5754, 199, 504, 30274, 63, 1730, 14, 7745, 63, 3494, 492, 11290, 1968, 7810, 6408, 199, 504, 1275, 466, 8710, 492, 437, 24134, 3041, 421, 199, 318, 511, 63, 3197, 63, 498, 342, 1035, 488, 26, 272, 543, 4613, 14, 3536, 8, 3393, 304, 267, 11290, 1968, 7810, 6408, 8, 66, 7, 4288, 358, 221, 327, 3974, 790, 421, 199, 318, 1852, 63, 5306, 8, 272, 1890, 26, 1379, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 666, 26, 7448, 59, 495, 12, 6184, 61, 199, 9, 1035, 488, 26, 272, 2351, 63, 576, 275, 469, 267, 283, 1730, 356, 666, 12, 267, 283, 3966, 356, 1109, 8, 521, 14, 521, 1012, 272, 789, 339, 5494, 63, 576, 275, 2022, 14, 4180, 8, 1730, 63, 576, 680, 2143, 360, 1624, 13, 24, 358, 272, 13711, 275, 302, 5853, 14, 1208, 14, 2355, 8, 7745, 14, 4731, 14, 13790, 3532, 14, 13887, 2089, 63, 4305, 9, 272, 666, 275, 7565, 1977, 14, 11929, 8, 5306, 63, 576, 12, 13711, 12, 2490, 10295, 29, 1563, 772, 6679, 680, 2708, 360, 1624, 13, 24, 358, 339, 327, 20489, 6854, 730, 5133, 30274, 3, 20, 6390, 365, 14286, 272, 1890, 14, 1730, 14, 5306, 63, 7338, 14, 873, 63, 7792, 8, 267, 791, 33, 2090, 2856, 63, 12763, 356, 666, 93, 221, 327, 730, 26, 3686, 272, 776, 421, 199, 318, 1218, 63, 571, 8, 272, 3016, 26, 485, 2461, 12, 272, 790, 26, 2783, 12, 272, 1390, 63, 474, 26, 4879, 59, 442, 61, 275, 488, 199, 9, 1035, 3330, 14, 5039, 26, 272, 10816, 275, 2351, 63, 5754, 8, 8565, 1968, 7810, 6408, 8, 498, 12, 1390, 63, 474, 29, 988, 63, 474, 430, 272, 1145, 275, 3330, 14, 5039, 8, 14885, 758, 470, 1524, 5754, 566, 272, 1145, 14, 4995, 14, 525, 63, 4449, 360, 2970, 297, 17220, 3016, 9, 272, 372, 1145, 421, 199, 318, 20090, 8, 4731, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 5494, 63, 585, 26, 620, 9, 1035, 6184, 26, 272, 702, 730, 8, 5306, 63, 585, 9, 508, 620, 272, 372, 2022, 14, 3640, 8, 267, 7565, 1977, 14, 15682, 8, 5306, 63, 585, 14, 2143, 360, 1624, 13, 24, 659, 2079, 10295, 29, 1563, 772, 6679, 680, 2708, 360, 1624, 13, 24, 358, 272, 776, 421, 199, 32, 4462, 14, 5997, 199, 318, 7565, 1977, 8, 498, 26, 2783, 9, 1035, 302, 5853, 14, 4731, 14, 13790, 3532, 26, 221, 327, 730, 26, 3686, 59, 9923, 61, 221, 327, 3091, 302, 5853, 2943, 272, 372, 302, 5853, 14, 4731, 14, 13790, 3532, 8, 498, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 790, 342, 1035, 2783, 26, 272, 372, 302, 5853, 14, 1208, 14, 2355, 8, 7745, 14, 4731, 14, 13790, 3532, 14, 3078, 63, 4305, 9, 221, 327, 730, 26, 3686, 59, 889, 13, 1629, 13, 1107, 61, 421, 199, 4146, 347, 511, 63, 981, 63, 1222, 63, 1730, 8, 272, 30274, 63, 1258, 26, 437, 24134, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 790, 26, 2783, 199, 9, 1035, 488, 26, 339, 5316, 347, 3016, 8, 1069, 26, 3330, 14, 2017, 9, 1035, 3330, 14, 3296, 2364, 26, 267, 2351, 275, 5517, 664, 63, 1730, 8, 1069, 9, 267, 702, 1228, 8, 1730, 12, 8596, 9, 267, 702, 2351, 14, 1222, 267, 702, 440, 2351, 423, 2489, 267, 702, 9106, 8, 17707, 7674, 59, 495, 12, 6184, 467, 5009, 508, 2351, 267, 372, 3330, 14, 2364, 8, 2030, 29, 66, 7, 3593, 358, 339, 1890, 275, 5517, 30274, 63, 1258, 8, 981, 63, 571, 8, 2232, 12, 790, 430, 272, 3085, 275, 5517, 1890, 14, 362, 7825, 272, 702, 3085, 14, 1205, 508, 1926, 421, 199, 4146, 347, 511, 63, 912, 63, 5952, 63, 1730, 8, 272, 30274, 63, 1258, 26, 437, 24134, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 790, 26, 2783, 199, 9, 1035, 488, 26, 339, 5316, 347, 3016, 8, 1069, 26, 3330, 14, 2017, 9, 1035, 3330, 14, 3296, 2364, 26, 267, 2351, 275, 5517, 664, 63, 1730, 8, 1069, 9, 267, 702, 1228, 8, 1730, 12, 8596, 9, 267, 702, 440, 2351, 14, 1222, 267, 702, 440, 2351, 423, 2489, 267, 702, 9106, 8, 17707, 7674, 59, 495, 12, 6184, 467, 791, 65, 356, 413, 12, 283, 66, 356, 3144, 1552, 508, 2351, 267, 372, 3330, 14, 2364, 8, 2030, 29, 66, 7, 3593, 358, 339, 1890, 275, 5517, 30274, 63, 1258, 8, 981, 63, 571, 8, 2232, 12, 790, 430, 272, 1852, 63, 5306, 8, 1258, 12, 7565, 1977, 12, 791, 65, 356, 413, 12, 283, 66, 356, 3144, 1552, 272, 3085, 275, 5517, 1890, 14, 362, 7825, 272, 702, 3085, 14, 1205, 508, 1926, 421, 199, 4146, 347, 511, 63, 1461, 63, 1730, 8, 272, 30274, 63, 1258, 26, 437, 24134, 3041, 12, 272, 7565, 1977, 26, 302, 5853, 14, 4731, 14, 13790, 3532, 12, 272, 790, 26, 2783, 199, 9, 1035, 488, 26, 339, 5316, 347, 3016, 8, 1069, 26, 3330, 14, 2017, 9, 1035, 3330, 14, 3296, 2364, 26, 267, 2351, 275, 5517, 664, 63, 1730, 8, 1069, 9, 267, 2351, 459, 67, 418, 275, 650, 267, 372, 3330, 14, 2364, 8, 2030, 29, 66, 7, 3593, 358, 339, 1890, 275, 5517, 30274, 63, 1258, 8, 981, 63, 571, 8, 2232, 12, 790, 430, 272, 1852, 63, 5306, 8, 1258, 12, 7565, 1977, 12, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1552, 272, 3085, 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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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 ]
deanhiller/databus
webapp/play1.3.x/python/Lib/nturl2path.py
5
2302
"""Convert a NT pathname to a file URL and vice versa.""" def url2pathname(url): """OS-specific conversion from a relative URL of the 'file' scheme to a file system path; not recommended for general use.""" # e.g. # ///C|/foo/bar/spam.foo # becomes # C:\foo\bar\spam.foo import string, urllib # Windows itself uses ":" even in URLs. url = url.replace(':', '|') if not '|' in url: # No drive specifier, just convert slashes if url[:4] == '////': # path is something like ////host/path/on/remote/host # convert this to \\host\path\on\remote\host # (notice halving of slashes at the start of the path) url = url[2:] components = url.split('/') # make sure not to convert quoted slashes :-) return urllib.unquote('\\'.join(components)) comp = url.split('|') if len(comp) != 2 or comp[0][-1] not in string.ascii_letters: error = 'Bad URL: ' + url raise IOError, error drive = comp[0][-1].upper() components = comp[1].split('/') path = drive + ':' for comp in components: if comp: path = path + '\\' + urllib.unquote(comp) return path def pathname2url(p): """OS-specific conversion from a file system path to a relative URL of the 'file' scheme; not recommended for general use.""" # e.g. # C:\foo\bar\spam.foo # becomes # ///C|/foo/bar/spam.foo import urllib if not ':' in p: # No drive specifier, just convert slashes and quote the name if p[:2] == '\\\\': # path is something like \\host\path\on\remote\host # convert this to ////host/path/on/remote/host # (notice doubling of slashes at the start of the path) p = '\\\\' + p components = p.split('\\') return urllib.quote('/'.join(components)) comp = p.split(':') if len(comp) != 2 or len(comp[0]) > 1: error = 'Bad path: ' + p raise IOError, error drive = urllib.quote(comp[0].upper()) components = comp[1].split('\\') path = '///' + drive + '|' for comp in components: if comp: path = path + '/' + urllib.quote(comp) return path
mpl-2.0
[ 624, 7306, 282, 23350, 11776, 370, 282, 570, 2851, 436, 1321, 301, 809, 2231, 1041, 2999, 199, 318, 1166, 18, 12445, 8, 633, 304, 1128, 408, 3100, 13, 6100, 8603, 687, 282, 3847, 2851, 402, 314, 283, 493, 7, 5687, 1128, 370, 282, 570, 2656, 931, 27, 440, 14318, 367, 8605, 675, 1041, 1128, 327, 325, 14, 71, 14, 1128, 327, 5001, 15, 35, 92, 15, 1421, 15, 1700, 15, 8283, 14, 1421, 1128, 327, 15410, 1128, 327, 445, 3427, 1421, 60, 1700, 60, 8283, 14, 1421, 1128, 492, 1059, 12, 4011, 1128, 327, 5417, 6337, 4440, 14725, 2755, 315, 10867, 14, 1128, 1166, 275, 1166, 14, 1814, 16451, 11280, 358, 1128, 340, 440, 24628, 315, 1166, 26, 1039, 327, 3091, 12912, 16628, 12, 2951, 3957, 20275, 1039, 340, 1166, 1491, 20, 61, 508, 283, 868, 356, 1675, 327, 931, 365, 6020, 2839, 221, 868, 1102, 15, 515, 15, 265, 15, 3846, 15, 1102, 1675, 327, 3957, 642, 370, 8522, 1102, 60, 515, 60, 265, 60, 3846, 60, 1102, 1675, 327, 334, 20556, 22939, 4007, 402, 20275, 737, 314, 1343, 402, 314, 931, 9, 1675, 1166, 275, 1166, 59, 18, 2938, 1039, 7323, 275, 1166, 14, 1294, 7825, 1039, 327, 1852, 3238, 440, 370, 3957, 10999, 20275, 22901, 9, 1039, 372, 4011, 14, 12240, 11671, 1370, 904, 8, 4608, 430, 1128, 1013, 275, 1166, 14, 1294, 20137, 358, 1128, 340, 822, 8, 863, 9, 1137, 499, 503, 1013, 59, 16, 15898, 17, 61, 440, 315, 1059, 14, 4371, 63, 16415, 26, 1039, 1125, 275, 283, 5725, 2851, 26, 283, 435, 1166, 1039, 746, 5925, 12, 1125, 1128, 12912, 275, 1013, 59, 16, 15898, 17, 1055, 4142, 342, 1128, 7323, 275, 1013, 59, 17, 1055, 1294, 7825, 1128, 931, 275, 12912, 435, 10871, 1128, 367, 221, 1013, 315, 7323, 26, 1039, 340, 1013, 26, 1675, 931, 275, 931, 435, 22548, 435, 4011, 14, 12240, 8, 863, 9, 1128, 372, 931, 2999, 199, 318, 11776, 18, 633, 8, 80, 304, 1128, 408, 3100, 13, 6100, 8603, 687, 282, 570, 2656, 931, 370, 282, 3847, 2851, 1128, 402, 314, 283, 493, 7, 5687, 27, 440, 14318, 367, 8605, 675, 1041, 1128, 327, 325, 14, 71, 14, 1128, 327, 445, 3427, 1421, 60, 1700, 60, 8283, 14, 1421, 1128, 327, 15410, 1128, 327, 5001, 15, 35, 92, 15, 1421, 15, 1700, 15, 8283, 14, 1421, 1128, 492, 4011, 1128, 340, 440, 10871, 315, 299, 26, 1039, 327, 3091, 12912, 16628, 12, 2951, 3957, 20275, 436, 6313, 314, 536, 1039, 340, 299, 1491, 18, 61, 508, 31375, 356, 1039, 327, 931, 365, 6020, 2839, 8522, 1102, 60, 515, 60, 265, 60, 3846, 60, 1102, 1039, 327, 3957, 642, 370, 221, 868, 1102, 15, 515, 15, 265, 15, 3846, 15, 1102, 1039, 327, 334, 20556, 28584, 2983, 402, 20275, 737, 314, 1343, 402, 314, 931, 9, 1675, 299, 275, 31375, 7, 435, 299, 1039, 7323, 275, 299, 14, 1294, 11671, 358, 1039, 372, 4011, 14, 3513, 2336, 1370, 904, 8, 4608, 430, 1128, 1013, 275, 299, 14, 1294, 11633, 1128, 340, 822, 8, 863, 9, 1137, 499, 503, 822, 8, 863, 59, 16, 566, 690, 413, 26, 1039, 1125, 275, 283, 5725, 931, 26, 283, 435, 299, 1039, 746, 5925, 12, 1125, 2958, 12912, 275, 4011, 14, 3513, 8, 863, 59, 16, 1055, 4142, 1012, 1128, 7323, 275, 1013, 59, 17, 1055, 1294, 11671, 358, 1128, 931, 275, 18290, 4805, 435, 12912, 435, 24628, 1128, 367, 1013, 315, 7323, 26, 1039, 340, 1013, 26, 1675, 931, 275, 931, 435, 7324, 435, 4011, 14, 3513, 8, 863, 9, 1128, 372, 931, 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 ]
[ 7306, 282, 23350, 11776, 370, 282, 570, 2851, 436, 1321, 301, 809, 2231, 1041, 2999, 199, 318, 1166, 18, 12445, 8, 633, 304, 1128, 408, 3100, 13, 6100, 8603, 687, 282, 3847, 2851, 402, 314, 283, 493, 7, 5687, 1128, 370, 282, 570, 2656, 931, 27, 440, 14318, 367, 8605, 675, 1041, 1128, 327, 325, 14, 71, 14, 1128, 327, 5001, 15, 35, 92, 15, 1421, 15, 1700, 15, 8283, 14, 1421, 1128, 327, 15410, 1128, 327, 445, 3427, 1421, 60, 1700, 60, 8283, 14, 1421, 1128, 492, 1059, 12, 4011, 1128, 327, 5417, 6337, 4440, 14725, 2755, 315, 10867, 14, 1128, 1166, 275, 1166, 14, 1814, 16451, 11280, 358, 1128, 340, 440, 24628, 315, 1166, 26, 1039, 327, 3091, 12912, 16628, 12, 2951, 3957, 20275, 1039, 340, 1166, 1491, 20, 61, 508, 283, 868, 356, 1675, 327, 931, 365, 6020, 2839, 221, 868, 1102, 15, 515, 15, 265, 15, 3846, 15, 1102, 1675, 327, 3957, 642, 370, 8522, 1102, 60, 515, 60, 265, 60, 3846, 60, 1102, 1675, 327, 334, 20556, 22939, 4007, 402, 20275, 737, 314, 1343, 402, 314, 931, 9, 1675, 1166, 275, 1166, 59, 18, 2938, 1039, 7323, 275, 1166, 14, 1294, 7825, 1039, 327, 1852, 3238, 440, 370, 3957, 10999, 20275, 22901, 9, 1039, 372, 4011, 14, 12240, 11671, 1370, 904, 8, 4608, 430, 1128, 1013, 275, 1166, 14, 1294, 20137, 358, 1128, 340, 822, 8, 863, 9, 1137, 499, 503, 1013, 59, 16, 15898, 17, 61, 440, 315, 1059, 14, 4371, 63, 16415, 26, 1039, 1125, 275, 283, 5725, 2851, 26, 283, 435, 1166, 1039, 746, 5925, 12, 1125, 1128, 12912, 275, 1013, 59, 16, 15898, 17, 1055, 4142, 342, 1128, 7323, 275, 1013, 59, 17, 1055, 1294, 7825, 1128, 931, 275, 12912, 435, 10871, 1128, 367, 221, 1013, 315, 7323, 26, 1039, 340, 1013, 26, 1675, 931, 275, 931, 435, 22548, 435, 4011, 14, 12240, 8, 863, 9, 1128, 372, 931, 2999, 199, 318, 11776, 18, 633, 8, 80, 304, 1128, 408, 3100, 13, 6100, 8603, 687, 282, 570, 2656, 931, 370, 282, 3847, 2851, 1128, 402, 314, 283, 493, 7, 5687, 27, 440, 14318, 367, 8605, 675, 1041, 1128, 327, 325, 14, 71, 14, 1128, 327, 445, 3427, 1421, 60, 1700, 60, 8283, 14, 1421, 1128, 327, 15410, 1128, 327, 5001, 15, 35, 92, 15, 1421, 15, 1700, 15, 8283, 14, 1421, 1128, 492, 4011, 1128, 340, 440, 10871, 315, 299, 26, 1039, 327, 3091, 12912, 16628, 12, 2951, 3957, 20275, 436, 6313, 314, 536, 1039, 340, 299, 1491, 18, 61, 508, 31375, 356, 1039, 327, 931, 365, 6020, 2839, 8522, 1102, 60, 515, 60, 265, 60, 3846, 60, 1102, 1039, 327, 3957, 642, 370, 221, 868, 1102, 15, 515, 15, 265, 15, 3846, 15, 1102, 1039, 327, 334, 20556, 28584, 2983, 402, 20275, 737, 314, 1343, 402, 314, 931, 9, 1675, 299, 275, 31375, 7, 435, 299, 1039, 7323, 275, 299, 14, 1294, 11671, 358, 1039, 372, 4011, 14, 3513, 2336, 1370, 904, 8, 4608, 430, 1128, 1013, 275, 299, 14, 1294, 11633, 1128, 340, 822, 8, 863, 9, 1137, 499, 503, 822, 8, 863, 59, 16, 566, 690, 413, 26, 1039, 1125, 275, 283, 5725, 931, 26, 283, 435, 299, 1039, 746, 5925, 12, 1125, 2958, 12912, 275, 4011, 14, 3513, 8, 863, 59, 16, 1055, 4142, 1012, 1128, 7323, 275, 1013, 59, 17, 1055, 1294, 11671, 358, 1128, 931, 275, 18290, 4805, 435, 12912, 435, 24628, 1128, 367, 1013, 315, 7323, 26, 1039, 340, 1013, 26, 1675, 931, 275, 931, 435, 7324, 435, 4011, 14, 3513, 8, 863, 9, 1128, 372, 931, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
SDX2000/hotwire
hotwire/builtins/json.py
1
2675
# This file is part of the Hotwire Shell project API. # Copyright (C) 2007 Colin Walters <walters@verbum.org> # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies # of the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR # THE USE OR OTHER DEALINGS IN THE SOFTWARE. import os,sys,pickle,inspect,locale from io import StringIO from hotwire.fs import FilePath from hotwire.builtin import Builtin, BuiltinRegistry, InputStreamSchema import simplejson class LossyObjectJSONDumper(simplejson.JSONEncoder): def __init__(self, *args, **kwargs): super(LossyObjectJSONDumper, self).__init__(*args, **kwargs) def default(self, o): name_repr = {} for name,member in sorted(inspect.getmembers(o), lambda a,b: locale.strcoll(a[0],b[0])): if name.startswith('_'): continue name_repr[name] = str(type(member)) return self.encode(name_repr) class JsonBuiltin(Builtin): __doc__ = _("""Convert object stream to JSON.""") def __init__(self): super(JsonBuiltin, self).__init__('json', output=str, # 'any' input=InputStreamSchema('any'), idempotent=True, argspec=None) def execute(self, context, args, options=[]): out = StringIO() for o in context.input: simplejson.dump(o, out, indent=2, cls=LossyObjectJSONDumper) # Should support binary streaming for line in StringIO(out.getvalue()): if line.endswith('\n'): yield line[0:-1] else: yield line BuiltinRegistry.getInstance().register_hotwire(JsonBuiltin())
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 314, 869, 357, 11239, 24599, 2199, 3261, 14, 199, 199, 3, 1898, 334, 35, 9, 10219, 3626, 262, 644, 31185, 665, 20877, 878, 32, 422, 7767, 14, 1308, 30, 199, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 221, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 221, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 221, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 221, 199, 3, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 221, 199, 3, 5420, 370, 314, 2569, 3704, 26, 199, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 221, 199, 3, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 5292, 12, 199, 3, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 3092, 2381, 437, 221, 199, 3, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 1323, 1868, 23447, 24967, 6262, 221, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 221, 199, 3, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 221, 199, 3, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 747, 12, 1274, 12, 8092, 12, 10955, 12, 5508, 199, 504, 5890, 492, 5228, 199, 199, 504, 18469, 11239, 14, 2319, 492, 27961, 199, 199, 504, 18469, 11239, 14, 5351, 492, 22422, 12, 22422, 10899, 12, 6924, 3296, 6700, 199, 199, 646, 13804, 199, 199, 533, 3835, 385, 89, 1692, 6243, 28593, 8, 4129, 1001, 14, 23069, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 8610, 89, 1692, 6243, 28593, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 5493, 347, 849, 8, 277, 12, 312, 304, 267, 536, 63, 2722, 275, 1052, 267, 367, 536, 12, 1114, 315, 3355, 8, 10955, 14, 28719, 8, 79, 395, 2400, 282, 12, 66, 26, 5867, 14, 495, 15772, 8, 65, 59, 16, 467, 66, 59, 16, 18710, 288, 340, 536, 14, 2460, 30018, 355, 1980, 288, 536, 63, 2722, 59, 354, 61, 275, 620, 8, 466, 8, 1114, 430, 267, 372, 291, 14, 2143, 8, 354, 63, 2722, 9, 199, 199, 533, 14587, 12306, 8, 12306, 304, 272, 636, 1301, 363, 275, 485, 4852, 7306, 909, 2547, 370, 4840, 24887, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 9653, 12306, 12, 291, 2843, 826, 19734, 1001, 297, 5101, 1072, 29, 495, 12, 327, 283, 1629, 7, 5101, 1324, 29, 27611, 6700, 360, 1629, 659, 5101, 32122, 29, 549, 12, 5101, 26632, 29, 403, 9, 339, 347, 5341, 8, 277, 12, 1067, 12, 1249, 12, 1511, 17894, 267, 734, 275, 5228, 342, 267, 367, 312, 315, 1067, 14, 1210, 26, 288, 13804, 14, 2724, 8, 79, 12, 734, 12, 4363, 29, 18, 12, 843, 29, 8610, 89, 1692, 6243, 28593, 9, 267, 327, 7719, 2291, 3366, 18490, 3777, 267, 367, 1004, 315, 5228, 8, 548, 14, 7150, 5109, 288, 340, 1004, 14, 4130, 2258, 78, 735, 355, 1995, 1004, 59, 16, 6809, 17, 61, 288, 587, 26, 355, 1995, 1004, 199, 12306, 10899, 14, 29964, 1252, 2683, 63, 8885, 11239, 8, 9653, 12306, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1777, 402, 314, 869, 357, 11239, 24599, 2199, 3261, 14, 199, 199, 3, 1898, 334, 35, 9, 10219, 3626, 262, 644, 31185, 665, 20877, 878, 32, 422, 7767, 14, 1308, 30, 199, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 221, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 221, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 221, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 221, 199, 3, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 221, 199, 3, 5420, 370, 314, 2569, 3704, 26, 199, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 221, 199, 3, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 5292, 12, 199, 3, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 3092, 2381, 437, 221, 199, 3, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 1323, 1868, 23447, 24967, 6262, 221, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 221, 199, 3, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 221, 199, 3, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 199, 646, 747, 12, 1274, 12, 8092, 12, 10955, 12, 5508, 199, 504, 5890, 492, 5228, 199, 199, 504, 18469, 11239, 14, 2319, 492, 27961, 199, 199, 504, 18469, 11239, 14, 5351, 492, 22422, 12, 22422, 10899, 12, 6924, 3296, 6700, 199, 199, 646, 13804, 199, 199, 533, 3835, 385, 89, 1692, 6243, 28593, 8, 4129, 1001, 14, 23069, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 8610, 89, 1692, 6243, 28593, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 5493, 347, 849, 8, 277, 12, 312, 304, 267, 536, 63, 2722, 275, 1052, 267, 367, 536, 12, 1114, 315, 3355, 8, 10955, 14, 28719, 8, 79, 395, 2400, 282, 12, 66, 26, 5867, 14, 495, 15772, 8, 65, 59, 16, 467, 66, 59, 16, 18710, 288, 340, 536, 14, 2460, 30018, 355, 1980, 288, 536, 63, 2722, 59, 354, 61, 275, 620, 8, 466, 8, 1114, 430, 267, 372, 291, 14, 2143, 8, 354, 63, 2722, 9, 199, 199, 533, 14587, 12306, 8, 12306, 304, 272, 636, 1301, 363, 275, 485, 4852, 7306, 909, 2547, 370, 4840, 24887, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 9653, 12306, 12, 291, 2843, 826, 19734, 1001, 297, 5101, 1072, 29, 495, 12, 327, 283, 1629, 7, 5101, 1324, 29, 27611, 6700, 360, 1629, 659, 5101, 32122, 29, 549, 12, 5101, 26632, 29, 403, 9, 339, 347, 5341, 8, 277, 12, 1067, 12, 1249, 12, 1511, 17894, 267, 734, 275, 5228, 342, 267, 367, 312, 315, 1067, 14, 1210, 26, 288, 13804, 14, 2724, 8, 79, 12, 734, 12, 4363, 29, 18, 12, 843, 29, 8610, 89, 1692, 6243, 28593, 9, 267, 327, 7719, 2291, 3366, 18490, 3777, 267, 367, 1004, 315, 5228, 8, 548, 14, 7150, 5109, 288, 340, 1004, 14, 4130, 2258, 78, 735, 355, 1995, 1004, 59, 16, 6809, 17, 61, 288, 587, 26, 355, 1995, 1004, 199, 12306, 10899, 14, 29964, 1252, 2683, 63, 8885, 11239, 8, 9653, 12306, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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from PIL import Image img_path = '/home/palm/deep/helen/train' lab_path = '/home/palm/deep/helen/annotation' filename = '/home/palm/deep/helen/trainnames.txt' f = open(filename) index = 1 for each in f: each = each.strip() img_file = os.path.join(img_path, each + '.jpg') img = Image.open(img_file) width, height = img.size img = img.resize((256, 256)) img = img.convert('L') lab_file = os.path.join(lab_path, str(index) + '.txt') fl = open(lab_file) for line in fl: line = line.strip() item = line.split(',') if len(item) == 2: x = int(float(item[0]) * 256 / width) y = int(float(item[1]) * 256 / height) if x > 0 and x < img.size[0] and y > 0 and y < img.size[1]: img.putpixel((x, y), 0xffffff) img.putpixel((x-1, y), 0xffffff) img.putpixel((x, y-1), 0xffffff) img.putpixel((x-1, y-1), 0xffffff) else: print index, each, img.size, x, y index += 1 img.show() break
apache-2.0
[ 646, 747, 199, 504, 14937, 492, 6047, 199, 199, 4060, 63, 515, 275, 1994, 4219, 15, 21516, 77, 15, 16131, 15, 426, 552, 15, 2834, 7, 199, 5561, 63, 515, 275, 1994, 4219, 15, 21516, 77, 15, 16131, 15, 426, 552, 15, 9340, 7, 199, 199, 1501, 275, 1994, 4219, 15, 21516, 77, 15, 16131, 15, 426, 552, 15, 2834, 1247, 14, 2424, 7, 199, 199, 70, 275, 1551, 8, 1501, 9, 199, 1080, 275, 413, 199, 509, 1924, 315, 289, 26, 272, 1924, 275, 1924, 14, 1913, 342, 272, 6050, 63, 493, 275, 747, 14, 515, 14, 904, 8, 4060, 63, 515, 12, 1924, 435, 1987, 8476, 358, 272, 6050, 275, 6047, 14, 1490, 8, 4060, 63, 493, 9, 272, 3462, 12, 4569, 275, 6050, 14, 890, 339, 6050, 275, 6050, 14, 8709, 1332, 3912, 12, 7633, 430, 272, 6050, 275, 6050, 14, 3916, 360, 44, 358, 339, 19888, 63, 493, 275, 747, 14, 515, 14, 904, 8, 5561, 63, 515, 12, 620, 8, 1080, 9, 435, 1987, 2424, 358, 272, 2717, 275, 1551, 8, 5561, 63, 493, 9, 272, 367, 1004, 315, 2717, 26, 267, 1004, 275, 1004, 14, 1913, 342, 267, 1242, 275, 1004, 14, 1294, 11917, 267, 340, 822, 8, 1053, 9, 508, 499, 26, 288, 671, 275, 1109, 8, 1609, 8, 1053, 59, 16, 566, 627, 7633, 1182, 3462, 9, 288, 612, 275, 1109, 8, 1609, 8, 1053, 59, 17, 566, 627, 7633, 1182, 4569, 9, 288, 340, 671, 690, 378, 436, 671, 665, 6050, 14, 890, 59, 16, 61, 436, 612, 690, 378, 436, 612, 665, 6050, 14, 890, 59, 17, 2189, 355, 6050, 14, 524, 8435, 1332, 88, 12, 612, 395, 378, 3581, 4717, 9, 355, 6050, 14, 524, 8435, 1332, 88, 13, 17, 12, 612, 395, 378, 3581, 4717, 9, 355, 6050, 14, 524, 8435, 1332, 88, 12, 612, 13, 17, 395, 378, 3581, 4717, 9, 355, 6050, 14, 524, 8435, 1332, 88, 13, 17, 12, 612, 13, 17, 395, 378, 3581, 4717, 9, 288, 587, 26, 355, 870, 1478, 12, 1924, 12, 6050, 14, 890, 12, 671, 12, 612, 339, 1478, 847, 413, 339, 6050, 14, 2384, 342, 272, 2059, 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 ]
[ 747, 199, 504, 14937, 492, 6047, 199, 199, 4060, 63, 515, 275, 1994, 4219, 15, 21516, 77, 15, 16131, 15, 426, 552, 15, 2834, 7, 199, 5561, 63, 515, 275, 1994, 4219, 15, 21516, 77, 15, 16131, 15, 426, 552, 15, 9340, 7, 199, 199, 1501, 275, 1994, 4219, 15, 21516, 77, 15, 16131, 15, 426, 552, 15, 2834, 1247, 14, 2424, 7, 199, 199, 70, 275, 1551, 8, 1501, 9, 199, 1080, 275, 413, 199, 509, 1924, 315, 289, 26, 272, 1924, 275, 1924, 14, 1913, 342, 272, 6050, 63, 493, 275, 747, 14, 515, 14, 904, 8, 4060, 63, 515, 12, 1924, 435, 1987, 8476, 358, 272, 6050, 275, 6047, 14, 1490, 8, 4060, 63, 493, 9, 272, 3462, 12, 4569, 275, 6050, 14, 890, 339, 6050, 275, 6050, 14, 8709, 1332, 3912, 12, 7633, 430, 272, 6050, 275, 6050, 14, 3916, 360, 44, 358, 339, 19888, 63, 493, 275, 747, 14, 515, 14, 904, 8, 5561, 63, 515, 12, 620, 8, 1080, 9, 435, 1987, 2424, 358, 272, 2717, 275, 1551, 8, 5561, 63, 493, 9, 272, 367, 1004, 315, 2717, 26, 267, 1004, 275, 1004, 14, 1913, 342, 267, 1242, 275, 1004, 14, 1294, 11917, 267, 340, 822, 8, 1053, 9, 508, 499, 26, 288, 671, 275, 1109, 8, 1609, 8, 1053, 59, 16, 566, 627, 7633, 1182, 3462, 9, 288, 612, 275, 1109, 8, 1609, 8, 1053, 59, 17, 566, 627, 7633, 1182, 4569, 9, 288, 340, 671, 690, 378, 436, 671, 665, 6050, 14, 890, 59, 16, 61, 436, 612, 690, 378, 436, 612, 665, 6050, 14, 890, 59, 17, 2189, 355, 6050, 14, 524, 8435, 1332, 88, 12, 612, 395, 378, 3581, 4717, 9, 355, 6050, 14, 524, 8435, 1332, 88, 13, 17, 12, 612, 395, 378, 3581, 4717, 9, 355, 6050, 14, 524, 8435, 1332, 88, 12, 612, 13, 17, 395, 378, 3581, 4717, 9, 355, 6050, 14, 524, 8435, 1332, 88, 13, 17, 12, 612, 13, 17, 395, 378, 3581, 4717, 9, 288, 587, 26, 355, 870, 1478, 12, 1924, 12, 6050, 14, 890, 12, 671, 12, 612, 339, 1478, 847, 413, 339, 6050, 14, 2384, 342, 272, 2059, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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------------- * Pre-1850 temperate broadleaved deciduous forest * Harvest forest. * Grassland from 1850-1982, mowed (+/- annually - DO NOT SIMULATE MOWING :P) * burnt prior to planting * At start of experiment aboveground biomass 5.5-11 kg C m-2 * Needleaf forest planted in 1983 Spin-up the model to a steady state. Recycle the met data in batches of a 50 years (over and over), until the SOM, plant and litter C pools cease to change. -> Spinup with forest params, fixed NDEP, fixed CO2 . -> Vary NDEP/CO2 for about 200 odd yrs...using grassland params so that we get through the industrial to the 1980s period. """ import os import shutil import sys import subprocess import numpy as np from gday import gday as model from gday import adjust_gday_param_file as ad from gday._version import __version__ as git_revision __author__ = "Martin De Kauwe" __version__ = "1.0 (14.12.2014)" __email__ = "mdekauwe@gmail.com" def main(experiment_id, site, SPIN_UP=True, POST_INDUST=True, SPIN_UP_SIMS=True): base_dir = os.path.dirname(os.getcwd()) # dir names base_param_name = "base_start" base_dir = os.path.dirname(os.getcwd()) base_param_dir = "/Users/mq42056055/Documents/gdayFresh/example/params" param_dir = os.path.join(base_dir, "params") met_dir = os.path.join(base_dir, "met_data") run_dir = os.path.join(base_dir, "outputs") if SPIN_UP == True: # copy base files to make two new experiment files shutil.copy(os.path.join(base_param_dir, base_param_name + ".cfg"), os.path.join(param_dir, "%s_%s_model_spinup.cfg" % \ (experiment_id, site))) # Run model to equilibrium assuming forest, growing C pools from effectively # zero itag = "%s_%s_model_spinup" % (experiment_id, site) otag = "%s_%s_model_spunup" % (experiment_id, site) mtag = "%s_met_data_equilibrium_50_yrs.csv" % (site) out_fn = itag + "_equilib.out" out_param_fname = os.path.join(param_dir, otag + ".cfg") cfg_fname = os.path.join(param_dir, itag + ".cfg") met_fname = os.path.join(met_dir, mtag) out_fname = os.path.join(run_dir, out_fn) replace_dict = { # git stuff "git_hash": str(git_revision), # files "out_param_fname": "%s" % (out_param_fname), "cfg_fname": "%s" % (cfg_fname), "met_fname": "%s" % (met_fname), "out_fname": "%s" % (out_fname), # state - default C:N 25. "age": "0.0", "canht": "17.0", # Canopy height increased from 16m in 2001 to 18m in 2004 at Duke "activesoil": "0.001", "activesoiln": "0.00004", "age": "0.0", "branch": "0.001", "branchn": "0.00004", "cstore": "0.001", "inorgn": "0.00004", "metabsoil": "0.0", "metabsoiln": "0.0", "metabsurf": "0.0", "metabsurfn": "0.0", "nstore": "0.00004", "passivesoil": "0.001", "passivesoiln": "0.0004", "prev_sma": "1.0", "root": "0.001", "root_depth": "-9999.9", "rootn": "0.00004", "sapwood": "0.001", "shoot": "0.001", "shootn": "0.00004", "slowsoil": "0.001", "slowsoiln": "0.00004", "stem": "0.001", "stemn": "0.00004", "stemnimm": "0.00004", "stemnmob": "0.0", "structsoil": "0.001", "structsoiln": "0.00004", "structsurf": "0.001", "structsurfn": "0.00004", "croot": "0.0", # don't simulate coarse roots "crootn": "0.0", # don't simulate coarse roots # parameters "latitude": "35.9", "intercep_frac": "0.15", "max_intercep_lai": "3.0", "albedo": "0.123", # modis site avg "finesoil": "0.51", # set based on silt+clay fractions of topsoil 0.42+0.09=0.5 "slamax": "4.4", # Protocol [m2 kg-1 DW] "sla": "4.4", # Protocol [m2 kg-1 DW] "slazero": "4.4", # Protocol [m2 kg-1 DW] "cfracts": "0.5", "lai_closed": "0.5", # I am effectively turning this feature off by setting it so low #"c_alloc_fmax": "0.25", #"c_alloc_fmin": "0.25", #"c_alloc_rmax": "0.05", #"c_alloc_rmin": "0.05", #"c_alloc_bmax": "0.2", #"c_alloc_bmin": "0.2", #"c_alloc_fmax": "0.3", #"c_alloc_fmin": "0.3", #"c_alloc_rmax": "0.3", #"c_alloc_rmin": "0.3", #"c_alloc_bmax": "0.2", #"c_alloc_bmin": "0.2", #"c_alloc_cmax": "0.0", # turn off coarse roots! "c_alloc_fmax": "0.35", "c_alloc_fmin": "0.15", "c_alloc_rmax": "0.35", "c_alloc_rmin": "0.05", "c_alloc_bmax": "0.1", "c_alloc_bmin": "0.1", "c_alloc_cmax": "0.0", # turn off coarse roots! "fretrans": "0.5", "rretrans": "0.0", "bretrans": "0.0", "wretrans": "0.0", "ncwnewz": "0.003", "ncwnew": "0.003", "ncwimmz": "0.003", "ncwimm": "0.003", "ncbnewz": "0.003", "ncbnew": "0.003", "ncrfac": "0.8", "ncmaxfyoung": "0.04", "ncmaxfold": "0.04", "ncmaxr": "0.03", "retransmob": "0.0", "fdecay": "0.59988", # Protocol [years-1] "fdecaydry": "0.59988", # Protocol "rdecay": "0.33333", # Protocol "rdecaydry": "0.33333", # Protocol "bdecay": "0.02", # No data, assuming 50 years "wdecay": "0.02", "crdecay": "0.00", # turn off coarse roots! "watdecaydry": "0.0", "watdecaywet": "0.1", "ligshoot": "0.24", # Based on White et al. 2000 for ENF "ligroot": "0.22", # Based on White et al. 2000 "rateuptake": "3.0", # set somewhat (very) arbitarly to get an LAI ~ 4. "rateloss": "0.5", "wcapac_root": "96.75", # [mm] (FC (m3/m-3)-WP (m3/m-3)) * rooting_depth (mm) using derived values and depth from protocol, 750 mm (FC=0.164 - WP=0.035) "wcapac_topsoil": "25.8", # [mm] (FC (m3/m-3)-WP (m3/m-3)) * rooting_depth (mm) using derived values and depth from protocol, assuming 200 mm top soil following Corbeels 2005a (FC=0.164 - WP=0.035) "ctheta_topsoil": "0.5", # Derive based on soil type clay_loam "ntheta_topsoil": "5.0", # Derive based on soil type clay_loam "ctheta_root": "0.4", # Derive based on soil type clay "ntheta_root": "3.0", # Derive based on soil type clay "topsoil_type": "clay_loam", "rootsoil_type": "clay", "measurement_temp": "25.0", "dz0v_dh": "0.075", # However I have used value from Jarvis, quoted in Jones 1992, pg. 67. Produces a value within the bounds of 3.5-1.1 mol m-2 s-1 Drake, 2010, GCB for canht=17 "displace_ratio": "0.78", "g1": "2.74", #"jmaxna": "60.0", # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg! #"jmaxnb": "0.0", # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg! #"vcmaxna": "30.61",# Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg! #"vcmaxnb": "0.0", # Original values Belinda had, I think based on Crous 2008, fig 2. Although those values I think are measured at 28 and 30 deg, the assumption being here that this is the same as 25 deg! "vcmaxna": "22.29", "vcmaxnb": "8.45", "jv_slope": "1.86", "jv_intercept": "0.0", "sapturnover": "0.1", "heighto": "4.826", "htpower": "0.35", "height0": "5.0", "height1": "20.0", "leafsap0": "8000.0", "leafsap1": "3060.0", # Duke protocol "branch0": "5.61", "branch1": "0.346", "targ_sens": "0.5", "density": "420.0", # control "adjust_rtslow": "false", # priming, off "alloc_model": "allometric", "assim_model": "mate", "calc_sw_params": "false", #false=use fwp values, true=derive them "deciduous_model": "false", "disturbance": "0", "exudation": "false", "fixed_stem_nc": "true", "fixleafnc": "false", "grazing": "false", "gs_model": "medlyn", "model_optroot": "false", "modeljm": "2", "ncycle": "true", "nuptake_model": "2", "passiveconst": "false", "print_options": "end", "ps_pathway": "c3", "respiration_model": "fixed", "strfloat": "0", "sw_stress_model": "1", # Sands and Landsberg "trans_model": "1", "use_eff_nc": "0", "use_leuning": "0", "water_stress": "true", } ad.adjust_param_file(cfg_fname, replace_dict) G = model.Gday(cfg_fname, spin_up=True) G.spin_up_pools() if POST_INDUST == True: # run for 200 odd years post industrial with increasing co2/ndep # we are swapping forest params for grass params now # copy spunup base files to make two new experiment files shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)), os.path.join(param_dir, "%s_%s_model_spunup_adj.cfg" % (experiment_id, site))) itag = "%s_%s_model_spunup_adj" % (experiment_id, site) otag = "%s_%s_model_indust" % (experiment_id, site) mtag = "%s_met_data_industrial_to_present_1850_1983.csv" % (site) out_fn = itag + "_indust.out" out_param_fname = os.path.join(param_dir, otag + ".cfg") cfg_fname = os.path.join(param_dir, itag + ".cfg") print cfg_fname met_fname = os.path.join(met_dir, mtag) out_fname = os.path.join(run_dir, out_fn) replace_dict = { # git stuff "git_hash": str(git_revision), # files "out_param_fname": "%s" % (out_param_fname), "cfg_fname": "%s" % (cfg_fname), "met_fname": "%s" % (met_fname), "out_fname": "%s" % (out_fname), # state - default C:N 25. "age": "0.0", "branch": "0.0", "branchn": "0.0", "canht": "0.79", # Taken default C3grass value from JULES "cstore": "0.001", "nstore": "0.00004", "croot": "0.0", # don't simulate coarse roots "crootn": "0.0", # don't simulate coarse roots "root": "0.001", "rootn": "0.00004", "sapwood": "0.0", "shoot": "0.001", "shootn": "0.00004", "stem": "0.0", "stemn": "0.0", "stemnimm": "0.0", "stemnmob": "0.0", "nepsum": "0.0", "nppsum": "0.0", # parameters "ligshoot": "0.09", # Smith et al. 2000, GRASS "ligroot": "0.22", # Smith et al. 2000 "age": "1.0", "slamax": "6.0", "sla": "6.0", "slazero": "6.0", "cfracts": "0.5", "lai_closed": "0.5", # I am effectively turning this feature off by setting it so low "c_alloc_fmax": "0.8", "c_alloc_fmin": "0.2", "c_alloc_rmax": "0.8", "c_alloc_rmin": "0.2", "c_alloc_bmax": "0.0", "c_alloc_bmin": "0.0", "c_alloc_cmax": "0.0", # turn off coarse roots! "fretrans": "0.4", "rretrans": "0.0", "bretrans": "0.0", "wretrans": "0.0", "ncwnewz": "0.0", "ncwnew": "0.0", "ncwimmz": "0.0", "ncwimm": "0.0", "ncbnewz": "0.0", "ncbnew": "0.0", "ncrfac": "0.7", "ncmaxfyoung": "0.035", "ncmaxfold": "0.035", "ncmaxr": "0.0287", "retransmob": "0.0", "fdecay": "1.0", "fdecaydry": "1.0", "rdecay": "1.0", "rdecaydry": "1.0", "bdecay": "0.0", "wdecay": "0.0", "watdecaydry": "0.0", "watdecaywet": "0.1", "crdecay": "0.00", # turn off coarse roots! "dz0v_dh": "0.10", # Taken default C3grass value from JULES "displace_ratio": "0.64", #Jones 1992, pg. 67. "z0h_z0m": "1.0", # Assume z0m = z0h, probably a big assumption [as z0h often < z0m.], see comment in code!! "jmaxna": "62.0", # assuming j = v * 2 "jmaxnb": "0.0", # assuming no intercept "vcmaxna": "31.0", # C3 grasses - CLM4 tech doc, table 8.2, Oleson et al 2010, page 176 "vcmaxnb": "0.0", # assuming no intercept # control "adjust_rtslow": "false", # priming, off "alloc_model": "grasses", "assim_model": "mate", "calc_sw_params": "false", #false=use fwp values, true=derive them "deciduous_model": "false", "disturbance": "0", "exudation": "false", "fixed_stem_nc": "true", "fixleafnc": "false", "grazing": "false", "gs_model": "medlyn", "model_optroot": "false", "modeljm": "1", "nuptake_model": "2", "ncycle": "true", "passiveconst": "false", "print_options": "end", "ps_pathway": "c3", "respiration_model": "fixed", "strfloat": "0", "sw_stress_model": "1", # Sands and Landsberg "trans_model": "1", "use_eff_nc": "0", "use_leuning": "0", "water_stress": "true", } ad.adjust_param_file(cfg_fname, replace_dict) G = model.Gday(cfg_fname) G.run_sim() if SPIN_UP_SIMS: # ## Equilib # # copy spunup base files to make two new experiment files shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)), os.path.join(param_dir, "%s_%s_model_spunup_trace.cfg" % (experiment_id, site))) itag = "%s_%s_model_spunup_trace" % (experiment_id, site) otag = "%s_%s_model_indust" % (experiment_id, site) mtag = "%s_met_data_preindust_traceability_equilib.csv" % (site) out_fn = "D1GDAY%sSU280.csv" % (site) out_param_fname = os.path.join(param_dir, otag + ".cfg") cfg_fname = os.path.join(param_dir, itag + ".cfg") met_fname = os.path.join(met_dir, mtag) out_fname = os.path.join(run_dir, out_fn) replace_dict = { # git stuff "git_hash": str(git_revision), # files "out_param_fname": "%s" % (out_param_fname), "cfg_fname": "%s" % (cfg_fname), "met_fname": "%s" % (met_fname), "out_fname": "%s" % (out_fname), "print_options": "daily", } ad.adjust_param_file(cfg_fname, replace_dict) G = model.Gday(cfg_fname) G.run_sim() # translate output to NCEAS style output # add this directory to python search path so we can find the scripts! sys.path.append(os.path.join(base_dir, "scripts")) import translate_GDAY_output_to_NCEAS_format as tr tr.translate_output(out_fname, met_fname) # ## Equilib - amb # # copy spunup base files to make two new experiment files shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)), os.path.join(param_dir, "%s_%s_model_spunup_trace.cfg" % (experiment_id, site))) itag = "%s_%s_model_spunup_trace" % (experiment_id, site) otag = "%s_%s_model_indust" % (experiment_id, site) mtag = "%s_met_data_amb_traceability_equilib.csv" % (site) out_fn = "D1GDAY%sSUAMB.csv" % (site) out_param_fname = os.path.join(param_dir, otag + ".cfg") cfg_fname = os.path.join(param_dir, itag + ".cfg") met_fname = os.path.join(met_dir, mtag) out_fname = os.path.join(run_dir, out_fn) replace_dict = { # git stuff "git_hash": str(git_revision), # files "out_param_fname": "%s" % (out_param_fname), "cfg_fname": "%s" % (cfg_fname), "met_fname": "%s" % (met_fname), "out_fname": "%s" % (out_fname), "print_options": "daily", } ad.adjust_param_file(cfg_fname, replace_dict) G = model.Gday(cfg_fname) G.run_sim() # translate output to NCEAS style output # add this directory to python search path so we can find the scripts! sys.path.append(os.path.join(base_dir, "scripts")) import translate_GDAY_output_to_NCEAS_format as tr tr.translate_output(out_fname, met_fname) # ## Equilib - ele # # copy spunup base files to make two new experiment files shutil.copy(os.path.join(param_dir, "%s_%s_model_spunup.cfg" % (experiment_id, site)), os.path.join(param_dir, "%s_%s_model_spunup_trace.cfg" % (experiment_id, site))) itag = "%s_%s_model_spunup_trace" % (experiment_id, site) otag = "%s_%s_model_indust" % (experiment_id, site) mtag = "%s_met_data_ele_traceability_equilib.csv" % (site) out_fn = "D1GDAY%sSUELE.csv" % (site) out_param_fname = os.path.join(param_dir, otag + ".cfg") cfg_fname = os.path.join(param_dir, itag + ".cfg") met_fname = os.path.join(met_dir, mtag) out_fname = os.path.join(run_dir, out_fn) replace_dict = { # git stuff "git_hash": str(git_revision), # files "out_param_fname": "%s" % (out_param_fname), "cfg_fname": "%s" % (cfg_fname), "met_fname": "%s" % (met_fname), "out_fname": "%s" % (out_fname), "print_options": "daily", } ad.adjust_param_file(cfg_fname, replace_dict) G = model.Gday(cfg_fname) G.run_sim() # translate output to NCEAS style output # add this directory to python search path so we can find the scripts! sys.path.append(os.path.join(base_dir, "scripts")) import translate_GDAY_output_to_NCEAS_format as tr tr.translate_output(out_fname, met_fname) if __name__ == "__main__": experiment_id = "NCEAS" site = "DUKE" main(experiment_id, site, SPIN_UP=True, POST_INDUST=True)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 577, 85, 415, 10751, 5332, 367, 653, 2089, 1179, 481, 4121, 11805, 9948, 199, 8972, 27829, 26, 199, 8684, 199, 10, 5543, 13, 1085, 1400, 2388, 281, 323, 330, 5063, 274, 4292, 477, 7504, 7514, 27882, 199, 10, 25378, 13981, 27882, 14, 199, 10, 598, 82, 405, 9688, 687, 6155, 1400, 13, 1167, 2564, 12, 333, 583, 379, 334, 19616, 13, 21172, 3163, 446, 3506, 2845, 428, 1469, 1293, 1951, 10362, 55, 1206, 520, 48, 9, 199, 10, 330, 300, 343, 6791, 370, 1620, 867, 316, 199, 10, 2854, 1343, 402, 11805, 3432, 3928, 12111, 676, 405, 959, 14, 21, 13, 845, 31746, 445, 333, 13, 18, 199, 10, 14012, 8914, 27882, 8683, 471, 315, 5851, 2658, 199, 199, 15519, 13, 384, 314, 1402, 370, 282, 308, 13558, 89, 1174, 14, 799, 7612, 314, 7647, 666, 315, 19593, 402, 282, 221, 199, 1400, 17399, 334, 1883, 436, 1806, 395, 5133, 314, 3562, 45, 12, 1620, 867, 436, 28649, 351, 445, 20092, 10142, 482, 370, 221, 199, 1461, 14, 199, 199, 5118, 428, 7751, 384, 543, 27882, 1862, 12, 6317, 653, 10814, 12, 6317, 5099, 18, 1275, 199, 5118, 812, 695, 653, 10814, 15, 1439, 18, 367, 3595, 1926, 16699, 612, 2393, 1396, 4941, 7192, 405, 9688, 1862, 880, 626, 781, 664, 2043, 4012, 314, 315, 2033, 816, 279, 370, 314, 5851, 1257, 83, 6247, 14, 199, 624, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 984, 199, 646, 3873, 199, 646, 2680, 465, 980, 199, 504, 486, 2977, 492, 486, 2977, 465, 1402, 199, 504, 486, 2977, 492, 11311, 63, 71, 2977, 63, 635, 63, 493, 465, 1503, 199, 504, 486, 2977, 423, 1023, 492, 636, 1023, 363, 465, 6135, 63, 5792, 199, 199, 363, 2502, 363, 221, 275, 298, 45, 26788, 1487, 1804, 3844, 1129, 2, 199, 363, 1023, 363, 275, 298, 17, 14, 16, 334, 1079, 14, 713, 14, 7280, 2924, 199, 363, 2123, 363, 257, 275, 298, 77, 271, 75, 3844, 1129, 32, 6799, 14, 957, 2, 421, 199, 318, 2446, 8, 10873, 63, 344, 12, 4770, 12, 6988, 568, 63, 2160, 29, 549, 12, 8761, 63, 3192, 7698, 29, 549, 12, 6988, 568, 63, 2160, 63, 16590, 51, 29, 549, 304, 272, 1300, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 9458, 1012, 2286, 327, 2935, 1561, 272, 1300, 63, 635, 63, 354, 275, 298, 1095, 63, 928, 2, 272, 1300, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 9458, 1012, 272, 1300, 63, 635, 63, 694, 275, 3286, 12117, 15, 8334, 25102, 15789, 1229, 15, 26872, 15, 71, 2977, 38, 2107, 15, 2694, 15, 1162, 2, 272, 1215, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 1162, 531, 272, 7647, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 10207, 63, 576, 531, 272, 1255, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 4467, 531, 17635, 340, 6988, 568, 63, 2160, 508, 715, 26, 13857, 327, 1331, 1300, 1584, 370, 1852, 2877, 892, 11805, 1584, 267, 5145, 14, 1574, 8, 736, 14, 515, 14, 904, 8, 1095, 63, 635, 63, 694, 12, 1300, 63, 635, 63, 354, 435, 3680, 4128, 1288, 463, 490, 747, 14, 515, 14, 904, 8, 635, 63, 694, 12, 2071, 83, 4970, 83, 63, 1238, 63, 14809, 384, 14, 4128, 2, 450, 971, 490, 334, 10873, 63, 344, 12, 4770, 1724, 2728, 327, 3378, 1402, 370, 325, 783, 773, 322, 453, 18002, 27882, 12, 20772, 316, 445, 20092, 687, 27881, 267, 327, 4697, 267, 284, 1450, 275, 2071, 83, 4970, 83, 63, 1238, 63, 14809, 384, 2, 450, 334, 10873, 63, 344, 12, 4770, 9, 267, 312, 1450, 275, 2071, 83, 4970, 83, 63, 1238, 63, 681, 324, 384, 2, 450, 334, 10873, 63, 344, 12, 4770, 9, 267, 333, 1450, 275, 2071, 83, 63, 10207, 63, 576, 63, 69, 783, 773, 322, 453, 63, 1400, 63, 89, 2393, 14, 4737, 2, 450, 334, 2124, 9, 267, 734, 63, 2324, 275, 284, 1450, 435, 2668, 69, 783, 773, 14, 548, 2, 4960, 734, 63, 635, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 635, 63, 694, 12, 312, 1450, 435, 3680, 4128, 531, 267, 4810, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 635, 63, 694, 12, 284, 1450, 435, 3680, 4128, 531, 267, 7647, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 10207, 63, 694, 12, 333, 1450, 9, 267, 734, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 1065, 63, 694, 12, 734, 63, 2324, 9, 2728, 3350, 63, 807, 275, 469, 221, 586, 327, 6135, 8292, 586, 298, 3187, 63, 2227, 582, 620, 8, 3187, 63, 5792, 395, 1993, 586, 327, 1584, 586, 298, 548, 63, 635, 63, 5252, 582, 2071, 83, 2, 450, 334, 548, 63, 635, 63, 5252, 395, 586, 298, 4128, 63, 5252, 582, 2071, 83, 2, 450, 334, 4128, 63, 5252, 395, 586, 298, 10207, 63, 5252, 582, 2071, 83, 2, 450, 334, 10207, 63, 5252, 395, 586, 298, 548, 63, 5252, 582, 2071, 83, 2, 450, 334, 548, 63, 5252, 395, 2079, 586, 327, 1174, 446, 849, 445, 26, 46, 5661, 14, 586, 298, 474, 582, 298, 16, 14, 16, 401, 586, 298, 2425, 517, 582, 298, 1196, 14, 16, 401, 327, 6855, 927, 4569, 10035, 11185, 687, 3193, 77, 315, 12521, 370, 6155, 77, 315, 8353, 737, 577, 85, 415, 586, 298, 5416, 2310, 79, 382, 582, 298, 16, 14, 4587, 401, 586, 298, 5416, 2310, 79, 382, 78, 582, 298, 16, 14, 993, 20, 401, 586, 298, 474, 582, 298, 16, 14, 16, 401, 586, 298, 4694, 582, 298, 16, 14, 4587, 401, 586, 298, 4694, 78, 582, 298, 16, 14, 993, 20, 401, 586, 298, 67, 1617, 582, 298, 16, 14, 4587, 401, 586, 298, 262, 269, 784, 582, 298, 16, 14, 993, 20, 401, 586, 298, 278, 2902, 1152, 382, 582, 298, 16, 14, 16, 401, 586, 298, 278, 2902, 1152, 382, 78, 582, 298, 16, 14, 16, 401, 586, 298, 278, 8741, 300, 70 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 577, 85, 415, 10751, 5332, 367, 653, 2089, 1179, 481, 4121, 11805, 9948, 199, 8972, 27829, 26, 199, 8684, 199, 10, 5543, 13, 1085, 1400, 2388, 281, 323, 330, 5063, 274, 4292, 477, 7504, 7514, 27882, 199, 10, 25378, 13981, 27882, 14, 199, 10, 598, 82, 405, 9688, 687, 6155, 1400, 13, 1167, 2564, 12, 333, 583, 379, 334, 19616, 13, 21172, 3163, 446, 3506, 2845, 428, 1469, 1293, 1951, 10362, 55, 1206, 520, 48, 9, 199, 10, 330, 300, 343, 6791, 370, 1620, 867, 316, 199, 10, 2854, 1343, 402, 11805, 3432, 3928, 12111, 676, 405, 959, 14, 21, 13, 845, 31746, 445, 333, 13, 18, 199, 10, 14012, 8914, 27882, 8683, 471, 315, 5851, 2658, 199, 199, 15519, 13, 384, 314, 1402, 370, 282, 308, 13558, 89, 1174, 14, 799, 7612, 314, 7647, 666, 315, 19593, 402, 282, 221, 199, 1400, 17399, 334, 1883, 436, 1806, 395, 5133, 314, 3562, 45, 12, 1620, 867, 436, 28649, 351, 445, 20092, 10142, 482, 370, 221, 199, 1461, 14, 199, 199, 5118, 428, 7751, 384, 543, 27882, 1862, 12, 6317, 653, 10814, 12, 6317, 5099, 18, 1275, 199, 5118, 812, 695, 653, 10814, 15, 1439, 18, 367, 3595, 1926, 16699, 612, 2393, 1396, 4941, 7192, 405, 9688, 1862, 880, 626, 781, 664, 2043, 4012, 314, 315, 2033, 816, 279, 370, 314, 5851, 1257, 83, 6247, 14, 199, 624, 199, 199, 646, 747, 199, 646, 5145, 199, 646, 984, 199, 646, 3873, 199, 646, 2680, 465, 980, 199, 504, 486, 2977, 492, 486, 2977, 465, 1402, 199, 504, 486, 2977, 492, 11311, 63, 71, 2977, 63, 635, 63, 493, 465, 1503, 199, 504, 486, 2977, 423, 1023, 492, 636, 1023, 363, 465, 6135, 63, 5792, 199, 199, 363, 2502, 363, 221, 275, 298, 45, 26788, 1487, 1804, 3844, 1129, 2, 199, 363, 1023, 363, 275, 298, 17, 14, 16, 334, 1079, 14, 713, 14, 7280, 2924, 199, 363, 2123, 363, 257, 275, 298, 77, 271, 75, 3844, 1129, 32, 6799, 14, 957, 2, 421, 199, 318, 2446, 8, 10873, 63, 344, 12, 4770, 12, 6988, 568, 63, 2160, 29, 549, 12, 8761, 63, 3192, 7698, 29, 549, 12, 6988, 568, 63, 2160, 63, 16590, 51, 29, 549, 304, 272, 1300, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 9458, 1012, 2286, 327, 2935, 1561, 272, 1300, 63, 635, 63, 354, 275, 298, 1095, 63, 928, 2, 272, 1300, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 9458, 1012, 272, 1300, 63, 635, 63, 694, 275, 3286, 12117, 15, 8334, 25102, 15789, 1229, 15, 26872, 15, 71, 2977, 38, 2107, 15, 2694, 15, 1162, 2, 272, 1215, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 1162, 531, 272, 7647, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 10207, 63, 576, 531, 272, 1255, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1095, 63, 694, 12, 298, 4467, 531, 17635, 340, 6988, 568, 63, 2160, 508, 715, 26, 13857, 327, 1331, 1300, 1584, 370, 1852, 2877, 892, 11805, 1584, 267, 5145, 14, 1574, 8, 736, 14, 515, 14, 904, 8, 1095, 63, 635, 63, 694, 12, 1300, 63, 635, 63, 354, 435, 3680, 4128, 1288, 463, 490, 747, 14, 515, 14, 904, 8, 635, 63, 694, 12, 2071, 83, 4970, 83, 63, 1238, 63, 14809, 384, 14, 4128, 2, 450, 971, 490, 334, 10873, 63, 344, 12, 4770, 1724, 2728, 327, 3378, 1402, 370, 325, 783, 773, 322, 453, 18002, 27882, 12, 20772, 316, 445, 20092, 687, 27881, 267, 327, 4697, 267, 284, 1450, 275, 2071, 83, 4970, 83, 63, 1238, 63, 14809, 384, 2, 450, 334, 10873, 63, 344, 12, 4770, 9, 267, 312, 1450, 275, 2071, 83, 4970, 83, 63, 1238, 63, 681, 324, 384, 2, 450, 334, 10873, 63, 344, 12, 4770, 9, 267, 333, 1450, 275, 2071, 83, 63, 10207, 63, 576, 63, 69, 783, 773, 322, 453, 63, 1400, 63, 89, 2393, 14, 4737, 2, 450, 334, 2124, 9, 267, 734, 63, 2324, 275, 284, 1450, 435, 2668, 69, 783, 773, 14, 548, 2, 4960, 734, 63, 635, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 635, 63, 694, 12, 312, 1450, 435, 3680, 4128, 531, 267, 4810, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 635, 63, 694, 12, 284, 1450, 435, 3680, 4128, 531, 267, 7647, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 10207, 63, 694, 12, 333, 1450, 9, 267, 734, 63, 5252, 275, 747, 14, 515, 14, 904, 8, 1065, 63, 694, 12, 734, 63, 2324, 9, 2728, 3350, 63, 807, 275, 469, 221, 586, 327, 6135, 8292, 586, 298, 3187, 63, 2227, 582, 620, 8, 3187, 63, 5792, 395, 1993, 586, 327, 1584, 586, 298, 548, 63, 635, 63, 5252, 582, 2071, 83, 2, 450, 334, 548, 63, 635, 63, 5252, 395, 586, 298, 4128, 63, 5252, 582, 2071, 83, 2, 450, 334, 4128, 63, 5252, 395, 586, 298, 10207, 63, 5252, 582, 2071, 83, 2, 450, 334, 10207, 63, 5252, 395, 586, 298, 548, 63, 5252, 582, 2071, 83, 2, 450, 334, 548, 63, 5252, 395, 2079, 586, 327, 1174, 446, 849, 445, 26, 46, 5661, 14, 586, 298, 474, 582, 298, 16, 14, 16, 401, 586, 298, 2425, 517, 582, 298, 1196, 14, 16, 401, 327, 6855, 927, 4569, 10035, 11185, 687, 3193, 77, 315, 12521, 370, 6155, 77, 315, 8353, 737, 577, 85, 415, 586, 298, 5416, 2310, 79, 382, 582, 298, 16, 14, 4587, 401, 586, 298, 5416, 2310, 79, 382, 78, 582, 298, 16, 14, 993, 20, 401, 586, 298, 474, 582, 298, 16, 14, 16, 401, 586, 298, 4694, 582, 298, 16, 14, 4587, 401, 586, 298, 4694, 78, 582, 298, 16, 14, 993, 20, 401, 586, 298, 67, 1617, 582, 298, 16, 14, 4587, 401, 586, 298, 262, 269, 784, 582, 298, 16, 14, 993, 20, 401, 586, 298, 278, 2902, 1152, 382, 582, 298, 16, 14, 16, 401, 586, 298, 278, 2902, 1152, 382, 78, 582, 298, 16, 14, 16, 401, 586, 298, 278, 8741, 300, 70, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
odoousers2014/odoo
addons/account/report/common_report_header.py
8
6346
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.tools.translate import _ # Mixin to use with rml_parse, so self.pool will be defined. class common_report_header(object): def _sum_debit(self, period_id=False, journal_id=False): if journal_id and isinstance(journal_id, int): journal_id = [journal_id] if period_id and isinstance(period_id, int): period_id = [period_id] if not journal_id: journal_id = self.journal_ids if not period_id: period_id = self.period_ids if not (period_id and journal_id): return 0.0 self.cr.execute('SELECT SUM(debit) FROM account_move_line l ' 'WHERE period_id IN %s AND journal_id IN %s ' + self.query_get_clause + ' ', (tuple(period_id), tuple(journal_id))) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, period_id=False, journal_id=False): if journal_id and isinstance(journal_id, int): journal_id = [journal_id] if period_id and isinstance(period_id, int): period_id = [period_id] if not journal_id: journal_id = self.journal_ids if not period_id: period_id = self.period_ids if not (period_id and journal_id): return 0.0 self.cr.execute('SELECT SUM(credit) FROM account_move_line l ' 'WHERE period_id IN %s AND journal_id IN %s '+ self.query_get_clause+'', (tuple(period_id), tuple(journal_id))) return self.cr.fetchone()[0] or 0.0 def _get_start_date(self, data): if data.get('form', False) and data['form'].get('date_from', False): return data['form']['date_from'] return '' def _get_target_move(self, data): if data.get('form', False) and data['form'].get('target_move', False): if data['form']['target_move'] == 'all': return _('All Entries') return _('All Posted Entries') return '' def _get_end_date(self, data): if data.get('form', False) and data['form'].get('date_to', False): return data['form']['date_to'] return '' def get_start_period(self, data): if data.get('form', False) and data['form'].get('period_from', False): return self.pool.get('account.period').browse(self.cr,self.uid,data['form']['period_from']).name return '' def get_end_period(self, data): if data.get('form', False) and data['form'].get('period_to', False): return self.pool.get('account.period').browse(self.cr, self.uid, data['form']['period_to']).name return '' def _get_account(self, data): if data.get('form', False) and data['form'].get('chart_account_id', False): return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).name return '' def _get_sortby(self, data): raise (_('Error!'), _('Not implemented.')) def _get_filter(self, data): if data.get('form', False) and data['form'].get('filter', False): if data['form']['filter'] == 'filter_date': return self._translate('Date') elif data['form']['filter'] == 'filter_period': return self._translate('Periods') return self._translate('No Filters') def _sum_debit_period(self, period_id, journal_id=None): journals = journal_id or self.journal_ids if not journals: return 0.0 self.cr.execute('SELECT SUM(debit) FROM account_move_line l ' 'WHERE period_id=%s AND journal_id IN %s '+ self.query_get_clause +'', (period_id, tuple(journals))) return self.cr.fetchone()[0] or 0.0 def _sum_credit_period(self, period_id, journal_id=None): journals = journal_id or self.journal_ids if not journals: return 0.0 self.cr.execute('SELECT SUM(credit) FROM account_move_line l ' 'WHERE period_id=%s AND journal_id IN %s ' + self.query_get_clause +' ', (period_id, tuple(journals))) return self.cr.fetchone()[0] or 0.0 def _get_fiscalyear(self, data): if data.get('form', False) and data['form'].get('fiscalyear_id', False): return self.pool.get('account.fiscalyear').browse(self.cr, self.uid, data['form']['fiscalyear_id']).name return '' def _get_company(self, data): if data.get('form', False) and data['form'].get('chart_account_id', False): return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).company_id.name return '' def _get_journal(self, data): codes = [] if data.get('form', False) and data['form'].get('journal_ids', False): self.cr.execute('select code from account_journal where id IN %s',(tuple(data['form']['journal_ids']),)) codes = [x for x, in self.cr.fetchall()] return codes def _get_currency(self, data): if data.get('form', False) and data['form'].get('chart_account_id', False): return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).company_id.currency_id.symbol return ''
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 3, 28438, 370, 675, 543, 519, 757, 63, 1122, 12, 880, 291, 14, 2293, 911, 506, 3247, 14, 199, 533, 2863, 63, 3070, 63, 1291, 8, 785, 304, 339, 347, 485, 1838, 63, 12964, 8, 277, 12, 6247, 63, 344, 29, 797, 12, 9605, 63, 344, 29, 797, 304, 267, 340, 9605, 63, 344, 436, 1228, 8, 7067, 63, 344, 12, 1109, 304, 288, 9605, 63, 344, 275, 359, 7067, 63, 344, 61, 267, 340, 6247, 63, 344, 436, 1228, 8, 5191, 63, 344, 12, 1109, 304, 288, 6247, 63, 344, 275, 359, 5191, 63, 344, 61, 267, 340, 440, 9605, 63, 344, 26, 288, 9605, 63, 344, 275, 291, 14, 7067, 63, 1580, 267, 340, 440, 6247, 63, 344, 26, 288, 6247, 63, 344, 275, 291, 14, 5191, 63, 1580, 267, 340, 440, 334, 5191, 63, 344, 436, 9605, 63, 344, 304, 288, 372, 378, 14, 16, 267, 291, 14, 1556, 14, 2526, 360, 4859, 24558, 8, 12964, 9, 4442, 2933, 63, 1185, 63, 604, 634, 283, 717, 283, 17688, 6247, 63, 344, 1621, 450, 83, 2401, 9605, 63, 344, 1621, 450, 83, 283, 435, 291, 14, 1131, 63, 362, 63, 8501, 435, 283, 1656, 717, 334, 2960, 8, 5191, 63, 344, 395, 2008, 8, 7067, 63, 344, 1724, 267, 372, 291, 14, 1556, 14, 11591, 3430, 16, 61, 503, 378, 14, 16, 339, 347, 485, 1838, 63, 9365, 8, 277, 12, 6247, 63, 344, 29, 797, 12, 9605, 63, 344, 29, 797, 304, 267, 340, 9605, 63, 344, 436, 1228, 8, 7067, 63, 344, 12, 1109, 304, 288, 9605, 63, 344, 275, 359, 7067, 63, 344, 61, 267, 340, 6247, 63, 344, 436, 1228, 8, 5191, 63, 344, 12, 1109, 304, 288, 6247, 63, 344, 275, 359, 5191, 63, 344, 61, 267, 340, 440, 9605, 63, 344, 26, 288, 9605, 63, 344, 275, 291, 14, 7067, 63, 1580, 267, 340, 440, 6247, 63, 344, 26, 288, 6247, 63, 344, 275, 291, 14, 5191, 63, 1580, 267, 340, 440, 334, 5191, 63, 344, 436, 9605, 63, 344, 304, 288, 372, 378, 14, 16, 267, 291, 14, 1556, 14, 2526, 360, 4859, 24558, 8, 9365, 9, 4442, 2933, 63, 1185, 63, 604, 634, 283, 717, 283, 17688, 6247, 63, 344, 1621, 450, 83, 2401, 9605, 63, 344, 1621, 450, 83, 6681, 291, 14, 1131, 63, 362, 63, 8501, 4786, 297, 717, 334, 2960, 8, 5191, 63, 344, 395, 2008, 8, 7067, 63, 344, 1724, 267, 372, 291, 14, 1556, 14, 11591, 3430, 16, 61, 503, 378, 14, 16, 339, 347, 485, 362, 63, 928, 63, 602, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 602, 63, 504, 297, 756, 304, 288, 372, 666, 459, 964, 2545, 602, 63, 504, 418, 267, 372, 2125, 339, 347, 485, 362, 63, 1375, 63, 1185, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 1375, 63, 1185, 297, 756, 304, 288, 340, 666, 459, 964, 2545, 1375, 63, 1185, 418, 508, 283, 452, 356, 355, 372, 4018, 2422, 23450, 1996, 358, 288, 372, 4018, 2422, 510, 17849, 23450, 1996, 358, 267, 372, 2125, 339, 347, 485, 362, 63, 500, 63, 602, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 602, 63, 475, 297, 756, 304, 288, 372, 666, 459, 964, 2545, 602, 63, 475, 418, 267, 372, 2125, 339, 347, 664, 63, 928, 63, 5191, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 5191, 63, 504, 297, 756, 304, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 5191, 1959, 4570, 8, 277, 14, 1556, 12, 277, 14, 1535, 12, 576, 459, 964, 2545, 5191, 63, 504, 13227, 354, 267, 372, 2125, 339, 347, 664, 63, 500, 63, 5191, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 5191, 63, 475, 297, 756, 304, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 5191, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 666, 459, 964, 2545, 5191, 63, 475, 13227, 354, 267, 372, 2125, 339, 347, 485, 362, 63, 2048, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 9019, 63, 2048, 63, 344, 297, 756, 304, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 666, 459, 964, 2545, 9019, 63, 2048, 63, 344, 13227, 354, 267, 372, 2125, 339, 347, 485, 362, 63, 3191, 991, 8, 277 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 3, 28438, 370, 675, 543, 519, 757, 63, 1122, 12, 880, 291, 14, 2293, 911, 506, 3247, 14, 199, 533, 2863, 63, 3070, 63, 1291, 8, 785, 304, 339, 347, 485, 1838, 63, 12964, 8, 277, 12, 6247, 63, 344, 29, 797, 12, 9605, 63, 344, 29, 797, 304, 267, 340, 9605, 63, 344, 436, 1228, 8, 7067, 63, 344, 12, 1109, 304, 288, 9605, 63, 344, 275, 359, 7067, 63, 344, 61, 267, 340, 6247, 63, 344, 436, 1228, 8, 5191, 63, 344, 12, 1109, 304, 288, 6247, 63, 344, 275, 359, 5191, 63, 344, 61, 267, 340, 440, 9605, 63, 344, 26, 288, 9605, 63, 344, 275, 291, 14, 7067, 63, 1580, 267, 340, 440, 6247, 63, 344, 26, 288, 6247, 63, 344, 275, 291, 14, 5191, 63, 1580, 267, 340, 440, 334, 5191, 63, 344, 436, 9605, 63, 344, 304, 288, 372, 378, 14, 16, 267, 291, 14, 1556, 14, 2526, 360, 4859, 24558, 8, 12964, 9, 4442, 2933, 63, 1185, 63, 604, 634, 283, 717, 283, 17688, 6247, 63, 344, 1621, 450, 83, 2401, 9605, 63, 344, 1621, 450, 83, 283, 435, 291, 14, 1131, 63, 362, 63, 8501, 435, 283, 1656, 717, 334, 2960, 8, 5191, 63, 344, 395, 2008, 8, 7067, 63, 344, 1724, 267, 372, 291, 14, 1556, 14, 11591, 3430, 16, 61, 503, 378, 14, 16, 339, 347, 485, 1838, 63, 9365, 8, 277, 12, 6247, 63, 344, 29, 797, 12, 9605, 63, 344, 29, 797, 304, 267, 340, 9605, 63, 344, 436, 1228, 8, 7067, 63, 344, 12, 1109, 304, 288, 9605, 63, 344, 275, 359, 7067, 63, 344, 61, 267, 340, 6247, 63, 344, 436, 1228, 8, 5191, 63, 344, 12, 1109, 304, 288, 6247, 63, 344, 275, 359, 5191, 63, 344, 61, 267, 340, 440, 9605, 63, 344, 26, 288, 9605, 63, 344, 275, 291, 14, 7067, 63, 1580, 267, 340, 440, 6247, 63, 344, 26, 288, 6247, 63, 344, 275, 291, 14, 5191, 63, 1580, 267, 340, 440, 334, 5191, 63, 344, 436, 9605, 63, 344, 304, 288, 372, 378, 14, 16, 267, 291, 14, 1556, 14, 2526, 360, 4859, 24558, 8, 9365, 9, 4442, 2933, 63, 1185, 63, 604, 634, 283, 717, 283, 17688, 6247, 63, 344, 1621, 450, 83, 2401, 9605, 63, 344, 1621, 450, 83, 6681, 291, 14, 1131, 63, 362, 63, 8501, 4786, 297, 717, 334, 2960, 8, 5191, 63, 344, 395, 2008, 8, 7067, 63, 344, 1724, 267, 372, 291, 14, 1556, 14, 11591, 3430, 16, 61, 503, 378, 14, 16, 339, 347, 485, 362, 63, 928, 63, 602, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 602, 63, 504, 297, 756, 304, 288, 372, 666, 459, 964, 2545, 602, 63, 504, 418, 267, 372, 2125, 339, 347, 485, 362, 63, 1375, 63, 1185, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 1375, 63, 1185, 297, 756, 304, 288, 340, 666, 459, 964, 2545, 1375, 63, 1185, 418, 508, 283, 452, 356, 355, 372, 4018, 2422, 23450, 1996, 358, 288, 372, 4018, 2422, 510, 17849, 23450, 1996, 358, 267, 372, 2125, 339, 347, 485, 362, 63, 500, 63, 602, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 602, 63, 475, 297, 756, 304, 288, 372, 666, 459, 964, 2545, 602, 63, 475, 418, 267, 372, 2125, 339, 347, 664, 63, 928, 63, 5191, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 5191, 63, 504, 297, 756, 304, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 5191, 1959, 4570, 8, 277, 14, 1556, 12, 277, 14, 1535, 12, 576, 459, 964, 2545, 5191, 63, 504, 13227, 354, 267, 372, 2125, 339, 347, 664, 63, 500, 63, 5191, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 5191, 63, 475, 297, 756, 304, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 5191, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 666, 459, 964, 2545, 5191, 63, 475, 13227, 354, 267, 372, 2125, 339, 347, 485, 362, 63, 2048, 8, 277, 12, 666, 304, 267, 340, 666, 14, 362, 360, 964, 297, 756, 9, 436, 666, 459, 964, 2278, 362, 360, 9019, 63, 2048, 63, 344, 297, 756, 304, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 666, 459, 964, 2545, 9019, 63, 2048, 63, 344, 13227, 354, 267, 372, 2125, 339, 347, 485, 362, 63, 3191, 991, 8, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
peterlauri/django
django/contrib/gis/forms/widgets.py
14
3351
from __future__ import unicode_literals import logging from django.conf import settings from django.contrib.gis import gdal from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.forms.widgets import Widget from django.template import loader from django.utils import six, translation logger = logging.getLogger('django.contrib.gis') class BaseGeometryWidget(Widget): """ The base class for rich geometry widgets. Renders a map using the WKT of the geometry. """ geom_type = 'GEOMETRY' map_srid = 4326 map_width = 600 map_height = 400 display_raw = False supports_3d = False template_name = '' # set on subclasses def __init__(self, attrs=None): self.attrs = {} for key in ('geom_type', 'map_srid', 'map_width', 'map_height', 'display_raw'): self.attrs[key] = getattr(self, key) if attrs: self.attrs.update(attrs) def serialize(self, value): return value.wkt if value else '' def deserialize(self, value): try: return GEOSGeometry(value, self.map_srid) except (GEOSException, ValueError) as err: logger.error("Error creating geometry from value '%s' (%s)", value, err) return None def render(self, name, value, attrs=None): # If a string reaches here (via a validation error on another # field) then just reconstruct the Geometry. if value and isinstance(value, six.string_types): value = self.deserialize(value) if value: # Check that srid of value and map match if value.srid != self.map_srid: try: ogr = value.ogr ogr.transform(self.map_srid) value = ogr except gdal.GDALException as err: logger.error( "Error transforming geometry from srid '%s' to srid '%s' (%s)", value.srid, self.map_srid, err ) context = self.build_attrs( attrs, name=name, module='geodjango_%s' % name.replace('-', '_'), # JS-safe serialized=self.serialize(value), geom_type=gdal.OGRGeomType(self.attrs['geom_type']), STATIC_URL=settings.STATIC_URL, LANGUAGE_BIDI=translation.get_language_bidi(), ) return loader.render_to_string(self.template_name, context) class OpenLayersWidget(BaseGeometryWidget): template_name = 'gis/openlayers.html' class Media: js = ( 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js', 'gis/js/OLMapWidget.js', ) class OSMWidget(BaseGeometryWidget): """ An OpenLayers/OpenStreetMap-based widget. """ template_name = 'gis/openlayers-osm.html' default_lon = 5 default_lat = 47 map_srid = 3857 class Media: js = ( 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js', 'gis/js/OLMapWidget.js', ) def __init__(self, attrs=None): super(OSMWidget, self).__init__() for key in ('default_lon', 'default_lat'): self.attrs[key] = getattr(self, key) if attrs: self.attrs.update(attrs)
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 5668, 492, 15834, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21390, 21686, 12, 21479, 199, 504, 1639, 14, 3351, 14, 8583, 492, 16905, 199, 504, 1639, 14, 1160, 492, 5077, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7761, 199, 199, 2921, 275, 2050, 14, 5572, 360, 1176, 14, 2828, 14, 5668, 358, 421, 199, 533, 3523, 6831, 3339, 8, 3339, 304, 272, 408, 272, 710, 1300, 1021, 367, 30162, 3400, 11114, 14, 272, 10055, 7735, 282, 2341, 1808, 314, 22561, 402, 314, 3400, 14, 272, 408, 272, 9671, 63, 466, 275, 283, 28472, 7, 272, 2341, 63, 10498, 275, 26719, 272, 2341, 63, 2063, 275, 11624, 272, 2341, 63, 3333, 275, 8290, 272, 2929, 63, 1773, 275, 756, 339, 5171, 63, 19, 68, 275, 756, 272, 1978, 63, 354, 275, 2125, 221, 327, 663, 641, 9180, 339, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 291, 14, 3288, 275, 1052, 267, 367, 790, 315, 661, 6481, 63, 466, 297, 283, 1130, 63, 10498, 297, 283, 1130, 63, 2063, 297, 283, 1130, 63, 3333, 297, 283, 2918, 63, 1773, 735, 288, 291, 14, 3288, 59, 498, 61, 275, 2519, 8, 277, 12, 790, 9, 267, 340, 3290, 26, 288, 291, 14, 3288, 14, 873, 8, 3288, 9, 339, 347, 8437, 8, 277, 12, 574, 304, 267, 372, 574, 14, 11412, 340, 574, 587, 2125, 339, 347, 22920, 8, 277, 12, 574, 304, 267, 862, 26, 288, 372, 21479, 8, 585, 12, 291, 14, 1130, 63, 10498, 9, 267, 871, 334, 18120, 21686, 12, 1722, 9, 465, 2329, 26, 288, 2512, 14, 705, 480, 547, 6425, 3400, 687, 574, 1543, 83, 7, 4366, 83, 4186, 574, 12, 2329, 9, 267, 372, 488, 339, 347, 3795, 8, 277, 12, 536, 12, 574, 12, 3290, 29, 403, 304, 267, 327, 982, 282, 1059, 12276, 397, 2348, 334, 12897, 282, 6411, 1125, 641, 4573, 267, 327, 901, 9, 2066, 2951, 28462, 314, 10579, 14, 267, 340, 574, 436, 1228, 8, 585, 12, 3816, 14, 875, 63, 1313, 304, 288, 574, 275, 291, 14, 11143, 8, 585, 9, 398, 340, 574, 26, 288, 327, 2670, 626, 15627, 402, 574, 436, 2341, 1336, 288, 340, 574, 14, 10498, 1137, 291, 14, 1130, 63, 10498, 26, 355, 862, 26, 490, 20713, 275, 574, 14, 14945, 490, 20713, 14, 4711, 8, 277, 14, 1130, 63, 10498, 9, 490, 574, 275, 20713, 355, 871, 15834, 14, 17835, 1726, 465, 2329, 26, 490, 2512, 14, 705, 8, 717, 298, 547, 5793, 316, 3400, 687, 15627, 1543, 83, 7, 370, 15627, 1543, 83, 7, 4366, 83, 4186, 717, 574, 14, 10498, 12, 291, 14, 1130, 63, 10498, 12, 2329, 490, 776, 398, 1067, 275, 291, 14, 1506, 63, 3288, 8, 288, 3290, 12, 288, 536, 29, 354, 12, 288, 859, 534, 303, 364, 858, 4970, 83, 7, 450, 536, 14, 1814, 13858, 2513, 659, 221, 327, 18001, 13, 3489, 288, 6380, 29, 277, 14, 3549, 8, 585, 395, 288, 9671, 63, 466, 29, 11600, 14, 17275, 22702, 8, 277, 14, 3288, 459, 6481, 63, 466, 3815, 288, 27815, 63, 2632, 29, 1751, 14, 10449, 63, 2632, 12, 288, 30508, 2962, 63, 34, 28904, 29, 6893, 14, 362, 63, 3671, 63, 21555, 1062, 267, 776, 267, 372, 5077, 14, 3352, 63, 475, 63, 875, 8, 277, 14, 1160, 63, 354, 12, 1067, 9, 421, 199, 533, 3232, 16862, 3339, 8, 1563, 6831, 3339, 304, 272, 1978, 63, 354, 275, 283, 5668, 15, 1490, 4359, 14, 1360, 7, 339, 1021, 12300, 26, 267, 8586, 275, 334, 288, 283, 2859, 921, 23982, 3596, 14, 4091, 14163, 264, 14, 957, 15, 12774, 15, 8450, 15, 1490, 4359, 15, 18, 14, 969, 14, 17, 15, 4299, 16862, 14, 3596, 297, 288, 283, 5668, 15, 3596, 15, 2228, 2956, 3339, 14, 3596, 297, 267, 776, 421, 199, 533, 593, 4029, 3339, 8, 1563, 6831, 3339, 304, 272, 408, 272, 1626, 3232, 16862, 15, 4299, 933, 7936, 2956, 13, 6788, 3938, 14, 272, 408, 272, 1978, 63, 354, 275, 283, 5668, 15, 1490, 4359, 13, 30613, 14, 1360, 7, 272, 849, 63, 5298, 275, 959, 272, 849, 63, 4452, 275, 10954, 272, 2341, 63, 10498, 275, 10448, 1641, 339, 1021, 12300, 26, 267, 8586, 275, 334, 288, 283, 2859, 921, 23982, 3596, 14, 4091, 14163, 264, 14, 957, 15, 12774, 15, 8450, 15, 1490, 4359, 15, 18, 14, 969, 14, 17, 15, 4299, 16862, 14, 3596, 297, 288, 283, 5668, 15, 3596, 15, 2228, 2956, 3339, 14, 3596, 297, 267, 776, 339, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 1613, 8, 3100, 45, 3339, 12, 291, 2843, 826, 4533, 267, 367, 790, 315, 661, 885, 63, 5298, 297, 283, 885, 63, 4452, 735, 288, 291, 14, 3288, 59, 498, 61, 275, 2519, 8, 277, 12, 790, 9, 267, 340, 3290, 26, 288, 291, 14, 3288, 14, 873, 8, 3288, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 2828, 14, 5668, 492, 15834, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 21390, 21686, 12, 21479, 199, 504, 1639, 14, 3351, 14, 8583, 492, 16905, 199, 504, 1639, 14, 1160, 492, 5077, 199, 504, 1639, 14, 1208, 492, 3816, 12, 7761, 199, 199, 2921, 275, 2050, 14, 5572, 360, 1176, 14, 2828, 14, 5668, 358, 421, 199, 533, 3523, 6831, 3339, 8, 3339, 304, 272, 408, 272, 710, 1300, 1021, 367, 30162, 3400, 11114, 14, 272, 10055, 7735, 282, 2341, 1808, 314, 22561, 402, 314, 3400, 14, 272, 408, 272, 9671, 63, 466, 275, 283, 28472, 7, 272, 2341, 63, 10498, 275, 26719, 272, 2341, 63, 2063, 275, 11624, 272, 2341, 63, 3333, 275, 8290, 272, 2929, 63, 1773, 275, 756, 339, 5171, 63, 19, 68, 275, 756, 272, 1978, 63, 354, 275, 2125, 221, 327, 663, 641, 9180, 339, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 291, 14, 3288, 275, 1052, 267, 367, 790, 315, 661, 6481, 63, 466, 297, 283, 1130, 63, 10498, 297, 283, 1130, 63, 2063, 297, 283, 1130, 63, 3333, 297, 283, 2918, 63, 1773, 735, 288, 291, 14, 3288, 59, 498, 61, 275, 2519, 8, 277, 12, 790, 9, 267, 340, 3290, 26, 288, 291, 14, 3288, 14, 873, 8, 3288, 9, 339, 347, 8437, 8, 277, 12, 574, 304, 267, 372, 574, 14, 11412, 340, 574, 587, 2125, 339, 347, 22920, 8, 277, 12, 574, 304, 267, 862, 26, 288, 372, 21479, 8, 585, 12, 291, 14, 1130, 63, 10498, 9, 267, 871, 334, 18120, 21686, 12, 1722, 9, 465, 2329, 26, 288, 2512, 14, 705, 480, 547, 6425, 3400, 687, 574, 1543, 83, 7, 4366, 83, 4186, 574, 12, 2329, 9, 267, 372, 488, 339, 347, 3795, 8, 277, 12, 536, 12, 574, 12, 3290, 29, 403, 304, 267, 327, 982, 282, 1059, 12276, 397, 2348, 334, 12897, 282, 6411, 1125, 641, 4573, 267, 327, 901, 9, 2066, 2951, 28462, 314, 10579, 14, 267, 340, 574, 436, 1228, 8, 585, 12, 3816, 14, 875, 63, 1313, 304, 288, 574, 275, 291, 14, 11143, 8, 585, 9, 398, 340, 574, 26, 288, 327, 2670, 626, 15627, 402, 574, 436, 2341, 1336, 288, 340, 574, 14, 10498, 1137, 291, 14, 1130, 63, 10498, 26, 355, 862, 26, 490, 20713, 275, 574, 14, 14945, 490, 20713, 14, 4711, 8, 277, 14, 1130, 63, 10498, 9, 490, 574, 275, 20713, 355, 871, 15834, 14, 17835, 1726, 465, 2329, 26, 490, 2512, 14, 705, 8, 717, 298, 547, 5793, 316, 3400, 687, 15627, 1543, 83, 7, 370, 15627, 1543, 83, 7, 4366, 83, 4186, 717, 574, 14, 10498, 12, 291, 14, 1130, 63, 10498, 12, 2329, 490, 776, 398, 1067, 275, 291, 14, 1506, 63, 3288, 8, 288, 3290, 12, 288, 536, 29, 354, 12, 288, 859, 534, 303, 364, 858, 4970, 83, 7, 450, 536, 14, 1814, 13858, 2513, 659, 221, 327, 18001, 13, 3489, 288, 6380, 29, 277, 14, 3549, 8, 585, 395, 288, 9671, 63, 466, 29, 11600, 14, 17275, 22702, 8, 277, 14, 3288, 459, 6481, 63, 466, 3815, 288, 27815, 63, 2632, 29, 1751, 14, 10449, 63, 2632, 12, 288, 30508, 2962, 63, 34, 28904, 29, 6893, 14, 362, 63, 3671, 63, 21555, 1062, 267, 776, 267, 372, 5077, 14, 3352, 63, 475, 63, 875, 8, 277, 14, 1160, 63, 354, 12, 1067, 9, 421, 199, 533, 3232, 16862, 3339, 8, 1563, 6831, 3339, 304, 272, 1978, 63, 354, 275, 283, 5668, 15, 1490, 4359, 14, 1360, 7, 339, 1021, 12300, 26, 267, 8586, 275, 334, 288, 283, 2859, 921, 23982, 3596, 14, 4091, 14163, 264, 14, 957, 15, 12774, 15, 8450, 15, 1490, 4359, 15, 18, 14, 969, 14, 17, 15, 4299, 16862, 14, 3596, 297, 288, 283, 5668, 15, 3596, 15, 2228, 2956, 3339, 14, 3596, 297, 267, 776, 421, 199, 533, 593, 4029, 3339, 8, 1563, 6831, 3339, 304, 272, 408, 272, 1626, 3232, 16862, 15, 4299, 933, 7936, 2956, 13, 6788, 3938, 14, 272, 408, 272, 1978, 63, 354, 275, 283, 5668, 15, 1490, 4359, 13, 30613, 14, 1360, 7, 272, 849, 63, 5298, 275, 959, 272, 849, 63, 4452, 275, 10954, 272, 2341, 63, 10498, 275, 10448, 1641, 339, 1021, 12300, 26, 267, 8586, 275, 334, 288, 283, 2859, 921, 23982, 3596, 14, 4091, 14163, 264, 14, 957, 15, 12774, 15, 8450, 15, 1490, 4359, 15, 18, 14, 969, 14, 17, 15, 4299, 16862, 14, 3596, 297, 288, 283, 5668, 15, 3596, 15, 2228, 2956, 3339, 14, 3596, 297, 267, 776, 339, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 1613, 8, 3100, 45, 3339, 12, 291, 2843, 826, 4533, 267, 367, 790, 315, 661, 885, 63, 5298, 297, 283, 885, 63, 4452, 735, 288, 291, 14, 3288, 59, 498, 61, 275, 2519, 8, 277, 12, 790, 9, 267, 340, 3290, 26, 288, 291, 14, 3288, 14, 873, 8, 3288, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nathanial/lettuce
tests/integration/lib/Django-1.3/django/contrib/admin/templatetags/log.py
310
2270
from django import template from django.contrib.admin.models import LogEntry register = template.Library() class AdminLogNode(template.Node): def __init__(self, limit, varname, user): self.limit, self.varname, self.user = limit, varname, user def __repr__(self): return "<GetAdminLog Node>" def render(self, context): if self.user is None: context[self.varname] = LogEntry.objects.all().select_related('content_type', 'user')[:self.limit] else: user_id = self.user if not user_id.isdigit(): user_id = context[self.user].id context[self.varname] = LogEntry.objects.filter(user__id__exact=user_id).select_related('content_type', 'user')[:self.limit] return '' class DoGetAdminLog: """ Populates a template variable with the admin log for the given criteria. Usage:: {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %} Examples:: {% get_admin_log 10 as admin_log for_user 23 %} {% get_admin_log 10 as admin_log for_user user %} {% get_admin_log 10 as admin_log %} Note that ``context_var_containing_user_obj`` can be a hard-coded integer (user ID) or the name of a template context variable containing the user object whose ID you want. """ def __init__(self, tag_name): self.tag_name = tag_name def __call__(self, parser, token): tokens = token.contents.split() if len(tokens) < 4: raise template.TemplateSyntaxError("'%s' statements require two arguments" % self.tag_name) if not tokens[1].isdigit(): raise template.TemplateSyntaxError("First argument in '%s' must be an integer" % self.tag_name) if tokens[2] != 'as': raise template.TemplateSyntaxError("Second argument in '%s' must be 'as'" % self.tag_name) if len(tokens) > 4: if tokens[4] != 'for_user': raise template.TemplateSyntaxError("Fourth argument in '%s' must be 'for_user'" % self.tag_name) return AdminLogNode(limit=tokens[1], varname=tokens[3], user=(len(tokens) > 5 and tokens[5] or None)) register.tag('get_admin_log', DoGetAdminLog('get_admin_log'))
gpl-3.0
[ 504, 1639, 492, 1978, 199, 504, 1639, 14, 2828, 14, 2113, 14, 992, 492, 5297, 3900, 199, 199, 2683, 275, 1978, 14, 7424, 342, 199, 199, 533, 9516, 2445, 1716, 8, 1160, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 2304, 12, 22071, 12, 922, 304, 267, 291, 14, 3097, 12, 291, 14, 16043, 12, 291, 14, 751, 275, 2304, 12, 22071, 12, 922, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 1002, 4880, 2445, 5013, 4335, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 340, 291, 14, 751, 365, 488, 26, 288, 1067, 59, 277, 14, 16043, 61, 275, 5297, 3900, 14, 1462, 14, 452, 1252, 2416, 63, 2407, 360, 1317, 63, 466, 297, 283, 751, 358, 1491, 277, 14, 3097, 61, 267, 587, 26, 288, 922, 63, 344, 275, 291, 14, 751, 288, 340, 440, 922, 63, 344, 14, 13896, 837, 355, 922, 63, 344, 275, 1067, 59, 277, 14, 751, 1055, 344, 288, 1067, 59, 277, 14, 16043, 61, 275, 5297, 3900, 14, 1462, 14, 1541, 8, 751, 363, 344, 363, 7327, 29, 751, 63, 344, 680, 2416, 63, 2407, 360, 1317, 63, 466, 297, 283, 751, 358, 1491, 277, 14, 3097, 61, 267, 372, 2125, 199, 199, 533, 4226, 1002, 4880, 2445, 26, 272, 408, 272, 13244, 15409, 282, 1978, 1750, 543, 314, 4628, 943, 367, 314, 1627, 15647, 14, 339, 11028, 447, 398, 7749, 664, 63, 2113, 63, 793, 359, 3097, 61, 465, 359, 16043, 61, 367, 63, 751, 359, 1100, 63, 1391, 63, 16133, 63, 751, 63, 1113, 61, 3674, 339, 6058, 447, 398, 7749, 664, 63, 2113, 63, 793, 1616, 465, 4628, 63, 793, 367, 63, 751, 6546, 3674, 267, 7749, 664, 63, 2113, 63, 793, 1616, 465, 4628, 63, 793, 367, 63, 751, 922, 3674, 267, 7749, 664, 63, 2113, 63, 793, 1616, 465, 4628, 63, 793, 3674, 339, 3390, 626, 1124, 1100, 63, 1391, 63, 16133, 63, 751, 63, 1113, 1040, 883, 506, 282, 7508, 13, 15282, 3000, 272, 334, 751, 2870, 9, 503, 314, 536, 402, 282, 1978, 1067, 1750, 3035, 314, 922, 272, 909, 7447, 2870, 1265, 2934, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1947, 63, 354, 304, 267, 291, 14, 1450, 63, 354, 275, 1947, 63, 354, 339, 347, 636, 1250, 721, 277, 12, 1798, 12, 1526, 304, 267, 4645, 275, 1526, 14, 4407, 14, 1294, 342, 267, 340, 822, 8, 4504, 9, 665, 841, 26, 288, 746, 1978, 14, 20837, 21065, 83, 7, 9834, 4409, 2877, 2368, 2, 450, 291, 14, 1450, 63, 354, 9, 267, 340, 440, 4645, 59, 17, 1055, 13896, 837, 288, 746, 1978, 14, 20837, 480, 7147, 1423, 315, 1543, 83, 7, 1471, 506, 376, 3000, 2, 450, 291, 14, 1450, 63, 354, 9, 267, 340, 4645, 59, 18, 61, 1137, 283, 305, 356, 288, 746, 1978, 14, 20837, 480, 11906, 1423, 315, 1543, 83, 7, 1471, 506, 283, 305, 4065, 450, 291, 14, 1450, 63, 354, 9, 267, 340, 822, 8, 4504, 9, 690, 841, 26, 288, 340, 4645, 59, 20, 61, 1137, 283, 509, 63, 751, 356, 355, 746, 1978, 14, 20837, 480, 24766, 273, 1423, 315, 1543, 83, 7, 1471, 506, 283, 509, 63, 751, 4065, 450, 291, 14, 1450, 63, 354, 9, 267, 372, 9516, 2445, 1716, 8, 3097, 29, 4504, 59, 17, 467, 22071, 29, 4504, 59, 19, 467, 922, 2687, 552, 8, 4504, 9, 690, 959, 436, 4645, 59, 21, 61, 503, 488, 430, 199, 199, 2683, 14, 1450, 360, 362, 63, 2113, 63, 793, 297, 4226, 1002, 4880, 2445, 360, 362, 63, 2113, 63, 793, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 492, 1978, 199, 504, 1639, 14, 2828, 14, 2113, 14, 992, 492, 5297, 3900, 199, 199, 2683, 275, 1978, 14, 7424, 342, 199, 199, 533, 9516, 2445, 1716, 8, 1160, 14, 1716, 304, 272, 347, 636, 826, 721, 277, 12, 2304, 12, 22071, 12, 922, 304, 267, 291, 14, 3097, 12, 291, 14, 16043, 12, 291, 14, 751, 275, 2304, 12, 22071, 12, 922, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 3886, 1002, 4880, 2445, 5013, 4335, 339, 347, 3795, 8, 277, 12, 1067, 304, 267, 340, 291, 14, 751, 365, 488, 26, 288, 1067, 59, 277, 14, 16043, 61, 275, 5297, 3900, 14, 1462, 14, 452, 1252, 2416, 63, 2407, 360, 1317, 63, 466, 297, 283, 751, 358, 1491, 277, 14, 3097, 61, 267, 587, 26, 288, 922, 63, 344, 275, 291, 14, 751, 288, 340, 440, 922, 63, 344, 14, 13896, 837, 355, 922, 63, 344, 275, 1067, 59, 277, 14, 751, 1055, 344, 288, 1067, 59, 277, 14, 16043, 61, 275, 5297, 3900, 14, 1462, 14, 1541, 8, 751, 363, 344, 363, 7327, 29, 751, 63, 344, 680, 2416, 63, 2407, 360, 1317, 63, 466, 297, 283, 751, 358, 1491, 277, 14, 3097, 61, 267, 372, 2125, 199, 199, 533, 4226, 1002, 4880, 2445, 26, 272, 408, 272, 13244, 15409, 282, 1978, 1750, 543, 314, 4628, 943, 367, 314, 1627, 15647, 14, 339, 11028, 447, 398, 7749, 664, 63, 2113, 63, 793, 359, 3097, 61, 465, 359, 16043, 61, 367, 63, 751, 359, 1100, 63, 1391, 63, 16133, 63, 751, 63, 1113, 61, 3674, 339, 6058, 447, 398, 7749, 664, 63, 2113, 63, 793, 1616, 465, 4628, 63, 793, 367, 63, 751, 6546, 3674, 267, 7749, 664, 63, 2113, 63, 793, 1616, 465, 4628, 63, 793, 367, 63, 751, 922, 3674, 267, 7749, 664, 63, 2113, 63, 793, 1616, 465, 4628, 63, 793, 3674, 339, 3390, 626, 1124, 1100, 63, 1391, 63, 16133, 63, 751, 63, 1113, 1040, 883, 506, 282, 7508, 13, 15282, 3000, 272, 334, 751, 2870, 9, 503, 314, 536, 402, 282, 1978, 1067, 1750, 3035, 314, 922, 272, 909, 7447, 2870, 1265, 2934, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1947, 63, 354, 304, 267, 291, 14, 1450, 63, 354, 275, 1947, 63, 354, 339, 347, 636, 1250, 721, 277, 12, 1798, 12, 1526, 304, 267, 4645, 275, 1526, 14, 4407, 14, 1294, 342, 267, 340, 822, 8, 4504, 9, 665, 841, 26, 288, 746, 1978, 14, 20837, 21065, 83, 7, 9834, 4409, 2877, 2368, 2, 450, 291, 14, 1450, 63, 354, 9, 267, 340, 440, 4645, 59, 17, 1055, 13896, 837, 288, 746, 1978, 14, 20837, 480, 7147, 1423, 315, 1543, 83, 7, 1471, 506, 376, 3000, 2, 450, 291, 14, 1450, 63, 354, 9, 267, 340, 4645, 59, 18, 61, 1137, 283, 305, 356, 288, 746, 1978, 14, 20837, 480, 11906, 1423, 315, 1543, 83, 7, 1471, 506, 283, 305, 4065, 450, 291, 14, 1450, 63, 354, 9, 267, 340, 822, 8, 4504, 9, 690, 841, 26, 288, 340, 4645, 59, 20, 61, 1137, 283, 509, 63, 751, 356, 355, 746, 1978, 14, 20837, 480, 24766, 273, 1423, 315, 1543, 83, 7, 1471, 506, 283, 509, 63, 751, 4065, 450, 291, 14, 1450, 63, 354, 9, 267, 372, 9516, 2445, 1716, 8, 3097, 29, 4504, 59, 17, 467, 22071, 29, 4504, 59, 19, 467, 922, 2687, 552, 8, 4504, 9, 690, 959, 436, 4645, 59, 21, 61, 503, 488, 430, 199, 199, 2683, 14, 1450, 360, 362, 63, 2113, 63, 793, 297, 4226, 1002, 4880, 2445, 360, 362, 63, 2113, 63, 793, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
safwanrahman/mozillians
vendor-local/lib/python/markdown/inlinepatterns.py
11
17252
""" INLINE PATTERNS ============================================================================= Inline patterns such as *emphasis* are handled by means of auxiliary objects, one per pattern. Pattern objects must be instances of classes that extend markdown.Pattern. Each pattern object uses a single regular expression and needs support the following methods: pattern.getCompiledRegExp() # returns a regular expression pattern.handleMatch(m) # takes a match object and returns # an ElementTree element or just plain text All of python markdown's built-in patterns subclass from Pattern, but you can add additional patterns that don't. Also note that all the regular expressions used by inline must capture the whole block. For this reason, they all start with '^(.*)' and end with '(.*)!'. In case with built-in expression Pattern takes care of adding the "^(.*)" and "(.*)!". Finally, the order in which regular expressions are applied is very important - e.g. if we first replace http://.../ links with <a> tags and _then_ try to replace inline html, we would end up with a mess. So, we apply the expressions in the following order: * escape and backticks have to go before everything else, so that we can preempt any markdown patterns by escaping them. * then we handle auto-links (must be done before inline html) * then we handle inline HTML. At this point we will simply replace all inline HTML strings with a placeholder and add the actual HTML to a hash. * then inline images (must be done before links) * then bracketed links, first regular then reference-style * finally we apply strong and emphasis """ from __future__ import absolute_import from __future__ import unicode_literals from . import util from . import odict import re try: from urllib.parse import urlparse, urlunparse except ImportError: from urlparse import urlparse, urlunparse try: from html import entities except ImportError: import htmlentitydefs as entities def build_inlinepatterns(md_instance, **kwargs): """ Build the default set of inline patterns for Markdown. """ inlinePatterns = odict.OrderedDict() inlinePatterns["backtick"] = BacktickPattern(BACKTICK_RE) inlinePatterns["escape"] = EscapePattern(ESCAPE_RE, md_instance) inlinePatterns["reference"] = ReferencePattern(REFERENCE_RE, md_instance) inlinePatterns["link"] = LinkPattern(LINK_RE, md_instance) inlinePatterns["image_link"] = ImagePattern(IMAGE_LINK_RE, md_instance) inlinePatterns["image_reference"] = \ ImageReferencePattern(IMAGE_REFERENCE_RE, md_instance) inlinePatterns["short_reference"] = \ ReferencePattern(SHORT_REF_RE, md_instance) inlinePatterns["autolink"] = AutolinkPattern(AUTOLINK_RE, md_instance) inlinePatterns["automail"] = AutomailPattern(AUTOMAIL_RE, md_instance) inlinePatterns["linebreak"] = SubstituteTagPattern(LINE_BREAK_RE, 'br') if md_instance.safeMode != 'escape': inlinePatterns["html"] = HtmlPattern(HTML_RE, md_instance) inlinePatterns["entity"] = HtmlPattern(ENTITY_RE, md_instance) inlinePatterns["not_strong"] = SimpleTextPattern(NOT_STRONG_RE) inlinePatterns["strong_em"] = DoubleTagPattern(STRONG_EM_RE, 'strong,em') inlinePatterns["strong"] = SimpleTagPattern(STRONG_RE, 'strong') inlinePatterns["emphasis"] = SimpleTagPattern(EMPHASIS_RE, 'em') if md_instance.smart_emphasis: inlinePatterns["emphasis2"] = SimpleTagPattern(SMART_EMPHASIS_RE, 'em') else: inlinePatterns["emphasis2"] = SimpleTagPattern(EMPHASIS_2_RE, 'em') return inlinePatterns """ The actual regular expressions for patterns ----------------------------------------------------------------------------- """ NOBRACKET = r'[^\]\[]*' BRK = ( r'\[(' + (NOBRACKET + r'(\[')*6 + (NOBRACKET+ r'\])*')*6 + NOBRACKET + r')\]' ) NOIMG = r'(?<!\!)' BACKTICK_RE = r'(?<!\\)(`+)(.+?)(?<!`)\2(?!`)' # `e=f()` or ``e=f("`")`` ESCAPE_RE = r'\\(.)' # \< EMPHASIS_RE = r'(\*)([^\*]+)\2' # *emphasis* STRONG_RE = r'(\*{2}|_{2})(.+?)\2' # **strong** STRONG_EM_RE = r'(\*{3}|_{3})(.+?)\2' # ***strong*** SMART_EMPHASIS_RE = r'(?<!\w)(_)(?!_)(.+?)(?<!_)\2(?!\w)' # _smart_emphasis_ EMPHASIS_2_RE = r'(_)(.+?)\2' # _emphasis_ LINK_RE = NOIMG + BRK + \ r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)''' # [text](url) or [text](<url>) or [text](url "title") IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^")]+"[^"]*"|[^\)]*))\)' # ![alttxt](http://x.com/) or ![alttxt](<http://x.com/>) REFERENCE_RE = NOIMG + BRK+ r'\s?\[([^\]]*)\]' # [Google][3] SHORT_REF_RE = NOIMG + r'\[([^\]]+)\]' # [Google] IMAGE_REFERENCE_RE = r'\!' + BRK + '\s?\[([^\]]*)\]' # ![alt text][2] NOT_STRONG_RE = r'((^| )(\*|_)( |$))' # stand-alone * or _ AUTOLINK_RE = r'<((?:[Ff]|[Hh][Tt])[Tt][Pp][Ss]?://[^>]*)>' # <http://www.123.com> AUTOMAIL_RE = r'<([^> \!]*@[^> ]*)>' # <me@example.com> HTML_RE = r'(\<([a-zA-Z/][^\>]*?|\!--.*?--)\>)' # <...> ENTITY_RE = r'(&[\#a-zA-Z0-9]*;)' # &amp; LINE_BREAK_RE = r' \n' # two spaces at end of line def dequote(string): """Remove quotes from around a string.""" if ( ( string.startswith('"') and string.endswith('"')) or (string.startswith("'") and string.endswith("'")) ): return string[1:-1] else: return string ATTR_RE = re.compile("\{@([^\}]*)=([^\}]*)}") # {@id=123} def handleAttributes(text, parent): """Set values of an element based on attribute definitions ({@id=123}).""" def attributeCallback(match): parent.set(match.group(1), match.group(2).replace('\n', ' ')) return ATTR_RE.sub(attributeCallback, text) """ The pattern classes ----------------------------------------------------------------------------- """ class Pattern(object): """Base class that inline patterns subclass. """ def __init__(self, pattern, markdown_instance=None): """ Create an instant of an inline pattern. Keyword arguments: * pattern: A regular expression that matches a pattern """ self.pattern = pattern self.compiled_re = re.compile("^(.*?)%s(.*?)$" % pattern, re.DOTALL | re.UNICODE) # Api for Markdown to pass safe_mode into instance self.safe_mode = False if markdown_instance: self.markdown = markdown_instance def getCompiledRegExp(self): """ Return a compiled regular expression. """ return self.compiled_re def handleMatch(self, m): """Return a ElementTree element from the given match. Subclasses should override this method. Keyword arguments: * m: A re match object containing a match of the pattern. """ pass def type(self): """ Return class name, to define pattern type """ return self.__class__.__name__ def unescape(self, text): """ Return unescaped text given text with an inline placeholder. """ try: stash = self.markdown.treeprocessors['inline'].stashed_nodes except KeyError: return text def itertext(el): ' Reimplement Element.itertext for older python versions ' tag = el.tag if not isinstance(tag, util.string_type) and tag is not None: return if el.text: yield el.text for e in el: for s in itertext(e): yield s if e.tail: yield e.tail def get_stash(m): id = m.group(1) if id in stash: value = stash.get(id) if isinstance(value, util.string_type): return value else: # An etree Element - return text content only return ''.join(itertext(value)) return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text) class SimpleTextPattern(Pattern): """ Return a simple text of group(2) of a Pattern. """ def handleMatch(self, m): text = m.group(2) if text == util.INLINE_PLACEHOLDER_PREFIX: return None return text class EscapePattern(Pattern): """ Return an escaped character. """ def handleMatch(self, m): char = m.group(2) if char in self.markdown.ESCAPED_CHARS: return '%s%s%s' % (util.STX, ord(char), util.ETX) else: return None class SimpleTagPattern(Pattern): """ Return element of type `tag` with a text attribute of group(3) of a Pattern. """ def __init__ (self, pattern, tag): Pattern.__init__(self, pattern) self.tag = tag def handleMatch(self, m): el = util.etree.Element(self.tag) el.text = m.group(3) return el class SubstituteTagPattern(SimpleTagPattern): """ Return an element of type `tag` with no children. """ def handleMatch (self, m): return util.etree.Element(self.tag) class BacktickPattern(Pattern): """ Return a `<code>` element containing the matching text. """ def __init__ (self, pattern): Pattern.__init__(self, pattern) self.tag = "code" def handleMatch(self, m): el = util.etree.Element(self.tag) el.text = util.AtomicString(m.group(3).strip()) return el class DoubleTagPattern(SimpleTagPattern): """Return a ElementTree element nested in tag2 nested in tag1. Useful for strong emphasis etc. """ def handleMatch(self, m): tag1, tag2 = self.tag.split(",") el1 = util.etree.Element(tag1) el2 = util.etree.SubElement(el1, tag2) el2.text = m.group(3) return el1 class HtmlPattern(Pattern): """ Store raw inline html and return a placeholder. """ def handleMatch (self, m): rawhtml = self.unescape(m.group(2)) place_holder = self.markdown.htmlStash.store(rawhtml) return place_holder def unescape(self, text): """ Return unescaped text given text with an inline placeholder. """ try: stash = self.markdown.treeprocessors['inline'].stashed_nodes except KeyError: return text def get_stash(m): id = m.group(1) value = stash.get(id) if value is not None: try: return self.markdown.serializer(value) except: return '\%s' % value return util.INLINE_PLACEHOLDER_RE.sub(get_stash, text) class LinkPattern(Pattern): """ Return a link element from the given match. """ def handleMatch(self, m): el = util.etree.Element("a") el.text = m.group(2) title = m.group(13) href = m.group(9) if href: if href[0] == "<": href = href[1:-1] el.set("href", self.sanitize_url(self.unescape(href.strip()))) else: el.set("href", "") if title: title = dequote(self.unescape(title)) el.set("title", title) return el def sanitize_url(self, url): """ Sanitize a url against xss attacks in "safe_mode". Rather than specifically blacklisting `javascript:alert("XSS")` and all its aliases (see <http://ha.ckers.org/xss.html>), we whitelist known safe url formats. Most urls contain a network location, however some are known not to (i.e.: mailto links). Script urls do not contain a location. Additionally, for `javascript:...`, the scheme would be "javascript" but some aliases will appear to `urlparse()` to have no scheme. On top of that relative links (i.e.: "foo/bar.html") have no scheme. Therefore we must check "path", "parameters", "query" and "fragment" for any literal colons. We don't check "scheme" for colons because it *should* never have any and "netloc" must allow the form: `username:password@host:port`. """ if not self.markdown.safeMode: # Return immediately bipassing parsing. return url try: scheme, netloc, path, params, query, fragment = url = urlparse(url) except ValueError: # Bad url - so bad it couldn't be parsed. return '' locless_schemes = ['', 'mailto', 'news'] allowed_schemes = locless_schemes + ['http', 'https', 'ftp', 'ftps'] if scheme not in allowed_schemes: # Not a known (allowed) scheme. Not safe. return '' if netloc == '' and scheme not in locless_schemes: # This should not happen. Treat as suspect. return '' for part in url[2:]: if ":" in part: # A colon in "path", "parameters", "query" or "fragment" is suspect. return '' # Url passes all tests. Return url as-is. return urlunparse(url) class ImagePattern(LinkPattern): """ Return a img element from the given match. """ def handleMatch(self, m): el = util.etree.Element("img") src_parts = m.group(9).split() if src_parts: src = src_parts[0] if src[0] == "<" and src[-1] == ">": src = src[1:-1] el.set('src', self.sanitize_url(self.unescape(src))) else: el.set('src', "") if len(src_parts) > 1: el.set('title', dequote(self.unescape(" ".join(src_parts[1:])))) if self.markdown.enable_attributes: truealt = handleAttributes(m.group(2), el) else: truealt = m.group(2) el.set('alt', self.unescape(truealt)) return el class ReferencePattern(LinkPattern): """ Match to a stored reference and return link element. """ NEWLINE_CLEANUP_RE = re.compile(r'[ ]?\n', re.MULTILINE) def handleMatch(self, m): try: id = m.group(9).lower() except IndexError: id = None if not id: # if we got something like "[Google][]" or "[Goggle]" # we'll use "google" as the id id = m.group(2).lower() # Clean up linebreaks in id id = self.NEWLINE_CLEANUP_RE.sub(' ', id) if not id in self.markdown.references: # ignore undefined refs return None href, title = self.markdown.references[id] text = m.group(2) return self.makeTag(href, title, text) def makeTag(self, href, title, text): el = util.etree.Element('a') el.set('href', self.sanitize_url(href)) if title: el.set('title', title) el.text = text return el class ImageReferencePattern(ReferencePattern): """ Match to a stored reference and return img element. """ def makeTag(self, href, title, text): el = util.etree.Element("img") el.set("src", self.sanitize_url(href)) if title: el.set("title", title) if self.markdown.enable_attributes: text = handleAttributes(text, el) el.set("alt", self.unescape(text)) return el class AutolinkPattern(Pattern): """ Return a link Element given an autolink (`<http://example/com>`). """ def handleMatch(self, m): el = util.etree.Element("a") el.set('href', self.unescape(m.group(2))) el.text = util.AtomicString(m.group(2)) return el class AutomailPattern(Pattern): """ Return a mailto link Element given an automail link (`<foo@example.com>`). """ def handleMatch(self, m): el = util.etree.Element('a') email = self.unescape(m.group(2)) if email.startswith("mailto:"): email = email[len("mailto:"):] def codepoint2name(code): """Return entity definition by code, or the code if not defined.""" entity = entities.codepoint2name.get(code) if entity: return "%s%s;" % (util.AMP_SUBSTITUTE, entity) else: return "%s#%d;" % (util.AMP_SUBSTITUTE, code) letters = [codepoint2name(ord(letter)) for letter in email] el.text = util.AtomicString(''.join(letters)) mailto = "mailto:" + email mailto = "".join([util.AMP_SUBSTITUTE + '#%d;' % ord(letter) for letter in mailto]) el.set('href', mailto) return el
bsd-3-clause
[ 624, 202, 199, 568, 6174, 31467, 1157, 2709, 202, 199, 5695, 9152, 2999, 199, 10307, 7970, 4066, 465, 627, 28907, 10, 787, 8860, 701, 4910, 402, 31407, 202, 199, 1462, 12, 1373, 1126, 3851, 14, 221, 27019, 2251, 1471, 506, 4454, 402, 3992, 202, 199, 9099, 12247, 18502, 14, 9959, 14, 221, 7048, 3851, 909, 4440, 282, 2849, 5578, 202, 199, 5599, 436, 4839, 2291, 314, 2569, 3102, 26, 2958, 3851, 14, 362, 32521, 2872, 4527, 342, 327, 2529, 282, 5578, 3965, 2958, 3851, 14, 2479, 4486, 8, 77, 9, 327, 6181, 282, 1336, 909, 436, 2529, 202, 2574, 327, 376, 13139, 1819, 503, 2951, 8971, 1318, 2999, 199, 2422, 402, 2366, 18502, 1159, 6137, 13, 262, 7970, 5516, 687, 27019, 12, 202, 199, 7911, 1265, 883, 1050, 4722, 7970, 626, 2793, 1133, 14, 2999, 199, 31892, 5317, 626, 1006, 314, 5578, 8455, 1202, 701, 8308, 1471, 202, 199, 12685, 314, 8852, 1853, 14, 221, 2104, 642, 4499, 12, 2985, 1006, 1343, 543, 202, 199, 4289, 19276, 3171, 436, 1284, 543, 8189, 12432, 1, 1370, 221, 1010, 1930, 543, 6137, 13, 262, 3965, 202, 199, 9959, 6181, 10296, 402, 7791, 314, 18129, 19276, 2924, 436, 7340, 12432, 1, 1674, 2999, 199, 8694, 1183, 12, 314, 1865, 315, 1314, 5578, 8455, 787, 6781, 365, 7437, 202, 199, 19559, 446, 325, 14, 71, 14, 340, 781, 1642, 3350, 1455, 921, 1396, 15, 6220, 543, 665, 65, 30, 3762, 202, 199, 460, 485, 12726, 63, 862, 370, 3350, 8308, 3517, 12, 781, 3955, 1284, 1536, 543, 282, 15634, 14, 202, 199, 5158, 12, 781, 4838, 314, 8455, 315, 314, 2569, 1865, 26, 2999, 199, 10, 4772, 436, 1771, 10406, 1172, 370, 2621, 2544, 8137, 587, 12, 880, 10292, 626, 781, 883, 299, 850, 4787, 1263, 18502, 7970, 701, 21375, 3062, 14, 2999, 199, 10, 2066, 781, 2429, 2599, 13, 4614, 334, 7790, 506, 4224, 2544, 8308, 3517, 9, 2999, 199, 10, 2066, 781, 2429, 8308, 4163, 14, 221, 2854, 642, 2376, 781, 911, 9329, 10292, 3350, 1006, 8308, 4163, 3326, 543, 282, 10069, 436, 1050, 10292, 314, 3503, 4163, 370, 282, 2631, 14, 2999, 199, 10, 2066, 8308, 5935, 334, 7790, 506, 4224, 2544, 6220, 9, 2999, 199, 10, 2066, 330, 8085, 69, 471, 6220, 12, 1642, 5578, 2066, 3659, 13, 2487, 2999, 199, 10, 3753, 781, 4838, 16925, 436, 9052, 24059, 202, 199, 624, 2999, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 202, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 202, 199, 504, 1275, 492, 4884, 202, 199, 504, 1275, 492, 312, 807, 202, 199, 646, 295, 202, 199, 893, 26, 1128, 687, 4011, 14, 1122, 492, 7097, 12, 30111, 202, 199, 2590, 3545, 26, 1128, 687, 7097, 492, 7097, 12, 30111, 202, 199, 893, 26, 1128, 687, 3517, 492, 9045, 202, 199, 2590, 3545, 26, 1128, 492, 30010, 552, 1701, 8710, 465, 9045, 8065, 199, 318, 1900, 63, 6460, 7435, 8, 1064, 63, 842, 12, 1011, 958, 304, 1128, 408, 6516, 314, 849, 663, 402, 8308, 7970, 367, 24537, 14, 408, 1128, 8308, 25662, 275, 312, 807, 14, 16882, 342, 1128, 8308, 25662, 905, 894, 8284, 937, 275, 10257, 8284, 9959, 8, 7111, 52, 13884, 63, 907, 9, 1128, 8308, 25662, 905, 3765, 937, 275, 21067, 9959, 8, 28879, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 4443, 937, 275, 10944, 9959, 8, 31177, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1073, 937, 275, 10967, 9959, 8, 7916, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1569, 63, 1073, 937, 275, 6047, 9959, 8, 9438, 63, 7916, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1569, 63, 4443, 937, 275, 971, 1675, 6047, 5083, 9959, 8, 9438, 63, 31177, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 3612, 63, 4443, 937, 275, 971, 1675, 10944, 9959, 8, 13003, 63, 8279, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 6898, 393, 2292, 937, 275, 27722, 393, 2292, 9959, 8, 10774, 2228, 12394, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 2495, 1198, 937, 275, 9195, 1198, 9959, 8, 13883, 8175, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 604, 4785, 937, 275, 4804, 25585, 1931, 9959, 8, 6174, 63, 14731, 63, 907, 12, 283, 3289, 358, 1128, 340, 6128, 63, 842, 14, 3489, 1385, 1137, 283, 3765, 356, 1039, 8308, 25662, 905, 1360, 937, 275, 20880, 9959, 8, 4943, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 4502, 937, 275, 20880, 9959, 8, 13630, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1397, 63, 9370, 937, 275, 5870, 1872, 9959, 8, 4609, 63, 3027, 7770, 63, 907, 9, 1128, 8308, 25662, 905, 9370, 63, 5633, 937, 275, 22945, 1931, 9959, 8, 3027, 7770, 63, 2769, 63, 907, 12, 283, 9370, 12, 5633, 358, 1128, 8308, 25662, 905, 9370, 937, 275, 5870, 1931, 9959, 8, 3027, 7770, 63, 907, 12, 283, 9370, 358, 1128, 8308, 25662, 905, 28907, 937, 275, 5870, 1931, 9959, 8, 37, 1658, 13533, 1311, 63, 907, 12, 283, 5633, 358, 1128, 340, 6128, 63, 842, 14, 7853, 63, 28907, 26, 1039, 8308, 25662, 905, 28907, 18, 937, 275, 5870, 1931, 9959, 8, 4029, 2294, 63, 37, 1658, 13533, 1311, 63, 907, 12, 283, 5633, 358, 1128, 587, 26, 1039, 8308, 25662, 905, 28907, 18, 937, 275, 5870, 1931, 9959, 8, 37, 1658, 13533, 1311, 63, 18, 63, 907, 12, 283, 5633, 358, 1128, 372, 8308, 25662, 2999, 199, 624, 202, 199, 1918, 3503, 5578, 8455, 367, 7970, 202, 199, 3606, 8684, 202, 199, 624, 2999, 199, 2826, 25950, 275, 519, 29538, 7272, 59, 3672, 7, 202, 199, 7184, 43, 275, 334, 519, 1154, 19412, 1039, 435, 334, 2826, 25950, 435, 519, 13445, 59, 358, 10, 22, 1039, 435, 334, 2826, 25950, 11, 519, 1154, 566, 13418, 10, 22, 1039, 435, 4825, 25950, 435, 519, 24431, 6616, 776, 202, 199, 2826, 26246, 275, 519, 10120, 11230, 60, 1, 3171, 2999, 199, 7111, 52, 13884, 63, 907, 275, 519, 10120, 11230, 1103, 5130, 64, 29653, 11198, 18168, 11230, 64, 2862 ]
[ 202, 199, 568, 6174, 31467, 1157, 2709, 202, 199, 5695, 9152, 2999, 199, 10307, 7970, 4066, 465, 627, 28907, 10, 787, 8860, 701, 4910, 402, 31407, 202, 199, 1462, 12, 1373, 1126, 3851, 14, 221, 27019, 2251, 1471, 506, 4454, 402, 3992, 202, 199, 9099, 12247, 18502, 14, 9959, 14, 221, 7048, 3851, 909, 4440, 282, 2849, 5578, 202, 199, 5599, 436, 4839, 2291, 314, 2569, 3102, 26, 2958, 3851, 14, 362, 32521, 2872, 4527, 342, 327, 2529, 282, 5578, 3965, 2958, 3851, 14, 2479, 4486, 8, 77, 9, 327, 6181, 282, 1336, 909, 436, 2529, 202, 2574, 327, 376, 13139, 1819, 503, 2951, 8971, 1318, 2999, 199, 2422, 402, 2366, 18502, 1159, 6137, 13, 262, 7970, 5516, 687, 27019, 12, 202, 199, 7911, 1265, 883, 1050, 4722, 7970, 626, 2793, 1133, 14, 2999, 199, 31892, 5317, 626, 1006, 314, 5578, 8455, 1202, 701, 8308, 1471, 202, 199, 12685, 314, 8852, 1853, 14, 221, 2104, 642, 4499, 12, 2985, 1006, 1343, 543, 202, 199, 4289, 19276, 3171, 436, 1284, 543, 8189, 12432, 1, 1370, 221, 1010, 1930, 543, 6137, 13, 262, 3965, 202, 199, 9959, 6181, 10296, 402, 7791, 314, 18129, 19276, 2924, 436, 7340, 12432, 1, 1674, 2999, 199, 8694, 1183, 12, 314, 1865, 315, 1314, 5578, 8455, 787, 6781, 365, 7437, 202, 199, 19559, 446, 325, 14, 71, 14, 340, 781, 1642, 3350, 1455, 921, 1396, 15, 6220, 543, 665, 65, 30, 3762, 202, 199, 460, 485, 12726, 63, 862, 370, 3350, 8308, 3517, 12, 781, 3955, 1284, 1536, 543, 282, 15634, 14, 202, 199, 5158, 12, 781, 4838, 314, 8455, 315, 314, 2569, 1865, 26, 2999, 199, 10, 4772, 436, 1771, 10406, 1172, 370, 2621, 2544, 8137, 587, 12, 880, 10292, 626, 781, 883, 299, 850, 4787, 1263, 18502, 7970, 701, 21375, 3062, 14, 2999, 199, 10, 2066, 781, 2429, 2599, 13, 4614, 334, 7790, 506, 4224, 2544, 8308, 3517, 9, 2999, 199, 10, 2066, 781, 2429, 8308, 4163, 14, 221, 2854, 642, 2376, 781, 911, 9329, 10292, 3350, 1006, 8308, 4163, 3326, 543, 282, 10069, 436, 1050, 10292, 314, 3503, 4163, 370, 282, 2631, 14, 2999, 199, 10, 2066, 8308, 5935, 334, 7790, 506, 4224, 2544, 6220, 9, 2999, 199, 10, 2066, 330, 8085, 69, 471, 6220, 12, 1642, 5578, 2066, 3659, 13, 2487, 2999, 199, 10, 3753, 781, 4838, 16925, 436, 9052, 24059, 202, 199, 624, 2999, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 202, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 202, 199, 504, 1275, 492, 4884, 202, 199, 504, 1275, 492, 312, 807, 202, 199, 646, 295, 202, 199, 893, 26, 1128, 687, 4011, 14, 1122, 492, 7097, 12, 30111, 202, 199, 2590, 3545, 26, 1128, 687, 7097, 492, 7097, 12, 30111, 202, 199, 893, 26, 1128, 687, 3517, 492, 9045, 202, 199, 2590, 3545, 26, 1128, 492, 30010, 552, 1701, 8710, 465, 9045, 8065, 199, 318, 1900, 63, 6460, 7435, 8, 1064, 63, 842, 12, 1011, 958, 304, 1128, 408, 6516, 314, 849, 663, 402, 8308, 7970, 367, 24537, 14, 408, 1128, 8308, 25662, 275, 312, 807, 14, 16882, 342, 1128, 8308, 25662, 905, 894, 8284, 937, 275, 10257, 8284, 9959, 8, 7111, 52, 13884, 63, 907, 9, 1128, 8308, 25662, 905, 3765, 937, 275, 21067, 9959, 8, 28879, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 4443, 937, 275, 10944, 9959, 8, 31177, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1073, 937, 275, 10967, 9959, 8, 7916, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1569, 63, 1073, 937, 275, 6047, 9959, 8, 9438, 63, 7916, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1569, 63, 4443, 937, 275, 971, 1675, 6047, 5083, 9959, 8, 9438, 63, 31177, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 3612, 63, 4443, 937, 275, 971, 1675, 10944, 9959, 8, 13003, 63, 8279, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 6898, 393, 2292, 937, 275, 27722, 393, 2292, 9959, 8, 10774, 2228, 12394, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 2495, 1198, 937, 275, 9195, 1198, 9959, 8, 13883, 8175, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 604, 4785, 937, 275, 4804, 25585, 1931, 9959, 8, 6174, 63, 14731, 63, 907, 12, 283, 3289, 358, 1128, 340, 6128, 63, 842, 14, 3489, 1385, 1137, 283, 3765, 356, 1039, 8308, 25662, 905, 1360, 937, 275, 20880, 9959, 8, 4943, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 4502, 937, 275, 20880, 9959, 8, 13630, 63, 907, 12, 6128, 63, 842, 9, 1128, 8308, 25662, 905, 1397, 63, 9370, 937, 275, 5870, 1872, 9959, 8, 4609, 63, 3027, 7770, 63, 907, 9, 1128, 8308, 25662, 905, 9370, 63, 5633, 937, 275, 22945, 1931, 9959, 8, 3027, 7770, 63, 2769, 63, 907, 12, 283, 9370, 12, 5633, 358, 1128, 8308, 25662, 905, 9370, 937, 275, 5870, 1931, 9959, 8, 3027, 7770, 63, 907, 12, 283, 9370, 358, 1128, 8308, 25662, 905, 28907, 937, 275, 5870, 1931, 9959, 8, 37, 1658, 13533, 1311, 63, 907, 12, 283, 5633, 358, 1128, 340, 6128, 63, 842, 14, 7853, 63, 28907, 26, 1039, 8308, 25662, 905, 28907, 18, 937, 275, 5870, 1931, 9959, 8, 4029, 2294, 63, 37, 1658, 13533, 1311, 63, 907, 12, 283, 5633, 358, 1128, 587, 26, 1039, 8308, 25662, 905, 28907, 18, 937, 275, 5870, 1931, 9959, 8, 37, 1658, 13533, 1311, 63, 18, 63, 907, 12, 283, 5633, 358, 1128, 372, 8308, 25662, 2999, 199, 624, 202, 199, 1918, 3503, 5578, 8455, 367, 7970, 202, 199, 3606, 8684, 202, 199, 624, 2999, 199, 2826, 25950, 275, 519, 29538, 7272, 59, 3672, 7, 202, 199, 7184, 43, 275, 334, 519, 1154, 19412, 1039, 435, 334, 2826, 25950, 435, 519, 13445, 59, 358, 10, 22, 1039, 435, 334, 2826, 25950, 11, 519, 1154, 566, 13418, 10, 22, 1039, 435, 4825, 25950, 435, 519, 24431, 6616, 776, 202, 199, 2826, 26246, 275, 519, 10120, 11230, 60, 1, 3171, 2999, 199, 7111, 52, 13884, 63, 907, 275, 519, 10120, 11230, 1103, 5130, 64, 29653, 11198, 18168, 11230, 64, 2862, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bponsler/pysiriproxy
pysiriproxy/config/plugins/resetPlugin.py
1
1672
# Copyright 2012 Brett Ponsler # This file is part of pysiriproxy. # # pysiriproxy 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. # # pysiriproxy 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 pysiriproxy. If not, see <http://www.gnu.org/licenses/>. '''Contains the Reset-Plugin.''' from pysiriproxy.plugins.plugin import BasePlugin from pysiriproxy.plugins.objectClasses import ClearContext, \ StartSpeechRequest, CancelRequest, CancelSpeech, CommandFailed from pyamp.logging import Colors class Plugin(BasePlugin): '''Handles resetting the context.''' # Define the name and log color for this plugin name = "Reset-Plugin" logColor = Colors.Foreground.Green ##### Define all of the filters for this plugin. ##### @CancelRequest @CancelSpeech @ClearContext @CommandFailed def resetFilter(self, obj, direction): '''Reset the context when a request is completed, or the context is cleared. * obj -- The received object * direction -- The direction of the received data ''' self.log.debug("Resetting object manager: %s" % obj.get("class", None), level=0) self.resetContext() return obj
gpl-3.0
[ 3, 1898, 6029, 699, 3292, 84, 510, 4654, 1435, 199, 3, 961, 570, 365, 1777, 402, 1134, 338, 322, 3280, 14, 199, 3, 199, 3, 1134, 338, 322, 3280, 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, 1134, 338, 322, 3280, 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, 1134, 338, 322, 3280, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 6906, 314, 15510, 13, 5061, 10595, 199, 504, 1134, 338, 322, 3280, 14, 5265, 14, 2718, 492, 3523, 5061, 199, 504, 1134, 338, 322, 3280, 14, 5265, 14, 785, 15711, 492, 14836, 2998, 12, 971, 272, 7707, 27047, 12736, 2017, 12, 28374, 2017, 12, 28374, 27047, 12736, 12, 5817, 4276, 199, 199, 504, 1134, 5282, 14, 4806, 492, 3626, 1384, 421, 199, 533, 11349, 8, 1563, 5061, 304, 272, 1449, 23555, 5305, 1337, 314, 1067, 10595, 339, 327, 13930, 314, 536, 436, 943, 3164, 367, 642, 3589, 272, 536, 275, 298, 9637, 13, 5061, 2, 272, 943, 4117, 275, 3626, 1384, 14, 29742, 14, 19456, 339, 22906, 13930, 1006, 402, 314, 4766, 367, 642, 3589, 14, 22906, 339, 768, 9083, 2017, 272, 768, 9083, 27047, 12736, 272, 768, 9721, 2998, 272, 768, 3110, 4276, 272, 347, 5305, 4131, 8, 277, 12, 1559, 12, 7581, 304, 267, 1449, 9637, 314, 1067, 1380, 282, 1056, 365, 9709, 12, 503, 314, 1067, 365, 267, 20518, 14, 398, 627, 1559, 1553, 710, 3086, 909, 267, 627, 7581, 1553, 710, 7581, 402, 314, 3086, 666, 398, 1449, 267, 291, 14, 793, 14, 1757, 480, 497, 6031, 909, 5256, 26, 450, 83, 2, 450, 1559, 14, 362, 480, 533, 401, 488, 395, 2432, 2166, 29, 16, 9, 267, 291, 14, 3958, 2998, 342, 267, 372, 1559, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6029, 699, 3292, 84, 510, 4654, 1435, 199, 3, 961, 570, 365, 1777, 402, 1134, 338, 322, 3280, 14, 199, 3, 199, 3, 1134, 338, 322, 3280, 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, 1134, 338, 322, 3280, 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, 1134, 338, 322, 3280, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 6906, 314, 15510, 13, 5061, 10595, 199, 504, 1134, 338, 322, 3280, 14, 5265, 14, 2718, 492, 3523, 5061, 199, 504, 1134, 338, 322, 3280, 14, 5265, 14, 785, 15711, 492, 14836, 2998, 12, 971, 272, 7707, 27047, 12736, 2017, 12, 28374, 2017, 12, 28374, 27047, 12736, 12, 5817, 4276, 199, 199, 504, 1134, 5282, 14, 4806, 492, 3626, 1384, 421, 199, 533, 11349, 8, 1563, 5061, 304, 272, 1449, 23555, 5305, 1337, 314, 1067, 10595, 339, 327, 13930, 314, 536, 436, 943, 3164, 367, 642, 3589, 272, 536, 275, 298, 9637, 13, 5061, 2, 272, 943, 4117, 275, 3626, 1384, 14, 29742, 14, 19456, 339, 22906, 13930, 1006, 402, 314, 4766, 367, 642, 3589, 14, 22906, 339, 768, 9083, 2017, 272, 768, 9083, 27047, 12736, 272, 768, 9721, 2998, 272, 768, 3110, 4276, 272, 347, 5305, 4131, 8, 277, 12, 1559, 12, 7581, 304, 267, 1449, 9637, 314, 1067, 1380, 282, 1056, 365, 9709, 12, 503, 314, 1067, 365, 267, 20518, 14, 398, 627, 1559, 1553, 710, 3086, 909, 267, 627, 7581, 1553, 710, 7581, 402, 314, 3086, 666, 398, 1449, 267, 291, 14, 793, 14, 1757, 480, 497, 6031, 909, 5256, 26, 450, 83, 2, 450, 1559, 14, 362, 480, 533, 401, 488, 395, 2432, 2166, 29, 16, 9, 267, 291, 14, 3958, 2998, 342, 267, 372, 1559, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
wxgeo/geophar
wxgeometrie/sympy/functions/special/tests/test_mathieu.py
85
1080
from sympy import (sqrt, sin, cos, diff, conjugate, mathieus, mathieuc, mathieusprime, mathieucprime) from sympy.abc import a, q, z def test_mathieus(): assert isinstance(mathieus(a, q, z), mathieus) assert mathieus(a, 0, z) == sin(sqrt(a)*z) assert conjugate(mathieus(a, q, z)) == mathieus(conjugate(a), conjugate(q), conjugate(z)) assert diff(mathieus(a, q, z), z) == mathieusprime(a, q, z) def test_mathieuc(): assert isinstance(mathieuc(a, q, z), mathieuc) assert mathieuc(a, 0, z) == cos(sqrt(a)*z) assert diff(mathieuc(a, q, z), z) == mathieucprime(a, q, z) def test_mathieusprime(): assert isinstance(mathieusprime(a, q, z), mathieusprime) assert mathieusprime(a, 0, z) == sqrt(a)*cos(sqrt(a)*z) assert diff(mathieusprime(a, q, z), z) == (-a + 2*q*cos(2*z))*mathieus(a, q, z) def test_mathieucprime(): assert isinstance(mathieucprime(a, q, z), mathieucprime) assert mathieucprime(a, 0, z) == -sqrt(a)*sin(sqrt(a)*z) assert diff(mathieucprime(a, q, z), z) == (-a + 2*q*cos(2*z))*mathieuc(a, q, z)
gpl-2.0
[ 504, 5840, 492, 334, 5079, 12, 9829, 12, 9794, 12, 3915, 12, 27246, 12, 673, 3473, 1873, 527, 12, 3473, 1873, 947, 12, 3473, 1873, 527, 12446, 12, 3473, 1873, 947, 12446, 9, 199, 199, 504, 5840, 14, 3175, 492, 282, 12, 1894, 12, 1315, 421, 199, 318, 511, 63, 3442, 1873, 527, 837, 272, 702, 1228, 8, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 527, 9, 272, 702, 3473, 1873, 527, 8, 65, 12, 378, 12, 1315, 9, 508, 9829, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 27246, 8, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 430, 508, 3473, 1873, 527, 8, 26000, 8, 65, 395, 27246, 8, 81, 395, 27246, 8, 90, 430, 272, 702, 3915, 8, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 3473, 1873, 527, 12446, 8, 65, 12, 1894, 12, 1315, 9, 199, 199, 318, 511, 63, 3442, 1873, 947, 837, 272, 702, 1228, 8, 3442, 1873, 947, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 947, 9, 272, 702, 3473, 1873, 947, 8, 65, 12, 378, 12, 1315, 9, 508, 9794, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 3915, 8, 3442, 1873, 947, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 3473, 1873, 947, 12446, 8, 65, 12, 1894, 12, 1315, 9, 199, 199, 318, 511, 63, 3442, 1873, 527, 12446, 837, 272, 702, 1228, 8, 3442, 1873, 527, 12446, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 527, 12446, 9, 272, 702, 3473, 1873, 527, 12446, 8, 65, 12, 378, 12, 1315, 9, 508, 7452, 8, 65, 3342, 5197, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 3915, 8, 3442, 1873, 527, 12446, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 5868, 65, 435, 499, 10, 81, 10, 5197, 8, 18, 10, 90, 19198, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 9, 199, 199, 318, 511, 63, 3442, 1873, 947, 12446, 837, 272, 702, 1228, 8, 3442, 1873, 947, 12446, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 947, 12446, 9, 272, 702, 3473, 1873, 947, 12446, 8, 65, 12, 378, 12, 1315, 9, 508, 446, 5079, 8, 65, 3342, 5911, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 3915, 8, 3442, 1873, 947, 12446, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 5868, 65, 435, 499, 10, 81, 10, 5197, 8, 18, 10, 90, 19198, 3442, 1873, 947, 8, 65, 12, 1894, 12, 1315, 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 ]
[ 5840, 492, 334, 5079, 12, 9829, 12, 9794, 12, 3915, 12, 27246, 12, 673, 3473, 1873, 527, 12, 3473, 1873, 947, 12, 3473, 1873, 527, 12446, 12, 3473, 1873, 947, 12446, 9, 199, 199, 504, 5840, 14, 3175, 492, 282, 12, 1894, 12, 1315, 421, 199, 318, 511, 63, 3442, 1873, 527, 837, 272, 702, 1228, 8, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 527, 9, 272, 702, 3473, 1873, 527, 8, 65, 12, 378, 12, 1315, 9, 508, 9829, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 27246, 8, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 430, 508, 3473, 1873, 527, 8, 26000, 8, 65, 395, 27246, 8, 81, 395, 27246, 8, 90, 430, 272, 702, 3915, 8, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 3473, 1873, 527, 12446, 8, 65, 12, 1894, 12, 1315, 9, 199, 199, 318, 511, 63, 3442, 1873, 947, 837, 272, 702, 1228, 8, 3442, 1873, 947, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 947, 9, 272, 702, 3473, 1873, 947, 8, 65, 12, 378, 12, 1315, 9, 508, 9794, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 3915, 8, 3442, 1873, 947, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 3473, 1873, 947, 12446, 8, 65, 12, 1894, 12, 1315, 9, 199, 199, 318, 511, 63, 3442, 1873, 527, 12446, 837, 272, 702, 1228, 8, 3442, 1873, 527, 12446, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 527, 12446, 9, 272, 702, 3473, 1873, 527, 12446, 8, 65, 12, 378, 12, 1315, 9, 508, 7452, 8, 65, 3342, 5197, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 3915, 8, 3442, 1873, 527, 12446, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 5868, 65, 435, 499, 10, 81, 10, 5197, 8, 18, 10, 90, 19198, 3442, 1873, 527, 8, 65, 12, 1894, 12, 1315, 9, 199, 199, 318, 511, 63, 3442, 1873, 947, 12446, 837, 272, 702, 1228, 8, 3442, 1873, 947, 12446, 8, 65, 12, 1894, 12, 1315, 395, 3473, 1873, 947, 12446, 9, 272, 702, 3473, 1873, 947, 12446, 8, 65, 12, 378, 12, 1315, 9, 508, 446, 5079, 8, 65, 3342, 5911, 8, 5079, 8, 65, 3342, 90, 9, 272, 702, 3915, 8, 3442, 1873, 947, 12446, 8, 65, 12, 1894, 12, 1315, 395, 1315, 9, 508, 5868, 65, 435, 499, 10, 81, 10, 5197, 8, 18, 10, 90, 19198, 3442, 1873, 947, 8, 65, 12, 1894, 12, 1315, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nawawi/poedit
deps/boost/tools/build/test/collect_debug_info.py
51
8397
#!/usr/bin/python # Copyright 2012 Jurko Gospodnetic # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) # Temporarily enabled dummy test that always fails and is used to collect # extra debugging information from Boost Build test runner sites. import BoostBuild import os import re import sys ############################################################################### # # Public interface. # ############################################################################### def collectDebugInfo(): t = _init() global tag tag = "Python version" try: _info(sys.version) except: _info_exc() tag = "Python platform" try: _info(sys.platform) except: _info_exc() tag = "Boost Jam/Build version" try: _infoX(_getJamVersionInfo(t)) except: _info_exc() #_collectDebugInfo_environ() # Report prepared annotations. t.fail_test(1, dump_difference=False, dump_stdio=False, dump_stack=False) ############################################################################### # # Private interface. # ############################################################################### varSeparator = "###$^%~~~" def _collect(results, prefix, name, t): results.append("%s - %s - os.getenv(): %r" % (prefix, name, os.getenv( name))) results.append("%s - %s - os.environ.get(): %r" % (prefix, name, os.environ.get(name))) external_values = _getExternalValues(t, name) results.append("%s - %s - external: %r" % (prefix, name, external_values[name])) def _collectDebugInfo_environ(t): dummyVars = ["WOOF_WOOFIE_%d" % x for x in xrange(4)] global tag tag = "XXX in os.environ" try: def f(name): return "%s: %s" % (name, name in os.environ) _infoX(f(x) for x in dummyVars) except: _info_exc() tag = "os.environ[XXX]" try: def f(name): try: result = os.environ[name] except: result = _str_exc() return "%s: %r" % (name, result) _infoX(f(x) for x in dummyVars) except: _info_exc() tag = "os.environ.get(XXX)" try: def f(name): return "%s: %r" % (name, os.environ.get(name)) _infoX(f(x) for x in dummyVars) except: _info_exc() tag = "os.getenv(XXX)" try: def f(name): return "%s: %r" % (name, os.getenv(name)) _infoX(f(x) for x in dummyVars) except: _info_exc() name = dummyVars[0] value = "foo" tag = "os.putenv(%s) to %r" % (name, value) try: results = [] _collect(results, "before", name, t) os.putenv(name, value) _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[1] value = "bar" tag = "os.environ[%s] to %r" % (name, value) try: results = [] _collect(results, "before", name, t) os.environ[name] = value _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[1] value = "baz" tag = "os.putenv(%s) to %r" % (name, value) try: results = [] _collect(results, "before", name, t) os.putenv(name, value) _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[1] value = "" tag = "os.putenv(%s) to %r" % (name, value) try: results = [] _collect(results, "before", name, t) os.putenv(name, value) _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[2] value = "foo" tag = "os.unsetenv(%s) from %r" % (name, value) try: results = [] os.environ[name] = value _collect(results, "before", name, t) os.unsetenv(name) _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[2] value = "foo" tag = "del os.environ[%s] from %r" % (name, value) try: results = [] os.environ[name] = value _collect(results, "before", name, t) del os.environ[name] _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[2] value = "foo" tag = "os.environ.pop(%s) from %r" % (name, value) try: results = [] os.environ[name] = value _collect(results, "before", name, t) os.environ.pop(name) _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[2] value1 = "foo" value2 = "" tag = "os.environ[%s] to %r from %r" % (name, value2, value1) try: results = [] os.environ[name] = value1 _collect(results, "before", name, t) os.environ[name] = value2 _collect(results, "after", name, t) _infoX(results) except: _info_exc() name = dummyVars[3] value = '""' tag = "os.environ[%s] to %r" % (name, value) try: results = [] _collect(results, "before", name, t) os.environ[name] = value _collect(results, "after", name, t) _infoX(results) except: _info_exc() def _getExternalValues(t, *args): t.run_build_system(["---var-name=%s" % x for x in args]) result = dict() for x in args: m = re.search(r"^\*\*\*ENV\*\*\* %s: '(.*)' \*\*\*$" % x, t.stdout(), re.MULTILINE) if m: result[x] = m.group(1) else: result[x] = None return result def _getJamVersionInfo(t): result = [] # JAM version variables. t.run_build_system(["---version"]) for m in re.finditer(r"^\*\*\*VAR\*\*\* ([^:]*): (.*)\*\*\*$", t.stdout(), re.MULTILINE): name = m.group(1) value = m.group(2) if not value: value = [] elif value[-1] == ' ': value = value[:-1].split(varSeparator) else: value = "!!!INVALID!!! - '%s'" % value result.append("%s = %s" % (name, value)) result.append("") # bjam -v output. t.run_build_system(["-v"]) result.append("--- output for 'bjam -v' ---") result.append(t.stdout()) # bjam --version output. t.run_build_system(["--version"], status=1) result.append("--- output for 'bjam --version' ---") result.append(t.stdout()) return result def _init(): toolsetName = "__myDummyToolset__" t = BoostBuild.Tester(["toolset=%s" % toolsetName], pass_toolset=False, use_test_config=False) # Prepare a dummy toolset so we do not get errors in case the default one # is not found. t.write(toolsetName + ".jam", """\ import feature ; feature.extend toolset : %s ; rule init ( ) { } """ % toolsetName ) # Python version of the same dummy toolset. t.write(toolsetName + ".py", """\ from b2.build import feature feature.extend('toolset', ['%s']) def init(): pass """ % toolsetName ) t.write("jamroot.jam", """\ import os ; .argv = [ modules.peek : ARGV ] ; local names = [ MATCH ^---var-name=(.*) : $(.argv) ] ; for x in $(names) { value = [ os.environ $(x) ] ; ECHO ***ENV*** $(x): '$(value)' *** ; } if ---version in $(.argv) { for x in JAMVERSION JAM_VERSION JAMUNAME JAM_TIMESTAMP_RESOLUTION OS { v = [ modules.peek : $(x) ] ; ECHO ***VAR*** $(x): "$(v:J=%s)" *** ; } } """ % varSeparator) return t def _info(*values): values = list(values) + [""] BoostBuild.annotation(tag, "\n".join(str(x) for x in values)) def _infoX(values): _info(*values) def _info_exc(): _info(_str_exc()) def _str_exc(): exc_type, exc_value = sys.exc_info()[0:2] if exc_type is None: exc_type_name = "None" else: exc_type_name = exc_type.__name__ return "*** EXCEPTION *** %s - %s ***" % (exc_type_name, exc_value) ############################################################################### # # main() # ------ # ############################################################################### collectDebugInfo()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 6029, 1603, 300, 7697, 3971, 681, 364, 685, 764, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 3, 257, 12540, 269, 11406, 5223, 7283, 511, 626, 3544, 6918, 436, 365, 1202, 370, 8775, 199, 3, 2402, 10201, 2556, 687, 30470, 6516, 511, 7876, 15424, 14, 199, 199, 646, 30470, 3425, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 421, 199, 11490, 199, 3, 199, 3, 1684, 3217, 14, 199, 3, 199, 11490, 199, 199, 318, 8775, 7084, 2354, 837, 272, 307, 275, 485, 826, 342, 339, 2288, 1947, 339, 1947, 275, 298, 4718, 1015, 2, 272, 862, 26, 267, 485, 815, 8, 1274, 14, 1023, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 4718, 4298, 2, 272, 862, 26, 267, 485, 815, 8, 1274, 14, 3246, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 18814, 1603, 455, 15, 3425, 1015, 2, 272, 862, 26, 267, 485, 815, 56, 1547, 362, 42, 455, 3353, 2354, 8, 84, 430, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 327, 63, 7112, 7084, 2354, 63, 2314, 342, 339, 327, 11774, 16318, 15538, 14, 272, 307, 14, 1633, 63, 396, 8, 17, 12, 5461, 63, 9196, 29, 797, 12, 5461, 63, 32011, 29, 797, 12, 5461, 63, 2340, 29, 797, 9, 421, 199, 11490, 199, 3, 199, 3, 18551, 3217, 14, 199, 3, 199, 11490, 199, 199, 1391, 23344, 275, 298, 5680, 4, 62, 5, 23597, 2, 421, 199, 318, 485, 7112, 8, 2604, 12, 2403, 12, 536, 12, 307, 304, 272, 2058, 14, 740, 3647, 83, 446, 450, 83, 446, 747, 14, 12959, 837, 450, 82, 2, 450, 334, 1861, 12, 536, 12, 747, 14, 12959, 8, 267, 536, 1724, 272, 2058, 14, 740, 3647, 83, 446, 450, 83, 446, 747, 14, 2314, 14, 362, 837, 450, 82, 2, 450, 334, 1861, 12, 536, 12, 267, 747, 14, 2314, 14, 362, 8, 354, 1724, 272, 5957, 63, 1459, 275, 485, 362, 11389, 6550, 8, 84, 12, 536, 9, 272, 2058, 14, 740, 3647, 83, 446, 450, 83, 446, 5957, 26, 450, 82, 2, 450, 334, 1861, 12, 536, 12, 267, 5957, 63, 1459, 59, 354, 2459, 421, 199, 318, 485, 7112, 7084, 2354, 63, 2314, 8, 84, 304, 272, 7283, 16270, 275, 2097, 11325, 3359, 63, 55, 5757, 1976, 37, 4970, 68, 2, 450, 671, 367, 671, 315, 4945, 8, 20, 1874, 272, 2288, 1947, 339, 1947, 275, 298, 13933, 315, 747, 14, 2314, 2, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 372, 2071, 83, 26, 450, 83, 2, 450, 334, 354, 12, 536, 315, 747, 14, 2314, 9, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 736, 14, 2314, 59, 13933, 8480, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 862, 26, 355, 754, 275, 747, 14, 2314, 59, 354, 61, 288, 871, 26, 355, 754, 275, 485, 495, 63, 2804, 342, 288, 372, 2071, 83, 26, 450, 82, 2, 450, 334, 354, 12, 754, 9, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 736, 14, 2314, 14, 362, 8, 13933, 2924, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 372, 2071, 83, 26, 450, 82, 2, 450, 334, 354, 12, 747, 14, 2314, 14, 362, 8, 354, 430, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 736, 14, 12959, 8, 13933, 2924, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 372, 2071, 83, 26, 450, 82, 2, 450, 334, 354, 12, 747, 14, 12959, 8, 354, 430, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 16, 61, 272, 574, 275, 298, 1421, 2, 272, 1947, 275, 298, 736, 14, 3165, 9072, 4042, 83, 9, 370, 450, 82, 2, 450, 334, 354, 12, 574, 9, 272, 862, 26, 267, 2058, 275, 942, 267, 485, 7112, 8, 2604, 12, 298, 5182, 401, 536, 12, 307, 9, 267, 747, 14, 3165, 9072, 8, 354, 12, 574, 9, 267, 485, 7112, 8, 2604, 12, 298, 4399, 401, 536, 12, 307, 9, 267, 485, 815, 56, 8, 2604, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 17, 61, 272, 574, 275, 298, 1700, 2, 272, 1947, 275, 298, 736, 14, 2314, 9722, 83, 61, 370, 450, 82, 2, 450, 334, 354, 12, 574, 9, 272, 862, 26, 267, 2058, 275, 942, 267, 485, 7112, 8, 2604, 12, 298, 5182, 401, 536, 12, 307, 9, 267, 747, 14, 2314, 59, 354, 61, 275, 574, 267, 485, 7112, 8, 2604, 12, 298, 4399, 401, 536, 12, 307, 9, 267, 485, 815, 56, 8, 2604, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 17, 61, 272, 574, 275, 298, 6185, 2, 272, 1947, 275, 298, 736, 14, 3165, 9072, 4042, 83, 9, 370, 450, 82, 2, 450, 334, 354, 12, 574, 9, 272, 862, 26, 267, 2058, 275, 942, 267, 485, 7112, 8, 2604, 12, 298, 5182, 401, 536, 12, 307, 9, 267, 747, 14, 3165, 9072, 8, 354, 12, 574, 9, 267, 485, 7112, 8, 2604, 12, 298, 4399, 401, 536, 12, 307, 9, 267, 485, 815, 56, 8, 2604, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 17, 61, 272, 574, 275, 3087, 272, 1947, 275, 298, 736, 14, 3165, 9072, 4042, 83 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 6029, 1603, 300, 7697, 3971, 681, 364, 685, 764, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 3, 257, 12540, 269, 11406, 5223, 7283, 511, 626, 3544, 6918, 436, 365, 1202, 370, 8775, 199, 3, 2402, 10201, 2556, 687, 30470, 6516, 511, 7876, 15424, 14, 199, 199, 646, 30470, 3425, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 421, 199, 11490, 199, 3, 199, 3, 1684, 3217, 14, 199, 3, 199, 11490, 199, 199, 318, 8775, 7084, 2354, 837, 272, 307, 275, 485, 826, 342, 339, 2288, 1947, 339, 1947, 275, 298, 4718, 1015, 2, 272, 862, 26, 267, 485, 815, 8, 1274, 14, 1023, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 4718, 4298, 2, 272, 862, 26, 267, 485, 815, 8, 1274, 14, 3246, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 18814, 1603, 455, 15, 3425, 1015, 2, 272, 862, 26, 267, 485, 815, 56, 1547, 362, 42, 455, 3353, 2354, 8, 84, 430, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 327, 63, 7112, 7084, 2354, 63, 2314, 342, 339, 327, 11774, 16318, 15538, 14, 272, 307, 14, 1633, 63, 396, 8, 17, 12, 5461, 63, 9196, 29, 797, 12, 5461, 63, 32011, 29, 797, 12, 5461, 63, 2340, 29, 797, 9, 421, 199, 11490, 199, 3, 199, 3, 18551, 3217, 14, 199, 3, 199, 11490, 199, 199, 1391, 23344, 275, 298, 5680, 4, 62, 5, 23597, 2, 421, 199, 318, 485, 7112, 8, 2604, 12, 2403, 12, 536, 12, 307, 304, 272, 2058, 14, 740, 3647, 83, 446, 450, 83, 446, 747, 14, 12959, 837, 450, 82, 2, 450, 334, 1861, 12, 536, 12, 747, 14, 12959, 8, 267, 536, 1724, 272, 2058, 14, 740, 3647, 83, 446, 450, 83, 446, 747, 14, 2314, 14, 362, 837, 450, 82, 2, 450, 334, 1861, 12, 536, 12, 267, 747, 14, 2314, 14, 362, 8, 354, 1724, 272, 5957, 63, 1459, 275, 485, 362, 11389, 6550, 8, 84, 12, 536, 9, 272, 2058, 14, 740, 3647, 83, 446, 450, 83, 446, 5957, 26, 450, 82, 2, 450, 334, 1861, 12, 536, 12, 267, 5957, 63, 1459, 59, 354, 2459, 421, 199, 318, 485, 7112, 7084, 2354, 63, 2314, 8, 84, 304, 272, 7283, 16270, 275, 2097, 11325, 3359, 63, 55, 5757, 1976, 37, 4970, 68, 2, 450, 671, 367, 671, 315, 4945, 8, 20, 1874, 272, 2288, 1947, 339, 1947, 275, 298, 13933, 315, 747, 14, 2314, 2, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 372, 2071, 83, 26, 450, 83, 2, 450, 334, 354, 12, 536, 315, 747, 14, 2314, 9, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 736, 14, 2314, 59, 13933, 8480, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 862, 26, 355, 754, 275, 747, 14, 2314, 59, 354, 61, 288, 871, 26, 355, 754, 275, 485, 495, 63, 2804, 342, 288, 372, 2071, 83, 26, 450, 82, 2, 450, 334, 354, 12, 754, 9, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 736, 14, 2314, 14, 362, 8, 13933, 2924, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 372, 2071, 83, 26, 450, 82, 2, 450, 334, 354, 12, 747, 14, 2314, 14, 362, 8, 354, 430, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 1947, 275, 298, 736, 14, 12959, 8, 13933, 2924, 272, 862, 26, 267, 347, 289, 8, 354, 304, 288, 372, 2071, 83, 26, 450, 82, 2, 450, 334, 354, 12, 747, 14, 12959, 8, 354, 430, 267, 485, 815, 56, 8, 70, 8, 88, 9, 367, 671, 315, 7283, 16270, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 16, 61, 272, 574, 275, 298, 1421, 2, 272, 1947, 275, 298, 736, 14, 3165, 9072, 4042, 83, 9, 370, 450, 82, 2, 450, 334, 354, 12, 574, 9, 272, 862, 26, 267, 2058, 275, 942, 267, 485, 7112, 8, 2604, 12, 298, 5182, 401, 536, 12, 307, 9, 267, 747, 14, 3165, 9072, 8, 354, 12, 574, 9, 267, 485, 7112, 8, 2604, 12, 298, 4399, 401, 536, 12, 307, 9, 267, 485, 815, 56, 8, 2604, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 17, 61, 272, 574, 275, 298, 1700, 2, 272, 1947, 275, 298, 736, 14, 2314, 9722, 83, 61, 370, 450, 82, 2, 450, 334, 354, 12, 574, 9, 272, 862, 26, 267, 2058, 275, 942, 267, 485, 7112, 8, 2604, 12, 298, 5182, 401, 536, 12, 307, 9, 267, 747, 14, 2314, 59, 354, 61, 275, 574, 267, 485, 7112, 8, 2604, 12, 298, 4399, 401, 536, 12, 307, 9, 267, 485, 815, 56, 8, 2604, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 17, 61, 272, 574, 275, 298, 6185, 2, 272, 1947, 275, 298, 736, 14, 3165, 9072, 4042, 83, 9, 370, 450, 82, 2, 450, 334, 354, 12, 574, 9, 272, 862, 26, 267, 2058, 275, 942, 267, 485, 7112, 8, 2604, 12, 298, 5182, 401, 536, 12, 307, 9, 267, 747, 14, 3165, 9072, 8, 354, 12, 574, 9, 267, 485, 7112, 8, 2604, 12, 298, 4399, 401, 536, 12, 307, 9, 267, 485, 815, 56, 8, 2604, 9, 272, 871, 26, 267, 485, 815, 63, 2804, 342, 339, 536, 275, 7283, 16270, 59, 17, 61, 272, 574, 275, 3087, 272, 1947, 275, 298, 736, 14, 3165, 9072, 4042, 83, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
seem-sky/kbengine
kbe/res/scripts/common/Lib/site-packages/setuptools/command/develop.py
477
6447
from setuptools.command.easy_install import easy_install from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError import os, sys, setuptools, glob class develop(easy_install): """Set up package for development""" description = "install package in 'development mode'" user_options = easy_install.user_options + [ ("uninstall", "u", "Uninstall this source package"), ("egg-path=", None, "Set the path to be used in the .egg-link file"), ] boolean_options = easy_install.boolean_options + ['uninstall'] command_consumes_arguments = False # override base def run(self): if self.uninstall: self.multi_version = True self.uninstall_link() else: self.install_for_development() self.warn_deprecated_options() def initialize_options(self): self.uninstall = None self.egg_path = None easy_install.initialize_options(self) self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: raise DistutilsError( "Please rename %r to %r before using 'develop'" % (ei.egg_info, ei.broken_egg_info) ) self.args = [ei.egg_name] easy_install.finalize_options(self) self.expand_basedirs() self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) target = normalize_path(self.egg_base) if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" " directory to "+target ) # Make a distribution for the package's source self.dist = Distribution( target, PathMetadata(target, os.path.abspath(ei.egg_info)), project_name = ei.egg_name ) p = self.egg_base.replace(os.sep,'/') if p!= os.curdir: p = '../' * (p.count('/')+1) self.setup_path = p p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) if p != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date self.reinitialize_command('build_py', inplace=0) self.run_command('build_py') bpy_cmd = self.get_finalized_command("build_py") build_path = normalize_path(bpy_cmd.build_lib) # Build extensions self.reinitialize_command('egg_info', egg_base=build_path) self.run_command('egg_info') self.reinitialize_command('build_ext', inplace=0) self.run_command('build_ext') # Fixup egg-link and easy-install.pth ei_cmd = self.get_finalized_command("egg_info") self.egg_path = build_path self.dist.location = build_path self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) # XXX else: # Without 2to3 inplace works fine: self.run_command('egg_info') # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) setuptools.bootstrap_install_from = None # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: f = open(self.egg_link,"w") f.write(self.egg_path + "\n" + self.setup_path) f.close() # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements self.process_distribution(None, self.dist, not self.no_deps) def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) egg_link_file = open(self.egg_link) contents = [line.rstrip() for line in egg_link_file] egg_link_file.close() if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return if not self.dry_run: os.unlink(self.egg_link) if not self.dry_run: self.update_pth(self.dist) # remove any .pth link to us if self.distribution.scripts: # XXX should also check for entry point scripts! log.warn("Note: you must uninstall or replace scripts manually!") def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior return easy_install.install_egg_scripts(self,dist) # create wrapper scripts in the script dir, pointing to dist.scripts # new-style... self.install_wrapper_scripts(dist) # ...and old-style for script_name in self.distribution.scripts or []: script_path = os.path.abspath(convert_path(script_name)) script_name = os.path.basename(script_path) f = open(script_path,'rU') script_text = f.read() f.close() self.install_script(dist, script_name, script_text, script_path)
lgpl-3.0
[ 504, 9116, 14, 1531, 14, 13581, 63, 3174, 492, 8837, 63, 3174, 199, 504, 7065, 14, 1974, 492, 3957, 63, 515, 12, 27321, 63, 2936, 199, 504, 5496, 63, 4435, 492, 11839, 12, 6912, 5142, 12, 7666, 63, 515, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 2550, 492, 12577, 547, 12, 31484, 199, 646, 747, 12, 984, 12, 9116, 12, 5739, 199, 199, 533, 477, 7549, 8, 13581, 63, 3174, 304, 272, 408, 1084, 1536, 2559, 367, 16367, 624, 339, 1369, 275, 298, 3174, 2559, 315, 283, 31688, 818, 4065, 339, 922, 63, 1419, 275, 8837, 63, 3174, 14, 751, 63, 1419, 435, 359, 267, 1689, 19502, 401, 298, 85, 401, 298, 1358, 3174, 642, 1350, 2559, 1288, 267, 1689, 5799, 13, 515, 11107, 488, 12, 298, 1084, 314, 931, 370, 506, 1202, 315, 314, 1275, 5799, 13, 1073, 570, 1288, 272, 1622, 339, 5046, 63, 1419, 275, 8837, 63, 3174, 14, 4871, 63, 1419, 435, 788, 19502, 418, 339, 1414, 63, 10235, 83, 63, 4958, 275, 756, 221, 327, 4278, 1300, 339, 347, 1255, 8, 277, 304, 267, 340, 291, 14, 19502, 26, 288, 291, 14, 3029, 63, 1023, 275, 715, 288, 291, 14, 19502, 63, 1073, 342, 267, 587, 26, 288, 291, 14, 3174, 63, 509, 63, 31688, 342, 267, 291, 14, 4050, 63, 6667, 63, 1419, 342, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 19502, 275, 488, 267, 291, 14, 5799, 63, 515, 275, 488, 267, 8837, 63, 3174, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 2758, 63, 515, 275, 488, 267, 291, 14, 9223, 63, 1574, 63, 504, 275, 7815, 257, 327, 3544, 1331, 22151, 4903, 315, 1094, 694, 16478, 347, 17284, 63, 1419, 8, 277, 304, 267, 20654, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 5799, 63, 815, 531, 267, 340, 20654, 14, 15697, 63, 5799, 63, 815, 26, 288, 746, 12577, 547, 8, 288, 298, 8254, 11441, 450, 82, 370, 450, 82, 2544, 1808, 283, 32176, 4065, 288, 450, 334, 24708, 14, 5799, 63, 815, 12, 20654, 14, 15697, 63, 5799, 63, 815, 9, 288, 776, 267, 291, 14, 589, 275, 359, 24708, 14, 5799, 63, 354, 61, 4388, 398, 8837, 63, 3174, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 4441, 63, 1095, 3220, 342, 267, 291, 14, 4441, 63, 3220, 342, 267, 327, 3732, 1536, 3272, 13, 694, 1275, 5799, 1584, 1454, 26, 949, 1275, 5799, 13, 815, 267, 291, 14, 2491, 63, 1080, 14, 6282, 8, 6463, 14, 6463, 360, 4856, 5799, 1333, 398, 291, 14, 5799, 63, 1073, 275, 747, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 20654, 14, 5799, 63, 354, 18098, 5799, 13, 1073, 358, 267, 291, 14, 5799, 63, 1095, 275, 20654, 14, 5799, 63, 1095, 267, 340, 291, 14, 5799, 63, 515, 365, 488, 26, 288, 291, 14, 5799, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 24708, 14, 5799, 63, 1095, 9, 398, 1347, 275, 7666, 63, 515, 8, 277, 14, 5799, 63, 1095, 9, 267, 340, 7666, 63, 515, 8, 736, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 291, 14, 5799, 63, 515, 430, 1137, 1347, 26, 288, 746, 31484, 8, 355, 4320, 5799, 13, 515, 1471, 506, 282, 3847, 931, 687, 314, 3907, 2, 355, 298, 2082, 370, 7210, 1375, 267, 776, 398, 327, 4155, 282, 4084, 367, 314, 2559, 1159, 1350, 267, 291, 14, 2686, 275, 11839, 8, 288, 1347, 12, 288, 6912, 5142, 8, 1375, 12, 747, 14, 515, 14, 4832, 8, 24708, 14, 5799, 63, 815, 1826, 288, 2199, 63, 354, 275, 20654, 14, 5799, 63, 354, 267, 776, 398, 299, 275, 291, 14, 5799, 63, 1095, 14, 1814, 8, 736, 14, 4127, 2584, 6217, 267, 340, 299, 1111, 747, 14, 15594, 26, 288, 299, 275, 11541, 4805, 627, 334, 80, 14, 835, 7825, 11, 17, 9, 267, 291, 14, 2758, 63, 515, 275, 299, 267, 299, 275, 7666, 63, 515, 8, 736, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 291, 14, 5799, 63, 515, 12, 299, 430, 267, 340, 221, 299, 1137, 7666, 63, 515, 8, 736, 14, 15594, 304, 288, 746, 31484, 8, 355, 298, 6049, 1133, 664, 282, 12137, 931, 370, 3272, 2884, 687, 2, 355, 298, 12096, 2082, 401, 299, 12, 7666, 63, 515, 8, 736, 14, 15594, 430, 339, 347, 3907, 63, 509, 63, 31688, 8, 277, 304, 267, 340, 984, 14, 1023, 63, 815, 2356, 334, 19, 4258, 436, 2519, 8, 277, 14, 4972, 12, 283, 1180, 63, 18, 475, 19, 297, 756, 304, 288, 327, 982, 781, 1255, 499, 475, 19, 781, 883, 440, 886, 642, 16304, 26, 953, 327, 7523, 3341, 365, 1536, 13, 475, 13, 602, 288, 291, 14, 264, 8489, 63, 1531, 360, 1506, 63, 647, 297, 16304, 29, 16, 9, 288, 291, 14, 1065, 63, 1531, 360, 1506, 63, 647, 358, 288, 20575, 63, 1760, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 1506, 63, 647, 531, 288, 1900, 63, 515, 275, 7666, 63, 515, 8, 66, 647, 63, 1760, 14, 1506, 63, 773, 9, 953, 327, 6516, 5478, 288, 291, 14, 264, 8489, 63, 1531, 360, 5799, 63, 815, 297, 11393, 63, 1095, 29, 1506, 63, 515, 9, 288, 291, 14, 1065, 63, 1531, 360, 5799, 63, 815, 358, 953, 291, 14, 264, 8489, 63, 1531, 360, 1506, 63, 832, 297, 16304, 29, 16, 9, 288, 291, 14, 1065, 63, 1531, 360, 1506, 63, 832, 358, 7846, 327, 14811, 384, 11393, 13, 1073, 436, 8837, 13, 3174, 14, 13316, 288, 20654, 63, 1760, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 5799, 63, 815, 531, 288, 291, 14, 5799, 63, 515, 275, 1900, 63, 515, 288, 291, 14, 2686, 14, 1985, 275, 1900, 63, 515, 288, 291, 14, 2686, 423, 3780, 275, 6912, 5142, 8, 1506, 63, 515, 12, 20654, 63, 1760, 14, 5799, 63, 815, 9, 259, 327, 5787, 267, 587, 26, 288, 327, 23952, 499, 475, 19, 16304, 5419, 15701, 26, 288, 291, 14, 1065, 63, 1531, 360, 5799, 63, 815, 358, 953, 327, 6516, 5478, 315, 13, 2778, 288, 291, 14 ]
[ 9116, 14, 1531, 14, 13581, 63, 3174, 492, 8837, 63, 3174, 199, 504, 7065, 14, 1974, 492, 3957, 63, 515, 12, 27321, 63, 2936, 199, 504, 5496, 63, 4435, 492, 11839, 12, 6912, 5142, 12, 7666, 63, 515, 199, 504, 7065, 492, 943, 199, 504, 7065, 14, 2550, 492, 12577, 547, 12, 31484, 199, 646, 747, 12, 984, 12, 9116, 12, 5739, 199, 199, 533, 477, 7549, 8, 13581, 63, 3174, 304, 272, 408, 1084, 1536, 2559, 367, 16367, 624, 339, 1369, 275, 298, 3174, 2559, 315, 283, 31688, 818, 4065, 339, 922, 63, 1419, 275, 8837, 63, 3174, 14, 751, 63, 1419, 435, 359, 267, 1689, 19502, 401, 298, 85, 401, 298, 1358, 3174, 642, 1350, 2559, 1288, 267, 1689, 5799, 13, 515, 11107, 488, 12, 298, 1084, 314, 931, 370, 506, 1202, 315, 314, 1275, 5799, 13, 1073, 570, 1288, 272, 1622, 339, 5046, 63, 1419, 275, 8837, 63, 3174, 14, 4871, 63, 1419, 435, 788, 19502, 418, 339, 1414, 63, 10235, 83, 63, 4958, 275, 756, 221, 327, 4278, 1300, 339, 347, 1255, 8, 277, 304, 267, 340, 291, 14, 19502, 26, 288, 291, 14, 3029, 63, 1023, 275, 715, 288, 291, 14, 19502, 63, 1073, 342, 267, 587, 26, 288, 291, 14, 3174, 63, 509, 63, 31688, 342, 267, 291, 14, 4050, 63, 6667, 63, 1419, 342, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 291, 14, 19502, 275, 488, 267, 291, 14, 5799, 63, 515, 275, 488, 267, 8837, 63, 3174, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 2758, 63, 515, 275, 488, 267, 291, 14, 9223, 63, 1574, 63, 504, 275, 7815, 257, 327, 3544, 1331, 22151, 4903, 315, 1094, 694, 16478, 347, 17284, 63, 1419, 8, 277, 304, 267, 20654, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 5799, 63, 815, 531, 267, 340, 20654, 14, 15697, 63, 5799, 63, 815, 26, 288, 746, 12577, 547, 8, 288, 298, 8254, 11441, 450, 82, 370, 450, 82, 2544, 1808, 283, 32176, 4065, 288, 450, 334, 24708, 14, 5799, 63, 815, 12, 20654, 14, 15697, 63, 5799, 63, 815, 9, 288, 776, 267, 291, 14, 589, 275, 359, 24708, 14, 5799, 63, 354, 61, 4388, 398, 8837, 63, 3174, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 4441, 63, 1095, 3220, 342, 267, 291, 14, 4441, 63, 3220, 342, 267, 327, 3732, 1536, 3272, 13, 694, 1275, 5799, 1584, 1454, 26, 949, 1275, 5799, 13, 815, 267, 291, 14, 2491, 63, 1080, 14, 6282, 8, 6463, 14, 6463, 360, 4856, 5799, 1333, 398, 291, 14, 5799, 63, 1073, 275, 747, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 20654, 14, 5799, 63, 354, 18098, 5799, 13, 1073, 358, 267, 291, 14, 5799, 63, 1095, 275, 20654, 14, 5799, 63, 1095, 267, 340, 291, 14, 5799, 63, 515, 365, 488, 26, 288, 291, 14, 5799, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 24708, 14, 5799, 63, 1095, 9, 398, 1347, 275, 7666, 63, 515, 8, 277, 14, 5799, 63, 1095, 9, 267, 340, 7666, 63, 515, 8, 736, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 291, 14, 5799, 63, 515, 430, 1137, 1347, 26, 288, 746, 31484, 8, 355, 4320, 5799, 13, 515, 1471, 506, 282, 3847, 931, 687, 314, 3907, 2, 355, 298, 2082, 370, 7210, 1375, 267, 776, 398, 327, 4155, 282, 4084, 367, 314, 2559, 1159, 1350, 267, 291, 14, 2686, 275, 11839, 8, 288, 1347, 12, 288, 6912, 5142, 8, 1375, 12, 747, 14, 515, 14, 4832, 8, 24708, 14, 5799, 63, 815, 1826, 288, 2199, 63, 354, 275, 20654, 14, 5799, 63, 354, 267, 776, 398, 299, 275, 291, 14, 5799, 63, 1095, 14, 1814, 8, 736, 14, 4127, 2584, 6217, 267, 340, 299, 1111, 747, 14, 15594, 26, 288, 299, 275, 11541, 4805, 627, 334, 80, 14, 835, 7825, 11, 17, 9, 267, 291, 14, 2758, 63, 515, 275, 299, 267, 299, 275, 7666, 63, 515, 8, 736, 14, 515, 14, 904, 8, 277, 14, 3174, 63, 694, 12, 291, 14, 5799, 63, 515, 12, 299, 430, 267, 340, 221, 299, 1137, 7666, 63, 515, 8, 736, 14, 15594, 304, 288, 746, 31484, 8, 355, 298, 6049, 1133, 664, 282, 12137, 931, 370, 3272, 2884, 687, 2, 355, 298, 12096, 2082, 401, 299, 12, 7666, 63, 515, 8, 736, 14, 15594, 430, 339, 347, 3907, 63, 509, 63, 31688, 8, 277, 304, 267, 340, 984, 14, 1023, 63, 815, 2356, 334, 19, 4258, 436, 2519, 8, 277, 14, 4972, 12, 283, 1180, 63, 18, 475, 19, 297, 756, 304, 288, 327, 982, 781, 1255, 499, 475, 19, 781, 883, 440, 886, 642, 16304, 26, 953, 327, 7523, 3341, 365, 1536, 13, 475, 13, 602, 288, 291, 14, 264, 8489, 63, 1531, 360, 1506, 63, 647, 297, 16304, 29, 16, 9, 288, 291, 14, 1065, 63, 1531, 360, 1506, 63, 647, 358, 288, 20575, 63, 1760, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 1506, 63, 647, 531, 288, 1900, 63, 515, 275, 7666, 63, 515, 8, 66, 647, 63, 1760, 14, 1506, 63, 773, 9, 953, 327, 6516, 5478, 288, 291, 14, 264, 8489, 63, 1531, 360, 5799, 63, 815, 297, 11393, 63, 1095, 29, 1506, 63, 515, 9, 288, 291, 14, 1065, 63, 1531, 360, 5799, 63, 815, 358, 953, 291, 14, 264, 8489, 63, 1531, 360, 1506, 63, 832, 297, 16304, 29, 16, 9, 288, 291, 14, 1065, 63, 1531, 360, 1506, 63, 832, 358, 7846, 327, 14811, 384, 11393, 13, 1073, 436, 8837, 13, 3174, 14, 13316, 288, 20654, 63, 1760, 275, 291, 14, 362, 63, 19231, 63, 1531, 480, 5799, 63, 815, 531, 288, 291, 14, 5799, 63, 515, 275, 1900, 63, 515, 288, 291, 14, 2686, 14, 1985, 275, 1900, 63, 515, 288, 291, 14, 2686, 423, 3780, 275, 6912, 5142, 8, 1506, 63, 515, 12, 20654, 63, 1760, 14, 5799, 63, 815, 9, 259, 327, 5787, 267, 587, 26, 288, 327, 23952, 499, 475, 19, 16304, 5419, 15701, 26, 288, 291, 14, 1065, 63, 1531, 360, 5799, 63, 815, 358, 953, 327, 6516, 5478, 315, 13, 2778, 288, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
arximboldi/jagsat
lib/tf/gfx/widget/basic.py
1
14927
# # Copyright (C) 2009 TribleFlame Oy # # This file is part of TF. # # TF 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. # # TF is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # from tf.gfx import ui from PySFML import sf import math import sets from tf.gfx import uirotation from tf.gfx import uiactions import re import os import random from PySFML import sf from tf import signalslot class PlayerPositionMarker(ui.Image): """This is a small marker symbol at the edge of the screen from which the user can control the direction in which the user interface is displayed.""" def __init__(self, parent, uirotationnotifier, realplayerinfo, marker_img_filename, markershadow_img_filename): ui.Image.__init__(self, parent, marker_img_filename) self.uirotationnotifier = uirotationnotifier self.set_enable_hitting(True) self.set_center(self._get_width() - 5, self._get_height() / 2.0) self.shadow = ui.Image(parent, markershadow_img_filename) self.shadow.set_center(self._get_width() - 5, self._get_height() / 2.0) self.shadow.set_visible(False) self.sticky_angles = sets.Set() def _calc_sticky_angles(self, window): self.sticky_angles = sets.Set([0, 90, 180, 270, 360]) ang = math.degrees(math.atan2(window.window.GetHeight(), window.window.GetWidth())) self.sticky_angles.add(90 - ang) self.sticky_angles.add(90 + ang) self.sticky_angles.add(270 + ang) self.sticky_angles.add(270 - ang) def set_focus(self, realplayerinfo, window): self.realplayerinfo = realplayerinfo self.window = window self._calc_sticky_angles(self.window) if self.realplayerinfo.rotate_ui: x, y = self.rotate(self.realplayerinfo.rotation) self.set_position(x, y) self.SetRotation(-self.realplayerinfo.rotation - 90) self.uirotationnotifier.notify_all_ui(self.realplayerinfo.rotation) def rotate(self, rotation): width = self.window.window.GetWidth() height = self.window.window.GetHeight() hw = width / 2 hh = height / 2 rot = rotation rot += 90 # XXX ??? rot = rot % 360 r = math.radians(rot) t = math.tan(r) # I don't understand this, but it seems to work if rot > 270 or rot <= 90: y = hh + t * hw x = width - 1 if y <= 0: y = 0 x = hw - hh / t elif y >= height: y = height - 1 x = hw + hh / t else: y = height - (hh + t * hw) x = 0 if y <= 0: y = 0 x = hw - hh / t elif y >= height: y = height - 1 x = hw + hh / t return x, y def start_pan(self, event): print "start player marker panning" self.shadow.set_visible(True) x, y = self.GetPosition() self.shadow.set_position(x, y) self.shadow.SetRotation(self.GetRotation()) def do_pan(self, event): x = event[0] y = event[1] angle = self._calc(x, y) x, y = self.rotate(angle) self.shadow.set_position(x, y) self.shadow.SetRotation(-angle - 90) def _calc(self, x, y): width = self.window.window.GetWidth() height = self.window.window.GetHeight() hw = width / 2 hh = height / 2 dx = x - hw dy = - (y - hh) angle = -math.degrees(math.atan2(dy, dx)) angle += 270 #?? angle = angle % 360 assert angle >= 0 assert angle < 360 STICKY_ANGLE = 3 for i in self.sticky_angles: da = abs(angle - i) if da < STICKY_ANGLE: angle = i break angle = angle % 360 return angle def end_pan(self, event): if self.realplayerinfo.rotate_ui: angle = self._calc(event[0], event[1]) self.realplayerinfo.rotation = angle self.set_focus(self.realplayerinfo, self.window) self.shadow.set_visible(False) def create_player_position_marker(parent, uirotationnotifier, realplayerinfo, img_name, imgshadow_name): c = PlayerPositionMarker(parent, uirotationnotifier, realplayerinfo, img_name, imgshadow_name) return c class _Key(ui.Image): def __init__(self, parent, fname, keyinfo): ui.Image.__init__(self, parent, fname) #self.set_center_rel(ui.CENTER) self.set_enable_hitting(True) self.keyinfo = keyinfo self.signal_click.add(lambda e: self.parent._hit_key(self)) # def user_hit(self, gameloop, x, y): # self.parent._hit_key(self) def get_dir_of_python_file(file): dir = re.sub("\\" + os.sep + "[^\\" + os.sep + "]+$", "", file) return dir class _KeyboardConfig: def __init__(self, parent, theme = None): self.keys = set() self.is_shifted = False dir = theme.directory if theme else get_dir_of_python_file(__file__) start_x = 30 start_y = 90 x = start_x y = start_y key_unit_width = 50 key_unit_height = 50 for i in [ #{ "key": "!", "pos": (0.0, 0.0) }, #{ "key": "?", }, #{ "key": ".", }, #{ "key": ",", }, #{ "key": ":", }, #{ "key": ";", }, #{ "key": "+", }, #{ "key": "-", }, #{ "key": "_", }, #{ "key": "\"", }, #{ "key": "#", }, #{ "key": "$", }, #{ "key": "%", }, #{ "key": "&", }, #{ "key": "/", }, #{ "key": "(", }, #{ "key": ")", }, #{ "key": "=", }, #{ "key": "<", "pos": (0.0, 0.0) }, #{ "key": ">", }, #{ "key": "{", }, #{ "key": "}", }, #{ "key": "[", }, #{ "key": "]", }, #{ "key": "", }, #{ "key": "", }, #{ "key": "", }, #{ "key": "", }, # + accented chars # + Other european chars # + others? {"key": "1", "shift": "!", "pos": (1.0, 0.0)}, {"key": "2", "shift": "\""}, {"key": "3", "shift": "#"}, {"key": "5", "shift": "%"}, {"key": "6", "shift": "&"}, {"key": "7", "shift": "/"}, {"key": "8", "shift": "("}, {"key": "9", "shift": ")"}, {"key": "0", "shift": "="}, {"key": "<-", "extra": "DEL", "pos": (13, 0)}, {"key": "q", "shift": "Q", "pos": (1.5, 1.0)}, {"key": "w", "shift": "W"}, {"key": "e", "shift": "E"}, {"key": "r", "shift": "R"}, {"key": "t", "shift": "T"}, {"key": "y", "shift": "Y"}, {"key": "u", "shift": "U"}, {"key": "i", "shift": "I"}, {"key": "o", "shift": "O"}, {"key": "p", "shift": "P"}, {"key": "a", "shift": "A", "pos": (2, 2.0)}, {"key": "s", "shift": "S"}, {"key": "d", "shift": "D"}, {"key": "f", "shift": "F"}, {"key": "g", "shift": "G"}, {"key": "h", "shift": "H"}, {"key": "j", "shift": "J"}, {"key": "k", "shift": "K"}, {"key": "l", "shift": "L"}, {"key": "<-/", "extra": "ENTER", "pos": (13, 1)}, {"key": "=^=", "extra": "SHIFTLEFT", "pos": (0.5, 3.0)}, {"key": "<", "shift": ">"}, {"key": "z", "shift": "Z"}, {"key": "x", "shift": "X"}, {"key": "c", "shift": "C"}, {"key": "v", "shift": "V"}, {"key": "b", "shift": "B"}, {"key": "n", "shift": "N"}, {"key": "m", "shift": "M"}, {"key": "=^=", "extra": "SHIFTRIGHT"}, ]: i["key"] = unicode(i["key"], "UTF-8") if "shift" in i: i["shift"] = unicode(i["shift"], "UTF-8") fname = None if "extra" in i: e = i["extra"] if False: pass elif e == "DEL": fname = dir + os.sep + "key_del.png" elif e == "ENTER": fname = dir + os.sep + "key_return.png" elif e == "SHIFTLEFT": fname = dir + os.sep + "key_shift_left.png" elif e == "SHIFTRIGHT": fname = dir + os.sep + "key_shift_right.png" else: # Key not supported print "KEY", e assert 0 else: fname = dir + os.sep + "one_key.png" u = _Key(None, fname, i) if "pos" in i: x = i["pos"][0] * key_unit_width + start_x y = i["pos"][1] * key_unit_height + start_y u.SetPosition(x, y) # XXX render this to the blackbox instead... parent.add_back_child(u) self.keys.add(u) if "extra" not in i: k = ui.String(None, i["key"]) yfuzz = -4 xfuzz = 0 k.SetPosition(u.GetPosition()[0] + u._get_width()/2.0 - \ k._get_width()/2.0 + xfuzz, u.GetPosition()[1] + u._get_height()/2.0 - \ k._get_height()/2.0 + yfuzz) parent.add_child(k) u.keysprite = k x += key_unit_width if x > parent.width - key_unit_width: x = start_x y += key_unit_height class Keyboard(ui.FreeformContainer): def __init__(self, parent, theme = None): ui.FreeformContainer.__init__(self, parent) self.width = 750 self.height = 300 self.set_position_rel(ui.CENTER) self.set_center_rel(ui.CENTER) # In letters -- not anymore, now in pixels :D self.maxlength = 260 blackbox = ui.RoundedRectangle(None, 0, 0, self.width, self.height, theme.blackbox.radius, theme.blackbox.color, theme.blackbox.border, theme.blackbox.thickness) self.set_enable_hitting(True) self.add_back_child(blackbox) whitestr = ui.String(None, u"") whitebox = ui.RoundedRectangle(None, 170, 30, 300, whitestr._get_height() + 45, theme.whitebox.radius, theme.whitebox.color, theme.whitebox.border, theme.whitebox.thickness) whitestr.SetPosition(15, 7) whitestr.set_size (25) self.add_child(whitebox) whitebox.add_child(whitestr) self.whitestr = whitestr self.kconfig = _KeyboardConfig(self, theme) self.signal_text_entered = signalslot.Signal("text_entered") self.signal_text_failed = signalslot.Signal("text_failed") uiactions.move_out(self, 200) def reinitialize(self): uiactions.move_in(self, 50) self.signal_text_entered.remove_all() self.signal_text_failed.remove_all() def set_max_length(self, mx): # In letters self.maxlength = mx def get_max_length(self): return self.maxlength def _hit_key(self, key): keyinfo = key.keyinfo s = self.whitestr.get_string() if "extra" in keyinfo: e = keyinfo["extra"] if 0: pass elif e == "DEL": s = s[:-1] elif e == "ENTER": # Accepts the string and sends it no observers e = signalslot.Event("text_entered", text = self.whitestr.get_string()) self.signal_text_entered.call(e) uiactions.move_out(self, 50) elif e == "SHIFTLEFT" or e == "SHIFTRIGHT": self.kconfig.is_shifted ^= True value = "key" if self.kconfig.is_shifted: value = "shift" for key in self.kconfig.keys: if "extra" in key.keyinfo: e = key.keyinfo["extra"] if e == "SHIFTLEFT" or e == "SHIFTRIGHT": if self.kconfig.is_shifted: c = sf.Color(200, 200, 200, 255) else: c = sf.Color(255, 255, 255, 255) key._sprite.SetColor(c) continue if value in key.keyinfo: # BUG this should be automatic u = key k = u.keysprite yfuzz = -4 xfuzz = 0 k.set_string(key.keyinfo[value]) k.SetPosition(u.GetPosition()[0] + \ u._get_width()/2.0 - \ k._get_width()/2.0 + xfuzz, u.GetPosition()[1] + \ u._get_height()/2.0 - \ k._get_height()/2.0 + yfuzz) else: assert 0 else: if self.whitestr._get_width () >= self.maxlength: return s += key.keysprite.get_string() self.whitestr.set_string(s) def show_keyboard_and_inject_answer(self, originstr, targetcallback_on_success, targetcallback_on_failure): self.reinitialize() self.whitestr.set_string(originstr) self.set_visible(True) self.signal_text_entered.add(targetcallback_on_success) self.signal_text_failed.add(targetcallback_on_failure) def show_keyboard_and_inject_answer_string(self, string): self.reinitialize() self.whitestr.set_string(string.get_string()) self.set_visible(True) self.signal_text_entered.add(lambda e: string.set_string(e.text))
gpl-3.0
[ 3, 199, 3, 221, 1898, 334, 35, 9, 8937, 12480, 830, 30999, 593, 89, 199, 3, 257, 199, 3, 221, 961, 570, 365, 1777, 402, 21721, 14, 199, 3, 257, 199, 3, 221, 21721, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 221, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 221, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 257, 199, 3, 221, 21721, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 257, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 3, 199, 199, 504, 2833, 14, 7102, 88, 492, 8574, 199, 504, 1611, 13107, 1698, 492, 13330, 199, 646, 3473, 199, 646, 5951, 199, 504, 2833, 14, 7102, 88, 492, 8574, 15362, 199, 504, 2833, 14, 7102, 88, 492, 8574, 3723, 199, 646, 295, 199, 646, 747, 199, 646, 2196, 199, 199, 504, 1611, 13107, 1698, 492, 13330, 199, 199, 504, 2833, 492, 10166, 1653, 421, 199, 533, 25610, 5625, 12825, 8, 1907, 14, 3491, 304, 272, 408, 2765, 365, 282, 7425, 3608, 5272, 737, 314, 6275, 402, 314, 6426, 272, 687, 1314, 314, 922, 883, 3304, 314, 7581, 315, 1314, 314, 922, 272, 3217, 365, 9080, 1041, 339, 347, 636, 826, 721, 277, 12, 326, 1676, 12, 326, 8574, 15362, 18031, 12, 326, 3363, 6147, 815, 12, 326, 3608, 63, 4060, 63, 1501, 12, 326, 3608, 14714, 63, 4060, 63, 1501, 304, 267, 8574, 14, 3491, 855, 826, 721, 277, 12, 1676, 12, 3608, 63, 4060, 63, 1501, 9, 267, 291, 14, 1907, 15362, 18031, 275, 8574, 15362, 18031, 267, 291, 14, 409, 63, 4296, 63, 12948, 1337, 8, 549, 9, 267, 291, 14, 409, 63, 4218, 8, 277, 423, 362, 63, 2063, 342, 446, 959, 12, 717, 291, 423, 362, 63, 3333, 342, 1182, 499, 14, 16, 9, 398, 291, 14, 14714, 275, 8574, 14, 3491, 8, 1708, 12, 3608, 14714, 63, 4060, 63, 1501, 9, 267, 291, 14, 14714, 14, 409, 63, 4218, 8, 277, 423, 362, 63, 2063, 342, 446, 959, 12, 3044, 291, 423, 362, 63, 3333, 342, 1182, 499, 14, 16, 9, 398, 291, 14, 14714, 14, 409, 63, 6604, 8, 797, 9, 267, 291, 14, 27364, 63, 13162, 275, 5951, 14, 1084, 342, 339, 347, 485, 8104, 63, 27364, 63, 13162, 8, 277, 12, 4353, 304, 267, 291, 14, 27364, 63, 13162, 275, 5951, 14, 1084, 779, 16, 12, 9137, 12, 13576, 12, 27632, 12, 19434, 566, 267, 14550, 275, 3473, 14, 20251, 8, 3442, 14, 16080, 18, 8, 3806, 14, 3806, 14, 1002, 8436, 1062, 4228, 4353, 14, 3806, 14, 1002, 6216, 4059, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 2710, 446, 14550, 9, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 2710, 435, 14550, 9, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 13299, 435, 14550, 9, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 13299, 446, 14550, 9, 339, 347, 663, 63, 12283, 8, 277, 12, 3363, 6147, 815, 12, 4353, 304, 267, 291, 14, 3093, 6147, 815, 275, 3363, 6147, 815, 267, 291, 14, 3806, 275, 4353, 267, 291, 423, 8104, 63, 27364, 63, 13162, 8, 277, 14, 3806, 9, 267, 340, 291, 14, 3093, 6147, 815, 14, 12873, 63, 1907, 26, 288, 671, 12, 612, 275, 291, 14, 12873, 8, 277, 14, 3093, 6147, 815, 14, 15362, 9, 288, 291, 14, 409, 63, 3124, 8, 88, 12, 612, 9, 288, 291, 14, 1084, 28247, 2801, 277, 14, 3093, 6147, 815, 14, 15362, 446, 9137, 9, 288, 291, 14, 1907, 15362, 18031, 14, 6814, 63, 452, 63, 1907, 8, 277, 14, 3093, 6147, 815, 14, 15362, 9, 339, 347, 20071, 8, 277, 12, 13038, 304, 267, 3462, 275, 291, 14, 3806, 14, 3806, 14, 1002, 6216, 342, 267, 4569, 275, 291, 14, 3806, 14, 3806, 14, 1002, 8436, 342, 267, 12073, 275, 3462, 1182, 499, 267, 25783, 275, 4569, 1182, 499, 267, 7513, 275, 13038, 267, 7513, 847, 9137, 327, 5787, 5805, 10674, 267, 7513, 275, 7513, 450, 19434, 267, 519, 275, 3473, 14, 22946, 8, 4571, 9, 267, 307, 275, 3473, 14, 12990, 8, 82, 9, 398, 327, 473, 2793, 1133, 20647, 642, 12, 1325, 652, 12237, 370, 1736, 398, 340, 7513, 690, 27632, 503, 7513, 2695, 9137, 26, 288, 612, 275, 25783, 435, 307, 627, 12073, 288, 671, 275, 3462, 446, 413, 288, 340, 612, 2695, 378, 26, 355, 612, 275, 378, 355, 671, 275, 12073, 446, 25783, 1182, 307, 288, 916, 612, 2356, 4569, 26, 355, 612, 275, 4569, 446, 413, 355, 671, 275, 12073, 435, 25783, 1182, 307, 267, 587, 26, 288, 612, 275, 4569, 446, 334, 12156, 435, 307, 627, 12073, 9, 288, 671, 275, 378, 288, 340, 612, 2695, 378, 26, 355, 612, 275, 378, 355, 671, 275, 12073, 446, 25783, 1182, 307, 288, 916, 612, 2356, 4569, 26, 355, 612, 275, 4569, 446, 413, 355, 671, 275, 12073, 435, 25783, 1182, 307, 398, 372, 671, 12, 612, 339, 347, 1343, 63, 10384, 8, 277, 12, 1566, 304, 267, 870, 298, 928, 7748, 3608, 299, 11495, 2, 267, 291, 14, 14714, 14, 409, 63, 6604, 8, 549, 9, 267, 671, 12, 612, 275, 291, 14, 1002, 5625, 342, 267, 291, 14, 14714, 14, 409, 63, 3124, 8, 88, 12, 612, 9, 267, 291, 14, 14714, 14, 1084, 28247, 8, 277, 14, 1002, 28247, 1012, 339, 347, 886, 63, 10384, 8, 277, 12, 1566, 304, 267, 671, 275, 1566, 59, 16, 61, 267, 612, 275, 1566, 59, 17, 61, 267, 9324, 275, 291, 423, 8104, 8, 88, 12, 612, 9 ]
[ 199, 3, 221, 1898, 334, 35, 9, 8937, 12480, 830, 30999, 593, 89, 199, 3, 257, 199, 3, 221, 961, 570, 365, 1777, 402, 21721, 14, 199, 3, 257, 199, 3, 221, 21721, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 221, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 221, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 257, 199, 3, 221, 21721, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 257, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 3, 199, 199, 504, 2833, 14, 7102, 88, 492, 8574, 199, 504, 1611, 13107, 1698, 492, 13330, 199, 646, 3473, 199, 646, 5951, 199, 504, 2833, 14, 7102, 88, 492, 8574, 15362, 199, 504, 2833, 14, 7102, 88, 492, 8574, 3723, 199, 646, 295, 199, 646, 747, 199, 646, 2196, 199, 199, 504, 1611, 13107, 1698, 492, 13330, 199, 199, 504, 2833, 492, 10166, 1653, 421, 199, 533, 25610, 5625, 12825, 8, 1907, 14, 3491, 304, 272, 408, 2765, 365, 282, 7425, 3608, 5272, 737, 314, 6275, 402, 314, 6426, 272, 687, 1314, 314, 922, 883, 3304, 314, 7581, 315, 1314, 314, 922, 272, 3217, 365, 9080, 1041, 339, 347, 636, 826, 721, 277, 12, 326, 1676, 12, 326, 8574, 15362, 18031, 12, 326, 3363, 6147, 815, 12, 326, 3608, 63, 4060, 63, 1501, 12, 326, 3608, 14714, 63, 4060, 63, 1501, 304, 267, 8574, 14, 3491, 855, 826, 721, 277, 12, 1676, 12, 3608, 63, 4060, 63, 1501, 9, 267, 291, 14, 1907, 15362, 18031, 275, 8574, 15362, 18031, 267, 291, 14, 409, 63, 4296, 63, 12948, 1337, 8, 549, 9, 267, 291, 14, 409, 63, 4218, 8, 277, 423, 362, 63, 2063, 342, 446, 959, 12, 717, 291, 423, 362, 63, 3333, 342, 1182, 499, 14, 16, 9, 398, 291, 14, 14714, 275, 8574, 14, 3491, 8, 1708, 12, 3608, 14714, 63, 4060, 63, 1501, 9, 267, 291, 14, 14714, 14, 409, 63, 4218, 8, 277, 423, 362, 63, 2063, 342, 446, 959, 12, 3044, 291, 423, 362, 63, 3333, 342, 1182, 499, 14, 16, 9, 398, 291, 14, 14714, 14, 409, 63, 6604, 8, 797, 9, 267, 291, 14, 27364, 63, 13162, 275, 5951, 14, 1084, 342, 339, 347, 485, 8104, 63, 27364, 63, 13162, 8, 277, 12, 4353, 304, 267, 291, 14, 27364, 63, 13162, 275, 5951, 14, 1084, 779, 16, 12, 9137, 12, 13576, 12, 27632, 12, 19434, 566, 267, 14550, 275, 3473, 14, 20251, 8, 3442, 14, 16080, 18, 8, 3806, 14, 3806, 14, 1002, 8436, 1062, 4228, 4353, 14, 3806, 14, 1002, 6216, 4059, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 2710, 446, 14550, 9, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 2710, 435, 14550, 9, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 13299, 435, 14550, 9, 267, 291, 14, 27364, 63, 13162, 14, 525, 8, 13299, 446, 14550, 9, 339, 347, 663, 63, 12283, 8, 277, 12, 3363, 6147, 815, 12, 4353, 304, 267, 291, 14, 3093, 6147, 815, 275, 3363, 6147, 815, 267, 291, 14, 3806, 275, 4353, 267, 291, 423, 8104, 63, 27364, 63, 13162, 8, 277, 14, 3806, 9, 267, 340, 291, 14, 3093, 6147, 815, 14, 12873, 63, 1907, 26, 288, 671, 12, 612, 275, 291, 14, 12873, 8, 277, 14, 3093, 6147, 815, 14, 15362, 9, 288, 291, 14, 409, 63, 3124, 8, 88, 12, 612, 9, 288, 291, 14, 1084, 28247, 2801, 277, 14, 3093, 6147, 815, 14, 15362, 446, 9137, 9, 288, 291, 14, 1907, 15362, 18031, 14, 6814, 63, 452, 63, 1907, 8, 277, 14, 3093, 6147, 815, 14, 15362, 9, 339, 347, 20071, 8, 277, 12, 13038, 304, 267, 3462, 275, 291, 14, 3806, 14, 3806, 14, 1002, 6216, 342, 267, 4569, 275, 291, 14, 3806, 14, 3806, 14, 1002, 8436, 342, 267, 12073, 275, 3462, 1182, 499, 267, 25783, 275, 4569, 1182, 499, 267, 7513, 275, 13038, 267, 7513, 847, 9137, 327, 5787, 5805, 10674, 267, 7513, 275, 7513, 450, 19434, 267, 519, 275, 3473, 14, 22946, 8, 4571, 9, 267, 307, 275, 3473, 14, 12990, 8, 82, 9, 398, 327, 473, 2793, 1133, 20647, 642, 12, 1325, 652, 12237, 370, 1736, 398, 340, 7513, 690, 27632, 503, 7513, 2695, 9137, 26, 288, 612, 275, 25783, 435, 307, 627, 12073, 288, 671, 275, 3462, 446, 413, 288, 340, 612, 2695, 378, 26, 355, 612, 275, 378, 355, 671, 275, 12073, 446, 25783, 1182, 307, 288, 916, 612, 2356, 4569, 26, 355, 612, 275, 4569, 446, 413, 355, 671, 275, 12073, 435, 25783, 1182, 307, 267, 587, 26, 288, 612, 275, 4569, 446, 334, 12156, 435, 307, 627, 12073, 9, 288, 671, 275, 378, 288, 340, 612, 2695, 378, 26, 355, 612, 275, 378, 355, 671, 275, 12073, 446, 25783, 1182, 307, 288, 916, 612, 2356, 4569, 26, 355, 612, 275, 4569, 446, 413, 355, 671, 275, 12073, 435, 25783, 1182, 307, 398, 372, 671, 12, 612, 339, 347, 1343, 63, 10384, 8, 277, 12, 1566, 304, 267, 870, 298, 928, 7748, 3608, 299, 11495, 2, 267, 291, 14, 14714, 14, 409, 63, 6604, 8, 549, 9, 267, 671, 12, 612, 275, 291, 14, 1002, 5625, 342, 267, 291, 14, 14714, 14, 409, 63, 3124, 8, 88, 12, 612, 9, 267, 291, 14, 14714, 14, 1084, 28247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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 ]
ToonTownInfiniteRepo/ToontownInfinite
toontown/toon/InventoryNew.py
1
56688
from direct.gui.DirectGui import * from pandac.PandaModules import * from toontown.toonbase.ToontownBattleGlobals import * import InventoryBase from toontown.toonbase import TTLocalizer from toontown.quest import BlinkingArrows from direct.interval.IntervalGlobal import * from direct.directnotify import DirectNotifyGlobal from toontown.toonbase import ToontownGlobals from otp.otpbase import OTPGlobals class InventoryNew(InventoryBase.InventoryBase, DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('InventoryNew') PressableTextColor = Vec4(1, 1, 1, 1) PressableGeomColor = Vec4(1, 1, 1, 1) PressableImageColor = Vec4(0, 0.6, 1, 1) PropBonusPressableImageColor = Vec4(1.0, 0.6, 0.0, 1) NoncreditPressableImageColor = Vec4(0.3, 0.6, 0.6, 1) PropBonusNoncreditPressableImageColor = Vec4(0.6, 0.6, 0.3, 1) DeletePressableImageColor = Vec4(0.7, 0.1, 0.1, 1) UnpressableTextColor = Vec4(1, 1, 1, 0.3) UnpressableGeomColor = Vec4(1, 1, 1, 0.3) UnpressableImageColor = Vec4(0.3, 0.3, 0.3, 0.8) BookUnpressableTextColor = Vec4(1, 1, 1, 1) BookUnpressableGeomColor = Vec4(1, 1, 1, 1) BookUnpressableImage0Color = Vec4(0, 0.6, 1, 1) BookUnpressableImage2Color = Vec4(0.1, 0.7, 1, 1) ShadowColor = Vec4(0, 0, 0, 0) ShadowBuffedColor = Vec4(1, 1, 1, 1) UnpressableShadowBuffedColor = Vec4(1, 1, 1, 0.3) TrackYOffset = 0.0 TrackYSpacing = -0.12 ButtonXOffset = -0.31 ButtonXSpacing = 0.18 def __init__(self, toon, invStr = None, ShowSuperGags = 1): InventoryBase.InventoryBase.__init__(self, toon, invStr) DirectFrame.__init__(self, relief=None) self.initialiseoptions(InventoryNew) self.battleCreditLevel = None self.detailCredit = None self.__battleCreditMultiplier = 1 self.__invasionCreditMultiplier = 1 self.__respectInvasions = 1 self._interactivePropTrackBonus = -1 self.tutorialFlag = 0 self.gagTutMode = 0 self.showSuperGags = ShowSuperGags self.clickSuperGags = 1 self.propAndOrganicBonusStack = base.config.GetBool('prop-and-organic-bonus-stack', 0) self.propBonusIval = Parallel() self.activateMode = 'book' self.load() self.hide() return def setBattleCreditMultiplier(self, mult): self.__battleCreditMultiplier = mult def getBattleCreditMultiplier(self): return self.__battleCreditMultiplier def setInteractivePropTrackBonus(self, trackBonus): self._interactivePropTrackBonus = trackBonus def getInteractivePropTrackBonus(self): return self._interactivePropTrackBonus def setInvasionCreditMultiplier(self, mult): self.__invasionCreditMultiplier = mult def getInvasionCreditMultiplier(self): return self.__invasionCreditMultiplier def setRespectInvasions(self, flag): self.__respectInvasions = flag def getRespectInvasions(self): return self.__respectInvasions def show(self): if self.tutorialFlag: self.tutArrows.arrowsOn(-0.43, -0.12, 180, -0.43, -0.24, 180, onTime=1.0, offTime=0.2) if self.numItem(THROW_TRACK, 0) == 0: self.tutArrows.arrow1.reparentTo(hidden) else: self.tutArrows.arrow1.reparentTo(self.battleFrame, 1) if self.numItem(SQUIRT_TRACK, 0) == 0: self.tutArrows.arrow2.reparentTo(hidden) else: self.tutArrows.arrow2.reparentTo(self.battleFrame, 1) self.tutText.show() self.tutText.reparentTo(self.battleFrame, 1) DirectFrame.show(self) def uberGagToggle(self, showSuperGags = 1): self.showSuperGags = showSuperGags for itemList in self.invModels: for itemIndex in xrange(MAX_LEVEL_INDEX + 1): if itemIndex <= LAST_REGULAR_GAG_LEVEL + 1 or self.showSuperGags: itemList[itemIndex].show() else: itemList[itemIndex].hide() for buttonList in self.buttons: for buttonIndex in xrange(MAX_LEVEL_INDEX + 1): if buttonIndex <= LAST_REGULAR_GAG_LEVEL or self.showSuperGags: buttonList[buttonIndex].show() else: buttonList[buttonIndex].hide() def enableUberGags(self, enableSG = -1): if enableSG != -1: self.clickSuperGags = enableSG for buttonList in self.buttons: for buttonIndex in xrange(LAST_REGULAR_GAG_LEVEL + 1, MAX_LEVEL_INDEX + 1): if self.clickSuperGags: pass else: self.makeUnpressable(buttonList[buttonIndex], self.buttons.index(buttonList), buttonIndex) def hide(self): if self.tutorialFlag: self.tutArrows.arrowsOff() self.tutText.hide() DirectFrame.hide(self) def updateTotalPropsText(self): textTotal = TTLocalizer.InventoryTotalGags % (self.totalProps, self.toon.getMaxCarry()) if localAvatar.getPinkSlips() > 1: textTotal = textTotal + '\n\n' + TTLocalizer.InventroyPinkSlips % localAvatar.getPinkSlips() elif localAvatar.getPinkSlips() == 1: textTotal = textTotal + '\n\n' + TTLocalizer.InventroyPinkSlip self.totalLabel['text'] = textTotal def unload(self): self.notify.debug('Unloading Inventory for %d' % self.toon.doId) self.stopAndClearPropBonusIval() self.propBonusIval.finish() self.propBonusIval = None del self.invModels self.buttonModels.removeNode() del self.buttonModels del self.upButton del self.downButton del self.rolloverButton del self.flatButton del self.invFrame del self.battleFrame del self.purchaseFrame del self.storePurchaseFrame self.deleteEnterButton.destroy() del self.deleteEnterButton self.deleteExitButton.destroy() del self.deleteExitButton del self.detailFrame del self.detailNameLabel del self.detailAmountLabel del self.detailDataLabel del self.totalLabel for row in self.trackRows: row.destroy() del self.trackRows del self.trackNameLabels del self.trackBars for buttonList in self.buttons: for buttonIndex in xrange(MAX_LEVEL_INDEX + 1): buttonList[buttonIndex].destroy() del self.buttons InventoryBase.InventoryBase.unload(self) DirectFrame.destroy(self) return def load(self): self.notify.debug('Loading Inventory for %d' % self.toon.doId) invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons') self.invModels = [] for track in xrange(len(AvPropsNew)): itemList = [] for item in xrange(len(AvPropsNew[track])): itemList.append(invModel.find('**/' + AvPropsNew[track][item])) self.invModels.append(itemList) invModel.removeNode() del invModel self.buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui') self.rowModel = self.buttonModels.find('**/InventoryRow') self.upButton = self.buttonModels.find('**/InventoryButtonUp') self.downButton = self.buttonModels.find('**/InventoryButtonDown') self.rolloverButton = self.buttonModels.find('**/InventoryButtonRollover') self.flatButton = self.buttonModels.find('**/InventoryButtonFlat') self.invFrame = DirectFrame(relief=None, parent=self) self.battleFrame = None self.purchaseFrame = None self.storePurchaseFrame = None trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui') self.deleteEnterButton = DirectButton(parent=self.invFrame, image=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.InventoryDelete, TTLocalizer.InventoryDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-1, 0, -0.35), scale=1.0) self.deleteExitButton = DirectButton(parent=self.invFrame, image=(trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.InventoryDone, TTLocalizer.InventoryDone), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(0, -0.1), text_font=getInterfaceFont(), textMayChange=0, relief=None, pos=(-1, 0, -0.35), scale=1.0) trashcanGui.removeNode() self.deleteHelpText = DirectLabel(parent=self.invFrame, relief=None, pos=(0.272, 0.3, -0.907), text=TTLocalizer.InventoryDeleteHelp, text_fg=(0, 0, 0, 1), text_scale=0.08, textMayChange=0) self.deleteHelpText.hide() self.detailFrame = DirectFrame(parent=self.invFrame, relief=None, pos=(1.05, 0, -0.08)) self.detailNameLabel = DirectLabel(parent=self.detailFrame, text='', text_scale=TTLocalizer.INdetailNameLabel, text_fg=(0.05, 0.14, 0.4, 1), scale=0.045, pos=(0, 0, 0), text_font=getInterfaceFont(), relief=None, image=self.invModels[0][0]) self.detailAmountLabel = DirectLabel(parent=self.detailFrame, text='', text_fg=(0.05, 0.14, 0.4, 1), scale=0.04, pos=(0.16, 0, -0.175), text_font=getInterfaceFont(), text_align=TextNode.ARight, relief=None) self.detailDataLabel = DirectLabel(parent=self.detailFrame, text='', text_fg=(0.05, 0.14, 0.4, 1), scale=0.04, pos=(-0.22, 0, -0.24), text_font=getInterfaceFont(), text_align=TextNode.ALeft, relief=None) self.detailCreditLabel = DirectLabel(parent=self.detailFrame, text=TTLocalizer.InventorySkillCreditNone, text_fg=(0.05, 0.14, 0.4, 1), scale=0.04, pos=(-0.22, 0, -0.365), text_font=getInterfaceFont(), text_align=TextNode.ALeft, relief=None) self.detailCreditLabel.hide() self.totalLabel = DirectLabel(text='', parent=self.detailFrame, pos=(0, 0, -0.095), scale=0.05, text_fg=(0.05, 0.14, 0.4, 1), text_font=getInterfaceFont(), relief=None) self.updateTotalPropsText() self.trackRows = [] self.trackNameLabels = [] self.trackBars = [] self.buttons = [] for track in xrange(0, len(Tracks)): trackFrame = DirectFrame(parent=self.invFrame, image=self.rowModel, scale=(1.0, 1.0, 1.1), pos=(0, 0.3, self.TrackYOffset + track * self.TrackYSpacing), image_color=(TrackColors[track][0], TrackColors[track][1], TrackColors[track][2], 1), state=DGG.NORMAL, relief=None) trackFrame.bind(DGG.WITHIN, self.enterTrackFrame, extraArgs=[track]) trackFrame.bind(DGG.WITHOUT, self.exitTrackFrame, extraArgs=[track]) self.trackRows.append(trackFrame) adjustLeft = -0.065 self.trackNameLabels.append(DirectLabel(text=TextEncoder.upper(Tracks[track]), parent=self.trackRows[track], pos=(-0.72 + adjustLeft, -0.1, 0.01), scale=TTLocalizer.INtrackNameLabels, relief=None, text_fg=(0.2, 0.2, 0.2, 1), text_font=getInterfaceFont(), text_align=TextNode.ALeft, textMayChange=0)) self.trackBars.append(DirectWaitBar(parent=self.trackRows[track], pos=(-0.58 + adjustLeft, -0.1, -0.025), relief=DGG.SUNKEN, frameSize=(-0.6, 0.6, -0.1, 0.1), borderWidth=(0.02, 0.02), scale=0.25, frameColor=(TrackColors[track][0] * 0.6, TrackColors[track][1] * 0.6, TrackColors[track][2] * 0.6, 1), barColor=(TrackColors[track][0] * 0.9, TrackColors[track][1] * 0.9, TrackColors[track][2] * 0.9, 1), text='0 / 0', text_scale=0.16, text_fg=(0, 0, 0, 0.8), text_align=TextNode.ACenter, text_pos=(0, -0.05))) self.buttons.append([]) for item in xrange(0, len(Levels[track])): button = DirectButton(parent=self.trackRows[track], image=(self.upButton, self.downButton, self.rolloverButton, self.flatButton), geom=self.invModels[track][item], text='50', text_scale=0.04, text_align=TextNode.ARight, geom_scale=0.7, geom_pos=(-0.01, -0.1, 0), text_fg=Vec4(1, 1, 1, 1), text_pos=(0.07, -0.04), textMayChange=1, relief=None, image_color=(0, 0.6, 1, 1), pos=(self.ButtonXOffset + item * self.ButtonXSpacing + adjustLeft, -0.1, 0), command=self.__handleSelection, extraArgs=[track, item]) button.bind(DGG.ENTER, self.showDetail, extraArgs=[track, item]) button.bind(DGG.EXIT, self.hideDetail) self.buttons[track].append(button) return def __handleSelection(self, track, level): if self.activateMode == 'purchaseDelete' or self.activateMode == 'bookDelete' or self.activateMode == 'storePurchaseDelete': if self.numItem(track, level): self.useItem(track, level) self.updateGUI(track, level) messenger.send('inventory-deletion', [track, level]) self.showDetail(track, level) elif self.activateMode == 'purchase' or self.activateMode == 'storePurchase': messenger.send('inventory-selection', [track, level]) self.showDetail(track, level) elif self.gagTutMode: pass else: messenger.send('inventory-selection', [track, level]) def __handleRun(self): messenger.send('inventory-run') def __handleFire(self): messenger.send('inventory-fire') def __handleSOS(self): messenger.send('inventory-sos') def __handlePass(self): messenger.send('inventory-pass') def __handleBackToPlayground(self): messenger.send('inventory-back-to-playground') def showDetail(self, track, level, event = None): self.totalLabel.hide() self.detailNameLabel.show() self.detailNameLabel.configure(text=AvPropStrings[track][level], image_image=self.invModels[track][level]) self.detailNameLabel.configure(image_scale=20, image_pos=(-0.2, 0, -2.2)) self.detailAmountLabel.show() self.detailAmountLabel.configure(text=TTLocalizer.InventoryDetailAmount % {'numItems': self.numItem(track, level), 'maxItems': self.getMax(track, level)}) self.detailDataLabel.show() damage = getAvPropDamage(track, level, self.toon.experience.getExp(track)) organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) damageBonusStr = '' damageBonus = 0 if self.propAndOrganicBonusStack: if propBonus: damageBonus += getDamageBonus(damage) if organicBonus: damageBonus += getDamageBonus(damage) if damageBonus: damageBonusStr = TTLocalizer.InventoryDamageBonus % damageBonus else: if propBonus or organicBonus: damageBonus += getDamageBonus(damage) if damageBonus: damageBonusStr = TTLocalizer.InventoryDamageBonus % damageBonus accString = AvTrackAccStrings[track] if (organicBonus or propBonus) and track == LURE_TRACK: accString = TTLocalizer.BattleGlobalLureAccMedium self.detailDataLabel.configure(text=TTLocalizer.InventoryDetailData % {'accuracy': accString, 'damageString': self.getToonupDmgStr(track, level), 'damage': damage, 'bonus': damageBonusStr, 'singleOrGroup': self.getSingleGroupStr(track, level)}) if self.itemIsCredit(track, level): mult = self.__battleCreditMultiplier if self.__respectInvasions: mult *= self.__invasionCreditMultiplier self.setDetailCredit(track, (level + 1) * mult) else: self.setDetailCredit(track, None) self.detailCreditLabel.show() return def setDetailCredit(self, track, credit): if credit != None: if self.toon.earnedExperience: maxCredit = ExperienceCap - self.toon.earnedExperience[track] credit = min(credit, maxCredit) credit = int(credit * 10 + 0.5) if credit % 10 == 0: credit /= 10 else: credit /= 10.0 if self.detailCredit == credit: return if credit != None: self.detailCreditLabel['text'] = TTLocalizer.InventorySkillCredit % credit if self.detailCredit == None: self.detailCreditLabel['text_fg'] = (0.05, 0.14, 0.4, 1) else: self.detailCreditLabel['text'] = TTLocalizer.InventorySkillCreditNone self.detailCreditLabel['text_fg'] = (0.5, 0.0, 0.0, 1.0) self.detailCredit = credit return def hideDetail(self, event = None): self.totalLabel.show() self.detailNameLabel.hide() self.detailAmountLabel.hide() self.detailDataLabel.hide() self.detailCreditLabel.hide() def noDetail(self): self.totalLabel.hide() self.detailNameLabel.hide() self.detailAmountLabel.hide() self.detailDataLabel.hide() self.detailCreditLabel.hide() def setActivateMode(self, mode, heal = 1, trap = 1, lure = 1, bldg = 0, creditLevel = None, tutorialFlag = 0, gagTutMode = 0): self.notify.debug('setActivateMode() mode:%s heal:%s trap:%s lure:%s bldg:%s' % (mode, heal, trap, lure, bldg)) self.previousActivateMode = self.activateMode self.activateMode = mode self.deactivateButtons() self.heal = heal self.trap = trap self.lure = lure self.bldg = bldg self.battleCreditLevel = creditLevel self.tutorialFlag = tutorialFlag self.gagTutMode = gagTutMode self.__activateButtons() self.enableUberGags() return None def setActivateModeBroke(self): if self.activateMode == 'storePurchase': self.setActivateMode('storePurchaseBroke') elif self.activateMode == 'purchase': self.setActivateMode('purchaseBroke', gagTutMode=self.gagTutMode) else: self.notify.error('Unexpected mode in setActivateModeBroke(): %s' % self.activateMode) self.enableUberGags() def deactivateButtons(self): if self.previousActivateMode == 'book': self.bookDeactivateButtons() elif self.previousActivateMode == 'bookDelete': self.bookDeleteDeactivateButtons() elif self.previousActivateMode == 'purchaseDelete': self.purchaseDeleteDeactivateButtons() elif self.previousActivateMode == 'purchase': self.purchaseDeactivateButtons() elif self.previousActivateMode == 'purchaseBroke': self.purchaseBrokeDeactivateButtons() elif self.previousActivateMode == 'gagTutDisabled': self.gagTutDisabledDeactivateButtons() elif self.previousActivateMode == 'battle': self.battleDeactivateButtons() elif self.previousActivateMode == 'storePurchaseDelete': self.storePurchaseDeleteDeactivateButtons() elif self.previousActivateMode == 'storePurchase': self.storePurchaseDeactivateButtons() elif self.previousActivateMode == 'storePurchaseBroke': self.storePurchaseBrokeDeactivateButtons() elif self.previousActivateMode == 'plantTree': self.plantTreeDeactivateButtons() else: self.notify.error('No such mode as %s' % self.previousActivateMode) return None def __activateButtons(self): if hasattr(self, 'activateMode'): if self.activateMode == 'book': self.bookActivateButtons() elif self.activateMode == 'bookDelete': self.bookDeleteActivateButtons() elif self.activateMode == 'purchaseDelete': self.purchaseDeleteActivateButtons() elif self.activateMode == 'purchase': self.purchaseActivateButtons() elif self.activateMode == 'purchaseBroke': self.purchaseBrokeActivateButtons() elif self.activateMode == 'gagTutDisabled': self.gagTutDisabledActivateButtons() elif self.activateMode == 'battle': self.battleActivateButtons() elif self.activateMode == 'storePurchaseDelete': self.storePurchaseDeleteActivateButtons() elif self.activateMode == 'storePurchase': self.storePurchaseActivateButtons() elif self.activateMode == 'storePurchaseBroke': self.storePurchaseBrokeActivateButtons() elif self.activateMode == 'plantTree': self.plantTreeActivateButtons() else: self.notify.error('No such mode as %s' % self.activateMode) return None def bookActivateButtons(self): self.setPos(0, 0, 0.52) self.setScale(1.0) self.detailFrame.setPos(0.1, 0, -0.855) self.detailFrame.setScale(0.75) self.deleteEnterButton.hide() self.deleteEnterButton.setPos(1.029, 0, -0.639) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.hide() self.deleteExitButton.setPos(1.029, 0, -0.639) self.deleteExitButton.setScale(0.75) self.invFrame.reparentTo(self) self.invFrame.setPos(0, 0, 0) self.invFrame.setScale(1) self.deleteEnterButton['command'] = self.setActivateMode self.deleteEnterButton['extraArgs'] = ['bookDelete'] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() self.makeBookUnpressable(button, track, level) else: button.hide() else: self.hideTrack(track) return None def bookDeactivateButtons(self): self.deleteEnterButton['command'] = None return def bookDeleteActivateButtons(self): messenger.send('enterBookDelete') self.setPos(-0.2, 0, 0.4) self.setScale(0.8) self.deleteEnterButton.hide() self.deleteEnterButton.setPos(1.029, 0, -0.639) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.show() self.deleteExitButton.setPos(1.029, 0, -0.639) self.deleteExitButton.setScale(0.75) self.deleteHelpText.show() self.invFrame.reparentTo(self) self.invFrame.setPos(0, 0, 0) self.invFrame.setScale(1) self.deleteExitButton['command'] = self.setActivateMode self.deleteExitButton['extraArgs'] = [self.previousActivateMode] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() if self.numItem(track, level) <= 0: self.makeUnpressable(button, track, level) else: self.makeDeletePressable(button, track, level) else: button.hide() else: self.hideTrack(track) def bookDeleteDeactivateButtons(self): messenger.send('exitBookDelete') self.deleteHelpText.hide() self.deleteDeactivateButtons() def purchaseDeleteActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.purchaseFrame == None: self.loadPurchaseFrame() self.purchaseFrame.show() self.invFrame.reparentTo(self.purchaseFrame) self.invFrame.setPos(-0.235, 0, 0.52) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.17, 0, -0.02) self.detailFrame.setScale(1.25) self.deleteEnterButton.hide() self.deleteEnterButton.setPos(-0.441, 0, -0.917) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.show() self.deleteExitButton.setPos(-0.441, 0, -0.917) self.deleteExitButton.setScale(0.75) self.deleteExitButton['command'] = self.setActivateMode self.deleteExitButton['extraArgs'] = [self.previousActivateMode] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() if self.numItem(track, level) <= 0 or level >= UBER_GAG_LEVEL_INDEX: self.makeUnpressable(button, track, level) else: self.makeDeletePressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def purchaseDeleteDeactivateButtons(self): self.invFrame.reparentTo(self) self.purchaseFrame.hide() self.deleteDeactivateButtons() for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() if self.numItem(track, level) <= 0 or level >= UBER_GAG_LEVEL_INDEX: self.makeUnpressable(button, track, level) else: self.makeDeletePressable(button, track, level) else: button.hide() else: self.hideTrack(track) def storePurchaseDeleteActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.storePurchaseFrame == None: self.loadStorePurchaseFrame() self.storePurchaseFrame.show() self.invFrame.reparentTo(self.storePurchaseFrame) self.invFrame.setPos(-0.23, 0, 0.505) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.175, 0, 0) self.detailFrame.setScale(1.25) self.deleteEnterButton.hide() self.deleteEnterButton.setPos(-0.55, 0, -0.91) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.show() self.deleteExitButton.setPos(-0.55, 0, -0.91) self.deleteExitButton.setScale(0.75) self.deleteExitButton['command'] = self.setActivateMode self.deleteExitButton['extraArgs'] = [self.previousActivateMode] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() if self.numItem(track, level) <= 0 or level >= UBER_GAG_LEVEL_INDEX: self.makeUnpressable(button, track, level) else: self.makeDeletePressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def storePurchaseDeleteDeactivateButtons(self): self.invFrame.reparentTo(self) self.storePurchaseFrame.hide() self.deleteDeactivateButtons() def storePurchaseBrokeActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.storePurchaseFrame == None: self.loadStorePurchaseFrame() self.storePurchaseFrame.show() self.invFrame.reparentTo(self.storePurchaseFrame) self.invFrame.setPos(-0.23, 0, 0.505) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.175, 0, 0) self.detailFrame.setScale(1.25) self.deleteEnterButton.show() self.deleteEnterButton.setPos(-0.55, 0, -0.91) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.hide() self.deleteExitButton.setPos(-0.551, 0, -0.91) self.deleteExitButton.setScale(0.75) for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() self.makeUnpressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def storePurchaseBrokeDeactivateButtons(self): self.invFrame.reparentTo(self) self.storePurchaseFrame.hide() def deleteActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0, 0, 0) self.setScale(1) self.deleteEnterButton.hide() self.deleteExitButton.show() self.deleteExitButton['command'] = self.setActivateMode self.deleteExitButton['extraArgs'] = [self.previousActivateMode] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() if self.numItem(track, level) <= 0: self.makeUnpressable(button, track, level) else: self.makePressable(button, track, level) else: button.hide() else: self.hideTrack(track) return None def deleteDeactivateButtons(self): self.deleteExitButton['command'] = None return def purchaseActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.purchaseFrame == None: self.loadPurchaseFrame() self.purchaseFrame.show() self.invFrame.reparentTo(self.purchaseFrame) self.invFrame.setPos(-0.235, 0, 0.52) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.17, 0, -0.02) self.detailFrame.setScale(1.25) totalProps = self.totalProps maxProps = self.toon.getMaxCarry() self.deleteEnterButton.show() self.deleteEnterButton.setPos(-0.441, 0, -0.917) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.hide() self.deleteExitButton.setPos(-0.441, 0, -0.917) self.deleteExitButton.setScale(0.75) if self.gagTutMode: self.deleteEnterButton.hide() self.deleteEnterButton['command'] = self.setActivateMode self.deleteEnterButton['extraArgs'] = ['purchaseDelete'] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() unpaid = not base.cr.isPaid() if self.numItem(track, level) >= self.getMax(track, level) or totalProps == maxProps or unpaid and gagIsPaidOnly(track, level) or level > LAST_REGULAR_GAG_LEVEL: if gagIsPaidOnly(track, level): self.makeDisabledPressable(button, track, level) elif unpaid and gagIsVelvetRoped(track, level): self.makeDisabledPressable(button, track, level) else: self.makeUnpressable(button, track, level) elif unpaid and gagIsVelvetRoped(track, level): self.makeDisabledPressable(button, track, level) else: self.makePressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def purchaseDeactivateButtons(self): self.invFrame.reparentTo(self) self.purchaseFrame.hide() def storePurchaseActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.storePurchaseFrame == None: self.loadStorePurchaseFrame() self.storePurchaseFrame.show() self.invFrame.reparentTo(self.storePurchaseFrame) self.invFrame.setPos(-0.23, 0, 0.505) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.175, 0, 0) self.detailFrame.setScale(1.25) totalProps = self.totalProps maxProps = self.toon.getMaxCarry() self.deleteEnterButton.show() self.deleteEnterButton.setPos(-0.55, 0, -0.91) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.hide() self.deleteExitButton.setPos(-0.55, 0, -0.91) self.deleteExitButton.setScale(0.75) self.deleteEnterButton['command'] = self.setActivateMode self.deleteEnterButton['extraArgs'] = ['storePurchaseDelete'] for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() unpaid = not base.cr.isPaid() if self.numItem(track, level) >= self.getMax(track, level) or totalProps == maxProps or unpaid and gagIsPaidOnly(track, level) or level > LAST_REGULAR_GAG_LEVEL: if gagIsPaidOnly(track, level): self.makeDisabledPressable(button, track, level) elif unpaid and gagIsVelvetRoped(track, level): self.makeDisabledPressable(button, track, level) else: self.makeUnpressable(button, track, level) elif unpaid and gagIsVelvetRoped(track, level): self.makeDisabledPressable(button, track, level) else: self.makePressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def storePurchaseDeactivateButtons(self): self.invFrame.reparentTo(self) self.storePurchaseFrame.hide() def purchaseBrokeActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.purchaseFrame == None: self.loadPurchaseFrame() self.purchaseFrame.show() self.invFrame.reparentTo(self.purchaseFrame) self.invFrame.setPos(-0.235, 0, 0.52) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.17, 0, -0.02) self.detailFrame.setScale(1.25) self.deleteEnterButton.show() self.deleteEnterButton.setPos(-0.441, 0, -0.917) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.hide() self.deleteExitButton.setPos(-0.441, 0, -0.917) self.deleteExitButton.setScale(0.75) if self.gagTutMode: self.deleteEnterButton.hide() for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() if not self.gagTutMode: self.makeUnpressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def purchaseBrokeDeactivateButtons(self): self.invFrame.reparentTo(self) self.purchaseFrame.hide() def gagTutDisabledActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0.2, 0, -0.04) self.setScale(1) if self.purchaseFrame == None: self.loadPurchaseFrame() self.purchaseFrame.show() self.invFrame.reparentTo(self.purchaseFrame) self.invFrame.setPos(-0.235, 0, 0.52) self.invFrame.setScale(0.81) self.detailFrame.setPos(1.17, 0, -0.02) self.detailFrame.setScale(1.25) self.deleteEnterButton.show() self.deleteEnterButton.setPos(-0.441, 0, -0.917) self.deleteEnterButton.setScale(0.75) self.deleteExitButton.hide() self.deleteExitButton.setPos(-0.441, 0, -0.917) self.deleteExitButton.setScale(0.75) self.deleteEnterButton.hide() for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): button.show() self.makeUnpressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def gagTutDisabledDeactivateButtons(self): self.invFrame.reparentTo(self) self.purchaseFrame.hide() def battleActivateButtons(self): self.stopAndClearPropBonusIval() self.reparentTo(aspect2d) self.setPos(0, 0, 0.1) self.setScale(1) if self.battleFrame == None: self.loadBattleFrame() self.battleFrame.show() self.battleFrame.setScale(0.9) self.invFrame.reparentTo(self.battleFrame) self.invFrame.setPos(-0.26, 0, 0.35) self.invFrame.setScale(1) self.detailFrame.setPos(1.125, 0, -0.08) self.detailFrame.setScale(1) self.deleteEnterButton.hide() self.deleteExitButton.hide() if self.bldg == 1: self.runButton.hide() self.sosButton.show() self.passButton.show() elif self.tutorialFlag == 1: self.runButton.hide() self.sosButton.hide() self.passButton.hide() self.fireButton.hide() else: self.runButton.show() self.sosButton.show() self.passButton.show() self.fireButton.show() if localAvatar.getPinkSlips() > 0: self.fireButton['state'] = DGG.NORMAL self.fireButton['image_color'] = Vec4(0, 0.6, 1, 1) else: self.fireButton['state'] = DGG.DISABLED self.fireButton['image_color'] = Vec4(0.4, 0.4, 0.4, 1) for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level): unpaid = not base.cr.isPaid() button.show() if self.numItem(track, level) <= 0 or track == HEAL_TRACK and not self.heal or track == TRAP_TRACK and not self.trap or track == LURE_TRACK and not self.lure: self.makeUnpressable(button, track, level) elif unpaid and gagIsVelvetRoped(track, level): self.makeDisabledPressable(button, track, level) elif self.itemIsCredit(track, level): self.makePressable(button, track, level) else: self.makeNoncreditPressable(button, track, level) else: button.hide() else: self.hideTrack(track) self.propBonusIval.loop() return def battleDeactivateButtons(self): self.invFrame.reparentTo(self) self.battleFrame.hide() self.stopAndClearPropBonusIval() def plantTreeActivateButtons(self): self.reparentTo(aspect2d) self.setPos(0, 0, 0.1) self.setScale(1) if self.battleFrame == None: self.loadBattleFrame() self.battleFrame.show() self.battleFrame.setScale(0.9) self.invFrame.reparentTo(self.battleFrame) self.invFrame.setPos(-0.25, 0, 0.35) self.invFrame.setScale(1) self.detailFrame.setPos(1.125, 0, -0.08) self.detailFrame.setScale(1) self.deleteEnterButton.hide() self.deleteExitButton.hide() self.runButton.hide() self.sosButton.hide() self.passButton['text'] = TTLocalizer.lCancel self.passButton.show() for track in xrange(len(Tracks)): if self.toon.hasTrackAccess(track): self.showTrack(track) for level in xrange(len(Levels[track])): button = self.buttons[track][level] if self.itemIsUsable(track, level) and (level == 0 or self.toon.doIHaveRequiredTrees(track, level)): button.show() self.makeUnpressable(button, track, level) if self.numItem(track, level) > 0: if not self.toon.isTreePlanted(track, level): self.makePressable(button, track, level) else: button.hide() else: self.hideTrack(track) return def plantTreeDeactivateButtons(self): self.passButton['text'] = TTLocalizer.InventoryPass self.invFrame.reparentTo(self) self.battleFrame.hide() def itemIsUsable(self, track, level): if self.gagTutMode: trackAccess = self.toon.getTrackAccess() return trackAccess[track] >= level + 1 curSkill = self.toon.experience.getExp(track) if curSkill < Levels[track][level]: return 0 else: return 1 def itemIsCredit(self, track, level): if self.toon.earnedExperience: if self.toon.earnedExperience[track] >= ExperienceCap: return 0 if self.battleCreditLevel == None: return 1 else: return level < self.battleCreditLevel return def getMax(self, track, level): if self.gagTutMode and (track not in (4, 5) or level > 0): return 1 return InventoryBase.InventoryBase.getMax(self, track, level) def getCurAndNextExpValues(self, track): curSkill = self.toon.experience.getExp(track) retVal = MaxSkill for amount in Levels[track]: if curSkill < amount: retVal = amount return (curSkill, retVal) return (curSkill, retVal) def makePressable(self, button, track, level): organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: shadowColor = self.ShadowBuffedColor else: shadowColor = self.ShadowColor button.configure(image0_image=self.upButton, image2_image=self.rolloverButton, text_shadow=shadowColor, geom_color=self.PressableGeomColor, commandButtons=(DGG.LMB,)) if self._interactivePropTrackBonus == track: button.configure(image_color=self.PropBonusPressableImageColor) self.addToPropBonusIval(button) else: button.configure(image_color=self.PressableImageColor) def makeDisabledPressable(self, button, track, level): organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: shadowColor = self.UnpressableShadowBuffedColor else: shadowColor = self.ShadowColor button.configure(text_shadow=shadowColor, geom_color=self.UnpressableGeomColor, image_image=self.flatButton, commandButtons=(DGG.LMB,)) button.configure(image_color=self.UnpressableImageColor) def makeNoncreditPressable(self, button, track, level): organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: shadowColor = self.ShadowBuffedColor else: shadowColor = self.ShadowColor button.configure(image0_image=self.upButton, image2_image=self.rolloverButton, text_shadow=shadowColor, geom_color=self.PressableGeomColor, commandButtons=(DGG.LMB,)) if self._interactivePropTrackBonus == track: button.configure(image_color=self.PropBonusNoncreditPressableImageColor) self.addToPropBonusIval(button) else: button.configure(image_color=self.NoncreditPressableImageColor) def makeDeletePressable(self, button, track, level): organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: shadowColor = self.ShadowBuffedColor else: shadowColor = self.ShadowColor button.configure(image0_image=self.upButton, image2_image=self.rolloverButton, text_shadow=shadowColor, geom_color=self.PressableGeomColor, commandButtons=(DGG.LMB,)) button.configure(image_color=self.DeletePressableImageColor) def makeUnpressable(self, button, track, level): organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: shadowColor = self.UnpressableShadowBuffedColor else: shadowColor = self.ShadowColor button.configure(text_shadow=shadowColor, geom_color=self.UnpressableGeomColor, image_image=self.flatButton, commandButtons=()) button.configure(image_color=self.UnpressableImageColor) def makeBookUnpressable(self, button, track, level): organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: shadowColor = self.ShadowBuffedColor else: shadowColor = self.ShadowColor button.configure(text_shadow=shadowColor, geom_color=self.BookUnpressableGeomColor, image_image=self.flatButton, commandButtons=()) button.configure(image0_color=self.BookUnpressableImage0Color, image2_color=self.BookUnpressableImage2Color) def hideTrack(self, trackIndex): self.trackNameLabels[trackIndex].show() self.trackBars[trackIndex].hide() for levelIndex in xrange(0, len(Levels[trackIndex])): self.buttons[trackIndex][levelIndex].hide() def showTrack(self, trackIndex): self.trackNameLabels[trackIndex].show() self.trackBars[trackIndex].show() for levelIndex in xrange(0, len(Levels[trackIndex])): self.buttons[trackIndex][levelIndex].show() curExp, nextExp = self.getCurAndNextExpValues(trackIndex) if curExp >= UnpaidMaxSkills[trackIndex] and self.toon.getGameAccess() != OTPGlobals.AccessFull: self.trackBars[trackIndex]['range'] = nextExp self.trackBars[trackIndex]['text'] = TTLocalizer.InventoryGuestExp elif curExp >= regMaxSkill: self.trackBars[trackIndex]['range'] = UberSkill self.trackBars[trackIndex]['text'] = TTLocalizer.InventoryUberTrackExp % {'nextExp': MaxSkill - curExp} else: self.trackBars[trackIndex]['range'] = nextExp self.trackBars[trackIndex]['text'] = TTLocalizer.InventoryTrackExp % {'curExp': curExp, 'nextExp': nextExp} def updateInvString(self, invString): InventoryBase.InventoryBase.updateInvString(self, invString) self.updateGUI() return None def updateButton(self, track, level): button = self.buttons[track][level] button['text'] = str(self.numItem(track, level)) organicBonus = self.toon.checkGagBonus(track, level) propBonus = self.checkPropBonus(track) bonus = organicBonus or propBonus if bonus: textScale = 0.05 else: textScale = 0.04 button.configure(text_scale=textScale) def buttonBoing(self, track, level): button = self.buttons[track][level] oldScale = button.getScale() s = Sequence(button.scaleInterval(0.1, oldScale * 1.333, blendType='easeOut'), button.scaleInterval(0.1, oldScale, blendType='easeIn'), name='inventoryButtonBoing-' + str(self.this)) s.start() def updateGUI(self, track = None, level = None): self.updateTotalPropsText() if track == None and level == None: for track in xrange(len(Tracks)): curExp, nextExp = self.getCurAndNextExpValues(track) if curExp >= UnpaidMaxSkills[track] and self.toon.getGameAccess() != OTPGlobals.AccessFull: self.trackBars[track]['range'] = nextExp self.trackBars[track]['text'] = TTLocalizer.InventoryGuestExp elif curExp >= regMaxSkill: self.trackBars[track]['text'] = TTLocalizer.InventoryUberTrackExp % {'nextExp': MaxSkill - curExp} self.trackBars[track]['value'] = curExp - regMaxSkill else: self.trackBars[track]['text'] = TTLocalizer.InventoryTrackExp % {'curExp': curExp, 'nextExp': nextExp} self.trackBars[track]['value'] = curExp for level in xrange(0, len(Levels[track])): self.updateButton(track, level) elif track != None and level != None: self.updateButton(track, level) else: self.notify.error('Invalid use of updateGUI') self.__activateButtons() return def getSingleGroupStr(self, track, level): if track == HEAL_TRACK: if isGroup(track, level): return TTLocalizer.InventoryAffectsAllToons else: return TTLocalizer.InventoryAffectsOneToon elif isGroup(track, level): return TTLocalizer.InventoryAffectsAllCogs else: return TTLocalizer.InventoryAffectsOneCog def getToonupDmgStr(self, track, level): if track == HEAL_TRACK: return TTLocalizer.InventoryHealString else: return TTLocalizer.InventoryDamageString def deleteItem(self, track, level): if self.numItem(track, level) > 0: self.useItem(track, level) self.updateGUI(track, level) def loadBattleFrame(self): battleModels = loader.loadModel('phase_3.5/models/gui/battle_gui') self.battleFrame = DirectFrame(relief=None, image=battleModels.find('**/BATTLE_Menu'), image_scale=0.8, parent=self) self.runButton = DirectButton(parent=self.battleFrame, relief=None, pos=(0.73, 0, -0.398), text=TTLocalizer.InventoryRun, text_scale=TTLocalizer.INrunButton, text_pos=(0, -0.02), text_fg=Vec4(1, 1, 1, 1), textMayChange=0, image=(self.upButton, self.downButton, self.rolloverButton), image_scale=1.05, image_color=(0, 0.6, 1, 1), command=self.__handleRun) self.sosButton = DirectButton(parent=self.battleFrame, relief=None, pos=(0.96, 0, -0.398), text=TTLocalizer.InventorySOS, text_scale=0.05, text_pos=(0, -0.02), text_fg=Vec4(1, 1, 1, 1), textMayChange=0, image=(self.upButton, self.downButton, self.rolloverButton), image_scale=1.05, image_color=(0, 0.6, 1, 1), command=self.__handleSOS) self.passButton = DirectButton(parent=self.battleFrame, relief=None, pos=(0.96, 0, -0.242), text=TTLocalizer.InventoryPass, text_scale=TTLocalizer.INpassButton, text_pos=(0, -0.02), text_fg=Vec4(1, 1, 1, 1), textMayChange=1, image=(self.upButton, self.downButton, self.rolloverButton), image_scale=1.05, image_color=(0, 0.6, 1, 1), command=self.__handlePass) self.fireButton = DirectButton(parent=self.battleFrame, relief=None, pos=(0.73, 0, -0.242), text=TTLocalizer.InventoryFire, text_scale=TTLocalizer.INfireButton, text_pos=(0, -0.02), text_fg=Vec4(1, 1, 1, 1), textMayChange=0, image=(self.upButton, self.downButton, self.rolloverButton), image_scale=1.05, image_color=(0, 0.6, 1, 1), command=self.__handleFire) self.tutText = DirectFrame(parent=self.battleFrame, relief=None, pos=(0.05, 0, -0.1133), scale=0.143, image=DGG.getDefaultDialogGeom(), image_scale=5.125, image_pos=(0, 0, -0.65), image_color=ToontownGlobals.GlobalDialogColor, text_scale=TTLocalizer.INclickToAttack, text=TTLocalizer.InventoryClickToAttack, textMayChange=0) self.tutText.hide() self.tutArrows = BlinkingArrows.BlinkingArrows(parent=self.battleFrame) battleModels.removeNode() self.battleFrame.hide() return def loadPurchaseFrame(self): purchaseModels = loader.loadModel('phase_4/models/gui/purchase_gui') self.purchaseFrame = DirectFrame(relief=None, image=purchaseModels.find('**/PurchasePanel'), image_pos=(-0.21, 0, 0.08), parent=self) self.purchaseFrame.setX(-.06) self.purchaseFrame.hide() purchaseModels.removeNode() return def loadStorePurchaseFrame(self): storePurchaseModels = loader.loadModel('phase_4/models/gui/gag_shop_purchase_gui') self.storePurchaseFrame = DirectFrame(relief=None, image=storePurchaseModels.find('**/gagShopPanel'), image_pos=(-0.21, 0, 0.18), parent=self) self.storePurchaseFrame.hide() storePurchaseModels.removeNode() return def buttonLookup(self, track, level): return self.invModels[track][level] def enterTrackFrame(self, track, guiItem): messenger.send('enterTrackFrame', [track]) def exitTrackFrame(self, track, guiItem): messenger.send('exitTrackFrame', [track]) def checkPropBonus(self, track): result = False if track == self._interactivePropTrackBonus: result = True return result def stopAndClearPropBonusIval(self): if self.propBonusIval and self.propBonusIval.isPlaying(): self.propBonusIval.finish() self.propBonusIval = Parallel(name='dummyPropBonusIval') def addToPropBonusIval(self, button): flashObject = button try: flashObject = button.component('image0') except: pass goDark = LerpColorScaleInterval(flashObject, 0.5, Point4(0.1, 0.1, 0.1, 1.0), Point4(1, 1, 1, 1), blendType='easeIn') goBright = LerpColorScaleInterval(flashObject, 0.5, Point4(1, 1, 1, 1), Point4(0.1, 0.1, 0.1, 1.0), blendType='easeOut') newSeq = Sequence(goDark, goBright, Wait(0.2)) self.propBonusIval.append(newSeq)
mit
[ 504, 4125, 14, 5885, 14, 16281, 4324, 492, 627, 199, 504, 299, 460, 645, 14, 48, 18328, 17981, 492, 627, 199, 504, 370, 265, 16231, 14, 475, 265, 1095, 14, 32435, 16231, 34, 29274, 21675, 492, 627, 199, 646, 19337, 1563, 199, 504, 370, 265, 16231, 14, 475, 265, 1095, 492, 377, 52, 5339, 1793, 199, 504, 370, 265, 16231, 14, 613, 492, 699, 1073, 316, 1596, 3838, 199, 504, 4125, 14, 4284, 14, 8227, 7025, 492, 627, 199, 504, 4125, 14, 2275, 6814, 492, 21128, 8645, 7025, 199, 504, 370, 265, 16231, 14, 475, 265, 1095, 492, 4005, 265, 16231, 21675, 199, 504, 312, 683, 14, 357, 80, 1095, 492, 593, 6495, 21675, 199, 199, 533, 19337, 4665, 8, 19304, 1563, 14, 19304, 1563, 12, 21128, 3160, 304, 272, 11705, 275, 21128, 8645, 7025, 14, 2275, 8645, 14, 1222, 7841, 360, 19304, 4665, 358, 272, 23583, 461, 1872, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 23583, 461, 13427, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 23583, 461, 3491, 4117, 275, 22223, 20, 8, 16, 12, 378, 14, 22, 12, 413, 12, 413, 9, 272, 2165, 80, 34, 265, 527, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 17, 14, 16, 12, 378, 14, 22, 12, 378, 14, 16, 12, 413, 9, 272, 10172, 9365, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 19, 12, 378, 14, 22, 12, 378, 14, 22, 12, 413, 9, 272, 2165, 80, 34, 265, 527, 6932, 9365, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 22, 12, 378, 14, 22, 12, 378, 14, 19, 12, 413, 9, 272, 8496, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 23, 12, 378, 14, 17, 12, 378, 14, 17, 12, 413, 9, 272, 1910, 2915, 461, 1872, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 378, 14, 19, 9, 272, 1910, 2915, 461, 13427, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 378, 14, 19, 9, 272, 1910, 2915, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 19, 12, 378, 14, 19, 12, 378, 14, 19, 12, 378, 14, 24, 9, 272, 8944, 1358, 2915, 461, 1872, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 8944, 1358, 2915, 461, 13427, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 8944, 1358, 2915, 461, 3491, 16, 4117, 275, 22223, 20, 8, 16, 12, 378, 14, 22, 12, 413, 12, 413, 9, 272, 8944, 1358, 2915, 461, 3491, 18, 4117, 275, 22223, 20, 8, 16, 14, 17, 12, 378, 14, 23, 12, 413, 12, 413, 9, 272, 5244, 8369, 4117, 275, 22223, 20, 8, 16, 12, 378, 12, 378, 12, 378, 9, 272, 5244, 8369, 1713, 556, 379, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 1910, 2915, 461, 23574, 1713, 556, 379, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 378, 14, 19, 9, 272, 17507, 57, 6397, 275, 378, 14, 16, 272, 17507, 57, 24052, 275, 446, 16, 14, 713, 272, 16005, 56, 6397, 275, 446, 16, 14, 2192, 272, 16005, 56, 24052, 275, 378, 14, 1085, 339, 347, 636, 826, 721, 277, 12, 370, 265, 12, 4572, 2848, 275, 488, 12, 12968, 11823, 39, 7391, 275, 413, 304, 267, 19337, 1563, 14, 19304, 1563, 855, 826, 721, 277, 12, 370, 265, 12, 4572, 2848, 9, 267, 21128, 3160, 855, 826, 721, 277, 12, 28958, 29, 403, 9, 267, 291, 14, 2747, 572, 1419, 8, 19304, 4665, 9, 267, 291, 14, 29787, 27228, 4670, 275, 488, 267, 291, 14, 5506, 27228, 275, 488, 267, 291, 855, 29787, 27228, 25314, 5697, 275, 413, 267, 291, 855, 262, 4755, 1636, 27228, 25314, 5697, 275, 413, 267, 291, 855, 27872, 607, 4755, 15293, 275, 413, 267, 291, 423, 13543, 9955, 7927, 34, 265, 527, 275, 446, 17, 267, 291, 14, 23561, 5318, 275, 378, 267, 291, 14, 71, 643, 52, 337, 1385, 275, 378, 267, 291, 14, 2384, 11823, 39, 7391, 275, 12968, 11823, 39, 7391, 267, 291, 14, 4891, 11823, 39, 7391, 275, 413, 267, 291, 14, 4469, 3325, 11014, 290, 530, 34, 265, 527, 4851, 275, 1300, 14, 888, 14, 1002, 10349, 360, 4469, 13, 460, 13, 19916, 530, 13, 13520, 527, 13, 2340, 297, 378, 9, 267, 291, 14, 4469, 34, 265, 527, 41, 637, 275, 27311, 342, 267, 291, 14, 8222, 1385, 275, 283, 2706, 7, 267, 291, 14, 912, 342, 267, 291, 14, 8191, 342, 267, 372, 339, 347, 663, 34, 29274, 27228, 25314, 5697, 8, 277, 12, 20861, 304, 267, 291, 855, 29787, 27228, 25314, 5697, 275, 20861, 339, 347, 664, 34, 29274, 27228, 25314, 5697, 8, 277, 304, 267, 372, 291, 855, 29787, 27228, 25314, 5697, 339, 347, 663, 23879, 9955, 7927, 34, 265, 527, 8, 277, 12, 4426, 34, 265, 527, 304, 267, 291, 423, 13543, 9955, 7927, 34, 265, 527, 275, 4426, 34, 265, 527, 339, 347, 664, 23879, 9955, 7927, 34, 265, 527, 8, 277, 304, 267, 372, 291, 423, 13543, 9955, 7927, 34, 265, 527, 339, 347, 663, 607, 4755, 1636, 27228, 25314, 5697, 8, 277, 12, 20861, 304, 267, 291, 855, 262, 4755, 1636, 27228, 25314, 5697, 275, 20861, 339, 347, 664, 607, 4755, 1636, 27228, 25314, 5697, 8, 277, 304, 267, 372, 291, 855, 262, 4755, 1636, 27228, 25314, 5697, 339, 347, 663, 1322, 1764, 607, 4755, 15293, 8, 277, 12, 3305, 304, 267, 291, 855, 27872, 607, 4755, 15293, 275, 3305, 339, 347, 664, 1322, 1764, 607, 4755, 15293, 8, 277, 304, 267, 372, 291, 855, 27872, 607, 4755, 15293, 339, 347, 2498, 8, 277, 304, 267, 340, 291, 14, 23561, 5318, 26, 288, 291, 14, 84, 337, 1596, 3838, 14, 285, 3838, 3314, 2801, 16, 14, 2824, 12, 446, 16, 14, 713, 12, 13576, 12, 446, 16, 14, 2824, 12, 446, 16, 14, 1194, 12, 13576, 12, 641, 1366, 29, 17, 14, 16, 12, 2331, 1366, 29, 16, 14, 18, 9, 288, 340, 291, 14, 1507, 2081, 8, 2080, 11415, 63, 19755 ]
[ 4125, 14, 5885, 14, 16281, 4324, 492, 627, 199, 504, 299, 460, 645, 14, 48, 18328, 17981, 492, 627, 199, 504, 370, 265, 16231, 14, 475, 265, 1095, 14, 32435, 16231, 34, 29274, 21675, 492, 627, 199, 646, 19337, 1563, 199, 504, 370, 265, 16231, 14, 475, 265, 1095, 492, 377, 52, 5339, 1793, 199, 504, 370, 265, 16231, 14, 613, 492, 699, 1073, 316, 1596, 3838, 199, 504, 4125, 14, 4284, 14, 8227, 7025, 492, 627, 199, 504, 4125, 14, 2275, 6814, 492, 21128, 8645, 7025, 199, 504, 370, 265, 16231, 14, 475, 265, 1095, 492, 4005, 265, 16231, 21675, 199, 504, 312, 683, 14, 357, 80, 1095, 492, 593, 6495, 21675, 199, 199, 533, 19337, 4665, 8, 19304, 1563, 14, 19304, 1563, 12, 21128, 3160, 304, 272, 11705, 275, 21128, 8645, 7025, 14, 2275, 8645, 14, 1222, 7841, 360, 19304, 4665, 358, 272, 23583, 461, 1872, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 23583, 461, 13427, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 23583, 461, 3491, 4117, 275, 22223, 20, 8, 16, 12, 378, 14, 22, 12, 413, 12, 413, 9, 272, 2165, 80, 34, 265, 527, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 17, 14, 16, 12, 378, 14, 22, 12, 378, 14, 16, 12, 413, 9, 272, 10172, 9365, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 19, 12, 378, 14, 22, 12, 378, 14, 22, 12, 413, 9, 272, 2165, 80, 34, 265, 527, 6932, 9365, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 22, 12, 378, 14, 22, 12, 378, 14, 19, 12, 413, 9, 272, 8496, 14414, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 23, 12, 378, 14, 17, 12, 378, 14, 17, 12, 413, 9, 272, 1910, 2915, 461, 1872, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 378, 14, 19, 9, 272, 1910, 2915, 461, 13427, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 378, 14, 19, 9, 272, 1910, 2915, 461, 3491, 4117, 275, 22223, 20, 8, 16, 14, 19, 12, 378, 14, 19, 12, 378, 14, 19, 12, 378, 14, 24, 9, 272, 8944, 1358, 2915, 461, 1872, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 8944, 1358, 2915, 461, 13427, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 8944, 1358, 2915, 461, 3491, 16, 4117, 275, 22223, 20, 8, 16, 12, 378, 14, 22, 12, 413, 12, 413, 9, 272, 8944, 1358, 2915, 461, 3491, 18, 4117, 275, 22223, 20, 8, 16, 14, 17, 12, 378, 14, 23, 12, 413, 12, 413, 9, 272, 5244, 8369, 4117, 275, 22223, 20, 8, 16, 12, 378, 12, 378, 12, 378, 9, 272, 5244, 8369, 1713, 556, 379, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 413, 9, 272, 1910, 2915, 461, 23574, 1713, 556, 379, 4117, 275, 22223, 20, 8, 17, 12, 413, 12, 413, 12, 378, 14, 19, 9, 272, 17507, 57, 6397, 275, 378, 14, 16, 272, 17507, 57, 24052, 275, 446, 16, 14, 713, 272, 16005, 56, 6397, 275, 446, 16, 14, 2192, 272, 16005, 56, 24052, 275, 378, 14, 1085, 339, 347, 636, 826, 721, 277, 12, 370, 265, 12, 4572, 2848, 275, 488, 12, 12968, 11823, 39, 7391, 275, 413, 304, 267, 19337, 1563, 14, 19304, 1563, 855, 826, 721, 277, 12, 370, 265, 12, 4572, 2848, 9, 267, 21128, 3160, 855, 826, 721, 277, 12, 28958, 29, 403, 9, 267, 291, 14, 2747, 572, 1419, 8, 19304, 4665, 9, 267, 291, 14, 29787, 27228, 4670, 275, 488, 267, 291, 14, 5506, 27228, 275, 488, 267, 291, 855, 29787, 27228, 25314, 5697, 275, 413, 267, 291, 855, 262, 4755, 1636, 27228, 25314, 5697, 275, 413, 267, 291, 855, 27872, 607, 4755, 15293, 275, 413, 267, 291, 423, 13543, 9955, 7927, 34, 265, 527, 275, 446, 17, 267, 291, 14, 23561, 5318, 275, 378, 267, 291, 14, 71, 643, 52, 337, 1385, 275, 378, 267, 291, 14, 2384, 11823, 39, 7391, 275, 12968, 11823, 39, 7391, 267, 291, 14, 4891, 11823, 39, 7391, 275, 413, 267, 291, 14, 4469, 3325, 11014, 290, 530, 34, 265, 527, 4851, 275, 1300, 14, 888, 14, 1002, 10349, 360, 4469, 13, 460, 13, 19916, 530, 13, 13520, 527, 13, 2340, 297, 378, 9, 267, 291, 14, 4469, 34, 265, 527, 41, 637, 275, 27311, 342, 267, 291, 14, 8222, 1385, 275, 283, 2706, 7, 267, 291, 14, 912, 342, 267, 291, 14, 8191, 342, 267, 372, 339, 347, 663, 34, 29274, 27228, 25314, 5697, 8, 277, 12, 20861, 304, 267, 291, 855, 29787, 27228, 25314, 5697, 275, 20861, 339, 347, 664, 34, 29274, 27228, 25314, 5697, 8, 277, 304, 267, 372, 291, 855, 29787, 27228, 25314, 5697, 339, 347, 663, 23879, 9955, 7927, 34, 265, 527, 8, 277, 12, 4426, 34, 265, 527, 304, 267, 291, 423, 13543, 9955, 7927, 34, 265, 527, 275, 4426, 34, 265, 527, 339, 347, 664, 23879, 9955, 7927, 34, 265, 527, 8, 277, 304, 267, 372, 291, 423, 13543, 9955, 7927, 34, 265, 527, 339, 347, 663, 607, 4755, 1636, 27228, 25314, 5697, 8, 277, 12, 20861, 304, 267, 291, 855, 262, 4755, 1636, 27228, 25314, 5697, 275, 20861, 339, 347, 664, 607, 4755, 1636, 27228, 25314, 5697, 8, 277, 304, 267, 372, 291, 855, 262, 4755, 1636, 27228, 25314, 5697, 339, 347, 663, 1322, 1764, 607, 4755, 15293, 8, 277, 12, 3305, 304, 267, 291, 855, 27872, 607, 4755, 15293, 275, 3305, 339, 347, 664, 1322, 1764, 607, 4755, 15293, 8, 277, 304, 267, 372, 291, 855, 27872, 607, 4755, 15293, 339, 347, 2498, 8, 277, 304, 267, 340, 291, 14, 23561, 5318, 26, 288, 291, 14, 84, 337, 1596, 3838, 14, 285, 3838, 3314, 2801, 16, 14, 2824, 12, 446, 16, 14, 713, 12, 13576, 12, 446, 16, 14, 2824, 12, 446, 16, 14, 1194, 12, 13576, 12, 641, 1366, 29, 17, 14, 16, 12, 2331, 1366, 29, 16, 14, 18, 9, 288, 340, 291, 14, 1507, 2081, 8, 2080, 11415, 63, 19755, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TheWardoctor/Wardoctors-repo
script.module.schism.common/lib/requests/packages/chardet/mbcssm.py
1783
19590
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .constants import eStart, eError, eItsMe # BIG5 BIG5_cls = ( 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as legal value 1,1,1,1,1,1,0,0, # 08 - 0f 1,1,1,1,1,1,1,1, # 10 - 17 1,1,1,0,1,1,1,1, # 18 - 1f 1,1,1,1,1,1,1,1, # 20 - 27 1,1,1,1,1,1,1,1, # 28 - 2f 1,1,1,1,1,1,1,1, # 30 - 37 1,1,1,1,1,1,1,1, # 38 - 3f 2,2,2,2,2,2,2,2, # 40 - 47 2,2,2,2,2,2,2,2, # 48 - 4f 2,2,2,2,2,2,2,2, # 50 - 57 2,2,2,2,2,2,2,2, # 58 - 5f 2,2,2,2,2,2,2,2, # 60 - 67 2,2,2,2,2,2,2,2, # 68 - 6f 2,2,2,2,2,2,2,2, # 70 - 77 2,2,2,2,2,2,2,1, # 78 - 7f 4,4,4,4,4,4,4,4, # 80 - 87 4,4,4,4,4,4,4,4, # 88 - 8f 4,4,4,4,4,4,4,4, # 90 - 97 4,4,4,4,4,4,4,4, # 98 - 9f 4,3,3,3,3,3,3,3, # a0 - a7 3,3,3,3,3,3,3,3, # a8 - af 3,3,3,3,3,3,3,3, # b0 - b7 3,3,3,3,3,3,3,3, # b8 - bf 3,3,3,3,3,3,3,3, # c0 - c7 3,3,3,3,3,3,3,3, # c8 - cf 3,3,3,3,3,3,3,3, # d0 - d7 3,3,3,3,3,3,3,3, # d8 - df 3,3,3,3,3,3,3,3, # e0 - e7 3,3,3,3,3,3,3,3, # e8 - ef 3,3,3,3,3,3,3,3, # f0 - f7 3,3,3,3,3,3,3,0 # f8 - ff ) BIG5_st = ( eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07 eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,#08-0f eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart#10-17 ) Big5CharLenTable = (0, 1, 1, 2, 0) Big5SMModel = {'classTable': BIG5_cls, 'classFactor': 5, 'stateTable': BIG5_st, 'charLenTable': Big5CharLenTable, 'name': 'Big5'} # CP949 CP949_cls = ( 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,0,0, # 00 - 0f 1,1,1,1,1,1,1,1, 1,1,1,0,1,1,1,1, # 10 - 1f 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, # 20 - 2f 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, # 30 - 3f 1,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4, # 40 - 4f 4,4,5,5,5,5,5,5, 5,5,5,1,1,1,1,1, # 50 - 5f 1,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5, # 60 - 6f 5,5,5,5,5,5,5,5, 5,5,5,1,1,1,1,1, # 70 - 7f 0,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6, # 80 - 8f 6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6, # 90 - 9f 6,7,7,7,7,7,7,7, 7,7,7,7,7,8,8,8, # a0 - af 7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7, # b0 - bf 7,7,7,7,7,7,9,2, 2,3,2,2,2,2,2,2, # c0 - cf 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, # d0 - df 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, # e0 - ef 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,0, # f0 - ff ) CP949_st = ( #cls= 0 1 2 3 4 5 6 7 8 9 # previous state = eError,eStart, 3,eError,eStart,eStart, 4, 5,eError, 6, # eStart eError,eError,eError,eError,eError,eError,eError,eError,eError,eError, # eError eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe, # eItsMe eError,eError,eStart,eStart,eError,eError,eError,eStart,eStart,eStart, # 3 eError,eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart,eStart, # 4 eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart,eStart,eStart, # 5 eError,eStart,eStart,eStart,eStart,eError,eError,eStart,eStart,eStart, # 6 ) CP949CharLenTable = (0, 1, 2, 0, 1, 1, 2, 2, 0, 2) CP949SMModel = {'classTable': CP949_cls, 'classFactor': 10, 'stateTable': CP949_st, 'charLenTable': CP949CharLenTable, 'name': 'CP949'} # EUC-JP EUCJP_cls = ( 4,4,4,4,4,4,4,4, # 00 - 07 4,4,4,4,4,4,5,5, # 08 - 0f 4,4,4,4,4,4,4,4, # 10 - 17 4,4,4,5,4,4,4,4, # 18 - 1f 4,4,4,4,4,4,4,4, # 20 - 27 4,4,4,4,4,4,4,4, # 28 - 2f 4,4,4,4,4,4,4,4, # 30 - 37 4,4,4,4,4,4,4,4, # 38 - 3f 4,4,4,4,4,4,4,4, # 40 - 47 4,4,4,4,4,4,4,4, # 48 - 4f 4,4,4,4,4,4,4,4, # 50 - 57 4,4,4,4,4,4,4,4, # 58 - 5f 4,4,4,4,4,4,4,4, # 60 - 67 4,4,4,4,4,4,4,4, # 68 - 6f 4,4,4,4,4,4,4,4, # 70 - 77 4,4,4,4,4,4,4,4, # 78 - 7f 5,5,5,5,5,5,5,5, # 80 - 87 5,5,5,5,5,5,1,3, # 88 - 8f 5,5,5,5,5,5,5,5, # 90 - 97 5,5,5,5,5,5,5,5, # 98 - 9f 5,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 0,0,0,0,0,0,0,0, # e0 - e7 0,0,0,0,0,0,0,0, # e8 - ef 0,0,0,0,0,0,0,0, # f0 - f7 0,0,0,0,0,0,0,5 # f8 - ff ) EUCJP_st = ( 3, 4, 3, 5,eStart,eError,eError,eError,#00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError,#10-17 eError,eError,eStart,eError,eError,eError, 3,eError,#18-1f 3,eError,eError,eError,eStart,eStart,eStart,eStart#20-27 ) EUCJPCharLenTable = (2, 2, 2, 3, 1, 0) EUCJPSMModel = {'classTable': EUCJP_cls, 'classFactor': 6, 'stateTable': EUCJP_st, 'charLenTable': EUCJPCharLenTable, 'name': 'EUC-JP'} # EUC-KR EUCKR_cls = ( 1,1,1,1,1,1,1,1, # 00 - 07 1,1,1,1,1,1,0,0, # 08 - 0f 1,1,1,1,1,1,1,1, # 10 - 17 1,1,1,0,1,1,1,1, # 18 - 1f 1,1,1,1,1,1,1,1, # 20 - 27 1,1,1,1,1,1,1,1, # 28 - 2f 1,1,1,1,1,1,1,1, # 30 - 37 1,1,1,1,1,1,1,1, # 38 - 3f 1,1,1,1,1,1,1,1, # 40 - 47 1,1,1,1,1,1,1,1, # 48 - 4f 1,1,1,1,1,1,1,1, # 50 - 57 1,1,1,1,1,1,1,1, # 58 - 5f 1,1,1,1,1,1,1,1, # 60 - 67 1,1,1,1,1,1,1,1, # 68 - 6f 1,1,1,1,1,1,1,1, # 70 - 77 1,1,1,1,1,1,1,1, # 78 - 7f 0,0,0,0,0,0,0,0, # 80 - 87 0,0,0,0,0,0,0,0, # 88 - 8f 0,0,0,0,0,0,0,0, # 90 - 97 0,0,0,0,0,0,0,0, # 98 - 9f 0,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,3,3,3, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,3,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,0 # f8 - ff ) EUCKR_st = ( eError,eStart, 3,eError,eError,eError,eError,eError,#00-07 eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart #08-0f ) EUCKRCharLenTable = (0, 1, 2, 0) EUCKRSMModel = {'classTable': EUCKR_cls, 'classFactor': 4, 'stateTable': EUCKR_st, 'charLenTable': EUCKRCharLenTable, 'name': 'EUC-KR'} # EUC-TW EUCTW_cls = ( 2,2,2,2,2,2,2,2, # 00 - 07 2,2,2,2,2,2,0,0, # 08 - 0f 2,2,2,2,2,2,2,2, # 10 - 17 2,2,2,0,2,2,2,2, # 18 - 1f 2,2,2,2,2,2,2,2, # 20 - 27 2,2,2,2,2,2,2,2, # 28 - 2f 2,2,2,2,2,2,2,2, # 30 - 37 2,2,2,2,2,2,2,2, # 38 - 3f 2,2,2,2,2,2,2,2, # 40 - 47 2,2,2,2,2,2,2,2, # 48 - 4f 2,2,2,2,2,2,2,2, # 50 - 57 2,2,2,2,2,2,2,2, # 58 - 5f 2,2,2,2,2,2,2,2, # 60 - 67 2,2,2,2,2,2,2,2, # 68 - 6f 2,2,2,2,2,2,2,2, # 70 - 77 2,2,2,2,2,2,2,2, # 78 - 7f 0,0,0,0,0,0,0,0, # 80 - 87 0,0,0,0,0,0,6,0, # 88 - 8f 0,0,0,0,0,0,0,0, # 90 - 97 0,0,0,0,0,0,0,0, # 98 - 9f 0,3,4,4,4,4,4,4, # a0 - a7 5,5,1,1,1,1,1,1, # a8 - af 1,1,1,1,1,1,1,1, # b0 - b7 1,1,1,1,1,1,1,1, # b8 - bf 1,1,3,1,3,3,3,3, # c0 - c7 3,3,3,3,3,3,3,3, # c8 - cf 3,3,3,3,3,3,3,3, # d0 - d7 3,3,3,3,3,3,3,3, # d8 - df 3,3,3,3,3,3,3,3, # e0 - e7 3,3,3,3,3,3,3,3, # e8 - ef 3,3,3,3,3,3,3,3, # f0 - f7 3,3,3,3,3,3,3,0 # f8 - ff ) EUCTW_st = ( eError,eError,eStart, 3, 3, 3, 4,eError,#00-07 eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError,#10-17 eStart,eStart,eStart,eError,eError,eError,eError,eError,#18-1f 5,eError,eError,eError,eStart,eError,eStart,eStart,#20-27 eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f ) EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3) EUCTWSMModel = {'classTable': EUCTW_cls, 'classFactor': 7, 'stateTable': EUCTW_st, 'charLenTable': EUCTWCharLenTable, 'name': 'x-euc-tw'} # GB2312 GB2312_cls = ( 1,1,1,1,1,1,1,1, # 00 - 07 1,1,1,1,1,1,0,0, # 08 - 0f 1,1,1,1,1,1,1,1, # 10 - 17 1,1,1,0,1,1,1,1, # 18 - 1f 1,1,1,1,1,1,1,1, # 20 - 27 1,1,1,1,1,1,1,1, # 28 - 2f 3,3,3,3,3,3,3,3, # 30 - 37 3,3,1,1,1,1,1,1, # 38 - 3f 2,2,2,2,2,2,2,2, # 40 - 47 2,2,2,2,2,2,2,2, # 48 - 4f 2,2,2,2,2,2,2,2, # 50 - 57 2,2,2,2,2,2,2,2, # 58 - 5f 2,2,2,2,2,2,2,2, # 60 - 67 2,2,2,2,2,2,2,2, # 68 - 6f 2,2,2,2,2,2,2,2, # 70 - 77 2,2,2,2,2,2,2,4, # 78 - 7f 5,6,6,6,6,6,6,6, # 80 - 87 6,6,6,6,6,6,6,6, # 88 - 8f 6,6,6,6,6,6,6,6, # 90 - 97 6,6,6,6,6,6,6,6, # 98 - 9f 6,6,6,6,6,6,6,6, # a0 - a7 6,6,6,6,6,6,6,6, # a8 - af 6,6,6,6,6,6,6,6, # b0 - b7 6,6,6,6,6,6,6,6, # b8 - bf 6,6,6,6,6,6,6,6, # c0 - c7 6,6,6,6,6,6,6,6, # c8 - cf 6,6,6,6,6,6,6,6, # d0 - d7 6,6,6,6,6,6,6,6, # d8 - df 6,6,6,6,6,6,6,6, # e0 - e7 6,6,6,6,6,6,6,6, # e8 - ef 6,6,6,6,6,6,6,6, # f0 - f7 6,6,6,6,6,6,6,0 # f8 - ff ) GB2312_st = ( eError,eStart,eStart,eStart,eStart,eStart, 3,eError,#00-07 eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,#10-17 4,eError,eStart,eStart,eError,eError,eError,eError,#18-1f eError,eError, 5,eError,eError,eError,eItsMe,eError,#20-27 eError,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f ) # To be accurate, the length of class 6 can be either 2 or 4. # But it is not necessary to discriminate between the two since # it is used for frequency analysis only, and we are validing # each code range there as well. So it is safe to set it to be # 2 here. GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2) GB2312SMModel = {'classTable': GB2312_cls, 'classFactor': 7, 'stateTable': GB2312_st, 'charLenTable': GB2312CharLenTable, 'name': 'GB2312'} # Shift_JIS SJIS_cls = ( 1,1,1,1,1,1,1,1, # 00 - 07 1,1,1,1,1,1,0,0, # 08 - 0f 1,1,1,1,1,1,1,1, # 10 - 17 1,1,1,0,1,1,1,1, # 18 - 1f 1,1,1,1,1,1,1,1, # 20 - 27 1,1,1,1,1,1,1,1, # 28 - 2f 1,1,1,1,1,1,1,1, # 30 - 37 1,1,1,1,1,1,1,1, # 38 - 3f 2,2,2,2,2,2,2,2, # 40 - 47 2,2,2,2,2,2,2,2, # 48 - 4f 2,2,2,2,2,2,2,2, # 50 - 57 2,2,2,2,2,2,2,2, # 58 - 5f 2,2,2,2,2,2,2,2, # 60 - 67 2,2,2,2,2,2,2,2, # 68 - 6f 2,2,2,2,2,2,2,2, # 70 - 77 2,2,2,2,2,2,2,1, # 78 - 7f 3,3,3,3,3,2,2,3, # 80 - 87 3,3,3,3,3,3,3,3, # 88 - 8f 3,3,3,3,3,3,3,3, # 90 - 97 3,3,3,3,3,3,3,3, # 98 - 9f #0xa0 is illegal in sjis encoding, but some pages does #contain such byte. We need to be more error forgiven. 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 3,3,3,3,3,3,3,3, # e0 - e7 3,3,3,3,3,4,4,4, # e8 - ef 3,3,3,3,3,3,3,3, # f0 - f7 3,3,3,3,3,0,0,0) # f8 - ff SJIS_st = ( eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart #10-17 ) SJISCharLenTable = (0, 1, 1, 2, 0, 0) SJISSMModel = {'classTable': SJIS_cls, 'classFactor': 6, 'stateTable': SJIS_st, 'charLenTable': SJISCharLenTable, 'name': 'Shift_JIS'} # UCS2-BE UCS2BE_cls = ( 0,0,0,0,0,0,0,0, # 00 - 07 0,0,1,0,0,2,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,3,0,0,0,0, # 18 - 1f 0,0,0,0,0,0,0,0, # 20 - 27 0,3,3,3,3,3,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,0,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 0,0,0,0,0,0,0,0, # 80 - 87 0,0,0,0,0,0,0,0, # 88 - 8f 0,0,0,0,0,0,0,0, # 90 - 97 0,0,0,0,0,0,0,0, # 98 - 9f 0,0,0,0,0,0,0,0, # a0 - a7 0,0,0,0,0,0,0,0, # a8 - af 0,0,0,0,0,0,0,0, # b0 - b7 0,0,0,0,0,0,0,0, # b8 - bf 0,0,0,0,0,0,0,0, # c0 - c7 0,0,0,0,0,0,0,0, # c8 - cf 0,0,0,0,0,0,0,0, # d0 - d7 0,0,0,0,0,0,0,0, # d8 - df 0,0,0,0,0,0,0,0, # e0 - e7 0,0,0,0,0,0,0,0, # e8 - ef 0,0,0,0,0,0,0,0, # f0 - f7 0,0,0,0,0,0,4,5 # f8 - ff ) UCS2BE_st = ( 5, 7, 7,eError, 4, 3,eError,eError,#00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f eItsMe,eItsMe, 6, 6, 6, 6,eError,eError,#10-17 6, 6, 6, 6, 6,eItsMe, 6, 6,#18-1f 6, 6, 6, 6, 5, 7, 7,eError,#20-27 5, 8, 6, 6,eError, 6, 6, 6,#28-2f 6, 6, 6, 6,eError,eError,eStart,eStart #30-37 ) UCS2BECharLenTable = (2, 2, 2, 0, 2, 2) UCS2BESMModel = {'classTable': UCS2BE_cls, 'classFactor': 6, 'stateTable': UCS2BE_st, 'charLenTable': UCS2BECharLenTable, 'name': 'UTF-16BE'} # UCS2-LE UCS2LE_cls = ( 0,0,0,0,0,0,0,0, # 00 - 07 0,0,1,0,0,2,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,3,0,0,0,0, # 18 - 1f 0,0,0,0,0,0,0,0, # 20 - 27 0,3,3,3,3,3,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,0,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 0,0,0,0,0,0,0,0, # 80 - 87 0,0,0,0,0,0,0,0, # 88 - 8f 0,0,0,0,0,0,0,0, # 90 - 97 0,0,0,0,0,0,0,0, # 98 - 9f 0,0,0,0,0,0,0,0, # a0 - a7 0,0,0,0,0,0,0,0, # a8 - af 0,0,0,0,0,0,0,0, # b0 - b7 0,0,0,0,0,0,0,0, # b8 - bf 0,0,0,0,0,0,0,0, # c0 - c7 0,0,0,0,0,0,0,0, # c8 - cf 0,0,0,0,0,0,0,0, # d0 - d7 0,0,0,0,0,0,0,0, # d8 - df 0,0,0,0,0,0,0,0, # e0 - e7 0,0,0,0,0,0,0,0, # e8 - ef 0,0,0,0,0,0,0,0, # f0 - f7 0,0,0,0,0,0,4,5 # f8 - ff ) UCS2LE_st = ( 6, 6, 7, 6, 4, 3,eError,eError,#00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f eItsMe,eItsMe, 5, 5, 5,eError,eItsMe,eError,#10-17 5, 5, 5,eError, 5,eError, 6, 6,#18-1f 7, 6, 8, 8, 5, 5, 5,eError,#20-27 5, 5, 5,eError,eError,eError, 5, 5,#28-2f 5, 5, 5,eError, 5,eError,eStart,eStart #30-37 ) UCS2LECharLenTable = (2, 2, 2, 2, 2, 2) UCS2LESMModel = {'classTable': UCS2LE_cls, 'classFactor': 6, 'stateTable': UCS2LE_st, 'charLenTable': UCS2LECharLenTable, 'name': 'UTF-16LE'} # UTF-8 UTF8_cls = ( 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as a legal value 1,1,1,1,1,1,0,0, # 08 - 0f 1,1,1,1,1,1,1,1, # 10 - 17 1,1,1,0,1,1,1,1, # 18 - 1f 1,1,1,1,1,1,1,1, # 20 - 27 1,1,1,1,1,1,1,1, # 28 - 2f 1,1,1,1,1,1,1,1, # 30 - 37 1,1,1,1,1,1,1,1, # 38 - 3f 1,1,1,1,1,1,1,1, # 40 - 47 1,1,1,1,1,1,1,1, # 48 - 4f 1,1,1,1,1,1,1,1, # 50 - 57 1,1,1,1,1,1,1,1, # 58 - 5f 1,1,1,1,1,1,1,1, # 60 - 67 1,1,1,1,1,1,1,1, # 68 - 6f 1,1,1,1,1,1,1,1, # 70 - 77 1,1,1,1,1,1,1,1, # 78 - 7f 2,2,2,2,3,3,3,3, # 80 - 87 4,4,4,4,4,4,4,4, # 88 - 8f 4,4,4,4,4,4,4,4, # 90 - 97 4,4,4,4,4,4,4,4, # 98 - 9f 5,5,5,5,5,5,5,5, # a0 - a7 5,5,5,5,5,5,5,5, # a8 - af 5,5,5,5,5,5,5,5, # b0 - b7 5,5,5,5,5,5,5,5, # b8 - bf 0,0,6,6,6,6,6,6, # c0 - c7 6,6,6,6,6,6,6,6, # c8 - cf 6,6,6,6,6,6,6,6, # d0 - d7 6,6,6,6,6,6,6,6, # d8 - df 7,8,8,8,8,8,8,8, # e0 - e7 8,8,8,8,8,9,8,8, # e8 - ef 10,11,11,11,11,11,11,11, # f0 - f7 12,13,13,13,14,15,0,0 # f8 - ff ) UTF8_st = ( eError,eStart,eError,eError,eError,eError, 12, 10,#00-07 9, 11, 8, 7, 6, 5, 4, 3,#08-0f eError,eError,eError,eError,eError,eError,eError,eError,#10-17 eError,eError,eError,eError,eError,eError,eError,eError,#18-1f eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#20-27 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#28-2f eError,eError, 5, 5, 5, 5,eError,eError,#30-37 eError,eError,eError,eError,eError,eError,eError,eError,#38-3f eError,eError,eError, 5, 5, 5,eError,eError,#40-47 eError,eError,eError,eError,eError,eError,eError,eError,#48-4f eError,eError, 7, 7, 7, 7,eError,eError,#50-57 eError,eError,eError,eError,eError,eError,eError,eError,#58-5f eError,eError,eError,eError, 7, 7,eError,eError,#60-67 eError,eError,eError,eError,eError,eError,eError,eError,#68-6f eError,eError, 9, 9, 9, 9,eError,eError,#70-77 eError,eError,eError,eError,eError,eError,eError,eError,#78-7f eError,eError,eError,eError,eError, 9,eError,eError,#80-87 eError,eError,eError,eError,eError,eError,eError,eError,#88-8f eError,eError, 12, 12, 12, 12,eError,eError,#90-97 eError,eError,eError,eError,eError,eError,eError,eError,#98-9f eError,eError,eError,eError,eError, 12,eError,eError,#a0-a7 eError,eError,eError,eError,eError,eError,eError,eError,#a8-af eError,eError, 12, 12, 12,eError,eError,eError,#b0-b7 eError,eError,eError,eError,eError,eError,eError,eError,#b8-bf eError,eError,eStart,eStart,eStart,eStart,eError,eError,#c0-c7 eError,eError,eError,eError,eError,eError,eError,eError #c8-cf ) UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6) UTF8SMModel = {'classTable': UTF8_cls, 'classFactor': 16, 'stateTable': UTF8_st, 'charLenTable': UTF8CharLenTable, 'name': 'UTF-8'}
apache-2.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 5559, 492, 325, 3162, 12, 19424, 12, 325, 12278, 199, 199, 3, 16524, 21, 199, 199, 18643, 21, 63, 1886, 275, 334, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 8733, 446, 24937, 259, 327, 3306, 378, 88, 383, 465, 18393, 574, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 16, 12, 16, 12, 221, 327, 19363, 446, 378, 70, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 1616, 446, 5557, 272, 413, 12, 17, 12, 17, 12, 16, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 6155, 446, 413, 70, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 3388, 446, 8087, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 7294, 446, 499, 70, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 4233, 446, 6877, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 10448, 446, 650, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 6335, 446, 10954, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 9615, 446, 841, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 5238, 446, 12699, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 13713, 446, 959, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 5212, 446, 13296, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 10851, 446, 1227, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 10045, 446, 8375, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 17, 12, 221, 327, 14679, 446, 1520, 70, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 5939, 446, 10513, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 10523, 446, 1695, 70, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 9137, 446, 15997, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 16096, 446, 1749, 70, 272, 841, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 282, 16, 446, 282, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 282, 24, 446, 15871, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 330, 16, 446, 330, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 330, 24, 446, 18839, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 286, 16, 446, 286, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 286, 24, 446, 3980, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 366, 16, 446, 366, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 366, 24, 446, 4051, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 325, 16, 446, 325, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 325, 24, 446, 9530, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 289, 16, 446, 289, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 16, 221, 327, 289, 24, 446, 16328, 199, 9, 199, 199, 18643 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 5559, 492, 325, 3162, 12, 19424, 12, 325, 12278, 199, 199, 3, 16524, 21, 199, 199, 18643, 21, 63, 1886, 275, 334, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 8733, 446, 24937, 259, 327, 3306, 378, 88, 383, 465, 18393, 574, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 16, 12, 16, 12, 221, 327, 19363, 446, 378, 70, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 1616, 446, 5557, 272, 413, 12, 17, 12, 17, 12, 16, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 6155, 446, 413, 70, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 3388, 446, 8087, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 7294, 446, 499, 70, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 4233, 446, 6877, 272, 413, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 10448, 446, 650, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 6335, 446, 10954, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 9615, 446, 841, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 5238, 446, 12699, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 13713, 446, 959, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 5212, 446, 13296, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 10851, 446, 1227, 70, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 221, 327, 10045, 446, 8375, 272, 499, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 18, 12, 17, 12, 221, 327, 14679, 446, 1520, 70, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 5939, 446, 10513, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 10523, 446, 1695, 70, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 9137, 446, 15997, 272, 841, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 20, 12, 221, 327, 16096, 446, 1749, 70, 272, 841, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 282, 16, 446, 282, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 282, 24, 446, 15871, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 330, 16, 446, 330, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 330, 24, 446, 18839, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 286, 16, 446, 286, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 286, 24, 446, 3980, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 366, 16, 446, 366, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 366, 24, 446, 4051, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 325, 16, 446, 325, 23, 272, 650, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 19, 12, 221, 327, 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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 ]
athkishore/vgr
tests/test_user_model.py
16
5437
import unittest import time from datetime import datetime from app import create_app, db from app.models import User, AnonymousUser, Role, Permission class UserModelTestCase(unittest.TestCase): def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all() Role.insert_roles() def tearDown(self): db.session.remove() db.drop_all() self.app_context.pop() def test_password_setter(self): u = User(password='cat') self.assertTrue(u.password_hash is not None) def test_no_password_getter(self): u = User(password='cat') with self.assertRaises(AttributeError): u.password def test_password_verification(self): u = User(password='cat') self.assertTrue(u.verify_password('cat')) self.assertFalse(u.verify_password('dog')) def test_password_salts_are_random(self): u = User(password='cat') u2 = User(password='cat') self.assertTrue(u.password_hash != u2.password_hash) def test_valid_confirmation_token(self): u = User(password='cat') db.session.add(u) db.session.commit() token = u.generate_confirmation_token() self.assertTrue(u.confirm(token)) def test_invalid_confirmation_token(self): u1 = User(password='cat') u2 = User(password='dog') db.session.add(u1) db.session.add(u2) db.session.commit() token = u1.generate_confirmation_token() self.assertFalse(u2.confirm(token)) def test_expired_confirmation_token(self): u = User(password='cat') db.session.add(u) db.session.commit() token = u.generate_confirmation_token(1) time.sleep(2) self.assertFalse(u.confirm(token)) def test_valid_reset_token(self): u = User(password='cat') db.session.add(u) db.session.commit() token = u.generate_reset_token() self.assertTrue(u.reset_password(token, 'dog')) self.assertTrue(u.verify_password('dog')) def test_invalid_reset_token(self): u1 = User(password='cat') u2 = User(password='dog') db.session.add(u1) db.session.add(u2) db.session.commit() token = u1.generate_reset_token() self.assertFalse(u2.reset_password(token, 'horse')) self.assertTrue(u2.verify_password('dog')) def test_valid_email_change_token(self): u = User(email='john@example.com', password='cat') db.session.add(u) db.session.commit() token = u.generate_email_change_token('susan@example.org') self.assertTrue(u.change_email(token)) self.assertTrue(u.email == 'susan@example.org') def test_invalid_email_change_token(self): u1 = User(email='john@example.com', password='cat') u2 = User(email='susan@example.org', password='dog') db.session.add(u1) db.session.add(u2) db.session.commit() token = u1.generate_email_change_token('david@example.net') self.assertFalse(u2.change_email(token)) self.assertTrue(u2.email == 'susan@example.org') def test_duplicate_email_change_token(self): u1 = User(email='john@example.com', password='cat') u2 = User(email='susan@example.org', password='dog') db.session.add(u1) db.session.add(u2) db.session.commit() token = u2.generate_email_change_token('john@example.com') self.assertFalse(u2.change_email(token)) self.assertTrue(u2.email == 'susan@example.org') def test_roles_and_permissions(self): u = User(email='john@example.com', password='cat') self.assertTrue(u.can(Permission.WRITE_ARTICLES)) self.assertFalse(u.can(Permission.MODERATE_COMMENTS)) def test_anonymous_user(self): u = AnonymousUser() self.assertFalse(u.can(Permission.FOLLOW)) def test_timestamps(self): u = User(password='cat') db.session.add(u) db.session.commit() self.assertTrue( (datetime.utcnow() - u.member_since).total_seconds() < 3) self.assertTrue( (datetime.utcnow() - u.last_seen).total_seconds() < 3) def test_ping(self): u = User(password='cat') db.session.add(u) db.session.commit() time.sleep(2) last_seen_before = u.last_seen u.ping() self.assertTrue(u.last_seen > last_seen_before) def test_gravatar(self): u = User(email='john@example.com', password='cat') with self.app.test_request_context('/'): gravatar = u.gravatar() gravatar_256 = u.gravatar(size=256) gravatar_pg = u.gravatar(rating='pg') gravatar_retro = u.gravatar(default='retro') with self.app.test_request_context('/', base_url='https://example.com'): gravatar_ssl = u.gravatar() self.assertTrue('http://www.gravatar.com/avatar/' + 'd4c74594d841139328695756648b6bd6'in gravatar) self.assertTrue('s=256' in gravatar_256) self.assertTrue('r=pg' in gravatar_pg) self.assertTrue('d=retro' in gravatar_retro) self.assertTrue('https://secure.gravatar.com/avatar/' + 'd4c74594d841139328695756648b6bd6' in gravatar_ssl)
mit
[ 646, 2882, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 504, 1145, 492, 1218, 63, 571, 12, 1592, 199, 504, 1145, 14, 992, 492, 2876, 12, 29952, 12, 18033, 12, 8779, 421, 199, 533, 2876, 1685, 1746, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 571, 275, 1218, 63, 571, 360, 4776, 358, 267, 291, 14, 571, 63, 1100, 275, 291, 14, 571, 14, 571, 63, 1100, 342, 267, 291, 14, 571, 63, 1100, 14, 5335, 342, 267, 1592, 14, 981, 63, 452, 342, 267, 18033, 14, 3176, 63, 8050, 342, 339, 347, 6766, 8, 277, 304, 267, 1592, 14, 1730, 14, 2168, 342, 267, 1592, 14, 4824, 63, 452, 342, 267, 291, 14, 571, 63, 1100, 14, 1935, 342, 339, 347, 511, 63, 2060, 63, 8345, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 291, 14, 1815, 8, 85, 14, 2060, 63, 2227, 365, 440, 488, 9, 339, 347, 511, 63, 889, 63, 2060, 63, 7416, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 543, 291, 14, 1855, 8, 10227, 304, 288, 399, 14, 2060, 339, 347, 511, 63, 2060, 63, 16257, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 291, 14, 1815, 8, 85, 14, 4712, 63, 2060, 360, 3385, 1333, 267, 291, 14, 3334, 8, 85, 14, 4712, 63, 2060, 360, 13889, 1333, 339, 347, 511, 63, 2060, 63, 6327, 1086, 63, 1530, 63, 2355, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2060, 534, 3385, 358, 267, 291, 14, 1815, 8, 85, 14, 2060, 63, 2227, 1137, 399, 18, 14, 2060, 63, 2227, 9, 339, 347, 511, 63, 1078, 63, 20903, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 20903, 63, 1418, 342, 267, 291, 14, 1815, 8, 85, 14, 9548, 8, 1418, 430, 339, 347, 511, 63, 3197, 63, 20903, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2060, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2060, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 17, 14, 4208, 63, 20903, 63, 1418, 342, 267, 291, 14, 3334, 8, 85, 18, 14, 9548, 8, 1418, 430, 339, 347, 511, 63, 16340, 63, 20903, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 20903, 63, 1418, 8, 17, 9, 267, 900, 14, 4532, 8, 18, 9, 267, 291, 14, 3334, 8, 85, 14, 9548, 8, 1418, 430, 339, 347, 511, 63, 1078, 63, 3958, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 3958, 63, 1418, 342, 267, 291, 14, 1815, 8, 85, 14, 3958, 63, 2060, 8, 1418, 12, 283, 13889, 1333, 267, 291, 14, 1815, 8, 85, 14, 4712, 63, 2060, 360, 13889, 1333, 339, 347, 511, 63, 3197, 63, 3958, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2060, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2060, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 17, 14, 4208, 63, 3958, 63, 1418, 342, 267, 291, 14, 3334, 8, 85, 18, 14, 3958, 63, 2060, 8, 1418, 12, 283, 28577, 1333, 267, 291, 14, 1815, 8, 85, 18, 14, 4712, 63, 2060, 360, 13889, 1333, 339, 347, 511, 63, 1078, 63, 2123, 63, 1461, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2123, 534, 20216, 32, 2694, 14, 957, 297, 2505, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 2123, 63, 1461, 63, 1418, 360, 25253, 290, 32, 2694, 14, 1308, 358, 267, 291, 14, 1815, 8, 85, 14, 1461, 63, 2123, 8, 1418, 430, 267, 291, 14, 1815, 8, 85, 14, 2123, 508, 283, 25253, 290, 32, 2694, 14, 1308, 358, 339, 347, 511, 63, 3197, 63, 2123, 63, 1461, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2123, 534, 20216, 32, 2694, 14, 957, 297, 2505, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2123, 534, 25253, 290, 32, 2694, 14, 1308, 297, 2505, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 17, 14, 4208, 63, 2123, 63, 1461, 63, 1418, 360, 983, 5017, 32, 2694, 14, 846, 358, 267, 291, 14, 3334, 8, 85, 18, 14, 1461, 63, 2123, 8, 1418, 430, 267, 291, 14, 1815, 8, 85, 18, 14, 2123, 508, 283, 25253, 290, 32, 2694, 14, 1308, 358, 339, 347, 511, 63, 11081, 63, 2123, 63, 1461, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2123, 534, 20216, 32, 2694, 14, 957, 297, 2505, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2123, 534, 25253, 290, 32, 2694, 14, 1308, 297, 2505, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 18, 14, 4208, 63, 2123, 63, 1461, 63, 1418, 360, 20216, 32, 2694, 14, 957, 358, 267, 291, 14, 3334, 8, 85, 18, 14, 1461, 63, 2123, 8, 1418, 430, 267, 291, 14, 1815, 8 ]
[ 2882, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 504, 1145, 492, 1218, 63, 571, 12, 1592, 199, 504, 1145, 14, 992, 492, 2876, 12, 29952, 12, 18033, 12, 8779, 421, 199, 533, 2876, 1685, 1746, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 571, 275, 1218, 63, 571, 360, 4776, 358, 267, 291, 14, 571, 63, 1100, 275, 291, 14, 571, 14, 571, 63, 1100, 342, 267, 291, 14, 571, 63, 1100, 14, 5335, 342, 267, 1592, 14, 981, 63, 452, 342, 267, 18033, 14, 3176, 63, 8050, 342, 339, 347, 6766, 8, 277, 304, 267, 1592, 14, 1730, 14, 2168, 342, 267, 1592, 14, 4824, 63, 452, 342, 267, 291, 14, 571, 63, 1100, 14, 1935, 342, 339, 347, 511, 63, 2060, 63, 8345, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 291, 14, 1815, 8, 85, 14, 2060, 63, 2227, 365, 440, 488, 9, 339, 347, 511, 63, 889, 63, 2060, 63, 7416, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 543, 291, 14, 1855, 8, 10227, 304, 288, 399, 14, 2060, 339, 347, 511, 63, 2060, 63, 16257, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 291, 14, 1815, 8, 85, 14, 4712, 63, 2060, 360, 3385, 1333, 267, 291, 14, 3334, 8, 85, 14, 4712, 63, 2060, 360, 13889, 1333, 339, 347, 511, 63, 2060, 63, 6327, 1086, 63, 1530, 63, 2355, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2060, 534, 3385, 358, 267, 291, 14, 1815, 8, 85, 14, 2060, 63, 2227, 1137, 399, 18, 14, 2060, 63, 2227, 9, 339, 347, 511, 63, 1078, 63, 20903, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 20903, 63, 1418, 342, 267, 291, 14, 1815, 8, 85, 14, 9548, 8, 1418, 430, 339, 347, 511, 63, 3197, 63, 20903, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2060, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2060, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 17, 14, 4208, 63, 20903, 63, 1418, 342, 267, 291, 14, 3334, 8, 85, 18, 14, 9548, 8, 1418, 430, 339, 347, 511, 63, 16340, 63, 20903, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 20903, 63, 1418, 8, 17, 9, 267, 900, 14, 4532, 8, 18, 9, 267, 291, 14, 3334, 8, 85, 14, 9548, 8, 1418, 430, 339, 347, 511, 63, 1078, 63, 3958, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2060, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 3958, 63, 1418, 342, 267, 291, 14, 1815, 8, 85, 14, 3958, 63, 2060, 8, 1418, 12, 283, 13889, 1333, 267, 291, 14, 1815, 8, 85, 14, 4712, 63, 2060, 360, 13889, 1333, 339, 347, 511, 63, 3197, 63, 3958, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2060, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2060, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 17, 14, 4208, 63, 3958, 63, 1418, 342, 267, 291, 14, 3334, 8, 85, 18, 14, 3958, 63, 2060, 8, 1418, 12, 283, 28577, 1333, 267, 291, 14, 1815, 8, 85, 18, 14, 4712, 63, 2060, 360, 13889, 1333, 339, 347, 511, 63, 1078, 63, 2123, 63, 1461, 63, 1418, 8, 277, 304, 267, 399, 275, 2876, 8, 2123, 534, 20216, 32, 2694, 14, 957, 297, 2505, 534, 3385, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 14, 4208, 63, 2123, 63, 1461, 63, 1418, 360, 25253, 290, 32, 2694, 14, 1308, 358, 267, 291, 14, 1815, 8, 85, 14, 1461, 63, 2123, 8, 1418, 430, 267, 291, 14, 1815, 8, 85, 14, 2123, 508, 283, 25253, 290, 32, 2694, 14, 1308, 358, 339, 347, 511, 63, 3197, 63, 2123, 63, 1461, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2123, 534, 20216, 32, 2694, 14, 957, 297, 2505, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2123, 534, 25253, 290, 32, 2694, 14, 1308, 297, 2505, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 17, 14, 4208, 63, 2123, 63, 1461, 63, 1418, 360, 983, 5017, 32, 2694, 14, 846, 358, 267, 291, 14, 3334, 8, 85, 18, 14, 1461, 63, 2123, 8, 1418, 430, 267, 291, 14, 1815, 8, 85, 18, 14, 2123, 508, 283, 25253, 290, 32, 2694, 14, 1308, 358, 339, 347, 511, 63, 11081, 63, 2123, 63, 1461, 63, 1418, 8, 277, 304, 267, 399, 17, 275, 2876, 8, 2123, 534, 20216, 32, 2694, 14, 957, 297, 2505, 534, 3385, 358, 267, 399, 18, 275, 2876, 8, 2123, 534, 25253, 290, 32, 2694, 14, 1308, 297, 2505, 534, 13889, 358, 267, 1592, 14, 1730, 14, 525, 8, 85, 17, 9, 267, 1592, 14, 1730, 14, 525, 8, 85, 18, 9, 267, 1592, 14, 1730, 14, 3543, 342, 267, 1526, 275, 399, 18, 14, 4208, 63, 2123, 63, 1461, 63, 1418, 360, 20216, 32, 2694, 14, 957, 358, 267, 291, 14, 3334, 8, 85, 18, 14, 1461, 63, 2123, 8, 1418, 430, 267, 291, 14, 1815, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
yasirkhan380/Tutorials
notebooks/fig_code/svm_gui.py
47
11549
""" ========== Libsvm GUI ========== A simple graphical frontend for Libsvm mainly intended for didactic purposes. You can create data points by point and click and visualize the decision region induced by different kernels and parameter settings. To create positive examples click the left mouse button; to create negative examples click the right button. If all examples are from the same class, it uses a one-class SVM. """ from __future__ import division, print_function print(__doc__) # Author: Peter Prettenhoer <peter.prettenhofer@gmail.com> # # License: BSD 3 clause import matplotlib matplotlib.use('TkAgg') from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg from matplotlib.figure import Figure from matplotlib.contour import ContourSet import Tkinter as Tk import sys import numpy as np from sklearn import svm from sklearn.datasets import dump_svmlight_file from sklearn.externals.six.moves import xrange y_min, y_max = -50, 50 x_min, x_max = -50, 50 class Model(object): """The Model which hold the data. It implements the observable in the observer pattern and notifies the registered observers on change event. """ def __init__(self): self.observers = [] self.surface = None self.data = [] self.cls = None self.surface_type = 0 def changed(self, event): """Notify the observers. """ for observer in self.observers: observer.update(event, self) def add_observer(self, observer): """Register an observer. """ self.observers.append(observer) def set_surface(self, surface): self.surface = surface def dump_svmlight_file(self, file): data = np.array(self.data) X = data[:, 0:2] y = data[:, 2] dump_svmlight_file(X, y, file) class Controller(object): def __init__(self, model): self.model = model self.kernel = Tk.IntVar() self.surface_type = Tk.IntVar() # Whether or not a model has been fitted self.fitted = False def fit(self): print("fit the model") train = np.array(self.model.data) X = train[:, 0:2] y = train[:, 2] C = float(self.complexity.get()) gamma = float(self.gamma.get()) coef0 = float(self.coef0.get()) degree = int(self.degree.get()) kernel_map = {0: "linear", 1: "rbf", 2: "poly"} if len(np.unique(y)) == 1: clf = svm.OneClassSVM(kernel=kernel_map[self.kernel.get()], gamma=gamma, coef0=coef0, degree=degree) clf.fit(X) else: clf = svm.SVC(kernel=kernel_map[self.kernel.get()], C=C, gamma=gamma, coef0=coef0, degree=degree) clf.fit(X, y) if hasattr(clf, 'score'): print("Accuracy:", clf.score(X, y) * 100) X1, X2, Z = self.decision_surface(clf) self.model.clf = clf self.model.set_surface((X1, X2, Z)) self.model.surface_type = self.surface_type.get() self.fitted = True self.model.changed("surface") def decision_surface(self, cls): delta = 1 x = np.arange(x_min, x_max + delta, delta) y = np.arange(y_min, y_max + delta, delta) X1, X2 = np.meshgrid(x, y) Z = cls.decision_function(np.c_[X1.ravel(), X2.ravel()]) Z = Z.reshape(X1.shape) return X1, X2, Z def clear_data(self): self.model.data = [] self.fitted = False self.model.changed("clear") def add_example(self, x, y, label): self.model.data.append((x, y, label)) self.model.changed("example_added") # update decision surface if already fitted. self.refit() def refit(self): """Refit the model if already fitted. """ if self.fitted: self.fit() class View(object): """Test docstring. """ def __init__(self, root, controller): f = Figure() ax = f.add_subplot(111) ax.set_xticks([]) ax.set_yticks([]) ax.set_xlim((x_min, x_max)) ax.set_ylim((y_min, y_max)) canvas = FigureCanvasTkAgg(f, master=root) canvas.show() canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) canvas.mpl_connect('key_press_event', self.onkeypress) canvas.mpl_connect('key_release_event', self.onkeyrelease) canvas.mpl_connect('button_press_event', self.onclick) toolbar = NavigationToolbar2TkAgg(canvas, root) toolbar.update() self.shift_down = False self.controllbar = ControllBar(root, controller) self.f = f self.ax = ax self.canvas = canvas self.controller = controller self.contours = [] self.c_labels = None self.plot_kernels() def plot_kernels(self): self.ax.text(-50, -60, "Linear: $u^T v$") self.ax.text(-20, -60, "RBF: $\exp (-\gamma \| u-v \|^2)$") self.ax.text(10, -60, "Poly: $(\gamma \, u^T v + r)^d$") def onkeypress(self, event): if event.key == "shift": self.shift_down = True def onkeyrelease(self, event): if event.key == "shift": self.shift_down = False def onclick(self, event): if event.xdata and event.ydata: if self.shift_down or event.button == 3: self.controller.add_example(event.xdata, event.ydata, -1) elif event.button == 1: self.controller.add_example(event.xdata, event.ydata, 1) def update_example(self, model, idx): x, y, l = model.data[idx] if l == 1: color = 'w' elif l == -1: color = 'k' self.ax.plot([x], [y], "%so" % color, scalex=0.0, scaley=0.0) def update(self, event, model): if event == "examples_loaded": for i in xrange(len(model.data)): self.update_example(model, i) if event == "example_added": self.update_example(model, -1) if event == "clear": self.ax.clear() self.ax.set_xticks([]) self.ax.set_yticks([]) self.contours = [] self.c_labels = None self.plot_kernels() if event == "surface": self.remove_surface() self.plot_support_vectors(model.clf.support_vectors_) self.plot_decision_surface(model.surface, model.surface_type) self.canvas.draw() def remove_surface(self): """Remove old decision surface.""" if len(self.contours) > 0: for contour in self.contours: if isinstance(contour, ContourSet): for lineset in contour.collections: lineset.remove() else: contour.remove() self.contours = [] def plot_support_vectors(self, support_vectors): """Plot the support vectors by placing circles over the corresponding data points and adds the circle collection to the contours list.""" cs = self.ax.scatter(support_vectors[:, 0], support_vectors[:, 1], s=80, edgecolors="k", facecolors="none") self.contours.append(cs) def plot_decision_surface(self, surface, type): X1, X2, Z = surface if type == 0: levels = [-1.0, 0.0, 1.0] linestyles = ['dashed', 'solid', 'dashed'] colors = 'k' self.contours.append(self.ax.contour(X1, X2, Z, levels, colors=colors, linestyles=linestyles)) elif type == 1: self.contours.append(self.ax.contourf(X1, X2, Z, 10, cmap=matplotlib.cm.bone, origin='lower', alpha=0.85)) self.contours.append(self.ax.contour(X1, X2, Z, [0.0], colors='k', linestyles=['solid'])) else: raise ValueError("surface type unknown") class ControllBar(object): def __init__(self, root, controller): fm = Tk.Frame(root) kernel_group = Tk.Frame(fm) Tk.Radiobutton(kernel_group, text="Linear", variable=controller.kernel, value=0, command=controller.refit).pack(anchor=Tk.W) Tk.Radiobutton(kernel_group, text="RBF", variable=controller.kernel, value=1, command=controller.refit).pack(anchor=Tk.W) Tk.Radiobutton(kernel_group, text="Poly", variable=controller.kernel, value=2, command=controller.refit).pack(anchor=Tk.W) kernel_group.pack(side=Tk.LEFT) valbox = Tk.Frame(fm) controller.complexity = Tk.StringVar() controller.complexity.set("1.0") c = Tk.Frame(valbox) Tk.Label(c, text="C:", anchor="e", width=7).pack(side=Tk.LEFT) Tk.Entry(c, width=6, textvariable=controller.complexity).pack( side=Tk.LEFT) c.pack() controller.gamma = Tk.StringVar() controller.gamma.set("0.01") g = Tk.Frame(valbox) Tk.Label(g, text="gamma:", anchor="e", width=7).pack(side=Tk.LEFT) Tk.Entry(g, width=6, textvariable=controller.gamma).pack(side=Tk.LEFT) g.pack() controller.degree = Tk.StringVar() controller.degree.set("3") d = Tk.Frame(valbox) Tk.Label(d, text="degree:", anchor="e", width=7).pack(side=Tk.LEFT) Tk.Entry(d, width=6, textvariable=controller.degree).pack(side=Tk.LEFT) d.pack() controller.coef0 = Tk.StringVar() controller.coef0.set("0") r = Tk.Frame(valbox) Tk.Label(r, text="coef0:", anchor="e", width=7).pack(side=Tk.LEFT) Tk.Entry(r, width=6, textvariable=controller.coef0).pack(side=Tk.LEFT) r.pack() valbox.pack(side=Tk.LEFT) cmap_group = Tk.Frame(fm) Tk.Radiobutton(cmap_group, text="Hyperplanes", variable=controller.surface_type, value=0, command=controller.refit).pack(anchor=Tk.W) Tk.Radiobutton(cmap_group, text="Surface", variable=controller.surface_type, value=1, command=controller.refit).pack(anchor=Tk.W) cmap_group.pack(side=Tk.LEFT) train_button = Tk.Button(fm, text='Fit', width=5, command=controller.fit) train_button.pack() fm.pack(side=Tk.LEFT) Tk.Button(fm, text='Clear', width=5, command=controller.clear_data).pack(side=Tk.LEFT) def get_parser(): from optparse import OptionParser op = OptionParser() op.add_option("--output", action="store", type="str", dest="output", help="Path where to dump data.") return op def main(argv): op = get_parser() opts, args = op.parse_args(argv[1:]) root = Tk.Tk() model = Model() controller = Controller(model) root.wm_title("Scikit-learn Libsvm GUI") view = View(root, controller) model.add_observer(view) Tk.mainloop() if opts.output: model.dump_svmlight_file(opts.output) if __name__ == "__main__": main(sys.argv)
bsd-3-clause
[ 624, 199, 17575, 199, 13009, 1533, 2611, 17160, 199, 17575, 199, 199, 33, 3486, 3343, 2652, 22523, 367, 24157, 1533, 2611, 27580, 11619, 367, 8103, 27296, 199, 6653, 10553, 14, 2047, 883, 1218, 666, 4501, 701, 2376, 436, 8968, 436, 13104, 794, 199, 1589, 14692, 4897, 315, 16584, 701, 3365, 26091, 436, 2725, 2202, 14, 199, 199, 1378, 1218, 7317, 7251, 8968, 314, 3602, 12817, 5528, 27, 370, 1218, 199, 7371, 7251, 8968, 314, 2451, 5528, 14, 199, 199, 3917, 1006, 7251, 787, 687, 314, 2011, 1021, 12, 652, 4440, 282, 1373, 13, 533, 428, 6849, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 199, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6529, 26, 22912, 510, 3292, 724, 526, 281, 665, 321, 351, 14, 657, 4075, 526, 2412, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 8027, 199, 16440, 14, 1180, 360, 15189, 7248, 358, 199, 199, 504, 8027, 14, 7765, 14, 4620, 63, 2663, 13452, 492, 16266, 15174, 15189, 7248, 199, 504, 8027, 14, 7765, 14, 4620, 63, 2663, 13452, 492, 20721, 5360, 29630, 18, 15189, 7248, 199, 504, 8027, 14, 8941, 492, 16266, 199, 504, 8027, 14, 17798, 492, 1448, 10808, 1084, 199, 199, 646, 16826, 465, 12435, 199, 646, 984, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 492, 23044, 199, 504, 6357, 14, 12281, 492, 5461, 63, 16820, 4040, 63, 493, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 4945, 199, 199, 89, 63, 827, 12, 612, 63, 988, 275, 446, 1400, 12, 5238, 199, 88, 63, 827, 12, 671, 63, 988, 275, 446, 1400, 12, 5238, 421, 199, 533, 5822, 8, 785, 304, 272, 408, 1918, 5822, 1314, 10266, 314, 666, 14, 2779, 9031, 314, 272, 2607, 29454, 315, 314, 27336, 3851, 436, 949, 1428, 397, 314, 272, 7264, 2607, 5871, 641, 1570, 1566, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2873, 5871, 275, 942, 267, 291, 14, 10992, 275, 488, 267, 291, 14, 576, 275, 942, 267, 291, 14, 1886, 275, 488, 267, 291, 14, 10992, 63, 466, 275, 378, 339, 347, 2896, 8, 277, 12, 1566, 304, 267, 408, 8645, 314, 2607, 5871, 14, 408, 267, 367, 27336, 315, 291, 14, 2873, 5871, 26, 288, 27336, 14, 873, 8, 1430, 12, 291, 9, 339, 347, 1050, 63, 23968, 8, 277, 12, 27336, 304, 267, 408, 7099, 376, 27336, 14, 408, 267, 291, 14, 2873, 5871, 14, 740, 8, 23968, 9, 339, 347, 663, 63, 10992, 8, 277, 12, 13195, 304, 267, 291, 14, 10992, 275, 13195, 339, 347, 5461, 63, 16820, 4040, 63, 493, 8, 277, 12, 570, 304, 267, 666, 275, 980, 14, 1144, 8, 277, 14, 576, 9, 267, 1323, 275, 666, 3981, 378, 26, 18, 61, 267, 612, 275, 666, 3981, 499, 61, 267, 5461, 63, 16820, 4040, 63, 493, 8, 56, 12, 612, 12, 570, 9, 421, 199, 533, 16282, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1402, 304, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 4989, 275, 12435, 14, 3241, 5894, 342, 267, 291, 14, 10992, 63, 466, 275, 12435, 14, 3241, 5894, 342, 267, 327, 7480, 503, 440, 282, 1402, 965, 2757, 26093, 267, 291, 14, 21903, 275, 756, 339, 347, 5542, 8, 277, 304, 267, 870, 480, 3269, 314, 1402, 531, 267, 3560, 275, 980, 14, 1144, 8, 277, 14, 1238, 14, 576, 9, 267, 1323, 275, 3560, 3981, 378, 26, 18, 61, 267, 612, 275, 3560, 3981, 499, 61, 398, 445, 275, 2069, 8, 277, 14, 5254, 1209, 14, 362, 1012, 267, 10169, 275, 2069, 8, 277, 14, 7325, 14, 362, 1012, 267, 7355, 16, 275, 2069, 8, 277, 14, 8009, 16, 14, 362, 1012, 267, 13666, 275, 1109, 8, 277, 14, 10956, 14, 362, 1012, 267, 5114, 63, 1130, 275, 469, 16, 26, 298, 6676, 401, 413, 26, 298, 25853, 401, 499, 26, 298, 6023, 3570, 267, 340, 822, 8, 1590, 14, 3235, 8, 89, 430, 508, 413, 26, 288, 6975, 275, 23044, 14, 4395, 2543, 29389, 8, 4989, 29, 4989, 63, 1130, 59, 277, 14, 4989, 14, 362, 15618, 3303, 10169, 29, 7325, 12, 7355, 16, 29, 8009, 16, 12, 13666, 29, 10956, 9, 288, 6975, 14, 3269, 8, 56, 9, 267, 587, 26, 288, 6975, 275, 23044, 14, 17675, 8, 4989, 29, 4989, 63, 1130, 59, 277, 14, 4989, 14, 362, 15618, 445, 29, 35, 12, 2079, 10169, 29, 7325, 12, 7355, 16, 29, 8009, 16, 12, 13666, 29, 10956, 9, 288, 6975, 14, 3269, 8, 56, 12, 612, 9, 267, 340, 2688, 8, 9694, 12, 283, 3397, 735, 288, 870, 480, 1945, 7933, 6783, 6975, 14, 3397, 8, 56, 12, 612, 9, 627, 2948, 9, 267, 1323, 17, 12, 1323, 18, 12, 3107, 275, 291, 14, 16622, 63, 10992, 8, 9694, 9, 267, 291, 14, 1238, 14, 9694, 275, 6975, 267, 291, 14, 1238, 14, 409, 63, 10992, 1332, 56, 17, 12, 1323, 18, 12, 3107, 430, 267, 291, 14, 1238, 14, 10992, 63, 466, 275, 291, 14, 10992, 63, 466, 14, 362, 342, 267, 291, 14, 21903, 275, 715, 267, 291, 14, 1238, 14, 2489, 480, 10992, 531, 339, 347, 14692, 63, 10992, 8, 277, 12, 843, 304, 267, 5762, 275, 413, 267, 671, 275, 980, 14, 5605, 8, 88, 63, 827, 12, 671, 63, 988, 435, 5762, 12, 5762, 9, 267, 612, 275, 980, 14, 5605, 8, 89, 63, 827, 12, 612, 63, 988, 435, 5762, 12, 5762, 9, 267, 1323, 17, 12, 1323, 18, 275, 980, 14, 6480, 3825, 8, 88, 12, 612, 9, 267, 3107, 275, 843, 14, 16622, 63, 1593, 8, 1590, 14, 67, 9925, 56, 17, 14, 11186, 1062, 1323, 18, 14, 11186, 9383, 267, 3107, 275, 3107, 14, 5217, 8, 56, 17, 14, 1392, 9, 267, 372, 1323, 17, 12, 1323, 18, 12, 3107, 339, 347, 5436, 63, 576, 8, 277, 304, 267, 291, 14, 1238, 14, 576, 275, 942, 267, 291, 14, 21903, 275, 756, 267, 291, 14, 1238, 14, 2489, 480, 3584, 531, 339, 347, 1050, 63, 2694, 8, 277, 12, 671, 12, 612, 12 ]
[ 199, 17575, 199, 13009, 1533, 2611, 17160, 199, 17575, 199, 199, 33, 3486, 3343, 2652, 22523, 367, 24157, 1533, 2611, 27580, 11619, 367, 8103, 27296, 199, 6653, 10553, 14, 2047, 883, 1218, 666, 4501, 701, 2376, 436, 8968, 436, 13104, 794, 199, 1589, 14692, 4897, 315, 16584, 701, 3365, 26091, 436, 2725, 2202, 14, 199, 199, 1378, 1218, 7317, 7251, 8968, 314, 3602, 12817, 5528, 27, 370, 1218, 199, 7371, 7251, 8968, 314, 2451, 5528, 14, 199, 199, 3917, 1006, 7251, 787, 687, 314, 2011, 1021, 12, 652, 4440, 282, 1373, 13, 533, 428, 6849, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 199, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6529, 26, 22912, 510, 3292, 724, 526, 281, 665, 321, 351, 14, 657, 4075, 526, 2412, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 8027, 199, 16440, 14, 1180, 360, 15189, 7248, 358, 199, 199, 504, 8027, 14, 7765, 14, 4620, 63, 2663, 13452, 492, 16266, 15174, 15189, 7248, 199, 504, 8027, 14, 7765, 14, 4620, 63, 2663, 13452, 492, 20721, 5360, 29630, 18, 15189, 7248, 199, 504, 8027, 14, 8941, 492, 16266, 199, 504, 8027, 14, 17798, 492, 1448, 10808, 1084, 199, 199, 646, 16826, 465, 12435, 199, 646, 984, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 492, 23044, 199, 504, 6357, 14, 12281, 492, 5461, 63, 16820, 4040, 63, 493, 199, 504, 6357, 14, 24688, 14, 4174, 14, 4912, 492, 4945, 199, 199, 89, 63, 827, 12, 612, 63, 988, 275, 446, 1400, 12, 5238, 199, 88, 63, 827, 12, 671, 63, 988, 275, 446, 1400, 12, 5238, 421, 199, 533, 5822, 8, 785, 304, 272, 408, 1918, 5822, 1314, 10266, 314, 666, 14, 2779, 9031, 314, 272, 2607, 29454, 315, 314, 27336, 3851, 436, 949, 1428, 397, 314, 272, 7264, 2607, 5871, 641, 1570, 1566, 14, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2873, 5871, 275, 942, 267, 291, 14, 10992, 275, 488, 267, 291, 14, 576, 275, 942, 267, 291, 14, 1886, 275, 488, 267, 291, 14, 10992, 63, 466, 275, 378, 339, 347, 2896, 8, 277, 12, 1566, 304, 267, 408, 8645, 314, 2607, 5871, 14, 408, 267, 367, 27336, 315, 291, 14, 2873, 5871, 26, 288, 27336, 14, 873, 8, 1430, 12, 291, 9, 339, 347, 1050, 63, 23968, 8, 277, 12, 27336, 304, 267, 408, 7099, 376, 27336, 14, 408, 267, 291, 14, 2873, 5871, 14, 740, 8, 23968, 9, 339, 347, 663, 63, 10992, 8, 277, 12, 13195, 304, 267, 291, 14, 10992, 275, 13195, 339, 347, 5461, 63, 16820, 4040, 63, 493, 8, 277, 12, 570, 304, 267, 666, 275, 980, 14, 1144, 8, 277, 14, 576, 9, 267, 1323, 275, 666, 3981, 378, 26, 18, 61, 267, 612, 275, 666, 3981, 499, 61, 267, 5461, 63, 16820, 4040, 63, 493, 8, 56, 12, 612, 12, 570, 9, 421, 199, 533, 16282, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1402, 304, 267, 291, 14, 1238, 275, 1402, 267, 291, 14, 4989, 275, 12435, 14, 3241, 5894, 342, 267, 291, 14, 10992, 63, 466, 275, 12435, 14, 3241, 5894, 342, 267, 327, 7480, 503, 440, 282, 1402, 965, 2757, 26093, 267, 291, 14, 21903, 275, 756, 339, 347, 5542, 8, 277, 304, 267, 870, 480, 3269, 314, 1402, 531, 267, 3560, 275, 980, 14, 1144, 8, 277, 14, 1238, 14, 576, 9, 267, 1323, 275, 3560, 3981, 378, 26, 18, 61, 267, 612, 275, 3560, 3981, 499, 61, 398, 445, 275, 2069, 8, 277, 14, 5254, 1209, 14, 362, 1012, 267, 10169, 275, 2069, 8, 277, 14, 7325, 14, 362, 1012, 267, 7355, 16, 275, 2069, 8, 277, 14, 8009, 16, 14, 362, 1012, 267, 13666, 275, 1109, 8, 277, 14, 10956, 14, 362, 1012, 267, 5114, 63, 1130, 275, 469, 16, 26, 298, 6676, 401, 413, 26, 298, 25853, 401, 499, 26, 298, 6023, 3570, 267, 340, 822, 8, 1590, 14, 3235, 8, 89, 430, 508, 413, 26, 288, 6975, 275, 23044, 14, 4395, 2543, 29389, 8, 4989, 29, 4989, 63, 1130, 59, 277, 14, 4989, 14, 362, 15618, 3303, 10169, 29, 7325, 12, 7355, 16, 29, 8009, 16, 12, 13666, 29, 10956, 9, 288, 6975, 14, 3269, 8, 56, 9, 267, 587, 26, 288, 6975, 275, 23044, 14, 17675, 8, 4989, 29, 4989, 63, 1130, 59, 277, 14, 4989, 14, 362, 15618, 445, 29, 35, 12, 2079, 10169, 29, 7325, 12, 7355, 16, 29, 8009, 16, 12, 13666, 29, 10956, 9, 288, 6975, 14, 3269, 8, 56, 12, 612, 9, 267, 340, 2688, 8, 9694, 12, 283, 3397, 735, 288, 870, 480, 1945, 7933, 6783, 6975, 14, 3397, 8, 56, 12, 612, 9, 627, 2948, 9, 267, 1323, 17, 12, 1323, 18, 12, 3107, 275, 291, 14, 16622, 63, 10992, 8, 9694, 9, 267, 291, 14, 1238, 14, 9694, 275, 6975, 267, 291, 14, 1238, 14, 409, 63, 10992, 1332, 56, 17, 12, 1323, 18, 12, 3107, 430, 267, 291, 14, 1238, 14, 10992, 63, 466, 275, 291, 14, 10992, 63, 466, 14, 362, 342, 267, 291, 14, 21903, 275, 715, 267, 291, 14, 1238, 14, 2489, 480, 10992, 531, 339, 347, 14692, 63, 10992, 8, 277, 12, 843, 304, 267, 5762, 275, 413, 267, 671, 275, 980, 14, 5605, 8, 88, 63, 827, 12, 671, 63, 988, 435, 5762, 12, 5762, 9, 267, 612, 275, 980, 14, 5605, 8, 89, 63, 827, 12, 612, 63, 988, 435, 5762, 12, 5762, 9, 267, 1323, 17, 12, 1323, 18, 275, 980, 14, 6480, 3825, 8, 88, 12, 612, 9, 267, 3107, 275, 843, 14, 16622, 63, 1593, 8, 1590, 14, 67, 9925, 56, 17, 14, 11186, 1062, 1323, 18, 14, 11186, 9383, 267,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jlelli/sched-deadline
tools/perf/scripts/python/syscall-counts.py
11181
1522
# system call counts # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts.py [comm]\n"; for_comm = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): print "%-40s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 1871, 221, 3837, 275, 715, 304, 6722, 870, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
GustavoHennig/ansible
lib/ansible/utils/module_docs_fragments/cloudstack.py
175
2631
# -*- coding: utf-8 -*- # Copyright (c) 2015 René Moser <mail@renemoser.net> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. class ModuleDocFragment(object): # Standard cloudstack documentation fragment DOCUMENTATION = ''' options: api_key: description: - API key of the CloudStack API. required: false default: null api_secret: description: - Secret key of the CloudStack API. required: false default: null api_url: description: - URL of the CloudStack API e.g. https://cloud.example.com/client/api. required: false default: null api_http_method: description: - HTTP method used. required: false default: 'get' choices: [ 'get', 'post' ] api_timeout: description: - HTTP timeout. required: false default: 10 api_region: description: - Name of the ini section in the C(cloustack.ini) file. required: false default: cloudstack requirements: - "python >= 2.6" - "cs >= 0.6.10" notes: - Ansible uses the C(cs) library's configuration method if credentials are not provided by the arguments C(api_url), C(api_key), C(api_secret). Configuration is read from several locations, in the following order. - The C(CLOUDSTACK_ENDPOINT), C(CLOUDSTACK_KEY), C(CLOUDSTACK_SECRET) and C(CLOUDSTACK_METHOD). C(CLOUDSTACK_TIMEOUT) environment variables. - A C(CLOUDSTACK_CONFIG) environment variable pointing to an C(.ini) file, - A C(cloudstack.ini) file in the current working directory. - A C(.cloudstack.ini) file in the users home directory. Optionally multiple credentials and endpoints can be specified using ini sections in C(cloudstack.ini). Use the argument C(api_region) to select the section name, default section is C(cloudstack). See https://github.com/exoscale/cs for more information. - A detailed guide about cloudstack modules can be found on http://docs.ansible.com/ansible/guide_cloudstack.html - This module supports check mode. '''
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6900, 10055, 5741, 3930, 332, 665, 1198, 32, 264, 685, 573, 332, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 339, 327, 9739, 8002, 2340, 3794, 7956, 272, 29970, 2594, 275, 1449, 199, 1419, 26, 523, 2986, 63, 498, 26, 272, 1369, 26, 489, 446, 3261, 790, 402, 314, 8142, 4851, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 4731, 26, 272, 1369, 26, 489, 446, 23580, 790, 402, 314, 8142, 4851, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 633, 26, 272, 1369, 26, 489, 446, 2851, 402, 314, 8142, 4851, 3261, 325, 14, 71, 14, 4178, 921, 4091, 14, 2694, 14, 957, 15, 1258, 15, 1246, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 1014, 63, 765, 26, 272, 1369, 26, 489, 446, 3101, 1083, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 362, 7, 272, 3415, 26, 359, 283, 362, 297, 283, 1932, 7, 1622, 523, 2986, 63, 2593, 26, 272, 1369, 26, 489, 446, 3101, 2653, 14, 272, 1415, 26, 3055, 272, 849, 26, 1616, 523, 2986, 63, 4551, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 20364, 3420, 315, 314, 445, 8, 1251, 833, 564, 14, 2730, 9, 570, 14, 272, 1415, 26, 3055, 272, 849, 26, 8002, 2340, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 298, 1259, 2356, 378, 14, 22, 14, 709, 2, 199, 5983, 26, 523, 446, 2622, 4440, 314, 445, 8, 1259, 9, 3555, 1159, 2897, 1083, 340, 6235, 787, 440, 272, 2741, 701, 314, 2368, 445, 8, 1246, 63, 633, 395, 445, 8, 1246, 63, 498, 395, 445, 8, 1246, 63, 4731, 680, 272, 11595, 365, 1586, 687, 9978, 9918, 12, 315, 314, 2569, 1865, 14, 272, 446, 710, 445, 8, 29495, 17014, 63, 21054, 395, 445, 8, 29495, 17014, 63, 3078, 395, 445, 8, 29495, 17014, 63, 12961, 9, 436, 489, 445, 8, 29495, 17014, 63, 9977, 680, 445, 8, 29495, 17014, 63, 8899, 9, 3734, 2860, 14, 272, 446, 437, 445, 8, 29495, 17014, 63, 5569, 9, 3734, 1750, 20686, 370, 376, 445, 13417, 2730, 9, 570, 12, 272, 446, 437, 445, 8, 4091, 2340, 14, 2730, 9, 570, 315, 314, 1453, 6449, 2082, 14, 272, 446, 437, 445, 13417, 4091, 2340, 14, 2730, 9, 570, 315, 314, 4390, 5629, 2082, 14, 272, 22383, 3663, 6235, 436, 16173, 883, 506, 2013, 1808, 20364, 10189, 315, 445, 8, 4091, 2340, 14, 2730, 680, 272, 3645, 314, 1423, 445, 8, 1246, 63, 4551, 9, 370, 3504, 314, 3420, 536, 12, 849, 3420, 365, 445, 8, 4091, 2340, 680, 272, 1666, 4178, 921, 5031, 14, 957, 15, 476, 79, 3467, 15, 1259, 367, 1655, 2556, 14, 523, 446, 437, 16212, 22885, 3595, 8002, 2340, 4621, 883, 506, 1911, 641, 1455, 921, 4757, 14, 4853, 14, 957, 15, 4853, 15, 17348, 63, 4091, 2340, 14, 1360, 523, 446, 961, 859, 5171, 1104, 818, 14, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6900, 10055, 5741, 3930, 332, 665, 1198, 32, 264, 685, 573, 332, 14, 846, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 533, 5673, 3768, 11080, 8, 785, 304, 339, 327, 9739, 8002, 2340, 3794, 7956, 272, 29970, 2594, 275, 1449, 199, 1419, 26, 523, 2986, 63, 498, 26, 272, 1369, 26, 489, 446, 3261, 790, 402, 314, 8142, 4851, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 4731, 26, 272, 1369, 26, 489, 446, 23580, 790, 402, 314, 8142, 4851, 3261, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 633, 26, 272, 1369, 26, 489, 446, 2851, 402, 314, 8142, 4851, 3261, 325, 14, 71, 14, 4178, 921, 4091, 14, 2694, 14, 957, 15, 1258, 15, 1246, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2986, 63, 1014, 63, 765, 26, 272, 1369, 26, 489, 446, 3101, 1083, 1202, 14, 272, 1415, 26, 3055, 272, 849, 26, 283, 362, 7, 272, 3415, 26, 359, 283, 362, 297, 283, 1932, 7, 1622, 523, 2986, 63, 2593, 26, 272, 1369, 26, 489, 446, 3101, 2653, 14, 272, 1415, 26, 3055, 272, 849, 26, 1616, 523, 2986, 63, 4551, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 20364, 3420, 315, 314, 445, 8, 1251, 833, 564, 14, 2730, 9, 570, 14, 272, 1415, 26, 3055, 272, 849, 26, 8002, 2340, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 298, 1259, 2356, 378, 14, 22, 14, 709, 2, 199, 5983, 26, 523, 446, 2622, 4440, 314, 445, 8, 1259, 9, 3555, 1159, 2897, 1083, 340, 6235, 787, 440, 272, 2741, 701, 314, 2368, 445, 8, 1246, 63, 633, 395, 445, 8, 1246, 63, 498, 395, 445, 8, 1246, 63, 4731, 680, 272, 11595, 365, 1586, 687, 9978, 9918, 12, 315, 314, 2569, 1865, 14, 272, 446, 710, 445, 8, 29495, 17014, 63, 21054, 395, 445, 8, 29495, 17014, 63, 3078, 395, 445, 8, 29495, 17014, 63, 12961, 9, 436, 489, 445, 8, 29495, 17014, 63, 9977, 680, 445, 8, 29495, 17014, 63, 8899, 9, 3734, 2860, 14, 272, 446, 437, 445, 8, 29495, 17014, 63, 5569, 9, 3734, 1750, 20686, 370, 376, 445, 13417, 2730, 9, 570, 12, 272, 446, 437, 445, 8, 4091, 2340, 14, 2730, 9, 570, 315, 314, 1453, 6449, 2082, 14, 272, 446, 437, 445, 13417, 4091, 2340, 14, 2730, 9, 570, 315, 314, 4390, 5629, 2082, 14, 272, 22383, 3663, 6235, 436, 16173, 883, 506, 2013, 1808, 20364, 10189, 315, 445, 8, 4091, 2340, 14, 2730, 680, 272, 3645, 314, 1423, 445, 8, 1246, 63, 4551, 9, 370, 3504, 314, 3420, 536, 12, 849, 3420, 365, 445, 8, 4091, 2340, 680, 272, 1666, 4178, 921, 5031, 14, 957, 15, 476, 79, 3467, 15, 1259, 367, 1655, 2556, 14, 523, 446, 437, 16212, 22885, 3595, 8002, 2340, 4621, 883, 506, 1911, 641, 1455, 921, 4757, 14, 4853, 14, 957, 15, 4853, 15, 17348, 63, 4091, 2340, 14, 1360, 523, 446, 961, 859, 5171, 1104, 818, 14, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
thiagopio/vendas_healthcheck
vendas/healthcheck/models.py
1
3084
# -*- coding: utf-8 -*- from django.db import models import requests import re class Project(models.Model): name = models.CharField(max_length=50) environment = models.CharField(max_length=10, choices=(('DEV', 'DEV'), ('QA', 'QA'), ('PROD', 'PROD'))) related_project = models.ManyToManyField('Project', blank=True) @staticmethod def in_environment(env): return Project.objects.filter(environment__iexact=env) def __unicode__(self): return u"{0} ({1})".format(self.name, self.environment) def dependents_size(self): return len(self.related_project.all()) def verify(self): working, info = (False, None) for expected_response in self.statusresponse_set.all(): working, info = expected_response.check() if working is False: return working, info return working, info def to_json(self, with_verify=True): working, info = self.verify() if with_verify else (False, requests.codes.NOT_FOUND) return { 'id': self.id, 'name': self.name, 'info': info, 'working': working, 'dependents_ids': [project.id for project in self.related_project.all()] } class StatusResponse(models.Model): OPTIONS = (('STATUS', 'Status'), ('TEXT', 'Text'), ('URL', 'Other Url'), ('REGEX', 'Regex')) project = models.ForeignKey(Project) name = models.CharField(max_length=50) url = models.URLField(max_length=100) response_type = models.CharField(max_length=10, choices=OPTIONS) method = models.CharField(max_length=10, choices=(('GET', 'GET'),)) status = models.PositiveSmallIntegerField(blank=False) content = models.CharField(max_length=200, blank=True) def check(self): working, info = False, None try: if self.method == 'GET': response = requests.get(self.url, timeout=2, verify=False) working, info = self.status_successful(response) else: raise Exception("Method '{}' not implemented".format(self.method)) except Exception: working, info = working, requests.codes.SERVER_ERROR return working, info def status_successful(self, response): status_from_response = response.status_code if status_from_response == self.status: if self.response_type == 'STATUS': return True, status_from_response elif self.response_type == 'TEXT': same_content = self.content == response.text return same_content, response.text elif self.response_type == 'URL': response_extra = requests.get(self.content, timeout=2, verify=False) same_content = response.text == response_extra.text return same_content, response_extra.text elif self.response_type == 'REGEX': return True, '+{}'.format(re.search(self.content, response.text).group(1)) return False, status_from_response
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 697, 492, 1709, 199, 646, 4145, 199, 646, 295, 421, 199, 533, 7290, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 3734, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 3415, 2687, 360, 13260, 297, 283, 13260, 659, 661, 14323, 297, 283, 14323, 659, 661, 2514, 36, 297, 283, 2514, 36, 7058, 272, 4048, 63, 1715, 275, 1709, 14, 7624, 360, 4761, 297, 4596, 29, 549, 9, 339, 768, 4639, 272, 347, 315, 63, 5418, 8, 1813, 304, 267, 372, 7290, 14, 1462, 14, 1541, 8, 5418, 363, 32344, 29, 1813, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 399, 14381, 16, 93, 11459, 17, 25974, 908, 8, 277, 14, 354, 12, 291, 14, 5418, 9, 339, 347, 11410, 83, 63, 890, 8, 277, 304, 267, 372, 822, 8, 277, 14, 2407, 63, 1715, 14, 452, 1012, 339, 347, 4911, 8, 277, 304, 267, 6449, 12, 2256, 275, 334, 797, 12, 488, 9, 267, 367, 1420, 63, 1310, 315, 291, 14, 1205, 1310, 63, 409, 14, 452, 837, 288, 6449, 12, 2256, 275, 1420, 63, 1310, 14, 1074, 342, 288, 340, 6449, 365, 756, 26, 355, 372, 6449, 12, 2256, 267, 372, 6449, 12, 2256, 339, 347, 370, 63, 1001, 8, 277, 12, 543, 63, 4712, 29, 549, 304, 267, 6449, 12, 2256, 275, 291, 14, 4712, 342, 340, 543, 63, 4712, 587, 334, 797, 12, 4145, 14, 6021, 14, 4609, 63, 13945, 9, 267, 372, 469, 288, 283, 344, 356, 291, 14, 344, 12, 288, 283, 354, 356, 291, 14, 354, 12, 288, 283, 815, 356, 2256, 12, 288, 283, 9818, 356, 6449, 12, 288, 283, 32333, 63, 1580, 356, 359, 1715, 14, 344, 367, 2199, 315, 291, 14, 2407, 63, 1715, 14, 452, 5106, 267, 789, 421, 199, 533, 9795, 2364, 8, 992, 14, 1685, 304, 272, 23860, 275, 13636, 6305, 297, 283, 3694, 659, 661, 3876, 297, 283, 1872, 659, 661, 2632, 297, 283, 8632, 20503, 659, 661, 10710, 297, 283, 5103, 1333, 339, 2199, 275, 1709, 14, 3190, 8, 4761, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 1166, 275, 1709, 14, 17363, 8, 988, 63, 1267, 29, 1960, 9, 272, 1177, 63, 466, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 3415, 29, 8808, 9, 272, 1083, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 3415, 2687, 360, 2970, 297, 283, 2970, 659, 430, 272, 2004, 275, 1709, 14, 25197, 8, 2500, 29, 797, 9, 272, 1564, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 4596, 29, 549, 9, 339, 347, 1104, 8, 277, 304, 267, 6449, 12, 2256, 275, 756, 12, 488, 267, 862, 26, 288, 340, 291, 14, 765, 508, 283, 2970, 356, 355, 1177, 275, 4145, 14, 362, 8, 277, 14, 633, 12, 2653, 29, 18, 12, 4911, 29, 797, 9, 355, 6449, 12, 2256, 275, 291, 14, 1205, 63, 18157, 8, 1310, 9, 288, 587, 26, 355, 746, 2186, 480, 3767, 19574, 440, 6366, 1674, 908, 8, 277, 14, 765, 430, 398, 871, 2186, 26, 288, 6449, 12, 2256, 275, 6449, 12, 4145, 14, 6021, 14, 6613, 63, 3170, 267, 372, 6449, 12, 2256, 339, 347, 2004, 63, 18157, 8, 277, 12, 1177, 304, 267, 2004, 63, 504, 63, 1310, 275, 1177, 14, 1205, 63, 600, 267, 340, 2004, 63, 504, 63, 1310, 508, 291, 14, 1205, 26, 288, 340, 291, 14, 1310, 63, 466, 508, 283, 6305, 356, 355, 372, 715, 12, 2004, 63, 504, 63, 1310, 953, 916, 291, 14, 1310, 63, 466, 508, 283, 3876, 356, 355, 2011, 63, 1317, 275, 291, 14, 1317, 508, 1177, 14, 505, 355, 372, 2011, 63, 1317, 12, 1177, 14, 505, 953, 916, 291, 14, 1310, 63, 466, 508, 283, 2632, 356, 355, 1177, 63, 2911, 275, 4145, 14, 362, 8, 277, 14, 1317, 12, 2653, 29, 18, 12, 4911, 29, 797, 9, 355, 2011, 63, 1317, 275, 1177, 14, 505, 508, 1177, 63, 2911, 14, 505, 355, 372, 2011, 63, 1317, 12, 1177, 63, 2911, 14, 505, 953, 916, 291, 14, 1310, 63, 466, 508, 283, 10710, 356, 355, 372, 715, 12, 6681, 11123, 908, 8, 264, 14, 1733, 8, 277, 14, 1317, 12, 1177, 14, 505, 680, 923, 8, 17, 430, 398, 372, 756, 12, 2004, 63, 504, 63, 1310, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 697, 492, 1709, 199, 646, 4145, 199, 646, 295, 421, 199, 533, 7290, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 3734, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 3415, 2687, 360, 13260, 297, 283, 13260, 659, 661, 14323, 297, 283, 14323, 659, 661, 2514, 36, 297, 283, 2514, 36, 7058, 272, 4048, 63, 1715, 275, 1709, 14, 7624, 360, 4761, 297, 4596, 29, 549, 9, 339, 768, 4639, 272, 347, 315, 63, 5418, 8, 1813, 304, 267, 372, 7290, 14, 1462, 14, 1541, 8, 5418, 363, 32344, 29, 1813, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 399, 14381, 16, 93, 11459, 17, 25974, 908, 8, 277, 14, 354, 12, 291, 14, 5418, 9, 339, 347, 11410, 83, 63, 890, 8, 277, 304, 267, 372, 822, 8, 277, 14, 2407, 63, 1715, 14, 452, 1012, 339, 347, 4911, 8, 277, 304, 267, 6449, 12, 2256, 275, 334, 797, 12, 488, 9, 267, 367, 1420, 63, 1310, 315, 291, 14, 1205, 1310, 63, 409, 14, 452, 837, 288, 6449, 12, 2256, 275, 1420, 63, 1310, 14, 1074, 342, 288, 340, 6449, 365, 756, 26, 355, 372, 6449, 12, 2256, 267, 372, 6449, 12, 2256, 339, 347, 370, 63, 1001, 8, 277, 12, 543, 63, 4712, 29, 549, 304, 267, 6449, 12, 2256, 275, 291, 14, 4712, 342, 340, 543, 63, 4712, 587, 334, 797, 12, 4145, 14, 6021, 14, 4609, 63, 13945, 9, 267, 372, 469, 288, 283, 344, 356, 291, 14, 344, 12, 288, 283, 354, 356, 291, 14, 354, 12, 288, 283, 815, 356, 2256, 12, 288, 283, 9818, 356, 6449, 12, 288, 283, 32333, 63, 1580, 356, 359, 1715, 14, 344, 367, 2199, 315, 291, 14, 2407, 63, 1715, 14, 452, 5106, 267, 789, 421, 199, 533, 9795, 2364, 8, 992, 14, 1685, 304, 272, 23860, 275, 13636, 6305, 297, 283, 3694, 659, 661, 3876, 297, 283, 1872, 659, 661, 2632, 297, 283, 8632, 20503, 659, 661, 10710, 297, 283, 5103, 1333, 339, 2199, 275, 1709, 14, 3190, 8, 4761, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 1166, 275, 1709, 14, 17363, 8, 988, 63, 1267, 29, 1960, 9, 272, 1177, 63, 466, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 3415, 29, 8808, 9, 272, 1083, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 3415, 2687, 360, 2970, 297, 283, 2970, 659, 430, 272, 2004, 275, 1709, 14, 25197, 8, 2500, 29, 797, 9, 272, 1564, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 4596, 29, 549, 9, 339, 347, 1104, 8, 277, 304, 267, 6449, 12, 2256, 275, 756, 12, 488, 267, 862, 26, 288, 340, 291, 14, 765, 508, 283, 2970, 356, 355, 1177, 275, 4145, 14, 362, 8, 277, 14, 633, 12, 2653, 29, 18, 12, 4911, 29, 797, 9, 355, 6449, 12, 2256, 275, 291, 14, 1205, 63, 18157, 8, 1310, 9, 288, 587, 26, 355, 746, 2186, 480, 3767, 19574, 440, 6366, 1674, 908, 8, 277, 14, 765, 430, 398, 871, 2186, 26, 288, 6449, 12, 2256, 275, 6449, 12, 4145, 14, 6021, 14, 6613, 63, 3170, 267, 372, 6449, 12, 2256, 339, 347, 2004, 63, 18157, 8, 277, 12, 1177, 304, 267, 2004, 63, 504, 63, 1310, 275, 1177, 14, 1205, 63, 600, 267, 340, 2004, 63, 504, 63, 1310, 508, 291, 14, 1205, 26, 288, 340, 291, 14, 1310, 63, 466, 508, 283, 6305, 356, 355, 372, 715, 12, 2004, 63, 504, 63, 1310, 953, 916, 291, 14, 1310, 63, 466, 508, 283, 3876, 356, 355, 2011, 63, 1317, 275, 291, 14, 1317, 508, 1177, 14, 505, 355, 372, 2011, 63, 1317, 12, 1177, 14, 505, 953, 916, 291, 14, 1310, 63, 466, 508, 283, 2632, 356, 355, 1177, 63, 2911, 275, 4145, 14, 362, 8, 277, 14, 1317, 12, 2653, 29, 18, 12, 4911, 29, 797, 9, 355, 2011, 63, 1317, 275, 1177, 14, 505, 508, 1177, 63, 2911, 14, 505, 355, 372, 2011, 63, 1317, 12, 1177, 63, 2911, 14, 505, 953, 916, 291, 14, 1310, 63, 466, 508, 283, 10710, 356, 355, 372, 715, 12, 6681, 11123, 908, 8, 264, 14, 1733, 8, 277, 14, 1317, 12, 1177, 14, 505, 680, 923, 8, 17, 430, 398, 372, 756, 12, 2004, 63, 504, 63, 1310, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
fufufanatic/pyNES
pynes/tests/guide_test.py
28
5904
# -*- coding: utf-8 -*- import unittest from pynes.compiler import lexical, syntax ''' Those tests are based on examples from: http://nesdev.parodius.com/6502guid.txt ''' class GuideTest(unittest.TestCase): def test_example_16_bit_subtraction_routine(self): ex_2 = ''' SEC ;clear the carry LDA $20 ;get the low byte of the first number SBC $22 ;add to it the low byte of the second STA $24 ;store in the low byte of the result LDA $21 ;get the high byte of the first number SBC $23 ;add to it the high byte of the second, plus carry STA $25 ;store in high byte of the result ''' tokens = list(lexical(ex_2)) self.assertEquals(21, len(tokens)) ast = syntax(tokens) self.assertEquals(7, len(ast)) def test_example_4_2(self): example_4_2 = ''' ; Example 4-2. Deleting an entry from an unordered list ; ; Delete the contents of $2F from a list whose starting ; address is in $30 and $31. The first byte of the list ; is its length. ; deluel: LDY #$00 ; fetch element count LDA ($30),Y TAX ; transfer length to X LDA $2F ; item to delete nextel: INY ; index to next element CMP ($30),Y ; do entry and element match? BEQ delete ; yes. delete element DEX ; no. decrement element count BNE nextel ; any more elements to compare? RTS ; no. element not in list. done ; delete an element by moving the ones below it up one location delete: DEX ; decrement element count BEQ deccnt ; end of list? INY ; no. move next element up LDA ($30),Y DEY STA ($30),Y INY JMP delete deccnt: LDA ($30,X) ; update element count of list SBC #$01 STA ($30,X) RTS ''' tokens = list(lexical(example_4_2)) self.assertEquals(96, len(tokens)) def test_example_5_6(self): """ example_5_6 = ''' ; Example 5-6. 16-bit by 16-bit unsigned multiply ; ; Multiply $22 (low) and $23 (high) by $20 (low) and ; $21 (high) producing a 32-bit result in $24 (low) to $27 (high) ; mlt16: LDA #$00 ; clear p2 and p3 of product STA $26 STA $27 LDX #$16 ; multiplier bit count = 16 nxtbt: LSR $21 ; shift two-byte multiplier right ROR $20 BCC align ; multiplier = 1? LDA $26 ; yes. fetch p2 CLC ADC $22 ; and add m0 to it STA $26 ; store new p2 LDA $27 ; fetch p3 ADC $23 ; and add m1 to it align: ROR A ; rotate four-byte product right STA $27 ; store new p3 ROR $26 ROR $25 ROR $24 DEX ; decrement bit count BNE nxtbt ; loop until 16 bits are done RTS ''' # TODO ROR A? # tokens = list(lexical(example_5_6)) """ def test_example_5_14(self): example_5_14 = ''' ; Example 5-14. Simple 16-bit square root. ; ; Returns the 8-bit square root in $20 of the ; 16-bit number in $20 (low) and $21 (high). The ; remainder is in location $21. sqrt16: LDY #$01 ; lsby of first odd number = 1 STY $22 DEY STY $23 ; msby of first odd number (sqrt = 0) again: SEC LDA $20 ; save remainder in X register TAX ; subtract odd lo from integer lo SBC $22 STA $20 LDA $21 ; subtract odd hi from integer hi SBC $23 STA $21 ; is subtract result negative? BCC nomore ; no. increment square root INY LDA $22 ; calculate next odd number ADC #$01 STA $22 BCC again INC $23 JMP again nomore: STY $20 ; all done, store square root STX $21 ; and remainder RTS ''' tokens = list(lexical(example_5_14)) self.assertEquals(74, len(tokens)) self.assertEquals('T_ENDLINE', tokens[0]['type']) self.assertEquals('T_ENDLINE', tokens[1]['type']) self.assertEquals('T_ENDLINE', tokens[2]['type']) self.assertEquals('T_ENDLINE', tokens[3]['type']) self.assertEquals('T_ENDLINE', tokens[4]['type']) self.assertEquals('T_ENDLINE', tokens[5]['type']) self.assertEquals('T_ENDLINE', tokens[6]['type']) self.assertEquals('T_LABEL', tokens[7]['type']) self.assertEquals('T_INSTRUCTION', tokens[8]['type']) self.assertEquals('T_HEX_NUMBER', tokens[9]['type']) self.assertEquals('T_ENDLINE', tokens[10]['type']) self.assertEquals('T_INSTRUCTION', tokens[11]['type']) self.assertEquals('T_ADDRESS', tokens[12]['type']) self.assertEquals('T_ENDLINE', tokens[13]['type']) self.assertEquals('T_INSTRUCTION', tokens[14]['type']) self.assertEquals('T_ENDLINE', tokens[15]['type']) self.assertEquals('T_INSTRUCTION', tokens[16]['type']) self.assertEquals('T_ADDRESS', tokens[17]['type']) self.assertEquals('T_ENDLINE', tokens[18]['type'])
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2882, 199, 199, 504, 1134, 17775, 14, 5772, 492, 7103, 2652, 12, 6302, 199, 199, 2344, 199, 52, 526, 261, 2295, 787, 4079, 641, 7251, 687, 26, 199, 1014, 921, 17775, 2374, 14, 462, 79, 5231, 14, 957, 15, 2182, 996, 9473, 14, 2424, 199, 2344, 421, 199, 533, 15423, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 2694, 63, 975, 63, 2075, 63, 954, 26137, 63, 17765, 8, 277, 304, 267, 444, 63, 18, 275, 1449, 288, 24143, 260, 8700, 3584, 314, 25176, 288, 491, 8980, 2672, 1165, 258, 8700, 362, 314, 6465, 3696, 402, 314, 1642, 1329, 288, 428, 6265, 2672, 1081, 258, 8700, 525, 370, 652, 314, 6465, 3696, 402, 314, 3499, 288, 4384, 33, 2672, 1194, 258, 8700, 1617, 315, 314, 6465, 3696, 402, 314, 754, 288, 491, 8980, 2672, 2025, 258, 8700, 362, 314, 4721, 3696, 402, 314, 1642, 1329, 288, 428, 6265, 2672, 1789, 258, 8700, 525, 370, 652, 314, 4721, 3696, 402, 314, 3499, 12, 12254, 25176, 288, 4384, 33, 2672, 821, 258, 8700, 1617, 315, 4721, 3696, 402, 314, 754, 288, 1449, 267, 4645, 275, 769, 8, 3113, 2652, 8, 476, 63, 18, 430, 267, 291, 14, 2947, 8, 2025, 12, 822, 8, 4504, 430, 267, 6073, 275, 6302, 8, 4504, 9, 267, 291, 14, 2947, 8, 23, 12, 822, 8, 1810, 430, 339, 347, 511, 63, 2694, 63, 20, 63, 18, 8, 277, 304, 267, 2893, 63, 20, 63, 18, 275, 1449, 267, 8700, 5679, 841, 13, 18, 14, 221, 15920, 376, 2397, 687, 376, 31716, 769, 267, 8700, 267, 8700, 8496, 314, 4072, 402, 2672, 18, 38, 687, 282, 769, 7447, 6617, 267, 8700, 2287, 365, 315, 2672, 1216, 436, 2672, 2192, 14, 221, 710, 1642, 3696, 402, 314, 769, 267, 8700, 365, 2399, 2582, 14, 267, 8700, 398, 2150, 13086, 26, 491, 11446, 327, 4, 383, 258, 8700, 5267, 1819, 2338, 355, 491, 8980, 334, 4, 1216, 395, 57, 355, 377, 9839, 3515, 8700, 9307, 2582, 370, 1323, 355, 491, 8980, 2672, 18, 38, 420, 8700, 1242, 370, 3145, 267, 22761, 14146, 26, 1621, 57, 3515, 8700, 1478, 370, 2163, 1819, 355, 445, 1658, 334, 4, 1216, 395, 57, 221, 8700, 886, 2397, 436, 1819, 1336, 31, 355, 6262, 49, 3145, 257, 8700, 9456, 14, 3145, 1819, 355, 577, 1438, 3515, 8700, 949, 14, 477, 4062, 1819, 2338, 355, 699, 6388, 22761, 14146, 257, 8700, 1263, 1655, 4008, 370, 6540, 31, 355, 820, 9730, 3515, 8700, 949, 14, 1819, 440, 315, 769, 14, 4224, 398, 8700, 3145, 376, 1819, 701, 12876, 314, 7869, 5084, 652, 1536, 1373, 2909, 398, 3145, 26, 577, 1438, 3515, 8700, 477, 4062, 1819, 2338, 355, 6262, 49, 477, 2055, 343, 257, 8700, 1284, 402, 769, 31, 355, 1621, 57, 3515, 8700, 949, 14, 4057, 2163, 1819, 1536, 355, 491, 8980, 334, 4, 1216, 395, 57, 355, 3265, 57, 355, 4384, 33, 334, 4, 1216, 395, 57, 355, 1621, 57, 355, 1603, 1658, 3145, 267, 477, 2055, 343, 26, 491, 8980, 334, 4, 1216, 12, 56, 9, 221, 8700, 1678, 1819, 2338, 402, 769, 355, 428, 6265, 327, 4, 614, 355, 4384, 33, 334, 4, 1216, 12, 56, 9, 355, 820, 9730, 267, 1449, 267, 4645, 275, 769, 8, 3113, 2652, 8, 2694, 63, 20, 63, 18, 430, 267, 291, 14, 2947, 8, 2534, 12, 822, 8, 4504, 430, 339, 347, 511, 63, 2694, 63, 21, 63, 22, 8, 277, 304, 267, 408, 267, 2893, 63, 21, 63, 22, 275, 1449, 267, 8700, 5679, 959, 13, 22, 14, 221, 3193, 13, 2075, 701, 3193, 13, 2075, 7381, 21699, 267, 8700, 267, 8700, 603, 2092, 590, 2672, 1081, 334, 674, 9, 436, 2672, 1789, 334, 6260, 9, 701, 2672, 1165, 334, 674, 9, 436, 267, 8700, 2672, 2025, 334, 6260, 9, 27955, 282, 4337, 13, 2075, 754, 315, 2672, 1194, 334, 674, 9, 370, 2672, 1465, 334, 6260, 9, 267, 8700, 398, 333, 4116, 975, 26, 221, 491, 8980, 327, 4, 383, 258, 8700, 5436, 299, 18, 436, 299, 19, 402, 3336, 355, 4384, 33, 2672, 1479, 355, 4384, 33, 2672, 1465, 355, 16978, 56, 327, 4, 975, 258, 8700, 22215, 4546, 2338, 275, 3193, 267, 302, 400, 13061, 26, 221, 491, 5943, 2672, 2025, 420, 8700, 7706, 2877, 13, 4414, 22215, 2451, 355, 820, 726, 2672, 1165, 355, 699, 2571, 6998, 259, 8700, 22215, 275, 413, 31, 355, 491, 8980, 2672, 1479, 420, 8700, 9456, 14, 5267, 299, 18, 355, 21458, 355, 437, 5196, 2672, 1081, 420, 8700, 436, 1050, 333, 16, 370, 652, 355, 4384, 33, 2672, 1479, 420, 8700, 3877, 892, 299, 18, 355, 491, 8980, 2672, 1465, 420, 8700, 5267, 299, 19, 355, 437, 5196, 2672, 1789, 420, 8700, 436, 1050, 333, 17, 370, 652, 267, 6998, 26, 221, 820, 726, 437, 263, 8700, 20071, 11648, 13, 4414, 3336, 2451, 355, 4384, 33, 2672, 1465, 420, 8700, 3877, 892, 299, 19, 355, 820, 726, 2672, 1479, 355, 820, 726, 2672, 821, 355, 820, 726, 2672, 1194, 355, 577, 1438, 3515, 8700, 477, 4062, 4546, 2338, 355, 699, 6388, 302, 400, 13061, 259, 8700, 4438, 5133, 3193, 5821, 787, 4224, 355, 820, 9730, 267, 1449, 267, 327, 3254, 820, 726, 437, 31, 267, 327, 4645, 275, 769, 8, 3113, 2652, 8, 2694, 63, 21, 63, 22, 430, 267, 408, 339, 347, 511, 63, 2694, 63, 21, 63, 1079, 8, 277, 304, 267, 2893, 63, 21, 63, 1079, 275, 1449, 267, 8700, 5679, 959, 13, 1079, 14, 221, 5870, 3193, 13, 2075, 12386, 1738, 14, 267, 8700, 267, 8700, 1803, 314, 1695, 13, 2075, 12386, 1738, 315, 2672, 1165, 402, 314, 267, 8700, 3193, 13, 2075, 1329, 315, 2672, 1165, 334, 674, 9, 436, 2672, 2025, 334, 6260, 680, 710, 267, 8700, 15748, 365, 315, 2909, 2672, 2025, 14, 398, 7452, 975, 26, 491, 11446, 327, 4, 614, 258, 8700, 9100, 991, 402, 1642, 16699, 1329, 275, 413, 355, 428, 2099, 2672, 1081, 355, 3265, 57, 355, 428, 2099, 2672, 1789, 420, 8700, 6605, 991, 402, 1642, 16699, 1329, 334, 5079, 275, 378, 9, 267, 4020, 26, 221, 24143, 355, 491, 8980, 2672, 1165, 420, 8700 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2882, 199, 199, 504, 1134, 17775, 14, 5772, 492, 7103, 2652, 12, 6302, 199, 199, 2344, 199, 52, 526, 261, 2295, 787, 4079, 641, 7251, 687, 26, 199, 1014, 921, 17775, 2374, 14, 462, 79, 5231, 14, 957, 15, 2182, 996, 9473, 14, 2424, 199, 2344, 421, 199, 533, 15423, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 2694, 63, 975, 63, 2075, 63, 954, 26137, 63, 17765, 8, 277, 304, 267, 444, 63, 18, 275, 1449, 288, 24143, 260, 8700, 3584, 314, 25176, 288, 491, 8980, 2672, 1165, 258, 8700, 362, 314, 6465, 3696, 402, 314, 1642, 1329, 288, 428, 6265, 2672, 1081, 258, 8700, 525, 370, 652, 314, 6465, 3696, 402, 314, 3499, 288, 4384, 33, 2672, 1194, 258, 8700, 1617, 315, 314, 6465, 3696, 402, 314, 754, 288, 491, 8980, 2672, 2025, 258, 8700, 362, 314, 4721, 3696, 402, 314, 1642, 1329, 288, 428, 6265, 2672, 1789, 258, 8700, 525, 370, 652, 314, 4721, 3696, 402, 314, 3499, 12, 12254, 25176, 288, 4384, 33, 2672, 821, 258, 8700, 1617, 315, 4721, 3696, 402, 314, 754, 288, 1449, 267, 4645, 275, 769, 8, 3113, 2652, 8, 476, 63, 18, 430, 267, 291, 14, 2947, 8, 2025, 12, 822, 8, 4504, 430, 267, 6073, 275, 6302, 8, 4504, 9, 267, 291, 14, 2947, 8, 23, 12, 822, 8, 1810, 430, 339, 347, 511, 63, 2694, 63, 20, 63, 18, 8, 277, 304, 267, 2893, 63, 20, 63, 18, 275, 1449, 267, 8700, 5679, 841, 13, 18, 14, 221, 15920, 376, 2397, 687, 376, 31716, 769, 267, 8700, 267, 8700, 8496, 314, 4072, 402, 2672, 18, 38, 687, 282, 769, 7447, 6617, 267, 8700, 2287, 365, 315, 2672, 1216, 436, 2672, 2192, 14, 221, 710, 1642, 3696, 402, 314, 769, 267, 8700, 365, 2399, 2582, 14, 267, 8700, 398, 2150, 13086, 26, 491, 11446, 327, 4, 383, 258, 8700, 5267, 1819, 2338, 355, 491, 8980, 334, 4, 1216, 395, 57, 355, 377, 9839, 3515, 8700, 9307, 2582, 370, 1323, 355, 491, 8980, 2672, 18, 38, 420, 8700, 1242, 370, 3145, 267, 22761, 14146, 26, 1621, 57, 3515, 8700, 1478, 370, 2163, 1819, 355, 445, 1658, 334, 4, 1216, 395, 57, 221, 8700, 886, 2397, 436, 1819, 1336, 31, 355, 6262, 49, 3145, 257, 8700, 9456, 14, 3145, 1819, 355, 577, 1438, 3515, 8700, 949, 14, 477, 4062, 1819, 2338, 355, 699, 6388, 22761, 14146, 257, 8700, 1263, 1655, 4008, 370, 6540, 31, 355, 820, 9730, 3515, 8700, 949, 14, 1819, 440, 315, 769, 14, 4224, 398, 8700, 3145, 376, 1819, 701, 12876, 314, 7869, 5084, 652, 1536, 1373, 2909, 398, 3145, 26, 577, 1438, 3515, 8700, 477, 4062, 1819, 2338, 355, 6262, 49, 477, 2055, 343, 257, 8700, 1284, 402, 769, 31, 355, 1621, 57, 3515, 8700, 949, 14, 4057, 2163, 1819, 1536, 355, 491, 8980, 334, 4, 1216, 395, 57, 355, 3265, 57, 355, 4384, 33, 334, 4, 1216, 395, 57, 355, 1621, 57, 355, 1603, 1658, 3145, 267, 477, 2055, 343, 26, 491, 8980, 334, 4, 1216, 12, 56, 9, 221, 8700, 1678, 1819, 2338, 402, 769, 355, 428, 6265, 327, 4, 614, 355, 4384, 33, 334, 4, 1216, 12, 56, 9, 355, 820, 9730, 267, 1449, 267, 4645, 275, 769, 8, 3113, 2652, 8, 2694, 63, 20, 63, 18, 430, 267, 291, 14, 2947, 8, 2534, 12, 822, 8, 4504, 430, 339, 347, 511, 63, 2694, 63, 21, 63, 22, 8, 277, 304, 267, 408, 267, 2893, 63, 21, 63, 22, 275, 1449, 267, 8700, 5679, 959, 13, 22, 14, 221, 3193, 13, 2075, 701, 3193, 13, 2075, 7381, 21699, 267, 8700, 267, 8700, 603, 2092, 590, 2672, 1081, 334, 674, 9, 436, 2672, 1789, 334, 6260, 9, 701, 2672, 1165, 334, 674, 9, 436, 267, 8700, 2672, 2025, 334, 6260, 9, 27955, 282, 4337, 13, 2075, 754, 315, 2672, 1194, 334, 674, 9, 370, 2672, 1465, 334, 6260, 9, 267, 8700, 398, 333, 4116, 975, 26, 221, 491, 8980, 327, 4, 383, 258, 8700, 5436, 299, 18, 436, 299, 19, 402, 3336, 355, 4384, 33, 2672, 1479, 355, 4384, 33, 2672, 1465, 355, 16978, 56, 327, 4, 975, 258, 8700, 22215, 4546, 2338, 275, 3193, 267, 302, 400, 13061, 26, 221, 491, 5943, 2672, 2025, 420, 8700, 7706, 2877, 13, 4414, 22215, 2451, 355, 820, 726, 2672, 1165, 355, 699, 2571, 6998, 259, 8700, 22215, 275, 413, 31, 355, 491, 8980, 2672, 1479, 420, 8700, 9456, 14, 5267, 299, 18, 355, 21458, 355, 437, 5196, 2672, 1081, 420, 8700, 436, 1050, 333, 16, 370, 652, 355, 4384, 33, 2672, 1479, 420, 8700, 3877, 892, 299, 18, 355, 491, 8980, 2672, 1465, 420, 8700, 5267, 299, 19, 355, 437, 5196, 2672, 1789, 420, 8700, 436, 1050, 333, 17, 370, 652, 267, 6998, 26, 221, 820, 726, 437, 263, 8700, 20071, 11648, 13, 4414, 3336, 2451, 355, 4384, 33, 2672, 1465, 420, 8700, 3877, 892, 299, 19, 355, 820, 726, 2672, 1479, 355, 820, 726, 2672, 821, 355, 820, 726, 2672, 1194, 355, 577, 1438, 3515, 8700, 477, 4062, 4546, 2338, 355, 699, 6388, 302, 400, 13061, 259, 8700, 4438, 5133, 3193, 5821, 787, 4224, 355, 820, 9730, 267, 1449, 267, 327, 3254, 820, 726, 437, 31, 267, 327, 4645, 275, 769, 8, 3113, 2652, 8, 2694, 63, 21, 63, 22, 430, 267, 408, 339, 347, 511, 63, 2694, 63, 21, 63, 1079, 8, 277, 304, 267, 2893, 63, 21, 63, 1079, 275, 1449, 267, 8700, 5679, 959, 13, 1079, 14, 221, 5870, 3193, 13, 2075, 12386, 1738, 14, 267, 8700, 267, 8700, 1803, 314, 1695, 13, 2075, 12386, 1738, 315, 2672, 1165, 402, 314, 267, 8700, 3193, 13, 2075, 1329, 315, 2672, 1165, 334, 674, 9, 436, 2672, 2025, 334, 6260, 680, 710, 267, 8700, 15748, 365, 315, 2909, 2672, 2025, 14, 398, 7452, 975, 26, 491, 11446, 327, 4, 614, 258, 8700, 9100, 991, 402, 1642, 16699, 1329, 275, 413, 355, 428, 2099, 2672, 1081, 355, 3265, 57, 355, 428, 2099, 2672, 1789, 420, 8700, 6605, 991, 402, 1642, 16699, 1329, 334, 5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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
maxlikely/scikit-learn
sklearn/ensemble/tests/test_partial_dependence.py
44
7031
""" Testing for the partial dependence module. """ import numpy as np from numpy.testing import assert_array_equal from sklearn.utils.testing import assert_raises from sklearn.utils.testing import if_matplotlib from sklearn.ensemble.partial_dependence import partial_dependence from sklearn.ensemble.partial_dependence import plot_partial_dependence from sklearn.ensemble import GradientBoostingClassifier from sklearn.ensemble import GradientBoostingRegressor from sklearn import datasets # toy sample X = [[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]] y = [-1, -1, -1, 1, 1, 1] T = [[-1, -1], [2, 2], [3, 2]] true_result = [-1, 1, 1] # also load the boston dataset boston = datasets.load_boston() # also load the iris dataset iris = datasets.load_iris() def test_partial_dependence_classifier(): """Test partial dependence for classifier """ clf = GradientBoostingClassifier(n_estimators=10, random_state=1) clf.fit(X, y) pdp, axes = partial_dependence(clf, [0], X=X, grid_resolution=5) # only 4 grid points instead of 5 because only 4 unique X[:,0] vals assert pdp.shape == (1, 4) assert axes[0].shape[0] == 4 # now with our own grid X_ = np.asarray(X) grid = np.unique(X_[:, 0]) pdp_2, axes = partial_dependence(clf, [0], grid=grid) assert axes is None assert_array_equal(pdp, pdp_2) def test_partial_dependence_multiclass(): """Test partial dependence for multi-class classifier """ clf = GradientBoostingClassifier(n_estimators=10, random_state=1) clf.fit(iris.data, iris.target) grid_resolution = 25 n_classes = clf.n_classes_ pdp, axes = partial_dependence( clf, [0], X=iris.data, grid_resolution=grid_resolution) assert pdp.shape == (n_classes, grid_resolution) assert len(axes) == 1 assert axes[0].shape[0] == grid_resolution def test_partial_dependence_regressor(): """Test partial dependence for regressor """ clf = GradientBoostingRegressor(n_estimators=10, random_state=1) clf.fit(boston.data, boston.target) grid_resolution = 25 pdp, axes = partial_dependence( clf, [0], X=boston.data, grid_resolution=grid_resolution) assert pdp.shape == (1, grid_resolution) assert axes[0].shape[0] == grid_resolution def test_partial_dependecy_input(): """Test input validation of partial dependence. """ clf = GradientBoostingClassifier(n_estimators=10, random_state=1) clf.fit(X, y) assert_raises(ValueError, partial_dependence, clf, [0], grid=None, X=None) assert_raises(ValueError, partial_dependence, clf, [0], grid=[0, 1], X=X) # first argument must be an instance of BaseGradientBoosting assert_raises(ValueError, partial_dependence, {}, [0], X=X) # Gradient boosting estimator must be fit assert_raises(ValueError, partial_dependence, GradientBoostingClassifier(), [0], X=X) assert_raises(ValueError, partial_dependence, clf, [-1], X=X) assert_raises(ValueError, partial_dependence, clf, [100], X=X) # wrong ndim for grid grid = np.random.rand(10, 2, 1) assert_raises(ValueError, partial_dependence, clf, [0], grid=grid) @if_matplotlib def test_plot_partial_dependence(): """Test partial dependence plot function. """ clf = GradientBoostingRegressor(n_estimators=10, random_state=1) clf.fit(boston.data, boston.target) grid_resolution = 25 fig, axs = plot_partial_dependence(clf, boston.data, [0, 1, (0, 1)], grid_resolution=grid_resolution, feature_names=boston.feature_names) assert len(axs) == 3 assert all(ax.has_data for ax in axs) # check with str features and array feature names fig, axs = plot_partial_dependence(clf, boston.data, ['CRIM', 'ZN', ('CRIM', 'ZN')], grid_resolution=grid_resolution, feature_names=boston.feature_names) assert len(axs) == 3 assert all(ax.has_data for ax in axs) # check with list feature_names feature_names = boston.feature_names.tolist() fig, axs = plot_partial_dependence(clf, boston.data, ['CRIM', 'ZN', ('CRIM', 'ZN')], grid_resolution=grid_resolution, feature_names=feature_names) assert len(axs) == 3 assert all(ax.has_data for ax in axs) @if_matplotlib def test_plot_partial_dependence_input(): """Test partial dependence plot function input checks. """ clf = GradientBoostingClassifier(n_estimators=10, random_state=1) # not fitted yet assert_raises(ValueError, plot_partial_dependence, clf, X, [0]) clf.fit(X, y) assert_raises(ValueError, plot_partial_dependence, clf, np.array(X)[:, :0], [0]) # first argument must be an instance of BaseGradientBoosting assert_raises(ValueError, plot_partial_dependence, {}, X, [0]) # must be larger than -1 assert_raises(ValueError, plot_partial_dependence, clf, X, [-1]) # too large feature value assert_raises(ValueError, plot_partial_dependence, clf, X, [100]) # str feature but no feature_names assert_raises(ValueError, plot_partial_dependence, clf, X, ['foobar']) # not valid features value assert_raises(ValueError, plot_partial_dependence, clf, X, [{'foo': 'bar'}]) @if_matplotlib def test_plot_partial_dependence_multiclass(): """Test partial dependence plot function on multi-class input. """ clf = GradientBoostingClassifier(n_estimators=10, random_state=1) clf.fit(iris.data, iris.target) grid_resolution = 25 fig, axs = plot_partial_dependence(clf, iris.data, [0, 1], label=0, grid_resolution=grid_resolution) assert len(axs) == 2 assert all(ax.has_data for ax in axs) # now with symbol labels target = iris.target_names[iris.target] clf = GradientBoostingClassifier(n_estimators=10, random_state=1) clf.fit(iris.data, target) grid_resolution = 25 fig, axs = plot_partial_dependence(clf, iris.data, [0, 1], label='setosa', grid_resolution=grid_resolution) assert len(axs) == 2 assert all(ax.has_data for ax in axs) # label not in gbrt.classes_ assert_raises(ValueError, plot_partial_dependence, clf, iris.data, [0, 1], label='foobar', grid_resolution=grid_resolution) # label not provided assert_raises(ValueError, plot_partial_dependence, clf, iris.data, [0, 1], grid_resolution=grid_resolution)
bsd-3-clause
[ 624, 199, 9029, 367, 314, 7417, 477, 29578, 859, 14, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 340, 63, 16440, 199, 504, 6357, 14, 15628, 14, 6672, 63, 271, 29578, 492, 7417, 63, 271, 29578, 199, 504, 6357, 14, 15628, 14, 6672, 63, 271, 29578, 492, 5137, 63, 6672, 63, 271, 29578, 199, 504, 6357, 14, 15628, 492, 19603, 27175, 8508, 199, 504, 6357, 14, 15628, 492, 19603, 27175, 15155, 199, 504, 6357, 492, 13148, 421, 199, 3, 31239, 2690, 199, 56, 275, 27291, 18, 12, 446, 17, 467, 5243, 17, 12, 446, 17, 467, 5243, 17, 12, 446, 18, 467, 359, 17, 12, 413, 467, 359, 17, 12, 499, 467, 359, 18, 12, 413, 2677, 199, 89, 275, 5243, 17, 12, 446, 17, 12, 446, 17, 12, 413, 12, 413, 12, 413, 61, 199, 52, 275, 27291, 17, 12, 446, 17, 467, 359, 18, 12, 499, 467, 359, 19, 12, 499, 2677, 199, 2052, 63, 1099, 275, 5243, 17, 12, 413, 12, 413, 61, 199, 199, 3, 2597, 2248, 314, 330, 7797, 4789, 199, 28275, 275, 13148, 14, 912, 63, 28275, 342, 199, 199, 3, 2597, 2248, 314, 12192, 4789, 199, 11885, 275, 13148, 14, 912, 63, 11885, 342, 421, 199, 318, 511, 63, 6672, 63, 271, 29578, 63, 14720, 837, 272, 408, 774, 7417, 477, 29578, 367, 12429, 408, 272, 6975, 275, 19603, 27175, 8508, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 56, 12, 612, 9, 339, 299, 5780, 12, 7824, 275, 7417, 63, 271, 29578, 8, 9694, 12, 359, 16, 467, 1323, 29, 56, 12, 6068, 63, 12588, 29, 21, 9, 339, 327, 1454, 841, 6068, 4501, 3140, 402, 959, 2952, 1454, 841, 3747, 1323, 3981, 16, 61, 5322, 272, 702, 299, 5780, 14, 1392, 508, 334, 17, 12, 841, 9, 272, 702, 7824, 59, 16, 1055, 1392, 59, 16, 61, 508, 841, 339, 327, 3063, 543, 4154, 5705, 6068, 272, 1323, 63, 275, 980, 14, 8748, 8, 56, 9, 272, 6068, 275, 980, 14, 3235, 8, 56, 63, 3981, 378, 566, 272, 299, 5780, 63, 18, 12, 7824, 275, 7417, 63, 271, 29578, 8, 9694, 12, 359, 16, 467, 6068, 29, 3825, 9, 339, 702, 7824, 365, 488, 272, 702, 63, 1144, 63, 1452, 8, 80, 5780, 12, 299, 5780, 63, 18, 9, 421, 199, 318, 511, 63, 6672, 63, 271, 29578, 63, 30016, 837, 272, 408, 774, 7417, 477, 29578, 367, 3510, 13, 533, 12429, 408, 272, 6975, 275, 19603, 27175, 8508, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 11885, 14, 576, 12, 12192, 14, 1375, 9, 339, 6068, 63, 12588, 275, 5661, 272, 302, 63, 2888, 275, 6975, 14, 78, 63, 2888, 63, 272, 299, 5780, 12, 7824, 275, 7417, 63, 271, 29578, 8, 267, 6975, 12, 359, 16, 467, 1323, 29, 11885, 14, 576, 12, 6068, 63, 12588, 29, 3825, 63, 12588, 9, 339, 702, 299, 5780, 14, 1392, 508, 334, 78, 63, 2888, 12, 6068, 63, 12588, 9, 272, 702, 822, 8, 6402, 9, 508, 413, 272, 702, 7824, 59, 16, 1055, 1392, 59, 16, 61, 508, 6068, 63, 12588, 421, 199, 318, 511, 63, 6672, 63, 271, 29578, 63, 1135, 11686, 837, 272, 408, 774, 7417, 477, 29578, 367, 1295, 11686, 408, 272, 6975, 275, 19603, 27175, 15155, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 28275, 14, 576, 12, 330, 7797, 14, 1375, 9, 339, 6068, 63, 12588, 275, 5661, 272, 299, 5780, 12, 7824, 275, 7417, 63, 271, 29578, 8, 267, 6975, 12, 359, 16, 467, 1323, 29, 28275, 14, 576, 12, 6068, 63, 12588, 29, 3825, 63, 12588, 9, 339, 702, 299, 5780, 14, 1392, 508, 334, 17, 12, 6068, 63, 12588, 9, 272, 702, 7824, 59, 16, 1055, 1392, 59, 16, 61, 508, 6068, 63, 12588, 421, 199, 318, 511, 63, 6672, 63, 271, 897, 271, 1480, 63, 1210, 837, 272, 408, 774, 1324, 6411, 402, 7417, 477, 29578, 14, 408, 272, 6975, 275, 19603, 27175, 8508, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 56, 12, 612, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 6975, 12, 359, 16, 467, 6068, 29, 403, 12, 1323, 29, 403, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 6975, 12, 359, 16, 467, 6068, 1524, 16, 12, 413, 467, 1323, 29, 56, 9, 339, 327, 1642, 1423, 1471, 506, 376, 1256, 402, 3523, 9942, 27175, 272, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 5479, 359, 16, 467, 1323, 29, 56, 9, 339, 327, 19603, 20198, 316, 8943, 1471, 506, 5542, 272, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 19603, 27175, 8508, 1062, 359, 16, 467, 1323, 29, 56, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 6975, 12, 5243, 17, 467, 1323, 29, 56, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 6975, 12, 359, 1960, 467, 1323, 29, 56, 9, 339, 327, 6835, 17951, 367, 6068, 272, 6068, 275, 980, 14, 2355, 14, 3759, 8, 709, 12, 499, 12, 413, 9, 272, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 6975, 12, 359, 16, 467, 6068, 29, 3825, 9, 421, 199, 32, 692, 63, 16440, 199, 318, 511, 63, 2798, 63, 6672, 63, 271, 29578, 837, 272, 408, 774, 7417, 477, 29578, 5137, 805, 14, 408, 272, 6975, 275, 19603, 27175, 15155, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 28275, 14, 576, 12, 330, 7797, 14, 1375, 9, 339, 6068, 63, 12588, 275, 5661, 272, 6085, 12, 2185, 83, 275, 5137, 63, 6672, 63, 271, 29578, 8, 9694, 12, 330, 7797, 14 ]
[ 199, 9029, 367, 314, 7417, 477, 29578, 859, 14, 199, 624, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 340, 63, 16440, 199, 504, 6357, 14, 15628, 14, 6672, 63, 271, 29578, 492, 7417, 63, 271, 29578, 199, 504, 6357, 14, 15628, 14, 6672, 63, 271, 29578, 492, 5137, 63, 6672, 63, 271, 29578, 199, 504, 6357, 14, 15628, 492, 19603, 27175, 8508, 199, 504, 6357, 14, 15628, 492, 19603, 27175, 15155, 199, 504, 6357, 492, 13148, 421, 199, 3, 31239, 2690, 199, 56, 275, 27291, 18, 12, 446, 17, 467, 5243, 17, 12, 446, 17, 467, 5243, 17, 12, 446, 18, 467, 359, 17, 12, 413, 467, 359, 17, 12, 499, 467, 359, 18, 12, 413, 2677, 199, 89, 275, 5243, 17, 12, 446, 17, 12, 446, 17, 12, 413, 12, 413, 12, 413, 61, 199, 52, 275, 27291, 17, 12, 446, 17, 467, 359, 18, 12, 499, 467, 359, 19, 12, 499, 2677, 199, 2052, 63, 1099, 275, 5243, 17, 12, 413, 12, 413, 61, 199, 199, 3, 2597, 2248, 314, 330, 7797, 4789, 199, 28275, 275, 13148, 14, 912, 63, 28275, 342, 199, 199, 3, 2597, 2248, 314, 12192, 4789, 199, 11885, 275, 13148, 14, 912, 63, 11885, 342, 421, 199, 318, 511, 63, 6672, 63, 271, 29578, 63, 14720, 837, 272, 408, 774, 7417, 477, 29578, 367, 12429, 408, 272, 6975, 275, 19603, 27175, 8508, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 56, 12, 612, 9, 339, 299, 5780, 12, 7824, 275, 7417, 63, 271, 29578, 8, 9694, 12, 359, 16, 467, 1323, 29, 56, 12, 6068, 63, 12588, 29, 21, 9, 339, 327, 1454, 841, 6068, 4501, 3140, 402, 959, 2952, 1454, 841, 3747, 1323, 3981, 16, 61, 5322, 272, 702, 299, 5780, 14, 1392, 508, 334, 17, 12, 841, 9, 272, 702, 7824, 59, 16, 1055, 1392, 59, 16, 61, 508, 841, 339, 327, 3063, 543, 4154, 5705, 6068, 272, 1323, 63, 275, 980, 14, 8748, 8, 56, 9, 272, 6068, 275, 980, 14, 3235, 8, 56, 63, 3981, 378, 566, 272, 299, 5780, 63, 18, 12, 7824, 275, 7417, 63, 271, 29578, 8, 9694, 12, 359, 16, 467, 6068, 29, 3825, 9, 339, 702, 7824, 365, 488, 272, 702, 63, 1144, 63, 1452, 8, 80, 5780, 12, 299, 5780, 63, 18, 9, 421, 199, 318, 511, 63, 6672, 63, 271, 29578, 63, 30016, 837, 272, 408, 774, 7417, 477, 29578, 367, 3510, 13, 533, 12429, 408, 272, 6975, 275, 19603, 27175, 8508, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 11885, 14, 576, 12, 12192, 14, 1375, 9, 339, 6068, 63, 12588, 275, 5661, 272, 302, 63, 2888, 275, 6975, 14, 78, 63, 2888, 63, 272, 299, 5780, 12, 7824, 275, 7417, 63, 271, 29578, 8, 267, 6975, 12, 359, 16, 467, 1323, 29, 11885, 14, 576, 12, 6068, 63, 12588, 29, 3825, 63, 12588, 9, 339, 702, 299, 5780, 14, 1392, 508, 334, 78, 63, 2888, 12, 6068, 63, 12588, 9, 272, 702, 822, 8, 6402, 9, 508, 413, 272, 702, 7824, 59, 16, 1055, 1392, 59, 16, 61, 508, 6068, 63, 12588, 421, 199, 318, 511, 63, 6672, 63, 271, 29578, 63, 1135, 11686, 837, 272, 408, 774, 7417, 477, 29578, 367, 1295, 11686, 408, 272, 6975, 275, 19603, 27175, 15155, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 28275, 14, 576, 12, 330, 7797, 14, 1375, 9, 339, 6068, 63, 12588, 275, 5661, 272, 299, 5780, 12, 7824, 275, 7417, 63, 271, 29578, 8, 267, 6975, 12, 359, 16, 467, 1323, 29, 28275, 14, 576, 12, 6068, 63, 12588, 29, 3825, 63, 12588, 9, 339, 702, 299, 5780, 14, 1392, 508, 334, 17, 12, 6068, 63, 12588, 9, 272, 702, 7824, 59, 16, 1055, 1392, 59, 16, 61, 508, 6068, 63, 12588, 421, 199, 318, 511, 63, 6672, 63, 271, 897, 271, 1480, 63, 1210, 837, 272, 408, 774, 1324, 6411, 402, 7417, 477, 29578, 14, 408, 272, 6975, 275, 19603, 27175, 8508, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 56, 12, 612, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 6975, 12, 359, 16, 467, 6068, 29, 403, 12, 1323, 29, 403, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 6975, 12, 359, 16, 467, 6068, 1524, 16, 12, 413, 467, 1323, 29, 56, 9, 339, 327, 1642, 1423, 1471, 506, 376, 1256, 402, 3523, 9942, 27175, 272, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 5479, 359, 16, 467, 1323, 29, 56, 9, 339, 327, 19603, 20198, 316, 8943, 1471, 506, 5542, 272, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 2116, 19603, 27175, 8508, 1062, 359, 16, 467, 1323, 29, 56, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 6975, 12, 5243, 17, 467, 1323, 29, 56, 9, 339, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 6975, 12, 359, 1960, 467, 1323, 29, 56, 9, 339, 327, 6835, 17951, 367, 6068, 272, 6068, 275, 980, 14, 2355, 14, 3759, 8, 709, 12, 499, 12, 413, 9, 272, 702, 63, 3536, 8, 3393, 12, 7417, 63, 271, 29578, 12, 6975, 12, 359, 16, 467, 6068, 29, 3825, 9, 421, 199, 32, 692, 63, 16440, 199, 318, 511, 63, 2798, 63, 6672, 63, 271, 29578, 837, 272, 408, 774, 7417, 477, 29578, 5137, 805, 14, 408, 272, 6975, 275, 19603, 27175, 15155, 8, 78, 63, 10646, 29, 709, 12, 2196, 63, 929, 29, 17, 9, 272, 6975, 14, 3269, 8, 28275, 14, 576, 12, 330, 7797, 14, 1375, 9, 339, 6068, 63, 12588, 275, 5661, 272, 6085, 12, 2185, 83, 275, 5137, 63, 6672, 63, 271, 29578, 8, 9694, 12, 330, 7797, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hrjn/scikit-learn
examples/feature_selection/plot_f_test_vs_mi.py
75
1647
""" =========================================== Comparison of F-test and mutual information =========================================== This example illustrates the differences between univariate F-test statistics and mutual information. We consider 3 features x_1, x_2, x_3 distributed uniformly over [0, 1], the target depends on them as follows: y = x_1 + sin(6 * pi * x_2) + 0.1 * N(0, 1), that is the third features is completely irrelevant. The code below plots the dependency of y against individual x_i and normalized values of univariate F-tests statistics and mutual information. As F-test captures only linear dependency, it rates x_1 as the most discriminative feature. On the other hand, mutual information can capture any kind of dependency between variables and it rates x_2 as the most discriminative feature, which probably agrees better with our intuitive perception for this example. Both methods correctly marks x_3 as irrelevant. """ print(__doc__) import numpy as np import matplotlib.pyplot as plt from sklearn.feature_selection import f_regression, mutual_info_regression np.random.seed(0) X = np.random.rand(1000, 3) y = X[:, 0] + np.sin(6 * np.pi * X[:, 1]) + 0.1 * np.random.randn(1000) f_test, _ = f_regression(X, y) f_test /= np.max(f_test) mi = mutual_info_regression(X, y) mi /= np.max(mi) plt.figure(figsize=(15, 5)) for i in range(3): plt.subplot(1, 3, i + 1) plt.scatter(X[:, i], y) plt.xlabel("$x_{}$".format(i + 1), fontsize=14) if i == 0: plt.ylabel("$y$", fontsize=14) plt.title("F-test={:.2f}, MI={:.2f}".format(f_test[i], mi[i]), fontsize=16) plt.show()
bsd-3-clause
[ 624, 199, 2486, 21326, 199, 25834, 402, 481, 13, 396, 436, 8567, 1061, 2556, 199, 2486, 21326, 199, 199, 2765, 2893, 22907, 11409, 2335, 314, 15109, 3382, 17225, 18449, 481, 13, 396, 11076, 199, 460, 8567, 1061, 2556, 14, 199, 199, 6004, 11201, 650, 4534, 671, 63, 17, 12, 671, 63, 18, 12, 671, 63, 19, 1854, 14818, 590, 1806, 359, 16, 12, 413, 467, 314, 199, 1375, 8350, 641, 3062, 465, 11924, 26, 199, 199, 89, 275, 671, 63, 17, 435, 9829, 8, 22, 627, 6682, 627, 671, 63, 18, 9, 435, 378, 14, 17, 627, 653, 8, 16, 12, 413, 395, 626, 365, 314, 10919, 4534, 365, 14793, 8190, 21906, 14, 199, 199, 1918, 1233, 5084, 19695, 314, 5936, 402, 612, 6169, 8212, 671, 63, 73, 436, 9657, 199, 1459, 402, 17225, 18449, 481, 13, 2219, 11076, 436, 8567, 1061, 2556, 14, 199, 199, 2822, 481, 13, 396, 12162, 1482, 1454, 7798, 5936, 12, 652, 24434, 671, 63, 17, 465, 314, 4750, 199, 328, 20129, 1905, 3878, 14, 4068, 314, 1163, 4926, 12, 8567, 1061, 2556, 883, 12296, 1263, 199, 5091, 402, 5936, 3382, 2860, 436, 652, 24434, 671, 63, 18, 465, 314, 4750, 199, 328, 20129, 1905, 3878, 12, 1314, 8646, 1839, 5710, 8034, 543, 4154, 1109, 1907, 857, 199, 529, 814, 367, 642, 2893, 14, 17650, 3102, 6657, 17370, 671, 63, 19, 465, 8190, 21906, 14, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 6357, 14, 4445, 63, 5592, 492, 289, 63, 12513, 12, 8567, 1061, 63, 815, 63, 12513, 199, 199, 1590, 14, 2355, 14, 5176, 8, 16, 9, 199, 56, 275, 980, 14, 2355, 14, 3759, 8, 5279, 12, 650, 9, 199, 89, 275, 1323, 3981, 378, 61, 435, 980, 14, 5911, 8, 22, 627, 980, 14, 1038, 627, 1323, 3981, 413, 566, 435, 378, 14, 17, 627, 980, 14, 2355, 14, 10843, 8, 5279, 9, 199, 199, 70, 63, 396, 12, 485, 275, 289, 63, 12513, 8, 56, 12, 612, 9, 199, 70, 63, 396, 12257, 980, 14, 988, 8, 70, 63, 396, 9, 199, 199, 2664, 275, 8567, 1061, 63, 815, 63, 12513, 8, 56, 12, 612, 9, 199, 2664, 12257, 980, 14, 988, 8, 2664, 9, 199, 199, 6003, 14, 8941, 8, 23899, 2687, 1046, 12, 959, 430, 199, 509, 284, 315, 1425, 8, 19, 304, 272, 4488, 14, 13334, 8, 17, 12, 650, 12, 284, 435, 413, 9, 272, 4488, 14, 13512, 8, 56, 3981, 284, 467, 612, 9, 272, 4488, 14, 14168, 21506, 88, 24306, 4, 1674, 908, 8, 73, 435, 413, 395, 19740, 29, 1079, 9, 272, 340, 284, 508, 378, 26, 267, 4488, 14, 13849, 21506, 89, 11918, 19740, 29, 1079, 9, 272, 4488, 14, 1213, 480, 38, 13, 396, 3126, 14010, 18, 70, 1386, 603, 41, 3126, 14010, 18, 70, 5469, 908, 8, 70, 63, 396, 59, 73, 467, 10684, 59, 73, 2522, 1598, 19740, 29, 975, 9, 199, 6003, 14, 2384, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2486, 21326, 199, 25834, 402, 481, 13, 396, 436, 8567, 1061, 2556, 199, 2486, 21326, 199, 199, 2765, 2893, 22907, 11409, 2335, 314, 15109, 3382, 17225, 18449, 481, 13, 396, 11076, 199, 460, 8567, 1061, 2556, 14, 199, 199, 6004, 11201, 650, 4534, 671, 63, 17, 12, 671, 63, 18, 12, 671, 63, 19, 1854, 14818, 590, 1806, 359, 16, 12, 413, 467, 314, 199, 1375, 8350, 641, 3062, 465, 11924, 26, 199, 199, 89, 275, 671, 63, 17, 435, 9829, 8, 22, 627, 6682, 627, 671, 63, 18, 9, 435, 378, 14, 17, 627, 653, 8, 16, 12, 413, 395, 626, 365, 314, 10919, 4534, 365, 14793, 8190, 21906, 14, 199, 199, 1918, 1233, 5084, 19695, 314, 5936, 402, 612, 6169, 8212, 671, 63, 73, 436, 9657, 199, 1459, 402, 17225, 18449, 481, 13, 2219, 11076, 436, 8567, 1061, 2556, 14, 199, 199, 2822, 481, 13, 396, 12162, 1482, 1454, 7798, 5936, 12, 652, 24434, 671, 63, 17, 465, 314, 4750, 199, 328, 20129, 1905, 3878, 14, 4068, 314, 1163, 4926, 12, 8567, 1061, 2556, 883, 12296, 1263, 199, 5091, 402, 5936, 3382, 2860, 436, 652, 24434, 671, 63, 18, 465, 314, 4750, 199, 328, 20129, 1905, 3878, 12, 1314, 8646, 1839, 5710, 8034, 543, 4154, 1109, 1907, 857, 199, 529, 814, 367, 642, 2893, 14, 17650, 3102, 6657, 17370, 671, 63, 19, 465, 8190, 21906, 14, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 6357, 14, 4445, 63, 5592, 492, 289, 63, 12513, 12, 8567, 1061, 63, 815, 63, 12513, 199, 199, 1590, 14, 2355, 14, 5176, 8, 16, 9, 199, 56, 275, 980, 14, 2355, 14, 3759, 8, 5279, 12, 650, 9, 199, 89, 275, 1323, 3981, 378, 61, 435, 980, 14, 5911, 8, 22, 627, 980, 14, 1038, 627, 1323, 3981, 413, 566, 435, 378, 14, 17, 627, 980, 14, 2355, 14, 10843, 8, 5279, 9, 199, 199, 70, 63, 396, 12, 485, 275, 289, 63, 12513, 8, 56, 12, 612, 9, 199, 70, 63, 396, 12257, 980, 14, 988, 8, 70, 63, 396, 9, 199, 199, 2664, 275, 8567, 1061, 63, 815, 63, 12513, 8, 56, 12, 612, 9, 199, 2664, 12257, 980, 14, 988, 8, 2664, 9, 199, 199, 6003, 14, 8941, 8, 23899, 2687, 1046, 12, 959, 430, 199, 509, 284, 315, 1425, 8, 19, 304, 272, 4488, 14, 13334, 8, 17, 12, 650, 12, 284, 435, 413, 9, 272, 4488, 14, 13512, 8, 56, 3981, 284, 467, 612, 9, 272, 4488, 14, 14168, 21506, 88, 24306, 4, 1674, 908, 8, 73, 435, 413, 395, 19740, 29, 1079, 9, 272, 340, 284, 508, 378, 26, 267, 4488, 14, 13849, 21506, 89, 11918, 19740, 29, 1079, 9, 272, 4488, 14, 1213, 480, 38, 13, 396, 3126, 14010, 18, 70, 1386, 603, 41, 3126, 14010, 18, 70, 5469, 908, 8, 70, 63, 396, 59, 73, 467, 10684, 59, 73, 2522, 1598, 19740, 29, 975, 9, 199, 6003, 14, 2384, 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, 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, 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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 ]
yufengg/tensorflow
tensorflow/python/framework/framework_lib.py
15
4208
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== # pylint: disable=unused-import,g-bad-import-order """Classes and functions for building TensorFlow graphs. ## Core graph data structures @@Graph @@Operation @@Tensor ## Tensor types @@DType @@as_dtype ## Utility functions @@device @@container @@name_scope @@control_dependencies @@convert_to_tensor @@convert_to_tensor_or_indexed_slices @@convert_to_tensor_or_sparse_tensor @@get_default_graph @@reset_default_graph @@import_graph_def @@load_file_system_library @@load_op_library @@make_tensor_proto @@make_ndarray ## Graph collections @@add_to_collection @@get_collection @@get_collection_ref @@GraphKeys ## Defining new operations @@RegisterGradient @@NotDifferentiable @@NoGradient @@TensorShape @@Dimension @@op_scope @@get_seed ## For libraries building on TensorFlow @@register_tensor_conversion_function """ from __future__ import absolute_import from __future__ import division from __future__ import print_function # Classes used when building a Graph. from tensorflow.python.framework.device import DeviceSpec from tensorflow.python.framework.ops import Graph from tensorflow.python.framework.ops import Operation from tensorflow.python.framework.ops import Tensor from tensorflow.python.framework.ops import IndexedSlices from tensorflow.python.framework.sparse_tensor import SparseTensor from tensorflow.python.framework.sparse_tensor import SparseTensorValue # Utilities used when building a Graph. from tensorflow.python.framework.ops import device from tensorflow.python.framework.ops import container from tensorflow.python.framework.ops import name_scope from tensorflow.python.framework.ops import op_scope from tensorflow.python.framework.ops import control_dependencies from tensorflow.python.framework.ops import get_default_graph from tensorflow.python.framework.ops import reset_default_graph from tensorflow.python.framework.ops import GraphKeys from tensorflow.python.framework.ops import add_to_collection from tensorflow.python.framework.ops import get_collection from tensorflow.python.framework.ops import get_collection_ref from tensorflow.python.framework.ops import convert_to_tensor from tensorflow.python.framework.ops import convert_to_tensor_or_indexed_slices from tensorflow.python.framework.random_seed import get_seed from tensorflow.python.framework.random_seed import set_random_seed from tensorflow.python.framework.sparse_tensor import convert_to_tensor_or_sparse_tensor from tensorflow.python.framework.subscribe import subscribe from tensorflow.python.framework.importer import import_graph_def # Utilities for working with Tensors from tensorflow.python.framework.tensor_util import make_tensor_proto from tensorflow.python.framework.tensor_util import MakeNdarray as make_ndarray # Needed when you defined a new Op in C++. from tensorflow.python.framework.ops import RegisterGradient from tensorflow.python.framework.ops import NotDifferentiable from tensorflow.python.framework.ops import NoGradient from tensorflow.python.framework.ops import RegisterShape from tensorflow.python.framework.tensor_shape import Dimension from tensorflow.python.framework.tensor_shape import TensorShape # Needed when interfacing tensorflow to new array libraries from tensorflow.python.framework.ops import register_tensor_conversion_function # go/tf-wildcard-import # pylint: disable=wildcard-import from tensorflow.python.framework.dtypes import * # Load a TensorFlow plugin from tensorflow.python.framework.load_library import * # pylint: enable=wildcard-import
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 624, 15711, 436, 3423, 367, 10015, 9134, 18312, 14, 199, 199, 309, 11672, 3343, 666, 13955, 199, 199, 7492, 4578, 199, 7492, 6044, 199, 7492, 3861, 199, 199, 309, 5878, 2943, 199, 199, 7492, 36, 804, 199, 7492, 305, 63, 2271, 199, 199, 309, 20511, 3423, 199, 199, 7492, 1782, 199, 7492, 3600, 199, 7492, 354, 63, 2645, 199, 7492, 2785, 63, 5714, 199, 7492, 3916, 63, 475, 63, 3128, 199, 7492, 3916, 63, 475, 63, 3128, 63, 269, 63, 16821, 63, 14865, 199, 7492, 3916, 63, 475, 63, 3128, 63, 269, 63, 4421, 63, 3128, 199, 7492, 362, 63, 885, 63, 2180, 199, 7492, 3958, 63, 885, 63, 2180, 199, 7492, 646, 63, 2180, 63, 318, 199, 7492, 912, 63, 493, 63, 2253, 63, 4342, 199, 7492, 912, 63, 411, 63, 4342, 199, 7492, 1875, 63, 3128, 63, 2625, 199, 7492, 1875, 63, 8237, 199, 199, 309, 11513, 5055, 199, 199, 7492, 525, 63, 475, 63, 3627, 199, 7492, 362, 63, 3627, 199, 7492, 362, 63, 3627, 63, 1121, 199, 7492, 19713, 199, 199, 309, 1487, 2408, 316, 892, 5331, 199, 199, 7492, 24876, 199, 7492, 1763, 16384, 30906, 461, 199, 7492, 1944, 9942, 199, 7492, 18592, 199, 7492, 17905, 199, 7492, 411, 63, 2645, 199, 7492, 362, 63, 5176, 199, 199, 309, 2104, 8363, 10015, 641, 9134, 199, 199, 7492, 2683, 63, 3128, 63, 15083, 63, 1593, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 27939, 1202, 1380, 10015, 282, 11513, 14, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1782, 492, 12272, 5307, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11513, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 17954, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 5878, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 26437, 19804, 199, 199, 504, 3228, 14, 1548, 14, 4857, 14, 4421, 63, 3128, 492, 14531, 3861, 199, 504, 3228, 14, 1548, 14, 4857, 14, 4421, 63, 3128, 492, 14531, 3861, 1110, 199, 199, 3, 738, 17933, 1202, 1380, 10015, 282, 11513, 14, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 2243, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3970, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 536, 63, 2645, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 1687, 63, 2645, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3304, 63, 5714, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 664, 63, 885, 63, 2180, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 5305, 63, 885, 63, 2180, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11513, 6340, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 1050, 63, 475, 63, 3627, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 664, 63, 3627, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 664, 63, 3627, 63, 1121, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3957, 63, 475, 63, 3128, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3957, 63, 475, 63, 3128, 63, 269, 63, 16821, 63, 14865, 199, 504, 3228, 14, 1548, 14, 4857, 14, 2355, 63, 5176, 492, 664, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4857, 14, 2355, 63, 5176, 492, 663, 63, 2355, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4857, 14, 4421, 63, 3128, 492, 3957, 63, 475, 63, 3128, 63, 269, 63, 4421, 63, 3128, 199, 504, 3228, 14, 1548, 14, 4857, 14, 10108, 492, 23421, 199, 504, 3228, 14, 1548, 14, 4857, 14, 12138, 492, 492, 63, 2180, 63, 318, 199, 199, 3, 738, 17933, 367, 6449, 543, 28373, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1974, 492, 1852, 63, 3128, 63, 2625, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1974, 492, 4155, 26947, 465, 1852, 63, 8237, 199, 199, 3, 28196, 1380, 1265, 3247, 282, 892, 9319, 315, 445, 4176, 14, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11828, 9942, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 2832, 16384, 30906, 461, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3091, 9942, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11828, 7238, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1392, 492, 25291, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1392, 492, 5878, 7238, 199, 199, 3, 28196, 1380, 1640, 32552, 3228, 370, 892, 1625, 8363, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 2274, 63, 3128, 63, 15083, 63, 1593, 199, 199, 3, 2621, 15, 3249, 13, 16692, 13, 646, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 199, 504, 3228, 14, 1548, 14, 4857, 14, 5717, 492, 627, 199, 199, 3, 7190, 282, 9134, 3589, 199, 504, 3228, 14, 1548, 14, 4857, 14, 912, 63, 4342, 492, 627, 199, 3, 4287, 26, 4756, 29, 16692, 13, 646, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 12, 71, 13, 4087, 13, 646, 13, 1648, 199, 624, 15711, 436, 3423, 367, 10015, 9134, 18312, 14, 199, 199, 309, 11672, 3343, 666, 13955, 199, 199, 7492, 4578, 199, 7492, 6044, 199, 7492, 3861, 199, 199, 309, 5878, 2943, 199, 199, 7492, 36, 804, 199, 7492, 305, 63, 2271, 199, 199, 309, 20511, 3423, 199, 199, 7492, 1782, 199, 7492, 3600, 199, 7492, 354, 63, 2645, 199, 7492, 2785, 63, 5714, 199, 7492, 3916, 63, 475, 63, 3128, 199, 7492, 3916, 63, 475, 63, 3128, 63, 269, 63, 16821, 63, 14865, 199, 7492, 3916, 63, 475, 63, 3128, 63, 269, 63, 4421, 63, 3128, 199, 7492, 362, 63, 885, 63, 2180, 199, 7492, 3958, 63, 885, 63, 2180, 199, 7492, 646, 63, 2180, 63, 318, 199, 7492, 912, 63, 493, 63, 2253, 63, 4342, 199, 7492, 912, 63, 411, 63, 4342, 199, 7492, 1875, 63, 3128, 63, 2625, 199, 7492, 1875, 63, 8237, 199, 199, 309, 11513, 5055, 199, 199, 7492, 525, 63, 475, 63, 3627, 199, 7492, 362, 63, 3627, 199, 7492, 362, 63, 3627, 63, 1121, 199, 7492, 19713, 199, 199, 309, 1487, 2408, 316, 892, 5331, 199, 199, 7492, 24876, 199, 7492, 1763, 16384, 30906, 461, 199, 7492, 1944, 9942, 199, 7492, 18592, 199, 7492, 17905, 199, 7492, 411, 63, 2645, 199, 7492, 362, 63, 5176, 199, 199, 309, 2104, 8363, 10015, 641, 9134, 199, 199, 7492, 2683, 63, 3128, 63, 15083, 63, 1593, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 3, 27939, 1202, 1380, 10015, 282, 11513, 14, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1782, 492, 12272, 5307, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11513, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 17954, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 5878, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 26437, 19804, 199, 199, 504, 3228, 14, 1548, 14, 4857, 14, 4421, 63, 3128, 492, 14531, 3861, 199, 504, 3228, 14, 1548, 14, 4857, 14, 4421, 63, 3128, 492, 14531, 3861, 1110, 199, 199, 3, 738, 17933, 1202, 1380, 10015, 282, 11513, 14, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 2243, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3970, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 536, 63, 2645, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 1687, 63, 2645, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3304, 63, 5714, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 664, 63, 885, 63, 2180, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 5305, 63, 885, 63, 2180, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11513, 6340, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 1050, 63, 475, 63, 3627, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 664, 63, 3627, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 664, 63, 3627, 63, 1121, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3957, 63, 475, 63, 3128, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3957, 63, 475, 63, 3128, 63, 269, 63, 16821, 63, 14865, 199, 504, 3228, 14, 1548, 14, 4857, 14, 2355, 63, 5176, 492, 664, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4857, 14, 2355, 63, 5176, 492, 663, 63, 2355, 63, 5176, 199, 504, 3228, 14, 1548, 14, 4857, 14, 4421, 63, 3128, 492, 3957, 63, 475, 63, 3128, 63, 269, 63, 4421, 63, 3128, 199, 504, 3228, 14, 1548, 14, 4857, 14, 10108, 492, 23421, 199, 504, 3228, 14, 1548, 14, 4857, 14, 12138, 492, 492, 63, 2180, 63, 318, 199, 199, 3, 738, 17933, 367, 6449, 543, 28373, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1974, 492, 1852, 63, 3128, 63, 2625, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1974, 492, 4155, 26947, 465, 1852, 63, 8237, 199, 199, 3, 28196, 1380, 1265, 3247, 282, 892, 9319, 315, 445, 4176, 14, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11828, 9942, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 2832, 16384, 30906, 461, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 3091, 9942, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 11828, 7238, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1392, 492, 25291, 199, 504, 3228, 14, 1548, 14, 4857, 14, 3128, 63, 1392, 492, 5878, 7238, 199, 199, 3, 28196, 1380, 1640, 32552, 3228, 370, 892, 1625, 8363, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 2274, 63, 3128, 63, 15083, 63, 1593, 199, 199, 3, 2621, 15, 3249, 13, 16692, 13, 646, 199, 3, 4287, 26, 3507, 29, 16692, 13, 646, 199, 504, 3228, 14, 1548, 14, 4857, 14, 5717, 492, 627, 199, 199, 3, 7190, 282, 9134, 3589, 199, 504, 3228, 14, 1548, 14, 4857, 14, 912, 63, 4342, 492, 627, 199, 3, 4287, 26, 4756, 29, 16692, 13, 646, 199, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
fbidu/namebench
nb_third_party/dns/e164.py
248
3063
# Copyright (C) 2006, 2007, 2009 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, # provided that the above copyright notice and this permission notice # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """DNS E.164 helpers @var public_enum_domain: The DNS public ENUM domain, e164.arpa. @type public_enum_domain: dns.name.Name object """ import dns.exception import dns.name import dns.resolver public_enum_domain = dns.name.from_text('e164.arpa.') def from_e164(text, origin=public_enum_domain): """Convert an E.164 number in textual form into a Name object whose value is the ENUM domain name for that number. @param text: an E.164 number in textual form. @type text: str @param origin: The domain in which the number should be constructed. The default is e164.arpa. @type: dns.name.Name object or None @rtype: dns.name.Name object """ parts = [d for d in text if d.isdigit()] parts.reverse() return dns.name.from_text('.'.join(parts), origin=origin) def to_e164(name, origin=public_enum_domain, want_plus_prefix=True): """Convert an ENUM domain name into an E.164 number. @param name: the ENUM domain name. @type name: dns.name.Name object. @param origin: A domain containing the ENUM domain name. The name is relativized to this domain before being converted to text. @type: dns.name.Name object or None @param want_plus_prefix: if True, add a '+' to the beginning of the returned number. @rtype: str """ if not origin is None: name = name.relativize(origin) dlabels = [d for d in name.labels if (d.isdigit() and len(d) == 1)] if len(dlabels) != len(name.labels): raise dns.exception.SyntaxError('non-digit labels in ENUM domain name') dlabels.reverse() text = ''.join(dlabels) if want_plus_prefix: text = '+' + text return text def query(number, domains, resolver=None): """Look for NAPTR RRs for the specified number in the specified domains. e.g. lookup('16505551212', ['e164.dnspython.org.', 'e164.arpa.']) """ if resolver is None: resolver = dns.resolver.get_default_resolver() for domain in domains: if isinstance(domain, (str, unicode)): domain = dns.name.from_text(domain) qname = dns.e164.from_e164(number, domain) try: return resolver.query(qname, 'NAPTR') except dns.resolver.NXDOMAIN: pass raise dns.resolver.NXDOMAIN
apache-2.0
[ 3, 1898, 334, 35, 9, 8315, 12, 10219, 12, 8937, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 12323, 662, 14, 8982, 10897, 199, 199, 32, 1391, 4575, 63, 4869, 63, 2261, 26, 710, 10237, 4575, 662, 7125, 2881, 12, 325, 8982, 14, 285, 387, 14, 199, 32, 466, 4575, 63, 4869, 63, 2261, 26, 6715, 14, 354, 14, 985, 909, 199, 624, 199, 199, 646, 6715, 14, 1971, 199, 646, 6715, 14, 354, 199, 646, 6715, 14, 7717, 199, 199, 3455, 63, 4869, 63, 2261, 275, 6715, 14, 354, 14, 504, 63, 505, 360, 69, 8982, 14, 285, 387, 2659, 199, 199, 318, 687, 63, 69, 8982, 8, 505, 12, 6330, 29, 3455, 63, 4869, 63, 2261, 304, 272, 408, 7306, 376, 662, 14, 8982, 1329, 315, 25884, 1824, 1901, 282, 2812, 909, 7447, 272, 574, 365, 314, 662, 7125, 2881, 536, 367, 626, 1329, 14, 272, 768, 635, 1318, 26, 376, 662, 14, 8982, 1329, 315, 25884, 1824, 14, 272, 768, 466, 1318, 26, 620, 272, 768, 635, 6330, 26, 710, 2881, 315, 1314, 314, 1329, 1077, 506, 14701, 14, 272, 710, 849, 365, 325, 8982, 14, 285, 387, 14, 272, 768, 466, 26, 6715, 14, 354, 14, 985, 909, 503, 488, 272, 768, 4500, 26, 6715, 14, 354, 14, 985, 909, 272, 408, 272, 4184, 275, 359, 68, 367, 366, 315, 1318, 340, 366, 14, 13896, 5106, 272, 4184, 14, 4471, 342, 272, 372, 6715, 14, 354, 14, 504, 63, 505, 5175, 1370, 904, 8, 4181, 395, 6330, 29, 6493, 9, 199, 199, 318, 370, 63, 69, 8982, 8, 354, 12, 6330, 29, 3455, 63, 4869, 63, 2261, 12, 2934, 63, 6666, 63, 1861, 29, 549, 304, 272, 408, 7306, 376, 662, 7125, 2881, 536, 1901, 376, 662, 14, 8982, 1329, 14, 272, 768, 635, 536, 26, 314, 662, 7125, 2881, 536, 14, 272, 768, 466, 536, 26, 6715, 14, 354, 14, 985, 909, 14, 272, 768, 635, 6330, 26, 437, 2881, 3035, 314, 662, 7125, 2881, 536, 14, 221, 710, 272, 536, 365, 13773, 3804, 7068, 370, 642, 2881, 2544, 3769, 6702, 370, 1318, 14, 272, 768, 466, 26, 6715, 14, 354, 14, 985, 909, 503, 488, 272, 768, 635, 2934, 63, 6666, 63, 1861, 26, 340, 715, 12, 1050, 282, 20246, 370, 314, 9608, 402, 314, 272, 2138, 1329, 14, 272, 768, 4500, 26, 620, 272, 408, 272, 340, 440, 6330, 365, 488, 26, 267, 536, 275, 536, 14, 17060, 29282, 8, 6493, 9, 272, 366, 3512, 275, 359, 68, 367, 366, 315, 536, 14, 3512, 340, 334, 68, 14, 13896, 342, 436, 822, 8, 68, 9, 508, 413, 1874, 272, 340, 822, 8, 68, 3512, 9, 1137, 822, 8, 354, 14, 3512, 304, 267, 746, 6715, 14, 1971, 14, 9294, 360, 2865, 13, 8573, 3628, 315, 662, 7125, 2881, 536, 358, 272, 366, 3512, 14, 4471, 342, 272, 1318, 275, 6522, 904, 8, 68, 3512, 9, 272, 340, 2934, 63, 6666, 63, 1861, 26, 267, 1318, 275, 20246, 435, 1318, 272, 372, 1318, 199, 199, 318, 1827, 8, 1955, 12, 14006, 12, 15611, 29, 403, 304, 272, 408, 20926, 367, 653, 1282, 1766, 27222, 83, 367, 314, 2013, 1329, 315, 314, 2013, 14006, 14, 339, 325, 14, 71, 14, 4237, 360, 975, 1400, 1229, 7736, 713, 297, 788, 69, 8982, 14, 5797, 1548, 14, 1308, 3130, 283, 69, 8982, 14, 285, 387, 25367, 272, 408, 272, 340, 15611, 365, 488, 26, 267, 15611, 275, 6715, 14, 7717, 14, 362, 63, 885, 63, 7717, 342, 272, 367, 2881, 315, 14006, 26, 267, 340, 1228, 8, 2261, 12, 334, 495, 12, 2649, 2298, 288, 2881, 275, 6715, 14, 354, 14, 504, 63, 505, 8, 2261, 9, 267, 20834, 275, 6715, 14, 69, 8982, 14, 504, 63, 69, 8982, 8, 1955, 12, 2881, 9, 267, 862, 26, 288, 372, 15611, 14, 1131, 8, 12333, 12, 283, 46, 1282, 1766, 358, 267, 871, 6715, 14, 7717, 14, 16764, 7378, 26, 288, 986, 272, 746, 6715, 14, 7717, 14, 16764, 7378, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 8315, 12, 10219, 12, 8937, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 12323, 662, 14, 8982, 10897, 199, 199, 32, 1391, 4575, 63, 4869, 63, 2261, 26, 710, 10237, 4575, 662, 7125, 2881, 12, 325, 8982, 14, 285, 387, 14, 199, 32, 466, 4575, 63, 4869, 63, 2261, 26, 6715, 14, 354, 14, 985, 909, 199, 624, 199, 199, 646, 6715, 14, 1971, 199, 646, 6715, 14, 354, 199, 646, 6715, 14, 7717, 199, 199, 3455, 63, 4869, 63, 2261, 275, 6715, 14, 354, 14, 504, 63, 505, 360, 69, 8982, 14, 285, 387, 2659, 199, 199, 318, 687, 63, 69, 8982, 8, 505, 12, 6330, 29, 3455, 63, 4869, 63, 2261, 304, 272, 408, 7306, 376, 662, 14, 8982, 1329, 315, 25884, 1824, 1901, 282, 2812, 909, 7447, 272, 574, 365, 314, 662, 7125, 2881, 536, 367, 626, 1329, 14, 272, 768, 635, 1318, 26, 376, 662, 14, 8982, 1329, 315, 25884, 1824, 14, 272, 768, 466, 1318, 26, 620, 272, 768, 635, 6330, 26, 710, 2881, 315, 1314, 314, 1329, 1077, 506, 14701, 14, 272, 710, 849, 365, 325, 8982, 14, 285, 387, 14, 272, 768, 466, 26, 6715, 14, 354, 14, 985, 909, 503, 488, 272, 768, 4500, 26, 6715, 14, 354, 14, 985, 909, 272, 408, 272, 4184, 275, 359, 68, 367, 366, 315, 1318, 340, 366, 14, 13896, 5106, 272, 4184, 14, 4471, 342, 272, 372, 6715, 14, 354, 14, 504, 63, 505, 5175, 1370, 904, 8, 4181, 395, 6330, 29, 6493, 9, 199, 199, 318, 370, 63, 69, 8982, 8, 354, 12, 6330, 29, 3455, 63, 4869, 63, 2261, 12, 2934, 63, 6666, 63, 1861, 29, 549, 304, 272, 408, 7306, 376, 662, 7125, 2881, 536, 1901, 376, 662, 14, 8982, 1329, 14, 272, 768, 635, 536, 26, 314, 662, 7125, 2881, 536, 14, 272, 768, 466, 536, 26, 6715, 14, 354, 14, 985, 909, 14, 272, 768, 635, 6330, 26, 437, 2881, 3035, 314, 662, 7125, 2881, 536, 14, 221, 710, 272, 536, 365, 13773, 3804, 7068, 370, 642, 2881, 2544, 3769, 6702, 370, 1318, 14, 272, 768, 466, 26, 6715, 14, 354, 14, 985, 909, 503, 488, 272, 768, 635, 2934, 63, 6666, 63, 1861, 26, 340, 715, 12, 1050, 282, 20246, 370, 314, 9608, 402, 314, 272, 2138, 1329, 14, 272, 768, 4500, 26, 620, 272, 408, 272, 340, 440, 6330, 365, 488, 26, 267, 536, 275, 536, 14, 17060, 29282, 8, 6493, 9, 272, 366, 3512, 275, 359, 68, 367, 366, 315, 536, 14, 3512, 340, 334, 68, 14, 13896, 342, 436, 822, 8, 68, 9, 508, 413, 1874, 272, 340, 822, 8, 68, 3512, 9, 1137, 822, 8, 354, 14, 3512, 304, 267, 746, 6715, 14, 1971, 14, 9294, 360, 2865, 13, 8573, 3628, 315, 662, 7125, 2881, 536, 358, 272, 366, 3512, 14, 4471, 342, 272, 1318, 275, 6522, 904, 8, 68, 3512, 9, 272, 340, 2934, 63, 6666, 63, 1861, 26, 267, 1318, 275, 20246, 435, 1318, 272, 372, 1318, 199, 199, 318, 1827, 8, 1955, 12, 14006, 12, 15611, 29, 403, 304, 272, 408, 20926, 367, 653, 1282, 1766, 27222, 83, 367, 314, 2013, 1329, 315, 314, 2013, 14006, 14, 339, 325, 14, 71, 14, 4237, 360, 975, 1400, 1229, 7736, 713, 297, 788, 69, 8982, 14, 5797, 1548, 14, 1308, 3130, 283, 69, 8982, 14, 285, 387, 25367, 272, 408, 272, 340, 15611, 365, 488, 26, 267, 15611, 275, 6715, 14, 7717, 14, 362, 63, 885, 63, 7717, 342, 272, 367, 2881, 315, 14006, 26, 267, 340, 1228, 8, 2261, 12, 334, 495, 12, 2649, 2298, 288, 2881, 275, 6715, 14, 354, 14, 504, 63, 505, 8, 2261, 9, 267, 20834, 275, 6715, 14, 69, 8982, 14, 504, 63, 69, 8982, 8, 1955, 12, 2881, 9, 267, 862, 26, 288, 372, 15611, 14, 1131, 8, 12333, 12, 283, 46, 1282, 1766, 358, 267, 871, 6715, 14, 7717, 14, 16764, 7378, 26, 288, 986, 272, 746, 6715, 14, 7717, 14, 16764, 7378, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Sylrob434/CouchPotatoServer
couchpotato/core/media/movie/providers/trailer/youtube_dl/extractor/newgrounds.py
19
1277
from __future__ import unicode_literals import json import re from .common import InfoExtractor class NewgroundsIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?newgrounds\.com/audio/listen/(?P<id>[0-9]+)' _TEST = { 'url': 'http://www.newgrounds.com/audio/listen/549479', 'md5': 'fe6033d297591288fa1c1f780386f07a', 'info_dict': { 'id': '549479', 'ext': 'mp3', 'title': 'B7 - BusMode', 'uploader': 'Burn7', } } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) music_id = mobj.group('id') webpage = self._download_webpage(url, music_id) title = self._html_search_regex( r',"name":"([^"]+)",', webpage, 'music title') uploader = self._html_search_regex( r',"artist":"([^"]+)",', webpage, 'music uploader') music_url_json_string = self._html_search_regex( r'({"url":"[^"]+"),', webpage, 'music url') + '}' music_url_json = json.loads(music_url_json_string) music_url = music_url_json['url'] return { 'id': music_id, 'title': title, 'url': music_url, 'uploader': uploader, }
gpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 7053, 3928, 83, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 1222, 3928, 83, 4537, 957, 15, 8130, 15, 5859, 9448, 48, 28, 344, 9514, 16, 13, 25, 29716, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 1222, 3928, 83, 14, 957, 15, 8130, 15, 5859, 15, 1477, 2635, 1965, 297, 267, 283, 1064, 21, 356, 283, 771, 2259, 1153, 68, 12615, 1427, 713, 1299, 667, 17, 67, 17, 70, 31829, 8040, 70, 1780, 65, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1477, 2635, 1965, 297, 288, 283, 832, 356, 283, 311, 19, 297, 288, 283, 1213, 356, 283, 34, 23, 446, 18573, 1385, 297, 288, 283, 13671, 356, 283, 34, 349, 23, 297, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 30891, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 30891, 63, 344, 9, 2728, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 297, 2, 354, 5122, 15710, 11, 4186, 297, 9248, 12, 283, 20544, 2538, 358, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 297, 2, 11215, 5122, 15710, 11, 4186, 297, 9248, 12, 283, 20544, 25257, 358, 2728, 30891, 63, 633, 63, 1001, 63, 875, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7, 6333, 633, 5122, 25153, 11, 1288, 297, 9248, 12, 283, 20544, 1166, 358, 435, 23618, 267, 30891, 63, 633, 63, 1001, 275, 2022, 14, 3640, 8, 20544, 63, 633, 63, 1001, 63, 875, 9, 267, 30891, 63, 633, 275, 30891, 63, 633, 63, 1001, 459, 633, 418, 398, 372, 469, 288, 283, 344, 356, 30891, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 633, 356, 30891, 63, 633, 12, 288, 283, 13671, 356, 25257, 12, 267, 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 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 7053, 3928, 83, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 1222, 3928, 83, 4537, 957, 15, 8130, 15, 5859, 9448, 48, 28, 344, 9514, 16, 13, 25, 29716, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 1222, 3928, 83, 14, 957, 15, 8130, 15, 5859, 15, 1477, 2635, 1965, 297, 267, 283, 1064, 21, 356, 283, 771, 2259, 1153, 68, 12615, 1427, 713, 1299, 667, 17, 67, 17, 70, 31829, 8040, 70, 1780, 65, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1477, 2635, 1965, 297, 288, 283, 832, 356, 283, 311, 19, 297, 288, 283, 1213, 356, 283, 34, 23, 446, 18573, 1385, 297, 288, 283, 13671, 356, 283, 34, 349, 23, 297, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 30891, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 30891, 63, 344, 9, 2728, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 297, 2, 354, 5122, 15710, 11, 4186, 297, 9248, 12, 283, 20544, 2538, 358, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 297, 2, 11215, 5122, 15710, 11, 4186, 297, 9248, 12, 283, 20544, 25257, 358, 2728, 30891, 63, 633, 63, 1001, 63, 875, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7, 6333, 633, 5122, 25153, 11, 1288, 297, 9248, 12, 283, 20544, 1166, 358, 435, 23618, 267, 30891, 63, 633, 63, 1001, 275, 2022, 14, 3640, 8, 20544, 63, 633, 63, 1001, 63, 875, 9, 267, 30891, 63, 633, 275, 30891, 63, 633, 63, 1001, 459, 633, 418, 398, 372, 469, 288, 283, 344, 356, 30891, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 633, 356, 30891, 63, 633, 12, 288, 283, 13671, 356, 25257, 12, 267, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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ports_linux.py
12
4427
#!/usr/bin/env python # # This is a module that gathers a list of serial ports including details on # GNU/Linux systems. # # This file is part of pySerial. https://github.com/pyserial/pyserial # (C) 2011-2015 Chris Liechti <cliechti@gmx.net> # # SPDX-License-Identifier: BSD-3-Clause import glob import os from serial.tools import list_ports_common class SysFS(list_ports_common.ListPortInfo): """Wrapper for easy sysfs access and device info""" def __init__(self, device): super(SysFS, self).__init__(device) # special handling for links if device is not None and os.path.islink(device): device = os.path.realpath(device) is_link = True else: is_link = False self.name = os.path.basename(device) self.usb_device_path = None if os.path.exists('/sys/class/tty/{}/device'.format(self.name)): self.device_path = os.path.realpath('/sys/class/tty/{}/device'.format(self.name)) self.subsystem = os.path.basename(os.path.realpath(os.path.join(self.device_path, 'subsystem'))) else: self.device_path = None self.subsystem = None # check device type if self.subsystem == 'usb-serial': self.usb_interface_path = os.path.dirname(self.device_path) elif self.subsystem == 'usb': self.usb_interface_path = self.device_path else: self.usb_interface_path = None # fill-in info for USB devices if self.usb_interface_path is not None: self.usb_device_path = os.path.dirname(self.usb_interface_path) try: num_if = int(self.read_line(self.usb_device_path, 'bNumInterfaces')) except ValueError: num_if = 1 self.vid = int(self.read_line(self.usb_device_path, 'idVendor'), 16) self.pid = int(self.read_line(self.usb_device_path, 'idProduct'), 16) self.serial_number = self.read_line(self.usb_device_path, 'serial') if num_if > 1: # multi interface devices like FT4232 self.location = os.path.basename(self.usb_interface_path) else: self.location = os.path.basename(self.usb_device_path) self.manufacturer = self.read_line(self.usb_device_path, 'manufacturer') self.product = self.read_line(self.usb_device_path, 'product') self.interface = self.read_line(self.device_path, 'interface') if self.subsystem in ('usb', 'usb-serial'): self.apply_usb_info() #~ elif self.subsystem in ('pnp', 'amba'): # PCI based devices, raspi elif self.subsystem == 'pnp': # PCI based devices self.description = self.name self.hwid = self.read_line(self.device_path, 'id') elif self.subsystem == 'amba': # raspi self.description = self.name self.hwid = os.path.basename(self.device_path) if is_link: self.hwid += ' LINK={}'.format(device) def read_line(self, *args): """\ Helper function to read a single line from a file. One or more parameters are allowed, they are joined with os.path.join. Returns None on errors.. """ try: with open(os.path.join(*args)) as f: line = f.readline().strip() return line except IOError: return None def comports(include_links=False): devices = glob.glob('/dev/ttyS*') # built-in serial ports devices.extend(glob.glob('/dev/ttyUSB*')) # usb-serial with own driver devices.extend(glob.glob('/dev/ttyACM*')) # usb-serial with CDC-ACM profile devices.extend(glob.glob('/dev/ttyAMA*')) # ARM internal port (raspi) devices.extend(glob.glob('/dev/rfcomm*')) # BT serial devices devices.extend(glob.glob('/dev/ttyAP*')) # Advantech multi-port serial controllers if include_links: devices.extend(list_ports_common.list_links(devices)) return [info for info in [SysFS(d) for d in devices] if info.subsystem != "platform"] # hide non-present internal serial ports # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # test if __name__ == '__main__': for port, desc, hwid in sorted(comports()): print("{}: {} [{}]".format(port, desc, hwid))
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 961, 365, 282, 859, 626, 13082, 83, 282, 769, 402, 3012, 8873, 5893, 2436, 641, 199, 3, 1664, 15, 14091, 10460, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1134, 3571, 14, 4178, 921, 5031, 14, 957, 15, 647, 2171, 15, 647, 2171, 199, 3, 334, 35, 9, 7760, 13, 7806, 2799, 5719, 491, 1873, 335, 280, 665, 2764, 12736, 280, 32, 71, 9457, 14, 846, 30, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 259, 6289, 13, 19, 13, 16009, 199, 199, 646, 5739, 199, 646, 747, 199, 504, 3012, 14, 2537, 492, 769, 63, 5203, 63, 2330, 421, 199, 533, 28766, 7079, 8, 513, 63, 5203, 63, 2330, 14, 1296, 4313, 2354, 304, 272, 408, 4590, 367, 8837, 984, 2319, 2879, 436, 2243, 2256, 624, 339, 347, 636, 826, 721, 277, 12, 2243, 304, 267, 1613, 8, 11319, 7079, 12, 291, 2843, 826, 721, 1782, 9, 267, 327, 4539, 7252, 367, 6220, 267, 340, 2243, 365, 440, 488, 436, 747, 14, 515, 14, 20719, 8, 1782, 304, 288, 2243, 275, 747, 14, 515, 14, 11091, 8, 1782, 9, 288, 365, 63, 1073, 275, 715, 267, 587, 26, 288, 365, 63, 1073, 275, 756, 267, 291, 14, 354, 275, 747, 14, 515, 14, 4846, 8, 1782, 9, 267, 291, 14, 17411, 63, 1782, 63, 515, 275, 488, 267, 340, 747, 14, 515, 14, 2444, 2336, 1274, 15, 533, 15, 4707, 19655, 1782, 1370, 908, 8, 277, 14, 354, 2298, 288, 291, 14, 1782, 63, 515, 275, 747, 14, 515, 14, 11091, 2336, 1274, 15, 533, 15, 4707, 19655, 1782, 1370, 908, 8, 277, 14, 354, 430, 288, 291, 14, 954, 2253, 275, 747, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1782, 63, 515, 12, 283, 954, 2253, 7058, 267, 587, 26, 288, 291, 14, 1782, 63, 515, 275, 488, 288, 291, 14, 954, 2253, 275, 488, 267, 327, 1104, 2243, 730, 267, 340, 291, 14, 954, 2253, 508, 283, 17411, 13, 2171, 356, 288, 291, 14, 17411, 63, 3266, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 277, 14, 1782, 63, 515, 9, 267, 916, 291, 14, 954, 2253, 508, 283, 17411, 356, 288, 291, 14, 17411, 63, 3266, 63, 515, 275, 291, 14, 1782, 63, 515, 267, 587, 26, 288, 291, 14, 17411, 63, 3266, 63, 515, 275, 488, 267, 327, 5554, 13, 262, 2256, 367, 28655, 7256, 267, 340, 291, 14, 17411, 63, 3266, 63, 515, 365, 440, 488, 26, 288, 291, 14, 17411, 63, 1782, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 277, 14, 17411, 63, 3266, 63, 515, 9, 953, 862, 26, 355, 1967, 63, 692, 275, 1109, 8, 277, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 66, 5667, 18680, 1333, 288, 871, 1722, 26, 355, 1967, 63, 692, 275, 413, 953, 291, 14, 5017, 275, 1109, 8, 277, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 344, 27111, 659, 3193, 9, 288, 291, 14, 3150, 275, 1109, 8, 277, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 344, 5884, 659, 3193, 9, 288, 291, 14, 2171, 63, 1955, 275, 291, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 2171, 358, 288, 340, 1967, 63, 692, 690, 413, 26, 221, 327, 3510, 3217, 7256, 2839, 481, 52, 2260, 708, 355, 291, 14, 1985, 275, 747, 14, 515, 14, 4846, 8, 277, 14, 17411, 63, 3266, 63, 515, 9, 288, 587, 26, 355, 291, 14, 1985, 275, 747, 14, 515, 14, 4846, 8, 277, 14, 17411, 63, 1782, 63, 515, 9, 953, 291, 14, 32214, 275, 291, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 32214, 358, 288, 291, 14, 2558, 275, 291, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 2558, 358, 288, 291, 14, 3266, 275, 291, 14, 739, 63, 604, 8, 277, 14, 1782, 63, 515, 12, 283, 3266, 358, 398, 340, 291, 14, 954, 2253, 315, 661, 17411, 297, 283, 17411, 13, 2171, 735, 288, 291, 14, 4998, 63, 17411, 63, 815, 342, 267, 15259, 916, 291, 14, 954, 2253, 315, 661, 80, 1590, 297, 283, 14310, 735, 221, 327, 510, 3553, 4079, 7256, 12, 519, 305, 1038, 267, 916, 291, 14, 954, 2253, 508, 283, 80, 1590, 356, 221, 327, 510, 3553, 4079, 7256, 288, 291, 14, 1802, 275, 291, 14, 354, 288, 291, 14, 8090, 344, 275, 291, 14, 739, 63, 604, 8, 277, 14, 1782, 63, 515, 12, 283, 344, 358, 267, 916, 291, 14, 954, 2253, 508, 283, 14310, 356, 221, 327, 519, 305, 1038, 288, 291, 14, 1802, 275, 291, 14, 354, 288, 291, 14, 8090, 344, 275, 747, 14, 515, 14, 4846, 8, 277, 14, 1782, 63, 515, 9, 398, 340, 365, 63, 1073, 26, 288, 291, 14, 8090, 344, 847, 283, 19774, 27244, 908, 8, 1782, 9, 339, 347, 1586, 63, 604, 8, 277, 12, 627, 589, 304, 267, 9638, 267, 11642, 805, 370, 1586, 282, 2849, 1004, 687, 282, 570, 14, 267, 7309, 503, 1655, 2633, 787, 4370, 12, 2985, 787, 16538, 543, 747, 14, 515, 14, 904, 14, 267, 1803, 488, 641, 2552, 703, 267, 408, 267, 862, 26, 288, 543, 1551, 8, 736, 14, 515, 14, 904, 2031, 589, 430, 465, 289, 26, 355, 1004, 275, 289, 14, 6407, 1252, 1913, 342, 288, 372, 1004, 267, 871, 5925, 26, 288, 372, 488, 421, 199, 318, 512, 412, 83, 8, 2613, 63, 4614, 29, 797, 304, 272, 7256, 275, 5739, 14, 6463, 2336, 2374, 15, 4707, 51, 13418, 3698, 327, 6137, 13, 262, 3012, 8873, 272, 7256, 14, 2880, 8, 6463, 14, 6463, 2336, 2374, 15, 4707, 19919, 10, 1333, 257, 327, 27923, 13, 2171, 543, 5705, 5253, 272, 7256, 14, 2880, 8, 6463, 14, 6463, 2336, 2374, 15, 4707, 1348, 45, 10, 1333, 257, 327, 27923, 13, 2171, 543, 445, 5196, 13, 1348, 45, 4690, 272, 7256, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 961, 365, 282, 859, 626, 13082, 83, 282, 769, 402, 3012, 8873, 5893, 2436, 641, 199, 3, 1664, 15, 14091, 10460, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1134, 3571, 14, 4178, 921, 5031, 14, 957, 15, 647, 2171, 15, 647, 2171, 199, 3, 334, 35, 9, 7760, 13, 7806, 2799, 5719, 491, 1873, 335, 280, 665, 2764, 12736, 280, 32, 71, 9457, 14, 846, 30, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 259, 6289, 13, 19, 13, 16009, 199, 199, 646, 5739, 199, 646, 747, 199, 504, 3012, 14, 2537, 492, 769, 63, 5203, 63, 2330, 421, 199, 533, 28766, 7079, 8, 513, 63, 5203, 63, 2330, 14, 1296, 4313, 2354, 304, 272, 408, 4590, 367, 8837, 984, 2319, 2879, 436, 2243, 2256, 624, 339, 347, 636, 826, 721, 277, 12, 2243, 304, 267, 1613, 8, 11319, 7079, 12, 291, 2843, 826, 721, 1782, 9, 267, 327, 4539, 7252, 367, 6220, 267, 340, 2243, 365, 440, 488, 436, 747, 14, 515, 14, 20719, 8, 1782, 304, 288, 2243, 275, 747, 14, 515, 14, 11091, 8, 1782, 9, 288, 365, 63, 1073, 275, 715, 267, 587, 26, 288, 365, 63, 1073, 275, 756, 267, 291, 14, 354, 275, 747, 14, 515, 14, 4846, 8, 1782, 9, 267, 291, 14, 17411, 63, 1782, 63, 515, 275, 488, 267, 340, 747, 14, 515, 14, 2444, 2336, 1274, 15, 533, 15, 4707, 19655, 1782, 1370, 908, 8, 277, 14, 354, 2298, 288, 291, 14, 1782, 63, 515, 275, 747, 14, 515, 14, 11091, 2336, 1274, 15, 533, 15, 4707, 19655, 1782, 1370, 908, 8, 277, 14, 354, 430, 288, 291, 14, 954, 2253, 275, 747, 14, 515, 14, 4846, 8, 736, 14, 515, 14, 11091, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1782, 63, 515, 12, 283, 954, 2253, 7058, 267, 587, 26, 288, 291, 14, 1782, 63, 515, 275, 488, 288, 291, 14, 954, 2253, 275, 488, 267, 327, 1104, 2243, 730, 267, 340, 291, 14, 954, 2253, 508, 283, 17411, 13, 2171, 356, 288, 291, 14, 17411, 63, 3266, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 277, 14, 1782, 63, 515, 9, 267, 916, 291, 14, 954, 2253, 508, 283, 17411, 356, 288, 291, 14, 17411, 63, 3266, 63, 515, 275, 291, 14, 1782, 63, 515, 267, 587, 26, 288, 291, 14, 17411, 63, 3266, 63, 515, 275, 488, 267, 327, 5554, 13, 262, 2256, 367, 28655, 7256, 267, 340, 291, 14, 17411, 63, 3266, 63, 515, 365, 440, 488, 26, 288, 291, 14, 17411, 63, 1782, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 277, 14, 17411, 63, 3266, 63, 515, 9, 953, 862, 26, 355, 1967, 63, 692, 275, 1109, 8, 277, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 66, 5667, 18680, 1333, 288, 871, 1722, 26, 355, 1967, 63, 692, 275, 413, 953, 291, 14, 5017, 275, 1109, 8, 277, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 344, 27111, 659, 3193, 9, 288, 291, 14, 3150, 275, 1109, 8, 277, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 344, 5884, 659, 3193, 9, 288, 291, 14, 2171, 63, 1955, 275, 291, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 2171, 358, 288, 340, 1967, 63, 692, 690, 413, 26, 221, 327, 3510, 3217, 7256, 2839, 481, 52, 2260, 708, 355, 291, 14, 1985, 275, 747, 14, 515, 14, 4846, 8, 277, 14, 17411, 63, 3266, 63, 515, 9, 288, 587, 26, 355, 291, 14, 1985, 275, 747, 14, 515, 14, 4846, 8, 277, 14, 17411, 63, 1782, 63, 515, 9, 953, 291, 14, 32214, 275, 291, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 32214, 358, 288, 291, 14, 2558, 275, 291, 14, 739, 63, 604, 8, 277, 14, 17411, 63, 1782, 63, 515, 12, 283, 2558, 358, 288, 291, 14, 3266, 275, 291, 14, 739, 63, 604, 8, 277, 14, 1782, 63, 515, 12, 283, 3266, 358, 398, 340, 291, 14, 954, 2253, 315, 661, 17411, 297, 283, 17411, 13, 2171, 735, 288, 291, 14, 4998, 63, 17411, 63, 815, 342, 267, 15259, 916, 291, 14, 954, 2253, 315, 661, 80, 1590, 297, 283, 14310, 735, 221, 327, 510, 3553, 4079, 7256, 12, 519, 305, 1038, 267, 916, 291, 14, 954, 2253, 508, 283, 80, 1590, 356, 221, 327, 510, 3553, 4079, 7256, 288, 291, 14, 1802, 275, 291, 14, 354, 288, 291, 14, 8090, 344, 275, 291, 14, 739, 63, 604, 8, 277, 14, 1782, 63, 515, 12, 283, 344, 358, 267, 916, 291, 14, 954, 2253, 508, 283, 14310, 356, 221, 327, 519, 305, 1038, 288, 291, 14, 1802, 275, 291, 14, 354, 288, 291, 14, 8090, 344, 275, 747, 14, 515, 14, 4846, 8, 277, 14, 1782, 63, 515, 9, 398, 340, 365, 63, 1073, 26, 288, 291, 14, 8090, 344, 847, 283, 19774, 27244, 908, 8, 1782, 9, 339, 347, 1586, 63, 604, 8, 277, 12, 627, 589, 304, 267, 9638, 267, 11642, 805, 370, 1586, 282, 2849, 1004, 687, 282, 570, 14, 267, 7309, 503, 1655, 2633, 787, 4370, 12, 2985, 787, 16538, 543, 747, 14, 515, 14, 904, 14, 267, 1803, 488, 641, 2552, 703, 267, 408, 267, 862, 26, 288, 543, 1551, 8, 736, 14, 515, 14, 904, 2031, 589, 430, 465, 289, 26, 355, 1004, 275, 289, 14, 6407, 1252, 1913, 342, 288, 372, 1004, 267, 871, 5925, 26, 288, 372, 488, 421, 199, 318, 512, 412, 83, 8, 2613, 63, 4614, 29, 797, 304, 272, 7256, 275, 5739, 14, 6463, 2336, 2374, 15, 4707, 51, 13418, 3698, 327, 6137, 13, 262, 3012, 8873, 272, 7256, 14, 2880, 8, 6463, 14, 6463, 2336, 2374, 15, 4707, 19919, 10, 1333, 257, 327, 27923, 13, 2171, 543, 5705, 5253, 272, 7256, 14, 2880, 8, 6463, 14, 6463, 2336, 2374, 15, 4707, 1348, 45, 10, 1333, 257, 327, 27923, 13, 2171, 543, 445, 5196, 13, 1348, 45, 4690, 272, 7256,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1, 1, 1, 1 ]
ojengwa/odoo
addons/crm/report/crm_phonecall_report.py
309
3982
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp import tools from openerp.addons.crm import crm from openerp.osv import fields, osv AVAILABLE_STATES = [ ('draft', 'Draft'), ('open', 'Todo'), ('cancel', 'Cancelled'), ('done', 'Held'), ('pending', 'Pending') ] class crm_phonecall_report(osv.osv): """ Phone calls by user and section """ _name = "crm.phonecall.report" _description = "Phone calls by user and section" _auto = False _columns = { 'user_id':fields.many2one('res.users', 'User', readonly=True), 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True), 'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')], 'Priority'), 'nbr': fields.integer('# of Cases', readonly=True), # TDE FIXME master: rename into nbr_cases 'state': fields.selection(AVAILABLE_STATES, 'Status', readonly=True), 'create_date': fields.datetime('Create Date', readonly=True, select=True), 'delay_close': fields.float('Delay to close', digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"), 'duration': fields.float('Duration', digits=(16,2),readonly=True, group_operator="avg"), 'delay_open': fields.float('Delay to open',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to open the case"), 'categ_id': fields.many2one('crm.case.categ', 'Category', \ domain="[('section_id','=',section_id),\ ('object_id.model', '=', 'crm.phonecall')]"), 'partner_id': fields.many2one('res.partner', 'Partner' , readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), 'opening_date': fields.datetime('Opening Date', readonly=True, select=True), 'date_closed': fields.datetime('Close Date', readonly=True, select=True), } def init(self, cr): """ Phone Calls By User And Section @param cr: the current row, from the database cursor, """ tools.drop_view_if_exists(cr, 'crm_phonecall_report') cr.execute(""" create or replace view crm_phonecall_report as ( select id, c.date_open as opening_date, c.date_closed as date_closed, c.state, c.user_id, c.section_id, c.categ_id, c.partner_id, c.duration, c.company_id, c.priority, 1 as nbr, c.create_date as create_date, extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close, extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open from crm_phonecall c )""") # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 10788, 14, 15213, 492, 2467, 77, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 17377, 63, 23162, 275, 359, 272, 661, 7185, 297, 283, 18332, 659, 272, 661, 1490, 297, 283, 52, 19657, 659, 272, 661, 6406, 297, 283, 22127, 659, 272, 661, 4456, 297, 283, 40, 457, 659, 272, 661, 6455, 297, 283, 15960, 358, 199, 61, 421, 199, 533, 2467, 77, 63, 9339, 1250, 63, 3070, 8, 4795, 14, 4795, 304, 272, 408, 27585, 4882, 701, 922, 436, 3420, 408, 339, 485, 354, 275, 298, 15213, 14, 9339, 1250, 14, 3070, 2, 272, 485, 1802, 275, 298, 15199, 4882, 701, 922, 436, 3420, 2, 272, 485, 2495, 275, 756, 339, 485, 3406, 275, 469, 267, 283, 751, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 1899, 297, 6863, 29, 549, 395, 267, 283, 2792, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 15213, 14, 2546, 14, 2792, 297, 283, 8660, 297, 6863, 29, 549, 395, 267, 283, 6693, 356, 1504, 14, 5592, 8318, 16, 1673, 10281, 659, 661, 17, 1673, 6241, 659, 661, 18, 1673, 11688, 2665, 283, 14354, 659, 267, 283, 23299, 356, 1504, 14, 4115, 7863, 402, 445, 3274, 297, 6863, 29, 549, 395, 221, 327, 377, 1093, 7600, 5288, 26, 11441, 1901, 31646, 63, 9403, 267, 283, 929, 356, 1504, 14, 5592, 8, 17377, 63, 23162, 12, 283, 3694, 297, 6863, 29, 549, 395, 267, 283, 981, 63, 602, 356, 1504, 14, 2083, 360, 2499, 6148, 297, 6863, 29, 549, 12, 3504, 29, 549, 395, 267, 283, 5814, 63, 1600, 356, 1504, 14, 1609, 360, 10796, 370, 4002, 297, 7576, 2687, 975, 12, 18, 395, 6753, 29, 549, 12, 1572, 63, 3856, 628, 8595, 401, 3437, 628, 3259, 402, 577, 5758, 370, 4002, 314, 1930, 1288, 267, 283, 5553, 356, 1504, 14, 1609, 360, 13283, 297, 7576, 2687, 975, 12, 18, 395, 6753, 29, 549, 12, 1572, 63, 3856, 628, 8595, 1288, 267, 283, 5814, 63, 1490, 356, 1504, 14, 1609, 360, 10796, 370, 1551, 297, 7022, 2687, 975, 12, 18, 395, 6753, 29, 549, 12, 1572, 63, 3856, 628, 8595, 401, 3437, 628, 3259, 402, 577, 5758, 370, 1551, 314, 1930, 1288, 267, 283, 3533, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 15213, 14, 2546, 14, 3533, 297, 283, 7841, 297, 971, 717, 2881, 628, 19412, 2792, 63, 344, 18937, 2792, 63, 344, 26323, 717, 661, 785, 63, 344, 14, 1238, 297, 6291, 283, 15213, 14, 9339, 1250, 5440, 1288, 267, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 283, 24120, 7, 2360, 6863, 29, 549, 395, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 6863, 29, 549, 395, 267, 283, 21849, 63, 602, 356, 1504, 14, 2083, 360, 4299, 316, 6148, 297, 6863, 29, 549, 12, 3504, 29, 549, 395, 267, 283, 602, 63, 5938, 356, 1504, 14, 2083, 360, 4724, 6148, 297, 6863, 29, 549, 12, 3504, 29, 549, 395, 272, 789, 339, 347, 4205, 8, 277, 12, 2467, 304, 398, 408, 27585, 28055, 4885, 2876, 6061, 15247, 288, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 408, 267, 7249, 14, 4824, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 283, 15213, 63, 9339, 1250, 63, 3070, 358, 267, 2467, 14, 2526, 4852, 288, 1218, 503, 3350, 2455, 2467, 77, 63, 9339, 1250, 63, 3070, 465, 334, 355, 3504, 490, 1305, 12, 490, 286, 14, 602, 63, 1490, 465, 13618, 63, 602, 12, 490, 286, 14, 602, 63, 5938, 465, 1434, 63, 5938, 12, 490, 286, 14, 929, 12, 490, 286, 14, 751, 63, 344, 12, 490, 286, 14, 2792, 63, 344, 12, 490, 286, 14, 3533, 63, 344, 12, 490, 286, 14, 3899, 63, 344, 12, 490, 286, 14, 5553, 12, 490, 286, 14, 4627, 63, 344, 12, 490, 286, 14, 6693, 12, 490, 413, 465, 31646, 12, 490, 286, 14, 981, 63, 602, 465, 1218, 63, 602, 12, 490, 5536, 360, 7367, 7, 687, 334, 67, 14, 602, 63, 5938, 13, 67, 14, 981, 63, 602, 430, 7985, 11035, 10, 1194, 9, 465, 221, 7339, 63, 1600, 12, 490, 5536, 360, 7367, 7, 687, 334, 67, 14, 602, 63, 1490, 13, 67, 14, 981, 63, 602, 430, 7985, 11035, 10, 1194, 9, 465, 221, 7339, 63, 1490, 355, 687, 490, 2467, 77, 63, 9339, 1250, 286, 288, 776, 6141, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 492, 7249, 199, 504, 5166, 14, 10788, 14, 15213, 492, 2467, 77, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 17377, 63, 23162, 275, 359, 272, 661, 7185, 297, 283, 18332, 659, 272, 661, 1490, 297, 283, 52, 19657, 659, 272, 661, 6406, 297, 283, 22127, 659, 272, 661, 4456, 297, 283, 40, 457, 659, 272, 661, 6455, 297, 283, 15960, 358, 199, 61, 421, 199, 533, 2467, 77, 63, 9339, 1250, 63, 3070, 8, 4795, 14, 4795, 304, 272, 408, 27585, 4882, 701, 922, 436, 3420, 408, 339, 485, 354, 275, 298, 15213, 14, 9339, 1250, 14, 3070, 2, 272, 485, 1802, 275, 298, 15199, 4882, 701, 922, 436, 3420, 2, 272, 485, 2495, 275, 756, 339, 485, 3406, 275, 469, 267, 283, 751, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 1899, 297, 6863, 29, 549, 395, 267, 283, 2792, 63, 344, 356, 955, 14, 3479, 18, 368, 360, 15213, 14, 2546, 14, 2792, 297, 283, 8660, 297, 6863, 29, 549, 395, 267, 283, 6693, 356, 1504, 14, 5592, 8318, 16, 1673, 10281, 659, 661, 17, 1673, 6241, 659, 661, 18, 1673, 11688, 2665, 283, 14354, 659, 267, 283, 23299, 356, 1504, 14, 4115, 7863, 402, 445, 3274, 297, 6863, 29, 549, 395, 221, 327, 377, 1093, 7600, 5288, 26, 11441, 1901, 31646, 63, 9403, 267, 283, 929, 356, 1504, 14, 5592, 8, 17377, 63, 23162, 12, 283, 3694, 297, 6863, 29, 549, 395, 267, 283, 981, 63, 602, 356, 1504, 14, 2083, 360, 2499, 6148, 297, 6863, 29, 549, 12, 3504, 29, 549, 395, 267, 283, 5814, 63, 1600, 356, 1504, 14, 1609, 360, 10796, 370, 4002, 297, 7576, 2687, 975, 12, 18, 395, 6753, 29, 549, 12, 1572, 63, 3856, 628, 8595, 401, 3437, 628, 3259, 402, 577, 5758, 370, 4002, 314, 1930, 1288, 267, 283, 5553, 356, 1504, 14, 1609, 360, 13283, 297, 7576, 2687, 975, 12, 18, 395, 6753, 29, 549, 12, 1572, 63, 3856, 628, 8595, 1288, 267, 283, 5814, 63, 1490, 356, 1504, 14, 1609, 360, 10796, 370, 1551, 297, 7022, 2687, 975, 12, 18, 395, 6753, 29, 549, 12, 1572, 63, 3856, 628, 8595, 401, 3437, 628, 3259, 402, 577, 5758, 370, 1551, 314, 1930, 1288, 267, 283, 3533, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 15213, 14, 2546, 14, 3533, 297, 283, 7841, 297, 971, 717, 2881, 628, 19412, 2792, 63, 344, 18937, 2792, 63, 344, 26323, 717, 661, 785, 63, 344, 14, 1238, 297, 6291, 283, 15213, 14, 9339, 1250, 5440, 1288, 267, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 283, 24120, 7, 2360, 6863, 29, 549, 395, 267, 283, 4627, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 4627, 297, 283, 16063, 297, 6863, 29, 549, 395, 267, 283, 21849, 63, 602, 356, 1504, 14, 2083, 360, 4299, 316, 6148, 297, 6863, 29, 549, 12, 3504, 29, 549, 395, 267, 283, 602, 63, 5938, 356, 1504, 14, 2083, 360, 4724, 6148, 297, 6863, 29, 549, 12, 3504, 29, 549, 395, 272, 789, 339, 347, 4205, 8, 277, 12, 2467, 304, 398, 408, 27585, 28055, 4885, 2876, 6061, 15247, 288, 768, 635, 2467, 26, 314, 1453, 1962, 12, 687, 314, 3050, 3920, 12, 267, 408, 267, 7249, 14, 4824, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 283, 15213, 63, 9339, 1250, 63, 3070, 358, 267, 2467, 14, 2526, 4852, 288, 1218, 503, 3350, 2455, 2467, 77, 63, 9339, 1250, 63, 3070, 465, 334, 355, 3504, 490, 1305, 12, 490, 286, 14, 602, 63, 1490, 465, 13618, 63, 602, 12, 490, 286, 14, 602, 63, 5938, 465, 1434, 63, 5938, 12, 490, 286, 14, 929, 12, 490, 286, 14, 751, 63, 344, 12, 490, 286, 14, 2792, 63, 344, 12, 490, 286, 14, 3533, 63, 344, 12, 490, 286, 14, 3899, 63, 344, 12, 490, 286, 14, 5553, 12, 490, 286, 14, 4627, 63, 344, 12, 490, 286, 14, 6693, 12, 490, 413, 465, 31646, 12, 490, 286, 14, 981, 63, 602, 465, 1218, 63, 602, 12, 490, 5536, 360, 7367, 7, 687, 334, 67, 14, 602, 63, 5938, 13, 67, 14, 981, 63, 602, 430, 7985, 11035, 10, 1194, 9, 465, 221, 7339, 63, 1600, 12, 490, 5536, 360, 7367, 7, 687, 334, 67, 14, 602, 63, 1490, 13, 67, 14, 981, 63, 602, 430, 7985, 11035, 10, 1194, 9, 465, 221, 7339, 63, 1490, 355, 687, 490, 2467, 77, 63, 9339, 1250, 286, 288, 776, 6141, 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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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 ]
PeterWangIntel/chromium-crosswalk
third_party/libxml/src/check-relaxng-test-suite2.py
343
10578
#!/usr/bin/python import sys import time import os import string import StringIO sys.path.insert(0, "python") import libxml2 # Memory debug specific libxml2.debugMemory(1) debug = 0 quiet = 1 # # the testsuite description # CONF=os.path.join(os.path.dirname(__file__), "test/relaxng/testsuite.xml") LOG="check-relaxng-test-suite2.log" log = open(LOG, "w") nb_schemas_tests = 0 nb_schemas_success = 0 nb_schemas_failed = 0 nb_instances_tests = 0 nb_instances_success = 0 nb_instances_failed = 0 libxml2.lineNumbersDefault(1) # # Resolver callback # resources = {} def resolver(URL, ID, ctxt): global resources if resources.has_key(URL): return(StringIO.StringIO(resources[URL])) log.write("Resolver failure: asked %s\n" % (URL)) log.write("resources: %s\n" % (resources)) return None # # Load the previous results # #results = {} #previous = {} # #try: # res = libxml2.parseFile(RES) #except: # log.write("Could not parse %s" % (RES)) # # handle a valid instance # def handle_valid(node, schema): global log global nb_instances_success global nb_instances_failed instance = node.prop("dtd") if instance == None: instance = "" child = node.children while child != None: if child.type != 'text': instance = instance + child.serialize() child = child.next # mem = libxml2.debugMemory(1); try: doc = libxml2.parseDoc(instance) except: doc = None if doc == None: log.write("\nFailed to parse correct instance:\n-----\n") log.write(instance) log.write("\n-----\n") nb_instances_failed = nb_instances_failed + 1 return if debug: print "instance line %d" % (node.lineNo()) try: ctxt = schema.relaxNGNewValidCtxt() ret = doc.relaxNGValidateDoc(ctxt) del ctxt except: ret = -1 doc.freeDoc() # if mem != libxml2.debugMemory(1): # print "validating instance %d line %d leaks" % ( # nb_instances_tests, node.lineNo()) if ret != 0: log.write("\nFailed to validate correct instance:\n-----\n") log.write(instance) log.write("\n-----\n") nb_instances_failed = nb_instances_failed + 1 else: nb_instances_success = nb_instances_success + 1 # # handle an invalid instance # def handle_invalid(node, schema): global log global nb_instances_success global nb_instances_failed instance = node.prop("dtd") if instance == None: instance = "" child = node.children while child != None: if child.type != 'text': instance = instance + child.serialize() child = child.next # mem = libxml2.debugMemory(1); try: doc = libxml2.parseDoc(instance) except: doc = None if doc == None: log.write("\nStrange: failed to parse incorrect instance:\n-----\n") log.write(instance) log.write("\n-----\n") return if debug: print "instance line %d" % (node.lineNo()) try: ctxt = schema.relaxNGNewValidCtxt() ret = doc.relaxNGValidateDoc(ctxt) del ctxt except: ret = -1 doc.freeDoc() # mem2 = libxml2.debugMemory(1) # if mem != mem2: # print "validating instance %d line %d leaks %d bytes" % ( # nb_instances_tests, node.lineNo(), mem2 - mem) if ret == 0: log.write("\nFailed to detect validation problem in instance:\n-----\n") log.write(instance) log.write("\n-----\n") nb_instances_failed = nb_instances_failed + 1 else: nb_instances_success = nb_instances_success + 1 # # handle an incorrect test # def handle_correct(node): global log global nb_schemas_success global nb_schemas_failed schema = "" child = node.children while child != None: if child.type != 'text': schema = schema + child.serialize() child = child.next try: rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema)) rngs = rngp.relaxNGParse() except: rngs = None if rngs == None: log.write("\nFailed to compile correct schema:\n-----\n") log.write(schema) log.write("\n-----\n") nb_schemas_failed = nb_schemas_failed + 1 else: nb_schemas_success = nb_schemas_success + 1 return rngs def handle_incorrect(node): global log global nb_schemas_success global nb_schemas_failed schema = "" child = node.children while child != None: if child.type != 'text': schema = schema + child.serialize() child = child.next try: rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema)) rngs = rngp.relaxNGParse() except: rngs = None if rngs != None: log.write("\nFailed to detect schema error in:\n-----\n") log.write(schema) log.write("\n-----\n") nb_schemas_failed = nb_schemas_failed + 1 else: # log.write("\nSuccess detecting schema error in:\n-----\n") # log.write(schema) # log.write("\n-----\n") nb_schemas_success = nb_schemas_success + 1 return None # # resource handling: keep a dictionary of URL->string mappings # def handle_resource(node, dir): global resources try: name = node.prop('name') except: name = None if name == None or name == '': log.write("resource has no name") return; if dir != None: # name = libxml2.buildURI(name, dir) name = dir + '/' + name res = "" child = node.children while child != None: if child.type != 'text': res = res + child.serialize() child = child.next resources[name] = res # # dir handling: pseudo directory resources # def handle_dir(node, dir): try: name = node.prop('name') except: name = None if name == None or name == '': log.write("resource has no name") return; if dir != None: # name = libxml2.buildURI(name, dir) name = dir + '/' + name dirs = node.xpathEval('dir') for dir in dirs: handle_dir(dir, name) res = node.xpathEval('resource') for r in res: handle_resource(r, name) # # handle a testCase element # def handle_testCase(node): global nb_schemas_tests global nb_instances_tests global resources sections = node.xpathEval('string(section)') log.write("\n ======== test %d line %d section %s ==========\n" % ( nb_schemas_tests, node.lineNo(), sections)) resources = {} if debug: print "test %d line %d" % (nb_schemas_tests, node.lineNo()) dirs = node.xpathEval('dir') for dir in dirs: handle_dir(dir, None) res = node.xpathEval('resource') for r in res: handle_resource(r, None) tsts = node.xpathEval('incorrect') if tsts != []: if len(tsts) != 1: print "warning test line %d has more than one <incorrect> example" %(node.lineNo()) schema = handle_incorrect(tsts[0]) else: tsts = node.xpathEval('correct') if tsts != []: if len(tsts) != 1: print "warning test line %d has more than one <correct> example"% (node.lineNo()) schema = handle_correct(tsts[0]) else: print "warning <testCase> line %d has no <correct> nor <incorrect> child" % (node.lineNo()) nb_schemas_tests = nb_schemas_tests + 1; valids = node.xpathEval('valid') invalids = node.xpathEval('invalid') nb_instances_tests = nb_instances_tests + len(valids) + len(invalids) if schema != None: for valid in valids: handle_valid(valid, schema) for invalid in invalids: handle_invalid(invalid, schema) # # handle a testSuite element # def handle_testSuite(node, level = 0): global nb_schemas_tests, nb_schemas_success, nb_schemas_failed global nb_instances_tests, nb_instances_success, nb_instances_failed if level >= 1: old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tests = nb_instances_tests old_instances_success = nb_instances_success old_instances_failed = nb_instances_failed docs = node.xpathEval('documentation') authors = node.xpathEval('author') if docs != []: msg = "" for doc in docs: msg = msg + doc.content + " " if authors != []: msg = msg + "written by " for author in authors: msg = msg + author.content + " " if quiet == 0: print msg sections = node.xpathEval('section') if sections != [] and level <= 0: msg = "" for section in sections: msg = msg + section.content + " " if quiet == 0: print "Tests for section %s" % (msg) for test in node.xpathEval('testCase'): handle_testCase(test) for test in node.xpathEval('testSuite'): handle_testSuite(test, level + 1) if level >= 1 and sections != []: msg = "" for section in sections: msg = msg + section.content + " " print "Result of tests for section %s" % (msg) if nb_schemas_tests != old_schemas_tests: print "found %d test schemas: %d success %d failures" % ( nb_schemas_tests - old_schemas_tests, nb_schemas_success - old_schemas_success, nb_schemas_failed - old_schemas_failed) if nb_instances_tests != old_instances_tests: print "found %d test instances: %d success %d failures" % ( nb_instances_tests - old_instances_tests, nb_instances_success - old_instances_success, nb_instances_failed - old_instances_failed) # # Parse the conf file # libxml2.substituteEntitiesDefault(1); testsuite = libxml2.parseFile(CONF) # # Error and warnng callbacks # def callback(ctx, str): global log log.write("%s%s" % (ctx, str)) libxml2.registerErrorHandler(callback, "") libxml2.setEntityLoader(resolver) root = testsuite.getRootElement() if root.name != 'testSuite': print "%s doesn't start with a testSuite element, aborting" % (CONF) sys.exit(1) if quiet == 0: print "Running Relax NG testsuite" handle_testSuite(root) if quiet == 0: print "\nTOTAL:\n" if quiet == 0 or nb_schemas_failed != 0: print "found %d test schemas: %d success %d failures" % ( nb_schemas_tests, nb_schemas_success, nb_schemas_failed) if quiet == 0 or nb_instances_failed != 0: print "found %d test instances: %d success %d failures" % ( nb_instances_tests, nb_instances_success, nb_instances_failed) testsuite.freeDoc() # Memory debug specific libxml2.relaxNGCleanupTypes() libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: if quiet == 0: print "OK" else: print "Memory leak %d bytes" % (libxml2.debugMemory(1)) libxml2.dumpMemory()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 646, 984, 199, 646, 900, 199, 646, 747, 199, 646, 1059, 199, 646, 5228, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 298, 1548, 531, 199, 646, 15404, 18, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 1757, 8628, 8, 17, 9, 199, 1757, 275, 378, 199, 10243, 275, 413, 199, 199, 3, 199, 3, 314, 2295, 2577, 1369, 199, 3, 199, 3103, 29, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 298, 396, 15, 32676, 2753, 15, 14239, 14, 1652, 531, 199, 4947, 628, 1074, 13, 32676, 2753, 13, 396, 13, 5768, 18, 14, 793, 2, 199, 199, 793, 275, 1551, 8, 4947, 12, 298, 87, 531, 199, 4994, 63, 9482, 63, 2219, 275, 378, 199, 4994, 63, 9482, 63, 3742, 275, 378, 199, 4994, 63, 9482, 63, 4892, 275, 378, 199, 4994, 63, 5990, 63, 2219, 275, 378, 199, 4994, 63, 5990, 63, 3742, 275, 378, 199, 4994, 63, 5990, 63, 4892, 275, 378, 199, 199, 773, 1652, 18, 14, 604, 22951, 2698, 8, 17, 9, 199, 3, 199, 3, 26046, 3233, 199, 3, 199, 4435, 275, 1052, 199, 318, 15611, 8, 2632, 12, 2870, 12, 11216, 304, 272, 2288, 5944, 339, 340, 5944, 14, 1989, 63, 498, 8, 2632, 304, 267, 372, 8, 6424, 14, 6424, 8, 4435, 59, 2632, 2459, 272, 943, 14, 952, 480, 12407, 5988, 26, 20864, 450, 83, 60, 78, 2, 450, 334, 2632, 430, 272, 943, 14, 952, 480, 4435, 26, 450, 83, 60, 78, 2, 450, 334, 4435, 430, 272, 372, 488, 199, 199, 3, 199, 3, 7190, 314, 4136, 2058, 199, 3, 199, 3, 2604, 275, 1052, 199, 3, 6352, 275, 1052, 199, 3, 199, 3, 893, 26, 199, 3, 259, 522, 275, 15404, 18, 14, 1122, 1173, 8, 3830, 9, 199, 3, 2590, 26, 199, 3, 259, 943, 14, 952, 480, 6531, 440, 2198, 450, 83, 2, 450, 334, 3830, 430, 1362, 199, 3, 199, 3, 2429, 282, 1686, 1256, 199, 3, 199, 318, 2429, 63, 1078, 8, 932, 12, 4177, 304, 272, 2288, 943, 272, 2288, 8526, 63, 5990, 63, 3742, 272, 2288, 8526, 63, 5990, 63, 4892, 339, 1256, 275, 1031, 14, 4469, 480, 15662, 531, 272, 340, 1256, 508, 488, 26, 267, 1256, 275, 3087, 272, 1982, 275, 1031, 14, 3223, 272, 1830, 1982, 1137, 488, 26, 267, 340, 1982, 14, 466, 1137, 283, 505, 356, 6722, 1256, 275, 1256, 435, 1982, 14, 3549, 342, 199, 198, 1739, 275, 1982, 14, 2184, 199, 199, 3, 259, 7573, 275, 15404, 18, 14, 1757, 8628, 8, 17, 2736, 272, 862, 26, 199, 198, 1301, 275, 15404, 18, 14, 1122, 3768, 8, 842, 9, 272, 871, 26, 267, 1382, 275, 488, 339, 340, 1382, 508, 488, 26, 267, 943, 14, 952, 4582, 78, 4276, 370, 2198, 3211, 1256, 3427, 78, 375, 2696, 78, 531, 199, 198, 793, 14, 952, 8, 842, 9, 267, 943, 14, 952, 4582, 78, 375, 2696, 78, 531, 199, 198, 4994, 63, 5990, 63, 4892, 275, 8526, 63, 5990, 63, 4892, 435, 413, 199, 198, 1107, 339, 340, 3105, 26, 267, 870, 298, 842, 1004, 450, 68, 2, 450, 334, 932, 14, 604, 1944, 1012, 267, 272, 862, 26, 267, 11216, 275, 4177, 14, 32676, 12259, 4665, 3490, 35, 2424, 342, 199, 198, 3292, 275, 1382, 14, 32676, 12259, 12584, 3768, 8, 6725, 9, 199, 198, 2264, 11216, 272, 871, 26, 267, 2203, 275, 446, 17, 339, 1382, 14, 4624, 3768, 342, 199, 3, 259, 340, 7573, 1137, 15404, 18, 14, 1757, 8628, 8, 17, 304, 199, 3, 198, 1361, 298, 1078, 1958, 1256, 450, 68, 1004, 450, 68, 1026, 14631, 2, 450, 334, 199, 3, 1057, 221, 8526, 63, 5990, 63, 2219, 12, 1031, 14, 604, 1944, 1012, 339, 340, 2203, 1137, 378, 26, 267, 943, 14, 952, 4582, 78, 4276, 370, 4107, 3211, 1256, 3427, 78, 375, 2696, 78, 531, 199, 198, 793, 14, 952, 8, 842, 9, 267, 943, 14, 952, 4582, 78, 375, 2696, 78, 531, 199, 198, 4994, 63, 5990, 63, 4892, 275, 8526, 63, 5990, 63, 4892, 435, 413, 272, 587, 26, 199, 198, 4994, 63, 5990, 63, 3742, 275, 8526, 63, 5990, 63, 3742, 435, 413, 199, 199, 3, 199, 3, 2429, 376, 3866, 1256, 199, 3, 199, 318, 2429, 63, 3197, 8, 932, 12, 4177, 304, 272, 2288, 943, 272, 2288, 8526, 63, 5990, 63, 3742, 272, 2288, 8526, 63, 5990, 63, 4892, 339, 1256, 275, 1031, 14, 4469, 480, 15662, 531, 272, 340, 1256, 508, 488, 26, 267, 1256, 275, 3087, 272, 1982, 275, 1031, 14, 3223, 272, 1830, 1982, 1137, 488, 26, 267, 340, 1982, 14, 466, 1137, 283, 505, 356, 6722, 1256, 275, 1256, 435, 1982, 14, 3549, 342, 199, 198, 1739, 275, 1982, 14, 2184, 199, 199, 3, 259, 7573, 275, 15404, 18, 14, 1757, 8628, 8, 17, 2736, 339, 862, 26, 199, 198, 1301, 275, 15404, 18, 14, 1122, 3768, 8, 842, 9, 272, 871, 26, 267, 1382, 275, 488, 339, 340, 1382, 508, 488, 26, 267, 943, 14, 952, 4582, 78, 2848, 618, 26, 3405, 370, 2198, 8927, 1256, 3427, 78, 375, 2696, 78, 531, 199, 198, 793, 14, 952, 8, 842, 9, 267, 943, 14, 952, 4582, 78, 375, 2696, 78, 531, 199, 198, 1107, 339, 340, 3105, 26, 267, 870, 298, 842, 1004, 450, 68, 2, 450, 334, 932, 14, 604, 1944, 1012, 267, 272, 862, 26, 267, 11216, 275, 4177, 14, 32676, 12259, 4665, 3490, 35, 2424, 342, 199, 198, 3292, 275, 1382, 14, 32676, 12259, 12584, 3768, 8, 6725, 9, 199, 198, 2264, 11216, 339, 871, 26, 267, 2203, 275, 446, 17, 339, 1382, 14, 4624, 3768, 342, 199, 3, 259, 7573, 18, 275, 15404, 18, 14, 1757, 8628, 8, 17, 9, 199, 3, 259, 340, 7573, 1137, 7573, 18, 26, 199, 3, 198, 1361, 298, 1078, 1958, 1256, 450, 68, 1004, 450, 68, 1026, 14631, 450, 68, 2783, 2, 450, 334, 199, 3, 1057, 221, 8526, 63, 5990, 63, 2219, 12, 1031, 14, 604, 1944, 1062, 7573, 18, 446, 7573, 9, 2286, 340, 2203, 508, 378, 26, 267, 943, 14, 952, 4582, 78 ]
[ 2647, 15, 1393, 15, 1548, 199, 646, 984, 199, 646, 900, 199, 646, 747, 199, 646, 1059, 199, 646, 5228, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 298, 1548, 531, 199, 646, 15404, 18, 199, 199, 3, 15825, 3105, 2488, 199, 773, 1652, 18, 14, 1757, 8628, 8, 17, 9, 199, 1757, 275, 378, 199, 10243, 275, 413, 199, 199, 3, 199, 3, 314, 2295, 2577, 1369, 199, 3, 199, 3103, 29, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 298, 396, 15, 32676, 2753, 15, 14239, 14, 1652, 531, 199, 4947, 628, 1074, 13, 32676, 2753, 13, 396, 13, 5768, 18, 14, 793, 2, 199, 199, 793, 275, 1551, 8, 4947, 12, 298, 87, 531, 199, 4994, 63, 9482, 63, 2219, 275, 378, 199, 4994, 63, 9482, 63, 3742, 275, 378, 199, 4994, 63, 9482, 63, 4892, 275, 378, 199, 4994, 63, 5990, 63, 2219, 275, 378, 199, 4994, 63, 5990, 63, 3742, 275, 378, 199, 4994, 63, 5990, 63, 4892, 275, 378, 199, 199, 773, 1652, 18, 14, 604, 22951, 2698, 8, 17, 9, 199, 3, 199, 3, 26046, 3233, 199, 3, 199, 4435, 275, 1052, 199, 318, 15611, 8, 2632, 12, 2870, 12, 11216, 304, 272, 2288, 5944, 339, 340, 5944, 14, 1989, 63, 498, 8, 2632, 304, 267, 372, 8, 6424, 14, 6424, 8, 4435, 59, 2632, 2459, 272, 943, 14, 952, 480, 12407, 5988, 26, 20864, 450, 83, 60, 78, 2, 450, 334, 2632, 430, 272, 943, 14, 952, 480, 4435, 26, 450, 83, 60, 78, 2, 450, 334, 4435, 430, 272, 372, 488, 199, 199, 3, 199, 3, 7190, 314, 4136, 2058, 199, 3, 199, 3, 2604, 275, 1052, 199, 3, 6352, 275, 1052, 199, 3, 199, 3, 893, 26, 199, 3, 259, 522, 275, 15404, 18, 14, 1122, 1173, 8, 3830, 9, 199, 3, 2590, 26, 199, 3, 259, 943, 14, 952, 480, 6531, 440, 2198, 450, 83, 2, 450, 334, 3830, 430, 1362, 199, 3, 199, 3, 2429, 282, 1686, 1256, 199, 3, 199, 318, 2429, 63, 1078, 8, 932, 12, 4177, 304, 272, 2288, 943, 272, 2288, 8526, 63, 5990, 63, 3742, 272, 2288, 8526, 63, 5990, 63, 4892, 339, 1256, 275, 1031, 14, 4469, 480, 15662, 531, 272, 340, 1256, 508, 488, 26, 267, 1256, 275, 3087, 272, 1982, 275, 1031, 14, 3223, 272, 1830, 1982, 1137, 488, 26, 267, 340, 1982, 14, 466, 1137, 283, 505, 356, 6722, 1256, 275, 1256, 435, 1982, 14, 3549, 342, 199, 198, 1739, 275, 1982, 14, 2184, 199, 199, 3, 259, 7573, 275, 15404, 18, 14, 1757, 8628, 8, 17, 2736, 272, 862, 26, 199, 198, 1301, 275, 15404, 18, 14, 1122, 3768, 8, 842, 9, 272, 871, 26, 267, 1382, 275, 488, 339, 340, 1382, 508, 488, 26, 267, 943, 14, 952, 4582, 78, 4276, 370, 2198, 3211, 1256, 3427, 78, 375, 2696, 78, 531, 199, 198, 793, 14, 952, 8, 842, 9, 267, 943, 14, 952, 4582, 78, 375, 2696, 78, 531, 199, 198, 4994, 63, 5990, 63, 4892, 275, 8526, 63, 5990, 63, 4892, 435, 413, 199, 198, 1107, 339, 340, 3105, 26, 267, 870, 298, 842, 1004, 450, 68, 2, 450, 334, 932, 14, 604, 1944, 1012, 267, 272, 862, 26, 267, 11216, 275, 4177, 14, 32676, 12259, 4665, 3490, 35, 2424, 342, 199, 198, 3292, 275, 1382, 14, 32676, 12259, 12584, 3768, 8, 6725, 9, 199, 198, 2264, 11216, 272, 871, 26, 267, 2203, 275, 446, 17, 339, 1382, 14, 4624, 3768, 342, 199, 3, 259, 340, 7573, 1137, 15404, 18, 14, 1757, 8628, 8, 17, 304, 199, 3, 198, 1361, 298, 1078, 1958, 1256, 450, 68, 1004, 450, 68, 1026, 14631, 2, 450, 334, 199, 3, 1057, 221, 8526, 63, 5990, 63, 2219, 12, 1031, 14, 604, 1944, 1012, 339, 340, 2203, 1137, 378, 26, 267, 943, 14, 952, 4582, 78, 4276, 370, 4107, 3211, 1256, 3427, 78, 375, 2696, 78, 531, 199, 198, 793, 14, 952, 8, 842, 9, 267, 943, 14, 952, 4582, 78, 375, 2696, 78, 531, 199, 198, 4994, 63, 5990, 63, 4892, 275, 8526, 63, 5990, 63, 4892, 435, 413, 272, 587, 26, 199, 198, 4994, 63, 5990, 63, 3742, 275, 8526, 63, 5990, 63, 3742, 435, 413, 199, 199, 3, 199, 3, 2429, 376, 3866, 1256, 199, 3, 199, 318, 2429, 63, 3197, 8, 932, 12, 4177, 304, 272, 2288, 943, 272, 2288, 8526, 63, 5990, 63, 3742, 272, 2288, 8526, 63, 5990, 63, 4892, 339, 1256, 275, 1031, 14, 4469, 480, 15662, 531, 272, 340, 1256, 508, 488, 26, 267, 1256, 275, 3087, 272, 1982, 275, 1031, 14, 3223, 272, 1830, 1982, 1137, 488, 26, 267, 340, 1982, 14, 466, 1137, 283, 505, 356, 6722, 1256, 275, 1256, 435, 1982, 14, 3549, 342, 199, 198, 1739, 275, 1982, 14, 2184, 199, 199, 3, 259, 7573, 275, 15404, 18, 14, 1757, 8628, 8, 17, 2736, 339, 862, 26, 199, 198, 1301, 275, 15404, 18, 14, 1122, 3768, 8, 842, 9, 272, 871, 26, 267, 1382, 275, 488, 339, 340, 1382, 508, 488, 26, 267, 943, 14, 952, 4582, 78, 2848, 618, 26, 3405, 370, 2198, 8927, 1256, 3427, 78, 375, 2696, 78, 531, 199, 198, 793, 14, 952, 8, 842, 9, 267, 943, 14, 952, 4582, 78, 375, 2696, 78, 531, 199, 198, 1107, 339, 340, 3105, 26, 267, 870, 298, 842, 1004, 450, 68, 2, 450, 334, 932, 14, 604, 1944, 1012, 267, 272, 862, 26, 267, 11216, 275, 4177, 14, 32676, 12259, 4665, 3490, 35, 2424, 342, 199, 198, 3292, 275, 1382, 14, 32676, 12259, 12584, 3768, 8, 6725, 9, 199, 198, 2264, 11216, 339, 871, 26, 267, 2203, 275, 446, 17, 339, 1382, 14, 4624, 3768, 342, 199, 3, 259, 7573, 18, 275, 15404, 18, 14, 1757, 8628, 8, 17, 9, 199, 3, 259, 340, 7573, 1137, 7573, 18, 26, 199, 3, 198, 1361, 298, 1078, 1958, 1256, 450, 68, 1004, 450, 68, 1026, 14631, 450, 68, 2783, 2, 450, 334, 199, 3, 1057, 221, 8526, 63, 5990, 63, 2219, 12, 1031, 14, 604, 1944, 1062, 7573, 18, 446, 7573, 9, 2286, 340, 2203, 508, 378, 26, 267, 943, 14, 952, 4582, 78, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jodal/comics
comics/core/migrations/0001_initial.py
1
5776
import django.core.files.storage from django.db import migrations, models import comics.core.models class Migration(migrations.Migration): dependencies = [] operations = [ migrations.CreateModel( name="Comic", fields=[ ( "id", models.AutoField( verbose_name="ID", serialize=False, auto_created=True, primary_key=True, ), ), ( "name", models.CharField(help_text="Name of the comic", max_length=100), ), ( "slug", models.SlugField( help_text="For file paths and URLs", unique=True, max_length=100, verbose_name="Short name", ), ), ( "language", models.CharField( help_text="The language of the comic", max_length=2, choices=[("en", "English"), ("no", "Norwegian")], ), ), ( "url", models.URLField( help_text="URL to the official website", verbose_name="URL", blank=True, ), ), ( "active", models.BooleanField( default=True, help_text="Wheter the comic is still being crawled", ), ), ( "start_date", models.DateField( help_text="First published at", null=True, blank=True ), ), ( "end_date", models.DateField( help_text="Last published at, if comic has been cancelled", null=True, blank=True, ), ), ( "rights", models.CharField( help_text="Author, copyright, and/or licensing " "information", max_length=100, blank=True, ), ), ( "added", models.DateTimeField( help_text="Time the comic was added to the site", auto_now_add=True, ), ), ], options={ "ordering": ["name"], "db_table": "comics_comic", }, bases=(models.Model,), ), migrations.CreateModel( name="Image", fields=[ ( "id", models.AutoField( verbose_name="ID", serialize=False, auto_created=True, primary_key=True, ), ), ( "file", models.ImageField( height_field="height", storage=django.core.files.storage.FileSystemStorage( base_url="/media/", location="/home/jodal/dev/comics/media", ), width_field="width", upload_to=comics.core.models.image_file_path, ), ), ("checksum", models.CharField(max_length=64, db_index=True)), ("title", models.CharField(max_length=255, blank=True)), ("text", models.TextField(blank=True)), ("fetched", models.DateTimeField(auto_now_add=True)), ("height", models.IntegerField()), ("width", models.IntegerField()), ( "comic", models.ForeignKey(to="core.Comic", on_delete=models.CASCADE), ), ], options={ "db_table": "comics_image", }, bases=(models.Model,), ), migrations.CreateModel( name="Release", fields=[ ( "id", models.AutoField( verbose_name="ID", serialize=False, auto_created=True, primary_key=True, ), ), ( "pub_date", models.DateField(verbose_name="publication date", db_index=True), ), ( "fetched", models.DateTimeField(auto_now_add=True, db_index=True), ), ( "comic", models.ForeignKey(to="core.Comic", on_delete=models.CASCADE), ), ( "images", models.ManyToManyField(related_name="releases", to="core.Image"), ), ], options={ "db_table": "comics_release", "get_latest_by": "pub_date", }, bases=(models.Model,), ), ]
agpl-3.0
[ 646, 1639, 14, 1018, 14, 1725, 14, 3494, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 199, 646, 2414, 2932, 14, 1018, 14, 992, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 942, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 628, 4373, 530, 401, 288, 1504, 1524, 355, 334, 490, 298, 344, 401, 490, 1709, 14, 4378, 8, 717, 3376, 63, 354, 628, 998, 401, 717, 8437, 29, 797, 12, 717, 2599, 63, 3966, 29, 549, 12, 717, 5062, 63, 498, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 354, 401, 490, 1709, 14, 2183, 8, 3437, 63, 505, 628, 985, 402, 314, 2414, 530, 401, 1390, 63, 1267, 29, 1960, 395, 355, 2318, 355, 334, 490, 298, 5464, 401, 490, 1709, 14, 17315, 8, 717, 1720, 63, 505, 628, 1858, 570, 3792, 436, 10867, 401, 717, 3747, 29, 549, 12, 717, 1390, 63, 1267, 29, 1960, 12, 717, 3376, 63, 354, 628, 10039, 536, 401, 490, 2318, 355, 2318, 355, 334, 490, 298, 3671, 401, 490, 1709, 14, 2183, 8, 717, 1720, 63, 505, 628, 1918, 2637, 402, 314, 2414, 530, 401, 717, 1390, 63, 1267, 29, 18, 12, 717, 3415, 1524, 480, 287, 401, 298, 19410, 1288, 1689, 889, 401, 298, 23008, 1129, 71, 5653, 17857, 490, 2318, 355, 2318, 355, 334, 490, 298, 633, 401, 490, 1709, 14, 17363, 8, 717, 1720, 63, 505, 628, 2632, 370, 314, 25410, 10691, 401, 717, 3376, 63, 354, 628, 2632, 401, 717, 4596, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 2682, 401, 490, 1709, 14, 5036, 8, 717, 849, 29, 549, 12, 717, 1720, 63, 505, 628, 55, 426, 351, 314, 2414, 530, 365, 5139, 3769, 286, 1773, 1146, 401, 490, 2318, 355, 2318, 355, 334, 490, 298, 928, 63, 602, 401, 490, 1709, 14, 14071, 8, 717, 1720, 63, 505, 628, 7147, 3267, 737, 401, 2973, 29, 549, 12, 4596, 29, 549, 490, 2318, 355, 2318, 355, 334, 490, 298, 500, 63, 602, 401, 490, 1709, 14, 14071, 8, 717, 1720, 63, 505, 628, 6090, 3267, 737, 12, 340, 2414, 530, 965, 2757, 20115, 401, 717, 2973, 29, 549, 12, 717, 4596, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 17307, 401, 490, 1709, 14, 2183, 8, 717, 1720, 63, 505, 628, 5949, 12, 4248, 12, 436, 15, 269, 32572, 298, 298, 11697, 401, 717, 1390, 63, 1267, 29, 1960, 12, 717, 4596, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 3270, 401, 490, 1709, 14, 4626, 8, 717, 1720, 63, 505, 628, 1366, 314, 2414, 530, 1990, 3483, 370, 314, 4770, 401, 717, 2599, 63, 2131, 63, 525, 29, 549, 12, 490, 2318, 355, 2318, 288, 2156, 288, 1511, 3126, 355, 298, 7128, 582, 2097, 354, 2255, 355, 298, 697, 63, 1224, 582, 298, 957, 2932, 63, 957, 530, 401, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 628, 3491, 401, 288, 1504, 1524, 355, 334, 490, 298, 344, 401, 490, 1709, 14, 4378, 8, 717, 3376, 63, 354, 628, 998, 401, 717, 8437, 29, 797, 12, 717, 2599, 63, 3966, 29, 549, 12, 717, 5062, 63, 498, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 493, 401, 490, 1709, 14, 21910, 8, 717, 4569, 63, 698, 628, 3333, 401, 717, 4887, 29, 1176, 14, 1018, 14, 1725, 14, 3494, 14, 17521, 6408, 8, 1169, 1300, 63, 633, 9555, 4603, 10665, 1169, 2909, 9555, 4219, 15, 74, 364, 279, 15, 2374, 15, 957, 2932, 15, 4603, 401, 717, 2318, 717, 3462, 63, 698, 628, 2063, 401, 717, 5802, 63, 475, 29, 957, 2932, 14, 1018, 14, 992, 14, 1569, 63, 493, 63, 515, 12, 490, 2318, 355, 2318, 355, 1689, 8928, 401, 1709, 14, 2183, 8, 988, 63, 1267, 29, 772, 12, 1592, 63, 1080, 29, 549, 1826, 355, 1689, 1213, 401, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 4596, 29, 549, 1826, 355, 1689, 505, 401, 1709, 14, 6254, 8, 2500, 29, 549, 1826, 355, 1689, 27236, 401, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 1689, 3333, 401, 1709, 14, 3901, 4000, 355, 1689, 2063, 401, 1709, 14, 3901, 4000, 355, 334, 490, 298, 957, 530, 401, 490, 1709, 14, 3190, 8, 475, 628, 1018, 14, 4373, 530, 401, 641, 63, 1807, 29, 992, 14, 10855, 395, 355, 2318, 288, 2156, 288, 1511, 3126, 355, 298, 697, 63, 1224, 582, 298, 957, 2932, 63, 1569, 401, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 628, 9625, 401, 288, 1504, 1524, 355, 334, 490, 298, 344, 401, 490, 1709, 14, 4378, 8, 717, 3376, 63, 354, 628, 998, 401, 717, 8437, 29, 797, 12, 717, 2599, 63, 3966, 29, 549, 12, 717, 5062, 63, 498, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 5645, 63, 602, 401, 490, 1709, 14, 14071, 8, 3832, 63, 354, 628, 22678, 1434, 401, 1592, 63, 1080, 29, 549, 395, 355, 2318, 355, 334, 490, 298, 27236, 401, 490, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 1592, 63, 1080, 29, 549, 395, 355, 2318, 355, 334, 490, 298, 957, 530, 401, 490, 1709, 14, 3190, 8, 475, 628, 1018, 14, 4373, 530, 401, 641, 63, 1807, 29, 992, 14, 10855, 395, 355, 2318, 355, 334, 490, 298, 4782, 401, 490, 1709, 14, 7624, 8, 2407, 63, 354, 628, 11840, 401, 370, 628, 1018, 14, 3491, 1288, 355, 2318, 288, 2156, 288, 1511, 3126, 355, 298, 697, 63, 1224, 582, 298, 957, 2932, 63, 3221, 401, 355, 298, 362, 63, 7410, 63, 991, 582, 298, 5645, 63, 602, 401, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 1018, 14, 1725, 14, 3494, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 199, 646, 2414, 2932, 14, 1018, 14, 992, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 942, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 628, 4373, 530, 401, 288, 1504, 1524, 355, 334, 490, 298, 344, 401, 490, 1709, 14, 4378, 8, 717, 3376, 63, 354, 628, 998, 401, 717, 8437, 29, 797, 12, 717, 2599, 63, 3966, 29, 549, 12, 717, 5062, 63, 498, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 354, 401, 490, 1709, 14, 2183, 8, 3437, 63, 505, 628, 985, 402, 314, 2414, 530, 401, 1390, 63, 1267, 29, 1960, 395, 355, 2318, 355, 334, 490, 298, 5464, 401, 490, 1709, 14, 17315, 8, 717, 1720, 63, 505, 628, 1858, 570, 3792, 436, 10867, 401, 717, 3747, 29, 549, 12, 717, 1390, 63, 1267, 29, 1960, 12, 717, 3376, 63, 354, 628, 10039, 536, 401, 490, 2318, 355, 2318, 355, 334, 490, 298, 3671, 401, 490, 1709, 14, 2183, 8, 717, 1720, 63, 505, 628, 1918, 2637, 402, 314, 2414, 530, 401, 717, 1390, 63, 1267, 29, 18, 12, 717, 3415, 1524, 480, 287, 401, 298, 19410, 1288, 1689, 889, 401, 298, 23008, 1129, 71, 5653, 17857, 490, 2318, 355, 2318, 355, 334, 490, 298, 633, 401, 490, 1709, 14, 17363, 8, 717, 1720, 63, 505, 628, 2632, 370, 314, 25410, 10691, 401, 717, 3376, 63, 354, 628, 2632, 401, 717, 4596, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 2682, 401, 490, 1709, 14, 5036, 8, 717, 849, 29, 549, 12, 717, 1720, 63, 505, 628, 55, 426, 351, 314, 2414, 530, 365, 5139, 3769, 286, 1773, 1146, 401, 490, 2318, 355, 2318, 355, 334, 490, 298, 928, 63, 602, 401, 490, 1709, 14, 14071, 8, 717, 1720, 63, 505, 628, 7147, 3267, 737, 401, 2973, 29, 549, 12, 4596, 29, 549, 490, 2318, 355, 2318, 355, 334, 490, 298, 500, 63, 602, 401, 490, 1709, 14, 14071, 8, 717, 1720, 63, 505, 628, 6090, 3267, 737, 12, 340, 2414, 530, 965, 2757, 20115, 401, 717, 2973, 29, 549, 12, 717, 4596, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 17307, 401, 490, 1709, 14, 2183, 8, 717, 1720, 63, 505, 628, 5949, 12, 4248, 12, 436, 15, 269, 32572, 298, 298, 11697, 401, 717, 1390, 63, 1267, 29, 1960, 12, 717, 4596, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 3270, 401, 490, 1709, 14, 4626, 8, 717, 1720, 63, 505, 628, 1366, 314, 2414, 530, 1990, 3483, 370, 314, 4770, 401, 717, 2599, 63, 2131, 63, 525, 29, 549, 12, 490, 2318, 355, 2318, 288, 2156, 288, 1511, 3126, 355, 298, 7128, 582, 2097, 354, 2255, 355, 298, 697, 63, 1224, 582, 298, 957, 2932, 63, 957, 530, 401, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 628, 3491, 401, 288, 1504, 1524, 355, 334, 490, 298, 344, 401, 490, 1709, 14, 4378, 8, 717, 3376, 63, 354, 628, 998, 401, 717, 8437, 29, 797, 12, 717, 2599, 63, 3966, 29, 549, 12, 717, 5062, 63, 498, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 493, 401, 490, 1709, 14, 21910, 8, 717, 4569, 63, 698, 628, 3333, 401, 717, 4887, 29, 1176, 14, 1018, 14, 1725, 14, 3494, 14, 17521, 6408, 8, 1169, 1300, 63, 633, 9555, 4603, 10665, 1169, 2909, 9555, 4219, 15, 74, 364, 279, 15, 2374, 15, 957, 2932, 15, 4603, 401, 717, 2318, 717, 3462, 63, 698, 628, 2063, 401, 717, 5802, 63, 475, 29, 957, 2932, 14, 1018, 14, 992, 14, 1569, 63, 493, 63, 515, 12, 490, 2318, 355, 2318, 355, 1689, 8928, 401, 1709, 14, 2183, 8, 988, 63, 1267, 29, 772, 12, 1592, 63, 1080, 29, 549, 1826, 355, 1689, 1213, 401, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 4596, 29, 549, 1826, 355, 1689, 505, 401, 1709, 14, 6254, 8, 2500, 29, 549, 1826, 355, 1689, 27236, 401, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 355, 1689, 3333, 401, 1709, 14, 3901, 4000, 355, 1689, 2063, 401, 1709, 14, 3901, 4000, 355, 334, 490, 298, 957, 530, 401, 490, 1709, 14, 3190, 8, 475, 628, 1018, 14, 4373, 530, 401, 641, 63, 1807, 29, 992, 14, 10855, 395, 355, 2318, 288, 2156, 288, 1511, 3126, 355, 298, 697, 63, 1224, 582, 298, 957, 2932, 63, 1569, 401, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 628, 9625, 401, 288, 1504, 1524, 355, 334, 490, 298, 344, 401, 490, 1709, 14, 4378, 8, 717, 3376, 63, 354, 628, 998, 401, 717, 8437, 29, 797, 12, 717, 2599, 63, 3966, 29, 549, 12, 717, 5062, 63, 498, 29, 549, 12, 490, 2318, 355, 2318, 355, 334, 490, 298, 5645, 63, 602, 401, 490, 1709, 14, 14071, 8, 3832, 63, 354, 628, 22678, 1434, 401, 1592, 63, 1080, 29, 549, 395, 355, 2318, 355, 334, 490, 298, 27236, 401, 490, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 12, 1592, 63, 1080, 29, 549, 395, 355, 2318, 355, 334, 490, 298, 957, 530, 401, 490, 1709, 14, 3190, 8, 475, 628, 1018, 14, 4373, 530, 401, 641, 63, 1807, 29, 992, 14, 10855, 395, 355, 2318, 355, 334, 490, 298, 4782, 401, 490, 1709, 14, 7624, 8, 2407, 63, 354, 628, 11840, 401, 370, 628, 1018, 14, 3491, 1288, 355, 2318, 288, 2156, 288, 1511, 3126, 355, 298, 697, 63, 1224, 582, 298, 957, 2932, 63, 3221, 401, 355, 298, 362, 63, 7410, 63, 991, 582, 298, 5645, 63, 602, 401, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pbrod/scipy
scipy/interpolate/tests/test_ndgriddata.py
50
7259
from __future__ import division, print_function, absolute_import import numpy as np from numpy.testing import (assert_equal, assert_array_equal, assert_allclose, run_module_suite, assert_raises) from scipy.interpolate import griddata, NearestNDInterpolator class TestGriddata(object): def test_fill_value(self): x = [(0,0), (0,1), (1,0)] y = [1, 2, 3] yi = griddata(x, y, [(1,1), (1,2), (0,0)], fill_value=-1) assert_array_equal(yi, [-1., -1, 1]) yi = griddata(x, y, [(1,1), (1,2), (0,0)]) assert_array_equal(yi, [np.nan, np.nan, 1]) def test_alternative_call(self): x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)], dtype=np.double) y = (np.arange(x.shape[0], dtype=np.double)[:,None] + np.array([0,1])[None,:]) for method in ('nearest', 'linear', 'cubic'): for rescale in (True, False): msg = repr((method, rescale)) yi = griddata((x[:,0], x[:,1]), y, (x[:,0], x[:,1]), method=method, rescale=rescale) assert_allclose(y, yi, atol=1e-14, err_msg=msg) def test_multivalue_2d(self): x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)], dtype=np.double) y = (np.arange(x.shape[0], dtype=np.double)[:,None] + np.array([0,1])[None,:]) for method in ('nearest', 'linear', 'cubic'): for rescale in (True, False): msg = repr((method, rescale)) yi = griddata(x, y, x, method=method, rescale=rescale) assert_allclose(y, yi, atol=1e-14, err_msg=msg) def test_multipoint_2d(self): x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)], dtype=np.double) y = np.arange(x.shape[0], dtype=np.double) xi = x[:,None,:] + np.array([0,0,0])[None,:,None] for method in ('nearest', 'linear', 'cubic'): for rescale in (True, False): msg = repr((method, rescale)) yi = griddata(x, y, xi, method=method, rescale=rescale) assert_equal(yi.shape, (5, 3), err_msg=msg) assert_allclose(yi, np.tile(y[:,None], (1, 3)), atol=1e-14, err_msg=msg) def test_complex_2d(self): x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)], dtype=np.double) y = np.arange(x.shape[0], dtype=np.double) y = y - 2j*y[::-1] xi = x[:,None,:] + np.array([0,0,0])[None,:,None] for method in ('nearest', 'linear', 'cubic'): for rescale in (True, False): msg = repr((method, rescale)) yi = griddata(x, y, xi, method=method, rescale=rescale) assert_equal(yi.shape, (5, 3), err_msg=msg) assert_allclose(yi, np.tile(y[:,None], (1, 3)), atol=1e-14, err_msg=msg) def test_1d(self): x = np.array([1, 2.5, 3, 4.5, 5, 6]) y = np.array([1, 2, 0, 3.9, 2, 1]) for method in ('nearest', 'linear', 'cubic'): assert_allclose(griddata(x, y, x, method=method), y, err_msg=method, atol=1e-14) assert_allclose(griddata(x.reshape(6, 1), y, x, method=method), y, err_msg=method, atol=1e-14) assert_allclose(griddata((x,), y, (x,), method=method), y, err_msg=method, atol=1e-14) def test_1d_borders(self): # Test for nearest neighbor case with xi outside # the range of the values. x = np.array([1, 2.5, 3, 4.5, 5, 6]) y = np.array([1, 2, 0, 3.9, 2, 1]) xi = np.array([0.9, 6.5]) yi_should = np.array([1.0, 1.0]) method = 'nearest' assert_allclose(griddata(x, y, xi, method=method), yi_should, err_msg=method, atol=1e-14) assert_allclose(griddata(x.reshape(6, 1), y, xi, method=method), yi_should, err_msg=method, atol=1e-14) assert_allclose(griddata((x, ), y, (xi, ), method=method), yi_should, err_msg=method, atol=1e-14) def test_1d_unsorted(self): x = np.array([2.5, 1, 4.5, 5, 6, 3]) y = np.array([1, 2, 0, 3.9, 2, 1]) for method in ('nearest', 'linear', 'cubic'): assert_allclose(griddata(x, y, x, method=method), y, err_msg=method, atol=1e-10) assert_allclose(griddata(x.reshape(6, 1), y, x, method=method), y, err_msg=method, atol=1e-10) assert_allclose(griddata((x,), y, (x,), method=method), y, err_msg=method, atol=1e-10) def test_square_rescale_manual(self): points = np.array([(0,0), (0,100), (10,100), (10,0), (1, 5)], dtype=np.double) points_rescaled = np.array([(0,0), (0,1), (1,1), (1,0), (0.1, 0.05)], dtype=np.double) values = np.array([1., 2., -3., 5., 9.], dtype=np.double) xx, yy = np.broadcast_arrays(np.linspace(0, 10, 14)[:,None], np.linspace(0, 100, 14)[None,:]) xx = xx.ravel() yy = yy.ravel() xi = np.array([xx, yy]).T.copy() for method in ('nearest', 'linear', 'cubic'): msg = method zi = griddata(points_rescaled, values, xi/np.array([10, 100.]), method=method) zi_rescaled = griddata(points, values, xi, method=method, rescale=True) assert_allclose(zi, zi_rescaled, err_msg=msg, atol=1e-12) def test_xi_1d(self): # Check that 1-D xi is interpreted as a coordinate x = np.array([(0,0), (-0.5,-0.5), (-0.5,0.5), (0.5, 0.5), (0.25, 0.3)], dtype=np.double) y = np.arange(x.shape[0], dtype=np.double) y = y - 2j*y[::-1] xi = np.array([0.5, 0.5]) for method in ('nearest', 'linear', 'cubic'): p1 = griddata(x, y, xi, method=method) p2 = griddata(x, y, xi[None,:], method=method) assert_allclose(p1, p2, err_msg=method) xi1 = np.array([0.5]) xi3 = np.array([0.5, 0.5, 0.5]) assert_raises(ValueError, griddata, x, y, xi1, method=method) assert_raises(ValueError, griddata, x, y, xi3, method=method) def test_nearest_options(): # smoke test that NearestNDInterpolator accept cKDTree options npts, nd = 4, 3 x = np.arange(npts*nd).reshape((npts, nd)) y = np.arange(npts) nndi = NearestNDInterpolator(x, y) opts = {'balanced_tree': False, 'compact_nodes': False} nndi_o = NearestNDInterpolator(x, y, tree_options=opts) assert_allclose(nndi(x), nndi_o(x), atol=1e-14) 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, 334, 479, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 702, 63, 7520, 12, 267, 1255, 63, 578, 63, 5768, 12, 702, 63, 3536, 9, 199, 199, 504, 7026, 14, 21294, 492, 6068, 576, 12, 5612, 9540, 8711, 22713, 707, 421, 199, 533, 1379, 7900, 576, 8, 785, 304, 272, 347, 511, 63, 4498, 63, 585, 8, 277, 304, 267, 671, 275, 3842, 16, 12, 16, 395, 334, 16, 12, 17, 395, 334, 17, 12, 16, 1874, 267, 612, 275, 359, 17, 12, 499, 12, 650, 61, 398, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 3842, 17, 12, 17, 395, 334, 17, 12, 18, 395, 334, 16, 12, 16, 4360, 5554, 63, 585, 4022, 17, 9, 267, 702, 63, 1144, 63, 1452, 8, 21643, 12, 5243, 17, 2020, 446, 17, 12, 413, 566, 398, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 3842, 17, 12, 17, 395, 334, 17, 12, 18, 395, 334, 16, 12, 16, 3948, 267, 702, 63, 1144, 63, 1452, 8, 21643, 12, 359, 1590, 14, 4304, 12, 980, 14, 4304, 12, 413, 566, 339, 347, 511, 63, 19389, 63, 1250, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 334, 1590, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 24517, 403, 61, 1467, 435, 980, 14, 1144, 779, 16, 12, 17, 11057, 403, 12, 5728, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 1332, 88, 3981, 16, 467, 671, 3981, 17, 2522, 612, 12, 334, 88, 3981, 16, 467, 671, 3981, 17, 2522, 1083, 29, 765, 12, 2892, 522, 2357, 29, 470, 2357, 9, 355, 702, 63, 7520, 8, 89, 12, 28008, 12, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 3029, 585, 63, 18, 68, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 334, 1590, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 24517, 403, 61, 1467, 435, 980, 14, 1144, 779, 16, 12, 17, 11057, 403, 12, 5728, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 671, 12, 1083, 29, 765, 12, 522, 2357, 29, 470, 2357, 9, 355, 702, 63, 7520, 8, 89, 12, 28008, 12, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 3029, 1403, 63, 18, 68, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 980, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 9, 398, 19905, 275, 671, 3981, 403, 21063, 435, 980, 14, 1144, 779, 16, 12, 16, 12, 16, 11057, 403, 32306, 403, 61, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 19905, 12, 1083, 29, 765, 12, 522, 2357, 29, 470, 2357, 9, 2234, 702, 63, 1452, 8, 21643, 14, 1392, 12, 334, 21, 12, 650, 395, 2329, 63, 1328, 29, 1328, 9, 355, 702, 63, 7520, 8, 21643, 12, 980, 14, 7172, 8, 89, 3981, 403, 467, 334, 17, 12, 650, 1826, 1816, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 5254, 63, 18, 68, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 980, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 612, 446, 499, 74, 10, 89, 14172, 17, 61, 398, 19905, 275, 671, 3981, 403, 21063, 435, 980, 14, 1144, 779, 16, 12, 16, 12, 16, 11057, 403, 32306, 403, 61, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 19905, 12, 1083, 29, 765, 12, 522, 2357, 29, 470, 2357, 9, 2234, 702, 63, 1452, 8, 21643, 14, 1392, 12, 334, 21, 12, 650, 395, 2329, 63, 1328, 29, 1328, 9, 355, 702, 63, 7520, 8, 21643, 12, 980, 14, 7172, 8, 89, 3981, 403, 467, 334, 17, 12, 650, 1826, 1816, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347 ]
[ 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, 334, 479, 63, 1452, 12, 702, 63, 1144, 63, 1452, 12, 702, 63, 7520, 12, 267, 1255, 63, 578, 63, 5768, 12, 702, 63, 3536, 9, 199, 199, 504, 7026, 14, 21294, 492, 6068, 576, 12, 5612, 9540, 8711, 22713, 707, 421, 199, 533, 1379, 7900, 576, 8, 785, 304, 272, 347, 511, 63, 4498, 63, 585, 8, 277, 304, 267, 671, 275, 3842, 16, 12, 16, 395, 334, 16, 12, 17, 395, 334, 17, 12, 16, 1874, 267, 612, 275, 359, 17, 12, 499, 12, 650, 61, 398, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 3842, 17, 12, 17, 395, 334, 17, 12, 18, 395, 334, 16, 12, 16, 4360, 5554, 63, 585, 4022, 17, 9, 267, 702, 63, 1144, 63, 1452, 8, 21643, 12, 5243, 17, 2020, 446, 17, 12, 413, 566, 398, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 3842, 17, 12, 17, 395, 334, 17, 12, 18, 395, 334, 16, 12, 16, 3948, 267, 702, 63, 1144, 63, 1452, 8, 21643, 12, 359, 1590, 14, 4304, 12, 980, 14, 4304, 12, 413, 566, 339, 347, 511, 63, 19389, 63, 1250, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 334, 1590, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 24517, 403, 61, 1467, 435, 980, 14, 1144, 779, 16, 12, 17, 11057, 403, 12, 5728, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 1332, 88, 3981, 16, 467, 671, 3981, 17, 2522, 612, 12, 334, 88, 3981, 16, 467, 671, 3981, 17, 2522, 1083, 29, 765, 12, 2892, 522, 2357, 29, 470, 2357, 9, 355, 702, 63, 7520, 8, 89, 12, 28008, 12, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 3029, 585, 63, 18, 68, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 334, 1590, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 24517, 403, 61, 1467, 435, 980, 14, 1144, 779, 16, 12, 17, 11057, 403, 12, 5728, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 671, 12, 1083, 29, 765, 12, 522, 2357, 29, 470, 2357, 9, 355, 702, 63, 7520, 8, 89, 12, 28008, 12, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 3029, 1403, 63, 18, 68, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 980, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 9, 398, 19905, 275, 671, 3981, 403, 21063, 435, 980, 14, 1144, 779, 16, 12, 16, 12, 16, 11057, 403, 32306, 403, 61, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 19905, 12, 1083, 29, 765, 12, 522, 2357, 29, 470, 2357, 9, 2234, 702, 63, 1452, 8, 21643, 14, 1392, 12, 334, 21, 12, 650, 395, 2329, 63, 1328, 29, 1328, 9, 355, 702, 63, 7520, 8, 21643, 12, 980, 14, 7172, 8, 89, 3981, 403, 467, 334, 17, 12, 650, 1826, 1816, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 5254, 63, 18, 68, 8, 277, 304, 267, 671, 275, 980, 14, 1144, 7694, 16, 12, 16, 395, 5868, 16, 14, 21, 3057, 16, 14, 21, 395, 5868, 16, 14, 21, 12, 16, 14, 21, 395, 334, 16, 14, 21, 12, 378, 14, 21, 395, 334, 16, 14, 821, 12, 378, 14, 19, 4360, 2151, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 980, 14, 5605, 8, 88, 14, 1392, 59, 16, 467, 2152, 29, 1590, 14, 3157, 9, 267, 612, 275, 612, 446, 499, 74, 10, 89, 14172, 17, 61, 398, 19905, 275, 671, 3981, 403, 21063, 435, 980, 14, 1144, 779, 16, 12, 16, 12, 16, 11057, 403, 32306, 403, 61, 398, 367, 1083, 315, 661, 16615, 297, 283, 6676, 297, 283, 18455, 530, 735, 288, 367, 522, 2357, 315, 334, 549, 12, 756, 304, 355, 1499, 275, 4700, 1332, 765, 12, 522, 2357, 430, 355, 28008, 275, 6068, 576, 8, 88, 12, 612, 12, 19905, 12, 1083, 29, 765, 12, 522, 2357, 29, 470, 2357, 9, 2234, 702, 63, 1452, 8, 21643, 14, 1392, 12, 334, 21, 12, 650, 395, 2329, 63, 1328, 29, 1328, 9, 355, 702, 63, 7520, 8, 21643, 12, 980, 14, 7172, 8, 89, 3981, 403, 467, 334, 17, 12, 650, 1826, 1816, 9543, 29, 17, 69, 13, 1079, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
dcroc16/skunk_works
google_appengine/lib/yaml-3.10/yaml/resolver.py
474
8972
__all__ = ['BaseResolver', 'Resolver'] from error import * from nodes import * import re class ResolverError(YAMLError): pass class BaseResolver(object): DEFAULT_SCALAR_TAG = u'tag:yaml.org,2002:str' DEFAULT_SEQUENCE_TAG = u'tag:yaml.org,2002:seq' DEFAULT_MAPPING_TAG = u'tag:yaml.org,2002:map' yaml_implicit_resolvers = {} yaml_path_resolvers = {} def __init__(self): self.resolver_exact_paths = [] self.resolver_prefix_paths = [] def add_implicit_resolver(cls, tag, regexp, first): if not 'yaml_implicit_resolvers' in cls.__dict__: cls.yaml_implicit_resolvers = cls.yaml_implicit_resolvers.copy() if first is None: first = [None] for ch in first: cls.yaml_implicit_resolvers.setdefault(ch, []).append((tag, regexp)) add_implicit_resolver = classmethod(add_implicit_resolver) def add_path_resolver(cls, tag, path, kind=None): # Note: `add_path_resolver` is experimental. The API could be changed. # `new_path` is a pattern that is matched against the path from the # root to the node that is being considered. `node_path` elements are # tuples `(node_check, index_check)`. `node_check` is a node class: # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None` # matches any kind of a node. `index_check` could be `None`, a boolean # value, a string value, or a number. `None` and `False` match against # any _value_ of sequence and mapping nodes. `True` matches against # any _key_ of a mapping node. A string `index_check` matches against # a mapping value that corresponds to a scalar key which content is # equal to the `index_check` value. An integer `index_check` matches # against a sequence value with the index equal to `index_check`. if not 'yaml_path_resolvers' in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % element) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is dict: node_check = MappingNode elif node_check not in [ScalarNode, SequenceNode, MappingNode] \ and not isinstance(node_check, basestring) \ and node_check is not None: raise ResolverError("Invalid node checker: %s" % node_check) if not isinstance(index_check, (basestring, int)) \ and index_check is not None: raise ResolverError("Invalid index checker: %s" % index_check) new_path.append((node_check, index_check)) if kind is str: kind = ScalarNode elif kind is list: kind = SequenceNode elif kind is dict: kind = MappingNode elif kind not in [ScalarNode, SequenceNode, MappingNode] \ and kind is not None: raise ResolverError("Invalid node kind: %s" % kind) cls.yaml_path_resolvers[tuple(new_path), kind] = tag add_path_resolver = classmethod(add_path_resolver) def descend_resolver(self, current_node, current_index): if not self.yaml_path_resolvers: return exact_paths = {} prefix_paths = [] if current_node: depth = len(self.resolver_prefix_paths) for path, kind in self.resolver_prefix_paths[-1]: if self.check_resolver_prefix(depth, path, kind, current_node, current_index): if len(path) > depth: prefix_paths.append((path, kind)) else: exact_paths[kind] = self.yaml_path_resolvers[path, kind] else: for path, kind in self.yaml_path_resolvers: if not path: exact_paths[kind] = self.yaml_path_resolvers[path, kind] else: prefix_paths.append((path, kind)) self.resolver_exact_paths.append(exact_paths) self.resolver_prefix_paths.append(prefix_paths) def ascend_resolver(self): if not self.yaml_path_resolvers: return self.resolver_exact_paths.pop() self.resolver_prefix_paths.pop() def check_resolver_prefix(self, depth, path, kind, current_node, current_index): node_check, index_check = path[depth-1] if isinstance(node_check, basestring): if current_node.tag != node_check: return elif node_check is not None: if not isinstance(current_node, node_check): return if index_check is True and current_index is not None: return if (index_check is False or index_check is None) \ and current_index is None: return if isinstance(index_check, basestring): if not (isinstance(current_index, ScalarNode) and index_check == current_index.value): return elif isinstance(index_check, int) and not isinstance(index_check, bool): if index_check != current_index: return return True def resolve(self, kind, value, implicit): if kind is ScalarNode and implicit[0]: if value == u'': resolvers = self.yaml_implicit_resolvers.get(u'', []) else: resolvers = self.yaml_implicit_resolvers.get(value[0], []) resolvers += self.yaml_implicit_resolvers.get(None, []) for tag, regexp in resolvers: if regexp.match(value): return tag implicit = implicit[1] if self.yaml_path_resolvers: exact_paths = self.resolver_exact_paths[-1] if kind in exact_paths: return exact_paths[kind] if None in exact_paths: return exact_paths[None] if kind is ScalarNode: return self.DEFAULT_SCALAR_TAG elif kind is SequenceNode: return self.DEFAULT_SEQUENCE_TAG elif kind is MappingNode: return self.DEFAULT_MAPPING_TAG class Resolver(BaseResolver): pass Resolver.add_implicit_resolver( u'tag:yaml.org,2002:bool', re.compile(ur'''^(?:yes|Yes|YES|no|No|NO |true|True|TRUE|false|False|FALSE |on|On|ON|off|Off|OFF)$''', re.X), list(u'yYnNtTfFoO')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:float', re.compile(ur'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)? |\.[0-9_]+(?:[eE][-+][0-9]+)? |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]* |[-+]?\.(?:inf|Inf|INF) |\.(?:nan|NaN|NAN))$''', re.X), list(u'-+0123456789.')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:int', re.compile(ur'''^(?:[-+]?0b[0-1_]+ |[-+]?0[0-7_]+ |[-+]?(?:0|[1-9][0-9_]*) |[-+]?0x[0-9a-fA-F_]+ |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X), list(u'-+0123456789')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:merge', re.compile(ur'^(?:<<)$'), [u'<']) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:null', re.compile(ur'''^(?: ~ |null|Null|NULL | )$''', re.X), [u'~', u'n', u'N', u'']) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:timestamp', re.compile(ur'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]? (?:[Tt]|[ \t]+)[0-9][0-9]? :[0-9][0-9] :[0-9][0-9] (?:\.[0-9]*)? (?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X), list(u'0123456789')) Resolver.add_implicit_resolver( u'tag:yaml.org,2002:value', re.compile(ur'^(?:=)$'), [u'=']) # The following resolver is only for documentation purposes. It cannot work # because plain scalars cannot start with '!', '&', or '*'. Resolver.add_implicit_resolver( u'tag:yaml.org,2002:yaml', re.compile(ur'^(?:!|&|\*)$'), list(u'!&*'))
mit
[ 199, 363, 452, 363, 275, 788, 1563, 12407, 297, 283, 12407, 418, 199, 199, 504, 1125, 492, 627, 199, 504, 3380, 492, 627, 199, 199, 646, 295, 199, 199, 533, 26046, 547, 8, 23103, 547, 304, 272, 986, 199, 199, 533, 3523, 12407, 8, 785, 304, 339, 6186, 63, 17209, 689, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 495, 7, 272, 6186, 63, 16585, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 3610, 7, 272, 6186, 63, 20351, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 1130, 7, 339, 8864, 63, 11886, 63, 12640, 275, 1052, 272, 8864, 63, 515, 63, 12640, 275, 1052, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 7717, 63, 7327, 63, 3771, 275, 942, 267, 291, 14, 7717, 63, 1861, 63, 3771, 275, 942, 339, 347, 1050, 63, 11886, 63, 7717, 8, 1886, 12, 1947, 12, 13156, 12, 1642, 304, 267, 340, 440, 283, 5963, 63, 11886, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 11886, 63, 12640, 275, 843, 14, 5963, 63, 11886, 63, 12640, 14, 1574, 342, 267, 340, 1642, 365, 488, 26, 288, 1642, 275, 359, 403, 61, 267, 367, 682, 315, 1642, 26, 288, 843, 14, 5963, 63, 11886, 63, 12640, 14, 5486, 8, 335, 12, 15364, 740, 1332, 1450, 12, 13156, 430, 272, 1050, 63, 11886, 63, 7717, 275, 18990, 8, 525, 63, 11886, 63, 7717, 9, 339, 347, 1050, 63, 515, 63, 7717, 8, 1886, 12, 1947, 12, 931, 12, 4928, 29, 403, 304, 267, 327, 3390, 26, 658, 525, 63, 515, 63, 7717, 64, 365, 22820, 14, 221, 710, 3261, 4293, 506, 2896, 14, 267, 327, 658, 1222, 63, 515, 64, 365, 282, 3851, 626, 365, 7838, 6169, 314, 931, 687, 314, 267, 327, 1738, 370, 314, 1031, 626, 365, 3769, 8652, 14, 221, 658, 932, 63, 515, 64, 4008, 787, 267, 327, 6346, 16918, 932, 63, 1074, 12, 1478, 63, 1074, 20414, 221, 658, 932, 63, 1074, 64, 365, 282, 1031, 1021, 26, 267, 327, 658, 13090, 1716, 3559, 658, 5826, 1716, 3559, 658, 7674, 1716, 64, 503, 658, 403, 2313, 221, 658, 403, 64, 267, 327, 4450, 1263, 4928, 402, 282, 1031, 14, 221, 658, 1080, 63, 1074, 64, 4293, 506, 658, 403, 3559, 282, 5046, 267, 327, 574, 12, 282, 1059, 574, 12, 503, 282, 1329, 14, 221, 658, 403, 64, 436, 658, 797, 64, 1336, 6169, 267, 327, 1263, 485, 585, 63, 402, 3414, 436, 4412, 3380, 14, 221, 658, 549, 64, 4450, 6169, 267, 327, 1263, 485, 498, 63, 402, 282, 4412, 1031, 14, 221, 437, 1059, 658, 1080, 63, 1074, 64, 4450, 6169, 267, 327, 282, 4412, 574, 626, 13718, 370, 282, 6917, 790, 1314, 1564, 365, 267, 327, 4472, 370, 314, 658, 1080, 63, 1074, 64, 574, 14, 221, 1626, 3000, 658, 1080, 63, 1074, 64, 4450, 267, 327, 6169, 282, 3414, 574, 543, 314, 1478, 4472, 370, 658, 1080, 63, 1074, 2313, 267, 340, 440, 283, 5963, 63, 515, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 515, 63, 12640, 275, 843, 14, 5963, 63, 515, 63, 12640, 14, 1574, 342, 267, 892, 63, 515, 275, 942, 267, 367, 1819, 315, 931, 26, 288, 340, 1228, 8, 2108, 12, 334, 513, 12, 2008, 2298, 355, 340, 822, 8, 2108, 9, 508, 499, 26, 490, 1031, 63, 1074, 12, 1478, 63, 1074, 275, 1819, 355, 916, 822, 8, 2108, 9, 508, 413, 26, 490, 1031, 63, 1074, 275, 1819, 59, 16, 61, 490, 1478, 63, 1074, 275, 715, 355, 587, 26, 490, 746, 26046, 547, 480, 3364, 931, 1819, 26, 450, 83, 2, 450, 1819, 9, 288, 587, 26, 355, 1031, 63, 1074, 275, 488, 355, 1478, 63, 1074, 275, 1819, 288, 340, 1031, 63, 1074, 365, 620, 26, 355, 1031, 63, 1074, 275, 24289, 1716, 288, 916, 1031, 63, 1074, 365, 769, 26, 355, 1031, 63, 1074, 275, 10975, 1716, 288, 916, 1031, 63, 1074, 365, 1211, 26, 355, 1031, 63, 1074, 275, 12340, 1716, 288, 916, 1031, 63, 1074, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 221, 971, 490, 436, 440, 1228, 8, 932, 63, 1074, 12, 7116, 9, 221, 971, 490, 436, 1031, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1031, 7739, 26, 450, 83, 2, 450, 1031, 63, 1074, 9, 288, 340, 440, 1228, 8, 1080, 63, 1074, 12, 334, 17628, 12, 1109, 430, 257, 971, 490, 436, 1478, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1478, 7739, 26, 450, 83, 2, 450, 1478, 63, 1074, 9, 288, 892, 63, 515, 14, 740, 1332, 932, 63, 1074, 12, 1478, 63, 1074, 430, 267, 340, 4928, 365, 620, 26, 288, 4928, 275, 24289, 1716, 267, 916, 4928, 365, 769, 26, 288, 4928, 275, 10975, 1716, 267, 916, 4928, 365, 1211, 26, 288, 4928, 275, 12340, 1716, 267, 916, 4928, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 259, 971, 355, 436, 4928, 365, 440, 488, 26, 288, 746, 26046, 547, 480, 3364, 1031, 4928, 26, 450, 83, 2, 450, 4928, 9, 267, 843, 14, 5963, 63, 515, 63, 12640, 59, 2960, 8, 1222, 63, 515, 395, 4928, 61, 275, 1947, 272, 1050, 63, 515, 63, 7717, 275, 18990, 8, 525, 63, 515, 63, 7717, 9, 339, 347, 16336, 63, 7717, 8, 277, 12, 1453, 63, 932, 12, 1453, 63, 1080, 304, 267, 340, 440, 291, 14, 5963, 63, 515, 63, 12640, 26, 288, 372, 267, 5835, 63, 3771, 275, 1052, 267, 2403, 63, 3771, 275, 942, 267, 340, 1453, 63, 932, 26, 288, 5818, 275, 822, 8, 277, 14, 7717, 63, 1861, 63, 3771, 9, 288, 367, 931, 12, 4928, 315, 291, 14, 7717, 63, 1861, 63, 3771, 1988, 17, 2189, 355, 340, 291, 14, 1074, 63, 7717, 63, 1861, 8, 4631, 12, 931, 12, 4928, 12, 717, 1453, 63, 932, 12, 1453, 63, 1080, 304, 490, 340, 822, 8, 515, 9, 690, 5818, 26, 717, 2403, 63, 3771, 14, 740, 1332, 515, 12, 4928 ]
[ 363, 452, 363, 275, 788, 1563, 12407, 297, 283, 12407, 418, 199, 199, 504, 1125, 492, 627, 199, 504, 3380, 492, 627, 199, 199, 646, 295, 199, 199, 533, 26046, 547, 8, 23103, 547, 304, 272, 986, 199, 199, 533, 3523, 12407, 8, 785, 304, 339, 6186, 63, 17209, 689, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 495, 7, 272, 6186, 63, 16585, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 3610, 7, 272, 6186, 63, 20351, 63, 6967, 275, 399, 1133, 643, 26, 5963, 14, 1308, 12, 15135, 26, 1130, 7, 339, 8864, 63, 11886, 63, 12640, 275, 1052, 272, 8864, 63, 515, 63, 12640, 275, 1052, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 7717, 63, 7327, 63, 3771, 275, 942, 267, 291, 14, 7717, 63, 1861, 63, 3771, 275, 942, 339, 347, 1050, 63, 11886, 63, 7717, 8, 1886, 12, 1947, 12, 13156, 12, 1642, 304, 267, 340, 440, 283, 5963, 63, 11886, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 11886, 63, 12640, 275, 843, 14, 5963, 63, 11886, 63, 12640, 14, 1574, 342, 267, 340, 1642, 365, 488, 26, 288, 1642, 275, 359, 403, 61, 267, 367, 682, 315, 1642, 26, 288, 843, 14, 5963, 63, 11886, 63, 12640, 14, 5486, 8, 335, 12, 15364, 740, 1332, 1450, 12, 13156, 430, 272, 1050, 63, 11886, 63, 7717, 275, 18990, 8, 525, 63, 11886, 63, 7717, 9, 339, 347, 1050, 63, 515, 63, 7717, 8, 1886, 12, 1947, 12, 931, 12, 4928, 29, 403, 304, 267, 327, 3390, 26, 658, 525, 63, 515, 63, 7717, 64, 365, 22820, 14, 221, 710, 3261, 4293, 506, 2896, 14, 267, 327, 658, 1222, 63, 515, 64, 365, 282, 3851, 626, 365, 7838, 6169, 314, 931, 687, 314, 267, 327, 1738, 370, 314, 1031, 626, 365, 3769, 8652, 14, 221, 658, 932, 63, 515, 64, 4008, 787, 267, 327, 6346, 16918, 932, 63, 1074, 12, 1478, 63, 1074, 20414, 221, 658, 932, 63, 1074, 64, 365, 282, 1031, 1021, 26, 267, 327, 658, 13090, 1716, 3559, 658, 5826, 1716, 3559, 658, 7674, 1716, 64, 503, 658, 403, 2313, 221, 658, 403, 64, 267, 327, 4450, 1263, 4928, 402, 282, 1031, 14, 221, 658, 1080, 63, 1074, 64, 4293, 506, 658, 403, 3559, 282, 5046, 267, 327, 574, 12, 282, 1059, 574, 12, 503, 282, 1329, 14, 221, 658, 403, 64, 436, 658, 797, 64, 1336, 6169, 267, 327, 1263, 485, 585, 63, 402, 3414, 436, 4412, 3380, 14, 221, 658, 549, 64, 4450, 6169, 267, 327, 1263, 485, 498, 63, 402, 282, 4412, 1031, 14, 221, 437, 1059, 658, 1080, 63, 1074, 64, 4450, 6169, 267, 327, 282, 4412, 574, 626, 13718, 370, 282, 6917, 790, 1314, 1564, 365, 267, 327, 4472, 370, 314, 658, 1080, 63, 1074, 64, 574, 14, 221, 1626, 3000, 658, 1080, 63, 1074, 64, 4450, 267, 327, 6169, 282, 3414, 574, 543, 314, 1478, 4472, 370, 658, 1080, 63, 1074, 2313, 267, 340, 440, 283, 5963, 63, 515, 63, 12640, 7, 315, 843, 855, 807, 10651, 288, 843, 14, 5963, 63, 515, 63, 12640, 275, 843, 14, 5963, 63, 515, 63, 12640, 14, 1574, 342, 267, 892, 63, 515, 275, 942, 267, 367, 1819, 315, 931, 26, 288, 340, 1228, 8, 2108, 12, 334, 513, 12, 2008, 2298, 355, 340, 822, 8, 2108, 9, 508, 499, 26, 490, 1031, 63, 1074, 12, 1478, 63, 1074, 275, 1819, 355, 916, 822, 8, 2108, 9, 508, 413, 26, 490, 1031, 63, 1074, 275, 1819, 59, 16, 61, 490, 1478, 63, 1074, 275, 715, 355, 587, 26, 490, 746, 26046, 547, 480, 3364, 931, 1819, 26, 450, 83, 2, 450, 1819, 9, 288, 587, 26, 355, 1031, 63, 1074, 275, 488, 355, 1478, 63, 1074, 275, 1819, 288, 340, 1031, 63, 1074, 365, 620, 26, 355, 1031, 63, 1074, 275, 24289, 1716, 288, 916, 1031, 63, 1074, 365, 769, 26, 355, 1031, 63, 1074, 275, 10975, 1716, 288, 916, 1031, 63, 1074, 365, 1211, 26, 355, 1031, 63, 1074, 275, 12340, 1716, 288, 916, 1031, 63, 1074, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 221, 971, 490, 436, 440, 1228, 8, 932, 63, 1074, 12, 7116, 9, 221, 971, 490, 436, 1031, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1031, 7739, 26, 450, 83, 2, 450, 1031, 63, 1074, 9, 288, 340, 440, 1228, 8, 1080, 63, 1074, 12, 334, 17628, 12, 1109, 430, 257, 971, 490, 436, 1478, 63, 1074, 365, 440, 488, 26, 355, 746, 26046, 547, 480, 3364, 1478, 7739, 26, 450, 83, 2, 450, 1478, 63, 1074, 9, 288, 892, 63, 515, 14, 740, 1332, 932, 63, 1074, 12, 1478, 63, 1074, 430, 267, 340, 4928, 365, 620, 26, 288, 4928, 275, 24289, 1716, 267, 916, 4928, 365, 769, 26, 288, 4928, 275, 10975, 1716, 267, 916, 4928, 365, 1211, 26, 288, 4928, 275, 12340, 1716, 267, 916, 4928, 440, 315, 359, 13090, 1716, 12, 10975, 1716, 12, 12340, 1716, 61, 259, 971, 355, 436, 4928, 365, 440, 488, 26, 288, 746, 26046, 547, 480, 3364, 1031, 4928, 26, 450, 83, 2, 450, 4928, 9, 267, 843, 14, 5963, 63, 515, 63, 12640, 59, 2960, 8, 1222, 63, 515, 395, 4928, 61, 275, 1947, 272, 1050, 63, 515, 63, 7717, 275, 18990, 8, 525, 63, 515, 63, 7717, 9, 339, 347, 16336, 63, 7717, 8, 277, 12, 1453, 63, 932, 12, 1453, 63, 1080, 304, 267, 340, 440, 291, 14, 5963, 63, 515, 63, 12640, 26, 288, 372, 267, 5835, 63, 3771, 275, 1052, 267, 2403, 63, 3771, 275, 942, 267, 340, 1453, 63, 932, 26, 288, 5818, 275, 822, 8, 277, 14, 7717, 63, 1861, 63, 3771, 9, 288, 367, 931, 12, 4928, 315, 291, 14, 7717, 63, 1861, 63, 3771, 1988, 17, 2189, 355, 340, 291, 14, 1074, 63, 7717, 63, 1861, 8, 4631, 12, 931, 12, 4928, 12, 717, 1453, 63, 932, 12, 1453, 63, 1080, 304, 490, 340, 822, 8, 515, 9, 690, 5818, 26, 717, 2403, 63, 3771, 14, 740, 1332, 515, 12, 4928, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
matteoalessiocarrara/lib-figafind
src/filter_rules.py
2
2575
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2016 Matteo Alessio Carrara <sw.matteoac@gmail.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 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. """ Regole per il filtro lib.fbfilter.src.fbfilter.FbFilter """ import logging from lib.fbfilter.src import filter_components import version # Configurazione del sistema di logging logger = logging.getLogger(version.lib_name) logger.addHandler(logging.NullHandler()) # TODO Controllare versione librerie class FigaFind(filter_components.FilterRules): def required_property_custom_test(self, profile): # Tenere docstring sincronizzata con quella di # filter_components.FilterRules.required_property_custom_test() """ Controlla se il profilo soddisfa i requisiti richiesti, con dei test personalizzati Restituisce True o False Parametri: profile: lib.htmlfbapi.fbobj.Profile Il profilo da controllare """ try: ok = (profile.gender['Italiano'] == "Donna") except KeyError: ok = False logger.warning("Impossibile valutare il genere di %s, perché '%s' non ha una traduzione in Italiano", profile.nickname, profile.gender[profile.fbobj.my_profile.lang]) return ok class CazzoFind(filter_components.FilterRules): def required_property_custom_test(self, profile): # Tenere docstring sincronizzata con quella di # filter_components.FilterRules.required_property_custom_test() """ Controlla se il profilo soddisfa i requisiti richiesti, con dei test personalizzati Restituisce True o False Parametri: profile: lib.htmlfbapi.fbobj.Profile Il profilo da controllare """ try: ok = (profile.gender['Italiano'] == "Uomo") except KeyError: ok = False logger.warning("Impossibile valutare il genere di %s, perché '%s' non ha una traduzione in Italiano", profile.nickname, profile.gender[profile.fbobj.my_profile.lang]) return ok
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 1898, 7800, 18619, 266, 79, 437, 2978, 22961, 445, 5250, 17956, 665, 3519, 14, 569, 266, 79, 645, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 199, 3, 221, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 199, 624, 799, 1939, 274, 1126, 21179, 1794, 1374, 1973, 14, 4675, 1541, 14, 2164, 14, 4675, 1541, 14, 38, 66, 4131, 408, 199, 199, 646, 2050, 421, 199, 504, 1973, 14, 4675, 1541, 14, 2164, 492, 2457, 63, 4608, 421, 199, 646, 1015, 421, 199, 3, 4094, 300, 30834, 2150, 308, 29729, 391, 487, 2050, 199, 2921, 275, 2050, 14, 5572, 8, 1023, 14, 773, 63, 354, 9, 199, 2921, 14, 18826, 8, 4806, 14, 8849, 2461, 1012, 421, 199, 3, 3254, 8612, 29200, 809, 9353, 1973, 264, 11317, 421, 199, 533, 481, 29055, 6591, 8, 1541, 63, 4608, 14, 4131, 12920, 304, 421, 198, 318, 1415, 63, 1829, 63, 4229, 63, 396, 8, 277, 12, 4690, 304, 507, 198, 3, 377, 6349, 264, 9214, 9829, 14829, 28981, 419, 406, 17414, 76, 416, 487, 507, 198, 3, 2457, 63, 4608, 14, 4131, 12920, 14, 2427, 63, 1829, 63, 4229, 63, 396, 342, 507, 198, 624, 507, 198, 3717, 416, 542, 21179, 557, 329, 320, 308, 364, 2297, 667, 284, 295, 783, 338, 280, 8012, 13175, 597, 73, 12, 406, 477, 73, 511, 11083, 198, 28686, 28981, 2159, 507, 198, 497, 6329, 85, 374, 301, 715, 312, 756, 9068, 198, 21438, 599, 26, 686, 686, 198, 2913, 26, 1973, 14, 15575, 276, 66, 1246, 14, 70, 656, 468, 14, 5736, 1585, 198, 27965, 557, 329, 320, 12927, 3304, 29200, 507, 198, 624, 9068, 198, 893, 26, 686, 198, 745, 275, 334, 2913, 14, 15791, 459, 7940, 25861, 79, 418, 508, 298, 16932, 3540, 531, 9068, 198, 2590, 4067, 26, 686, 198, 745, 275, 756, 686, 198, 2921, 14, 3764, 480, 8499, 736, 6637, 441, 1139, 337, 1530, 21179, 15599, 264, 487, 450, 83, 12, 1126, 335, 5741, 1543, 83, 7, 2222, 18251, 32686, 1468, 2033, 16079, 368, 315, 2779, 25861, 79, 401, 4690, 14, 18544, 12, 4690, 14, 15791, 59, 2913, 14, 70, 656, 468, 14, 1662, 63, 2913, 14, 4159, 566, 28550, 198, 1107, 4112, 421, 199, 533, 8790, 4348, 79, 6591, 8, 1541, 63, 4608, 14, 4131, 12920, 304, 8299, 198, 318, 1415, 63, 1829, 63, 4229, 63, 396, 8, 277, 12, 4690, 304, 507, 198, 3, 377, 6349, 264, 9214, 9829, 14829, 28981, 419, 406, 17414, 76, 416, 487, 507, 198, 3, 2457, 63, 4608, 14, 4131, 12920, 14, 2427, 63, 1829, 63, 4229, 63, 396, 342, 507, 198, 624, 507, 198, 3717, 416, 542, 21179, 557, 329, 320, 308, 364, 2297, 667, 284, 295, 783, 338, 280, 8012, 13175, 597, 73, 12, 406, 477, 73, 511, 11083, 198, 28686, 28981, 2159, 507, 198, 497, 6329, 85, 374, 301, 715, 312, 756, 9068, 198, 21438, 599, 26, 686, 686, 198, 2913, 26, 1973, 14, 15575, 276, 66, 1246, 14, 70, 656, 468, 14, 5736, 1585, 198, 27965, 557, 329, 320, 12927, 3304, 29200, 507, 198, 624, 9068, 198, 893, 26, 686, 198, 745, 275, 334, 2913, 14, 15791, 459, 7940, 25861, 79, 418, 508, 298, 53, 79, 573, 531, 9068, 198, 2590, 4067, 26, 686, 198, 745, 275, 756, 686, 198, 2921, 14, 3764, 480, 8499, 736, 6637, 441, 1139, 337, 1530, 21179, 15599, 264, 487, 450, 83, 12, 1126, 335, 5741, 1543, 83, 7, 2222, 18251, 32686, 1468, 2033, 16079, 368, 315, 2779, 25861, 79, 401, 4690, 14, 18544, 12, 4690, 14, 15791, 59, 2913, 14, 70, 656, 468, 14, 1662, 63, 2913, 14, 4159, 566, 28550, 198, 1107, 4112, 8299, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 1898, 7800, 18619, 266, 79, 437, 2978, 22961, 445, 5250, 17956, 665, 3519, 14, 569, 266, 79, 645, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 221, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 221, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 221, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 221, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 221, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 221, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 199, 3, 221, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 199, 624, 799, 1939, 274, 1126, 21179, 1794, 1374, 1973, 14, 4675, 1541, 14, 2164, 14, 4675, 1541, 14, 38, 66, 4131, 408, 199, 199, 646, 2050, 421, 199, 504, 1973, 14, 4675, 1541, 14, 2164, 492, 2457, 63, 4608, 421, 199, 646, 1015, 421, 199, 3, 4094, 300, 30834, 2150, 308, 29729, 391, 487, 2050, 199, 2921, 275, 2050, 14, 5572, 8, 1023, 14, 773, 63, 354, 9, 199, 2921, 14, 18826, 8, 4806, 14, 8849, 2461, 1012, 421, 199, 3, 3254, 8612, 29200, 809, 9353, 1973, 264, 11317, 421, 199, 533, 481, 29055, 6591, 8, 1541, 63, 4608, 14, 4131, 12920, 304, 421, 198, 318, 1415, 63, 1829, 63, 4229, 63, 396, 8, 277, 12, 4690, 304, 507, 198, 3, 377, 6349, 264, 9214, 9829, 14829, 28981, 419, 406, 17414, 76, 416, 487, 507, 198, 3, 2457, 63, 4608, 14, 4131, 12920, 14, 2427, 63, 1829, 63, 4229, 63, 396, 342, 507, 198, 624, 507, 198, 3717, 416, 542, 21179, 557, 329, 320, 308, 364, 2297, 667, 284, 295, 783, 338, 280, 8012, 13175, 597, 73, 12, 406, 477, 73, 511, 11083, 198, 28686, 28981, 2159, 507, 198, 497, 6329, 85, 374, 301, 715, 312, 756, 9068, 198, 21438, 599, 26, 686, 686, 198, 2913, 26, 1973, 14, 15575, 276, 66, 1246, 14, 70, 656, 468, 14, 5736, 1585, 198, 27965, 557, 329, 320, 12927, 3304, 29200, 507, 198, 624, 9068, 198, 893, 26, 686, 198, 745, 275, 334, 2913, 14, 15791, 459, 7940, 25861, 79, 418, 508, 298, 16932, 3540, 531, 9068, 198, 2590, 4067, 26, 686, 198, 745, 275, 756, 686, 198, 2921, 14, 3764, 480, 8499, 736, 6637, 441, 1139, 337, 1530, 21179, 15599, 264, 487, 450, 83, 12, 1126, 335, 5741, 1543, 83, 7, 2222, 18251, 32686, 1468, 2033, 16079, 368, 315, 2779, 25861, 79, 401, 4690, 14, 18544, 12, 4690, 14, 15791, 59, 2913, 14, 70, 656, 468, 14, 1662, 63, 2913, 14, 4159, 566, 28550, 198, 1107, 4112, 421, 199, 533, 8790, 4348, 79, 6591, 8, 1541, 63, 4608, 14, 4131, 12920, 304, 8299, 198, 318, 1415, 63, 1829, 63, 4229, 63, 396, 8, 277, 12, 4690, 304, 507, 198, 3, 377, 6349, 264, 9214, 9829, 14829, 28981, 419, 406, 17414, 76, 416, 487, 507, 198, 3, 2457, 63, 4608, 14, 4131, 12920, 14, 2427, 63, 1829, 63, 4229, 63, 396, 342, 507, 198, 624, 507, 198, 3717, 416, 542, 21179, 557, 329, 320, 308, 364, 2297, 667, 284, 295, 783, 338, 280, 8012, 13175, 597, 73, 12, 406, 477, 73, 511, 11083, 198, 28686, 28981, 2159, 507, 198, 497, 6329, 85, 374, 301, 715, 312, 756, 9068, 198, 21438, 599, 26, 686, 686, 198, 2913, 26, 1973, 14, 15575, 276, 66, 1246, 14, 70, 656, 468, 14, 5736, 1585, 198, 27965, 557, 329, 320, 12927, 3304, 29200, 507, 198, 624, 9068, 198, 893, 26, 686, 198, 745, 275, 334, 2913, 14, 15791, 459, 7940, 25861, 79, 418, 508, 298, 53, 79, 573, 531, 9068, 198, 2590, 4067, 26, 686, 198, 745, 275, 756, 686, 198, 2921, 14, 3764, 480, 8499, 736, 6637, 441, 1139, 337, 1530, 21179, 15599, 264, 487, 450, 83, 12, 1126, 335, 5741, 1543, 83, 7, 2222, 18251, 32686, 1468, 2033, 16079, 368, 315, 2779, 25861, 79, 401, 4690, 14, 18544, 12, 4690, 14, 15791, 59, 2913, 14, 70, 656, 468, 14, 1662, 63, 2913, 14, 4159, 566, 28550, 198, 1107, 4112, 8299, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jjscarafia/odoo
addons/hr_recruitment/wizard/__init__.py
381
1095
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-Today OpenERP (<http://www.openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import hr_recruitment_create_partner_job # 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, 31982, 7653, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 264, 31365, 434, 63, 981, 63, 3899, 63, 2423, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 31982, 7653, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 16140, 63, 264, 31365, 434, 63, 981, 63, 3899, 63, 2423, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
2013Commons/HUE-SHARK
build/env/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/db/models/fields/related.py
6
54548
from django.conf import settings from django.db import connection, router, transaction from django.db.backends import util from django.db.models import signals, get_model from django.db.models.fields import (AutoField, Field, IntegerField, PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist) from django.db.models.related import RelatedObject from django.db.models.query import QuerySet from django.db.models.query_utils import QueryWrapper from django.utils.encoding import smart_unicode from django.utils.translation import ugettext_lazy as _, string_concat, ungettext, ugettext from django.utils.functional import curry from django.core import exceptions from django import forms RECURSIVE_RELATIONSHIP_CONSTANT = 'self' pending_lookups = {} def add_lazy_relation(cls, field, relation, operation): """ Adds a lookup on ``cls`` when a related field is defined using a string, i.e.:: class MyModel(Model): fk = ForeignKey("AnotherModel") This string can be: * RECURSIVE_RELATIONSHIP_CONSTANT (i.e. "self") to indicate a recursive relation. * The name of a model (i.e "AnotherModel") to indicate another model in the same app. * An app-label and model name (i.e. "someapp.AnotherModel") to indicate another model in a different app. If the other model hasn't yet been loaded -- almost a given if you're using lazy relationships -- then the relation won't be set up until the class_prepared signal fires at the end of model initialization. operation is the work that must be performed once the relation can be resolved. """ # Check for recursive relations if relation == RECURSIVE_RELATIONSHIP_CONSTANT: app_label = cls._meta.app_label model_name = cls.__name__ else: # Look for an "app.Model" relation try: app_label, model_name = relation.split(".") except ValueError: # If we can't split, assume a model in current app app_label = cls._meta.app_label model_name = relation except AttributeError: # If it doesn't have a split it's actually a model class app_label = relation._meta.app_label model_name = relation._meta.object_name # Try to look up the related model, and if it's already loaded resolve the # string right away. If get_model returns None, it means that the related # model isn't loaded yet, so we need to pend the relation until the class # is prepared. model = get_model(app_label, model_name, False) if model: operation(field, model, cls) else: key = (app_label, model_name) value = (cls, field, operation) pending_lookups.setdefault(key, []).append(value) def do_pending_lookups(sender, **kwargs): """ Handle any pending relations to the sending model. Sent from class_prepared. """ key = (sender._meta.app_label, sender.__name__) for cls, field, operation in pending_lookups.pop(key, []): operation(field, sender, cls) signals.class_prepared.connect(do_pending_lookups) #HACK class RelatedField(object): def contribute_to_class(self, cls, name): sup = super(RelatedField, self) # Store the opts for related_query_name() self.opts = cls._meta if hasattr(sup, 'contribute_to_class'): sup.contribute_to_class(cls, name) if not cls._meta.abstract and self.rel.related_name: self.rel.related_name = self.rel.related_name % { 'class': cls.__name__.lower(), 'app_label': cls._meta.app_label.lower(), } other = self.rel.to if isinstance(other, basestring) or other._meta.pk is None: def resolve_related_class(field, model, cls): field.rel.to = model field.do_related_class(model, cls) add_lazy_relation(cls, self, other, resolve_related_class) else: self.do_related_class(other, cls) def set_attributes_from_rel(self): self.name = self.name or (self.rel.to._meta.object_name.lower() + '_' + self.rel.to._meta.pk.name) if self.verbose_name is None: self.verbose_name = self.rel.to._meta.verbose_name self.rel.field_name = self.rel.field_name or self.rel.to._meta.pk.name def do_related_class(self, other, cls): self.set_attributes_from_rel() self.related = RelatedObject(other, cls, self) if not cls._meta.abstract: self.contribute_to_related_class(other, self.related) def get_prep_lookup(self, lookup_type, value): if hasattr(value, 'prepare'): return value.prepare() if hasattr(value, '_prepare'): return value._prepare() # FIXME: lt and gt are explicitly allowed to make # get_(next/prev)_by_date work; other lookups are not allowed since that # gets messy pretty quick. This is a good candidate for some refactoring # in the future. if lookup_type in ['exact', 'gt', 'lt', 'gte', 'lte']: return self._pk_trace(value, 'get_prep_lookup', lookup_type) if lookup_type in ('range', 'in'): return [self._pk_trace(v, 'get_prep_lookup', lookup_type) for v in value] elif lookup_type == 'isnull': return [] raise TypeError("Related Field has invalid lookup: %s" % lookup_type) def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False): if not prepared: value = self.get_prep_lookup(lookup_type, value) if hasattr(value, 'get_compiler'): value = value.get_compiler(connection=connection) if hasattr(value, 'as_sql') or hasattr(value, '_as_sql'): # If the value has a relabel_aliases method, it will need to # be invoked before the final SQL is evaluated if hasattr(value, 'relabel_aliases'): return value if hasattr(value, 'as_sql'): sql, params = value.as_sql() else: sql, params = value._as_sql(connection=connection) return QueryWrapper(('(%s)' % sql), params) # FIXME: lt and gt are explicitly allowed to make # get_(next/prev)_by_date work; other lookups are not allowed since that # gets messy pretty quick. This is a good candidate for some refactoring # in the future. if lookup_type in ['exact', 'gt', 'lt', 'gte', 'lte']: return [self._pk_trace(value, 'get_db_prep_lookup', lookup_type, connection=connection, prepared=prepared)] if lookup_type in ('range', 'in'): return [self._pk_trace(v, 'get_db_prep_lookup', lookup_type, connection=connection, prepared=prepared) for v in value] elif lookup_type == 'isnull': return [] raise TypeError("Related Field has invalid lookup: %s" % lookup_type) def _pk_trace(self, value, prep_func, lookup_type, **kwargs): # Value may be a primary key, or an object held in a relation. # If it is an object, then we need to get the primary key value for # that object. In certain conditions (especially one-to-one relations), # the primary key may itself be an object - so we need to keep drilling # down until we hit a value that can be used for a comparison. v = value try: while True: v = getattr(v, v._meta.pk.name) except AttributeError: pass except exceptions.ObjectDoesNotExist: v = None field = self while field.rel: if hasattr(field.rel, 'field_name'): field = field.rel.to._meta.get_field(field.rel.field_name) else: field = field.rel.to._meta.pk if lookup_type in ('range', 'in'): v = [v] v = getattr(field, prep_func)(lookup_type, v, **kwargs) if isinstance(v, list): v = v[0] return v def related_query_name(self): # This method defines the name that can be used to identify this # related object in a table-spanning query. It uses the lower-cased # object_name by default, but this can be overridden with the # "related_name" option. return self.rel.related_name or self.opts.object_name.lower() class SingleRelatedObjectDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # a single "remote" value, on the class pointed to by a related field. # In the example "place.restaurant", the restaurant attribute is a # SingleRelatedObjectDescriptor instance. def __init__(self, related): self.related = related self.cache_name = related.get_cache_name() def __get__(self, instance, instance_type=None): if instance is None: return self try: return getattr(instance, self.cache_name) except AttributeError: params = {'%s__pk' % self.related.field.name: instance._get_pk_val()} db = router.db_for_read(self.related.model, instance=instance) rel_obj = self.related.model._base_manager.using(db).get(**params) setattr(instance, self.cache_name, rel_obj) return rel_obj def __set__(self, instance, value): if instance is None: raise AttributeError("%s must be accessed via instance" % self.related.opts.object_name) # The similarity of the code below to the code in # ReverseSingleRelatedObjectDescriptor is annoying, but there's a bunch # of small differences that would make a common base class convoluted. # If null=True, we can assign null here, but otherwise the value needs # to be an instance of the related class. if value is None and self.related.field.null == False: raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' % (instance._meta.object_name, self.related.get_accessor_name())) elif value is not None and not isinstance(value, self.related.model): raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' % (value, instance._meta.object_name, self.related.get_accessor_name(), self.related.opts.object_name)) elif value is not None: if instance._state.db is None: instance._state.db = router.db_for_write(instance.__class__, instance=value) elif value._state.db is None: value._state.db = router.db_for_write(value.__class__, instance=instance) elif value._state.db is not None and instance._state.db is not None: if not router.allow_relation(value, instance): raise ValueError('Cannot assign "%r": instance is on database "%s", value is on database "%s"' % (value, instance._state.db, value._state.db)) # Set the value of the related field to the value of the related object's related field setattr(value, self.related.field.attname, getattr(instance, self.related.field.rel.get_related_field().attname)) # Since we already know what the related object is, seed the related # object caches now, too. This avoids another db hit if you get the # object you just set. setattr(instance, self.cache_name, value) setattr(value, self.related.field.get_cache_name(), instance) class ReverseSingleRelatedObjectDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # a single "remote" value, on the class that defines the related field. # In the example "choice.poll", the poll attribute is a # ReverseSingleRelatedObjectDescriptor instance. def __init__(self, field_with_rel): self.field = field_with_rel def __get__(self, instance, instance_type=None): if instance is None: return self cache_name = self.field.get_cache_name() try: return getattr(instance, cache_name) except AttributeError: val = getattr(instance, self.field.attname) if val is None: # If NULL is an allowed value, return it. if self.field.null: return None raise self.field.rel.to.DoesNotExist other_field = self.field.rel.get_related_field() if other_field.rel: params = {'%s__pk' % self.field.rel.field_name: val} else: params = {'%s__exact' % self.field.rel.field_name: val} # If the related manager indicates that it should be used for # related fields, respect that. rel_mgr = self.field.rel.to._default_manager db = router.db_for_read(self.field.rel.to, instance=instance) if getattr(rel_mgr, 'use_for_related_fields', False): rel_obj = rel_mgr.using(db).get(**params) else: rel_obj = QuerySet(self.field.rel.to).using(db).get(**params) setattr(instance, cache_name, rel_obj) return rel_obj def __set__(self, instance, value): if instance is None: raise AttributeError("%s must be accessed via instance" % self._field.name) # If null=True, we can assign null here, but otherwise the value needs # to be an instance of the related class. if value is None and self.field.null == False: raise ValueError('Cannot assign None: "%s.%s" does not allow null values.' % (instance._meta.object_name, self.field.name)) elif value is not None and not isinstance(value, self.field.rel.to): raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' % (value, instance._meta.object_name, self.field.name, self.field.rel.to._meta.object_name)) elif value is not None: if instance._state.db is None: instance._state.db = router.db_for_write(instance.__class__, instance=value) elif value._state.db is None: value._state.db = router.db_for_write(value.__class__, instance=instance) elif value._state.db is not None and instance._state.db is not None: if not router.allow_relation(value, instance): raise ValueError('Cannot assign "%r": instance is on database "%s", value is on database "%s"' % (value, instance._state.db, value._state.db)) # If we're setting the value of a OneToOneField to None, we need to clear # out the cache on any old related object. Otherwise, deleting the # previously-related object will also cause this object to be deleted, # which is wrong. if value is None: # Look up the previously-related object, which may still be available # since we've not yet cleared out the related field. # Use the cache directly, instead of the accessor; if we haven't # populated the cache, then we don't care - we're only accessing # the object to invalidate the accessor cache, so there's no # need to populate the cache just to expire it again. related = getattr(instance, self.field.get_cache_name(), None) # If we've got an old related object, we need to clear out its # cache. This cache also might not exist if the related object # hasn't been accessed yet. if related: cache_name = self.field.related.get_cache_name() try: delattr(related, cache_name) except AttributeError: pass # Set the value of the related field try: val = getattr(value, self.field.rel.get_related_field().attname) except AttributeError: val = None setattr(instance, self.field.attname, val) # Since we already know what the related object is, seed the related # object cache now, too. This avoids another db hit if you get the # object you just set. setattr(instance, self.field.get_cache_name(), value) class ForeignRelatedObjectsDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # multiple "remote" values and have a ForeignKey pointed at them by # some other model. In the example "poll.choice_set", the choice_set # attribute is a ForeignRelatedObjectsDescriptor instance. def __init__(self, related): self.related = related # RelatedObject instance def __get__(self, instance, instance_type=None): if instance is None: return self return self.create_manager(instance, self.related.model._default_manager.__class__) def __set__(self, instance, value): if instance is None: raise AttributeError("Manager must be accessed via instance") manager = self.__get__(instance) # If the foreign key can support nulls, then completely clear the related set. # Otherwise, just move the named objects into the set. if self.related.field.null: manager.clear() manager.add(*value) def delete_manager(self, instance): """ Returns a queryset based on the related model's base manager (rather than the default manager, as returned by __get__). Used by Model.delete(). """ return self.create_manager(instance, self.related.model._base_manager.__class__) def create_manager(self, instance, superclass): """ Creates the managers used by other methods (__get__() and delete()). """ rel_field = self.related.field rel_model = self.related.model class RelatedManager(superclass): def get_query_set(self): db = self._db or router.db_for_read(rel_model, instance=instance) return superclass.get_query_set(self).using(db).filter(**(self.core_filters)) def add(self, *objs): for obj in objs: if not isinstance(obj, self.model): raise TypeError("'%s' instance expected" % self.model._meta.object_name) setattr(obj, rel_field.name, instance) obj.save() add.alters_data = True def create(self, **kwargs): kwargs.update({rel_field.name: instance}) db = router.db_for_write(rel_model, instance=instance) return super(RelatedManager, self).using(db).create(**kwargs) create.alters_data = True def get_or_create(self, **kwargs): # Update kwargs with the related object that this # ForeignRelatedObjectsDescriptor knows about. kwargs.update({rel_field.name: instance}) db = router.db_for_write(rel_model, instance=instance) return super(RelatedManager, self).using(db).get_or_create(**kwargs) get_or_create.alters_data = True # remove() and clear() are only provided if the ForeignKey can have a value of null. if rel_field.null: def remove(self, *objs): val = getattr(instance, rel_field.rel.get_related_field().attname) for obj in objs: # Is obj actually part of this descriptor set? if getattr(obj, rel_field.attname) == val: setattr(obj, rel_field.name, None) obj.save() else: raise rel_field.rel.to.DoesNotExist("%r is not related to %r." % (obj, instance)) remove.alters_data = True def clear(self): for obj in self.all(): setattr(obj, rel_field.name, None) obj.save() clear.alters_data = True manager = RelatedManager() attname = rel_field.rel.get_related_field().name manager.core_filters = {'%s__%s' % (rel_field.name, attname): getattr(instance, attname)} manager.model = self.related.model return manager def create_many_related_manager(superclass, rel=False): """Creates a manager that subclasses 'superclass' (which is a Manager) and adds behavior for many-to-many related objects.""" through = rel.through class ManyRelatedManager(superclass): def __init__(self, model=None, core_filters=None, instance=None, symmetrical=None, join_table=None, source_field_name=None, target_field_name=None, reverse=False): super(ManyRelatedManager, self).__init__() self.core_filters = core_filters self.model = model self.symmetrical = symmetrical self.instance = instance self.source_field_name = source_field_name self.target_field_name = target_field_name self.through = through self._pk_val = self.instance.pk self.reverse = reverse if self._pk_val is None: raise ValueError("%r instance needs to have a primary key value before a many-to-many relationship can be used." % instance.__class__.__name__) def get_query_set(self): db = self._db or router.db_for_read(self.instance.__class__, instance=self.instance) return superclass.get_query_set(self).using(db)._next_is_sticky().filter(**(self.core_filters)) # If the ManyToMany relation has an intermediary model, # the add and remove methods do not exist. if rel.through._meta.auto_created: def add(self, *objs): self._add_items(self.source_field_name, self.target_field_name, *objs) # If this is a symmetrical m2m relation to self, add the mirror entry in the m2m table if self.symmetrical: self._add_items(self.target_field_name, self.source_field_name, *objs) add.alters_data = True def remove(self, *objs): self._remove_items(self.source_field_name, self.target_field_name, *objs) # If this is a symmetrical m2m relation to self, remove the mirror entry in the m2m table if self.symmetrical: self._remove_items(self.target_field_name, self.source_field_name, *objs) remove.alters_data = True def clear(self): self._clear_items(self.source_field_name) # If this is a symmetrical m2m relation to self, clear the mirror entry in the m2m table if self.symmetrical: self._clear_items(self.target_field_name) clear.alters_data = True def create(self, **kwargs): # This check needs to be done here, since we can't later remove this # from the method lookup table, as we do with add and remove. if not rel.through._meta.auto_created: opts = through._meta raise AttributeError("Cannot use create() on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name)) db = router.db_for_write(self.instance.__class__, instance=self.instance) new_obj = super(ManyRelatedManager, self).using(db).create(**kwargs) self.add(new_obj) return new_obj create.alters_data = True def get_or_create(self, **kwargs): db = router.db_for_write(self.instance.__class__, instance=self.instance) obj, created = \ super(ManyRelatedManager, self).using(db).get_or_create(**kwargs) # We only need to add() if created because if we got an object back # from get() then the relationship already exists. if created: self.add(obj) return obj, created get_or_create.alters_data = True def _add_items(self, source_field_name, target_field_name, *objs): # join_table: name of the m2m link table # source_field_name: the PK fieldname in join_table for the source object # target_field_name: the PK fieldname in join_table for the target object # *objs - objects to add. Either object instances, or primary keys of object instances. # If there aren't any objects, there is nothing to do. from django.db.models import Model if objs: new_ids = set() for obj in objs: if isinstance(obj, self.model): if not router.allow_relation(obj, self.instance): raise ValueError('Cannot add "%r": instance is on database "%s", value is on database "%s"' % (obj, self.instance._state.db, obj._state.db)) new_ids.add(obj.pk) elif isinstance(obj, Model): raise TypeError("'%s' instance expected" % self.model._meta.object_name) else: new_ids.add(obj) db = router.db_for_write(self.through.__class__, instance=self.instance) vals = self.through._default_manager.using(db).values_list(target_field_name, flat=True) vals = vals.filter(**{ source_field_name: self._pk_val, '%s__in' % target_field_name: new_ids, }) new_ids = new_ids - set(vals) if self.reverse or source_field_name == self.source_field_name: # Don't send the signal when we are inserting the # duplicate data row for symmetrical reverse entries. signals.m2m_changed.send(sender=rel.through, action='pre_add', instance=self.instance, reverse=self.reverse, model=self.model, pk_set=new_ids) # Add the ones that aren't there already for obj_id in new_ids: self.through._default_manager.using(db).create(**{ '%s_id' % source_field_name: self._pk_val, '%s_id' % target_field_name: obj_id, }) if self.reverse or source_field_name == self.source_field_name: # Don't send the signal when we are inserting the # duplicate data row for symmetrical reverse entries. signals.m2m_changed.send(sender=rel.through, action='post_add', instance=self.instance, reverse=self.reverse, model=self.model, pk_set=new_ids) def _remove_items(self, source_field_name, target_field_name, *objs): # source_col_name: the PK colname in join_table for the source object # target_col_name: the PK colname in join_table for the target object # *objs - objects to remove # If there aren't any objects, there is nothing to do. if objs: # Check that all the objects are of the right type old_ids = set() for obj in objs: if isinstance(obj, self.model): old_ids.add(obj.pk) else: old_ids.add(obj) if self.reverse or source_field_name == self.source_field_name: # Don't send the signal when we are deleting the # duplicate data row for symmetrical reverse entries. signals.m2m_changed.send(sender=rel.through, action="pre_remove", instance=self.instance, reverse=self.reverse, model=self.model, pk_set=old_ids) # Remove the specified objects from the join table db = router.db_for_write(self.through.__class__, instance=self.instance) self.through._default_manager.using(db).filter(**{ source_field_name: self._pk_val, '%s__in' % target_field_name: old_ids }).delete() if self.reverse or source_field_name == self.source_field_name: # Don't send the signal when we are deleting the # duplicate data row for symmetrical reverse entries. signals.m2m_changed.send(sender=rel.through, action="post_remove", instance=self.instance, reverse=self.reverse, model=self.model, pk_set=old_ids) def _clear_items(self, source_field_name): # source_col_name: the PK colname in join_table for the source object if self.reverse or source_field_name == self.source_field_name: # Don't send the signal when we are clearing the # duplicate data rows for symmetrical reverse entries. signals.m2m_changed.send(sender=rel.through, action="pre_clear", instance=self.instance, reverse=self.reverse, model=self.model, pk_set=None) db = router.db_for_write(self.through.__class__, instance=self.instance) self.through._default_manager.using(db).filter(**{ source_field_name: self._pk_val }).delete() if self.reverse or source_field_name == self.source_field_name: # Don't send the signal when we are clearing the # duplicate data rows for symmetrical reverse entries. signals.m2m_changed.send(sender=rel.through, action="post_clear", instance=self.instance, reverse=self.reverse, model=self.model, pk_set=None) return ManyRelatedManager class ManyRelatedObjectsDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # multiple "remote" values and have a ManyToManyField pointed at them by # some other model (rather than having a ManyToManyField themselves). # In the example "publication.article_set", the article_set attribute is a # ManyRelatedObjectsDescriptor instance. def __init__(self, related): self.related = related # RelatedObject instance def __get__(self, instance, instance_type=None): if instance is None: return self # Dynamically create a class that subclasses the related # model's default manager. rel_model = self.related.model superclass = rel_model._default_manager.__class__ RelatedManager = create_many_related_manager(superclass, self.related.field.rel) manager = RelatedManager( model=rel_model, core_filters={'%s__pk' % self.related.field.name: instance._get_pk_val()}, instance=instance, symmetrical=False, source_field_name=self.related.field.m2m_reverse_field_name(), target_field_name=self.related.field.m2m_field_name(), reverse=True ) return manager def __set__(self, instance, value): if instance is None: raise AttributeError("Manager must be accessed via instance") if not self.related.field.rel.through._meta.auto_created: opts = self.related.field.rel.through._meta raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name)) manager = self.__get__(instance) manager.clear() manager.add(*value) class ReverseManyRelatedObjectsDescriptor(object): # This class provides the functionality that makes the related-object # managers available as attributes on a model class, for fields that have # multiple "remote" values and have a ManyToManyField defined in their # model (rather than having another model pointed *at* them). # In the example "article.publications", the publications attribute is a # ReverseManyRelatedObjectsDescriptor instance. def __init__(self, m2m_field): self.field = m2m_field def _through(self): # through is provided so that you have easy access to the through # model (Book.authors.through) for inlines, etc. This is done as # a property to ensure that the fully resolved value is returned. return self.field.rel.through through = property(_through) def __get__(self, instance, instance_type=None): if instance is None: return self # Dynamically create a class that subclasses the related # model's default manager. rel_model=self.field.rel.to superclass = rel_model._default_manager.__class__ RelatedManager = create_many_related_manager(superclass, self.field.rel) manager = RelatedManager( model=rel_model, core_filters={'%s__pk' % self.field.related_query_name(): instance._get_pk_val()}, instance=instance, symmetrical=self.field.rel.symmetrical, source_field_name=self.field.m2m_field_name(), target_field_name=self.field.m2m_reverse_field_name(), reverse=False ) return manager def __set__(self, instance, value): if instance is None: raise AttributeError("Manager must be accessed via instance") if not self.field.rel.through._meta.auto_created: opts = self.field.rel.through._meta raise AttributeError("Cannot set values on a ManyToManyField which specifies an intermediary model. Use %s.%s's Manager instead." % (opts.app_label, opts.object_name)) manager = self.__get__(instance) manager.clear() manager.add(*value) class ManyToOneRel(object): def __init__(self, to, field_name, related_name=None, limit_choices_to=None, lookup_overrides=None, parent_link=False): try: to._meta except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT assert isinstance(to, basestring), "'to' must be either a model, a model name or the string %r" % RECURSIVE_RELATIONSHIP_CONSTANT self.to, self.field_name = to, field_name self.related_name = related_name if limit_choices_to is None: limit_choices_to = {} self.limit_choices_to = limit_choices_to self.lookup_overrides = lookup_overrides or {} self.multiple = True self.parent_link = parent_link def is_hidden(self): "Should the related object be hidden?" return self.related_name and self.related_name[-1] == '+' def get_related_field(self): """ Returns the Field in the 'to' object to which this relationship is tied. """ data = self.to._meta.get_field_by_name(self.field_name) if not data[2]: raise FieldDoesNotExist("No related field named '%s'" % self.field_name) return data[0] class OneToOneRel(ManyToOneRel): def __init__(self, to, field_name, related_name=None, limit_choices_to=None, lookup_overrides=None, parent_link=False): super(OneToOneRel, self).__init__(to, field_name, related_name=related_name, limit_choices_to=limit_choices_to, lookup_overrides=lookup_overrides, parent_link=parent_link) self.multiple = False class ManyToManyRel(object): def __init__(self, to, related_name=None, limit_choices_to=None, symmetrical=True, through=None): self.to = to self.related_name = related_name if limit_choices_to is None: limit_choices_to = {} self.limit_choices_to = limit_choices_to self.symmetrical = symmetrical self.multiple = True self.through = through def is_hidden(self): "Should the related object be hidden?" return self.related_name and self.related_name[-1] == '+' def get_related_field(self): """ Returns the field in the to' object to which this relationship is tied (this is always the primary key on the target model). Provided for symmetry with ManyToOneRel. """ return self.to._meta.pk class ForeignKey(RelatedField, Field): empty_strings_allowed = False default_error_messages = { 'invalid': _('Model %(model)s with pk %(pk)r does not exist.') } description = _("Foreign Key (type determined by related field)") def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs): try: to_name = to._meta.object_name.lower() except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT assert isinstance(to, basestring), "%s(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT) else: assert not to._meta.abstract, "%s cannot define a relation with abstract class %s" % (self.__class__.__name__, to._meta.object_name) # For backwards compatibility purposes, we need to *try* and set # the to_field during FK construction. It won't be guaranteed to # be correct until contribute_to_class is called. Refs #12190. to_field = to_field or (to._meta.pk and to._meta.pk.name) kwargs['verbose_name'] = kwargs.get('verbose_name', None) if 'db_index' not in kwargs: kwargs['db_index'] = True kwargs['rel'] = rel_class(to, to_field, related_name=kwargs.pop('related_name', None), limit_choices_to=kwargs.pop('limit_choices_to', None), lookup_overrides=kwargs.pop('lookup_overrides', None), parent_link=kwargs.pop('parent_link', False)) Field.__init__(self, **kwargs) def validate(self, value, model_instance): if self.rel.parent_link: return super(ForeignKey, self).validate(value, model_instance) if value is None: return qs = self.rel.to._default_manager.filter(**{self.rel.field_name:value}) qs = qs.complex_filter(self.rel.limit_choices_to) if not qs.exists(): raise exceptions.ValidationError(self.error_messages['invalid'] % { 'model': self.rel.to._meta.verbose_name, 'pk': value}) def get_attname(self): return '%s_id' % self.name def get_validator_unique_lookup_type(self): return '%s__%s__exact' % (self.name, self.rel.get_related_field().name) def get_default(self): "Here we check if the default value is an object and return the to_field if so." field_default = super(ForeignKey, self).get_default() if isinstance(field_default, self.rel.to): return getattr(field_default, self.rel.get_related_field().attname) return field_default def get_db_prep_save(self, value, connection): if value == '' or value == None: return None else: return self.rel.get_related_field().get_db_prep_save(value, connection=connection) def value_to_string(self, obj): if not obj: # In required many-to-one fields with only one available choice, # select that one available choice. Note: For SelectFields # we have to check that the length of choices is *2*, not 1, # because SelectFields always have an initial "blank" value. if not self.blank and self.choices: choice_list = self.get_choices_default() if len(choice_list) == 2: return smart_unicode(choice_list[1][0]) return Field.value_to_string(self, obj) def contribute_to_class(self, cls, name): super(ForeignKey, self).contribute_to_class(cls, name) setattr(cls, self.name, ReverseSingleRelatedObjectDescriptor(self)) if isinstance(self.rel.to, basestring): target = self.rel.to else: target = self.rel.to._meta.db_table cls._meta.duplicate_targets[self.column] = (target, "o2m") def contribute_to_related_class(self, cls, related): # Internal FK's - i.e., those with a related name ending with '+' - # don't get a related descriptor. if not self.rel.is_hidden(): setattr(cls, related.get_accessor_name(), ForeignRelatedObjectsDescriptor(related)) if self.rel.field_name is None: self.rel.field_name = cls._meta.pk.name def formfield(self, **kwargs): db = kwargs.pop('using', None) defaults = { 'form_class': forms.ModelChoiceField, 'queryset': self.rel.to._default_manager.using(db).complex_filter(self.rel.limit_choices_to), 'to_field_name': self.rel.field_name, } defaults.update(kwargs) return super(ForeignKey, self).formfield(**defaults) def db_type(self, connection): # The database column type of a ForeignKey is the column type # of the field to which it points. An exception is if the ForeignKey # points to an AutoField/PositiveIntegerField/PositiveSmallIntegerField, # in which case the column type is simply that of an IntegerField. # If the database needs similar types for key fields however, the only # thing we can do is making AutoField an IntegerField. rel_field = self.rel.get_related_field() if (isinstance(rel_field, AutoField) or (not connection.features.related_fields_match_type and isinstance(rel_field, (PositiveIntegerField, PositiveSmallIntegerField)))): return IntegerField().db_type(connection=connection) return rel_field.db_type(connection=connection) class OneToOneField(ForeignKey): """ A OneToOneField is essentially the same as a ForeignKey, with the exception that always carries a "unique" constraint with it and the reverse relation always returns the object pointed to (since there will only ever be one), rather than returning a list. """ description = _("One-to-one relationship") def __init__(self, to, to_field=None, **kwargs): kwargs['unique'] = True super(OneToOneField, self).__init__(to, to_field, OneToOneRel, **kwargs) def contribute_to_related_class(self, cls, related): setattr(cls, related.get_accessor_name(), SingleRelatedObjectDescriptor(related)) def formfield(self, **kwargs): if self.rel.parent_link: return None return super(OneToOneField, self).formfield(**kwargs) def save_form_data(self, instance, data): if isinstance(data, self.rel.to): setattr(instance, self.name, data) else: setattr(instance, self.attname, data) def create_many_to_many_intermediary_model(field, klass): from django.db import models managed = True if isinstance(field.rel.to, basestring) and field.rel.to != RECURSIVE_RELATIONSHIP_CONSTANT: to_model = field.rel.to to = to_model.split('.')[-1] def set_managed(field, model, cls): field.rel.through._meta.managed = model._meta.managed or cls._meta.managed add_lazy_relation(klass, field, to_model, set_managed) elif isinstance(field.rel.to, basestring): to = klass._meta.object_name to_model = klass managed = klass._meta.managed else: to = field.rel.to._meta.object_name to_model = field.rel.to managed = klass._meta.managed or to_model._meta.managed name = '%s_%s' % (klass._meta.object_name, field.name) if field.rel.to == RECURSIVE_RELATIONSHIP_CONSTANT or to == klass._meta.object_name: from_ = 'from_%s' % to.lower() to = 'to_%s' % to.lower() else: from_ = klass._meta.object_name.lower() to = to.lower() meta = type('Meta', (object,), { 'db_table': field._get_m2m_db_table(klass._meta), 'managed': managed, 'auto_created': klass, 'app_label': klass._meta.app_label, 'unique_together': (from_, to), 'verbose_name': '%(from)s-%(to)s relationship' % {'from': from_, 'to': to}, 'verbose_name_plural': '%(from)s-%(to)s relationships' % {'from': from_, 'to': to}, }) # Construct and return the new class. return type(name, (models.Model,), { 'Meta': meta, '__module__': klass.__module__, from_: models.ForeignKey(klass, related_name='%s+' % name), to: models.ForeignKey(to_model, related_name='%s+' % name) }) class ManyToManyField(RelatedField, Field): description = _("Many-to-many relationship") def __init__(self, to, **kwargs): try: assert not to._meta.abstract, "%s cannot define a relation with abstract class %s" % (self.__class__.__name__, to._meta.object_name) except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT assert isinstance(to, basestring), "%s(%r) is invalid. First parameter to ManyToManyField must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT) kwargs['verbose_name'] = kwargs.get('verbose_name', None) kwargs['rel'] = ManyToManyRel(to, related_name=kwargs.pop('related_name', None), limit_choices_to=kwargs.pop('limit_choices_to', None), symmetrical=kwargs.pop('symmetrical', to==RECURSIVE_RELATIONSHIP_CONSTANT), through=kwargs.pop('through', None)) self.db_table = kwargs.pop('db_table', None) if kwargs['rel'].through is not None: assert self.db_table is None, "Cannot specify a db_table if an intermediary model is used." Field.__init__(self, **kwargs) msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.') self.help_text = string_concat(self.help_text, ' ', msg) def get_choices_default(self): return Field.get_choices(self, include_blank=False) def _get_m2m_db_table(self, opts): "Function that can be curried to provide the m2m table name for this relation" if self.rel.through is not None: return self.rel.through._meta.db_table elif self.db_table: return self.db_table else: return util.truncate_name('%s_%s' % (opts.db_table, self.name), connection.ops.max_name_length()) def _get_m2m_attr(self, related, attr): "Function that can be curried to provide the source accessor or DB column name for the m2m table" cache_attr = '_m2m_%s_cache' % attr if hasattr(self, cache_attr): return getattr(self, cache_attr) for f in self.rel.through._meta.fields: if hasattr(f,'rel') and f.rel and f.rel.to == related.model: setattr(self, cache_attr, getattr(f, attr)) return getattr(self, cache_attr) def _get_m2m_reverse_attr(self, related, attr): "Function that can be curried to provide the related accessor or DB column name for the m2m table" cache_attr = '_m2m_reverse_%s_cache' % attr if hasattr(self, cache_attr): return getattr(self, cache_attr) found = False for f in self.rel.through._meta.fields: if hasattr(f,'rel') and f.rel and f.rel.to == related.parent_model: if related.model == related.parent_model: # If this is an m2m-intermediate to self, # the first foreign key you find will be # the source column. Keep searching for # the second foreign key. if found: setattr(self, cache_attr, getattr(f, attr)) break else: found = True else: setattr(self, cache_attr, getattr(f, attr)) break return getattr(self, cache_attr) def isValidIDList(self, field_data, all_data): "Validates that the value is a valid list of foreign keys" mod = self.rel.to try: pks = map(int, field_data.split(',')) except ValueError: # the CommaSeparatedIntegerField validator will catch this error return objects = mod._default_manager.in_bulk(pks) if len(objects) != len(pks): badkeys = [k for k in pks if k not in objects] raise exceptions.ValidationError( ungettext("Please enter valid %(self)s IDs. The value %(value)r is invalid.", "Please enter valid %(self)s IDs. The values %(value)r are invalid.", len(badkeys)) % { 'self': self.verbose_name, 'value': len(badkeys) == 1 and badkeys[0] or tuple(badkeys), }) def value_to_string(self, obj): data = '' if obj: qs = getattr(obj, self.name).all() data = [instance._get_pk_val() for instance in qs] else: # In required many-to-many fields with only one available choice, # select that one available choice. if not self.blank: choices_list = self.get_choices_default() if len(choices_list) == 1: data = [choices_list[0][0]] return smart_unicode(data) def contribute_to_class(self, cls, name): # To support multiple relations to self, it's useful to have a non-None # related name on symmetrical relations for internal reasons. The # concept doesn't make a lot of sense externally ("you want me to # specify *what* on my non-reversible relation?!"), so we set it up # automatically. The funky name reduces the chance of an accidental # clash. if self.rel.symmetrical and (self.rel.to == "self" or self.rel.to == cls._meta.object_name): self.rel.related_name = "%s_rel_+" % name super(ManyToManyField, self).contribute_to_class(cls, name) # The intermediate m2m model is not auto created if: # 1) There is a manually specified intermediate, or # 2) The class owning the m2m field is abstract. if not self.rel.through and not cls._meta.abstract: self.rel.through = create_many_to_many_intermediary_model(self, cls) # Add the descriptor for the m2m relation setattr(cls, self.name, ReverseManyRelatedObjectsDescriptor(self)) # Set up the accessor for the m2m table name for the relation self.m2m_db_table = curry(self._get_m2m_db_table, cls._meta) # Populate some necessary rel arguments so that cross-app relations # work correctly. if isinstance(self.rel.through, basestring): def resolve_through_model(field, model, cls): field.rel.through = model add_lazy_relation(cls, self, self.rel.through, resolve_through_model) if isinstance(self.rel.to, basestring): target = self.rel.to else: target = self.rel.to._meta.db_table cls._meta.duplicate_targets[self.column] = (target, "m2m") def contribute_to_related_class(self, cls, related): # Internal M2Ms (i.e., those with a related name ending with '+') # don't get a related descriptor. if not self.rel.is_hidden(): setattr(cls, related.get_accessor_name(), ManyRelatedObjectsDescriptor(related)) # Set up the accessors for the column names on the m2m table self.m2m_column_name = curry(self._get_m2m_attr, related, 'column') self.m2m_reverse_name = curry(self._get_m2m_reverse_attr, related, 'column') self.m2m_field_name = curry(self._get_m2m_attr, related, 'name') self.m2m_reverse_field_name = curry(self._get_m2m_reverse_attr, related, 'name') def set_attributes_from_rel(self): pass def value_from_object(self, obj): "Returns the value of this field in the given model instance." return getattr(obj, self.attname).all() def save_form_data(self, instance, data): setattr(instance, self.attname, data) def formfield(self, **kwargs): db = kwargs.pop('using', None) defaults = { 'form_class': forms.ModelMultipleChoiceField, 'queryset': self.rel.to._default_manager.using(db).complex_filter(self.rel.limit_choices_to) } defaults.update(kwargs) # If initial is passed in, it's a list of related objects, but the # MultipleChoiceField takes a list of IDs. if defaults.get('initial') is not None: initial = defaults['initial'] if callable(initial): initial = initial() defaults['initial'] = [i._get_pk_val() for i in initial] return super(ManyToManyField, self).formfield(**defaults) def db_type(self, connection): # A ManyToManyField is not represented by a single column, # so return None. return None
apache-2.0
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1950, 12, 6197, 12, 6008, 199, 504, 1639, 14, 697, 14, 7765, 492, 4884, 199, 504, 1639, 14, 697, 14, 992, 492, 10166, 12, 664, 63, 1238, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 334, 4378, 12, 5024, 12, 26141, 12, 272, 30245, 3901, 12, 30245, 14640, 12, 29994, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 2407, 492, 20116, 1692, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 5501, 1059, 63, 9419, 12, 26843, 12, 10366, 199, 504, 1639, 14, 1208, 14, 15481, 492, 1094, 651, 199, 504, 1639, 14, 1018, 492, 4967, 199, 504, 1639, 492, 4513, 421, 199, 907, 7013, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 275, 283, 277, 7, 199, 199, 6455, 63, 17438, 275, 1052, 199, 199, 318, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 901, 12, 5850, 12, 3439, 304, 272, 408, 272, 15747, 282, 4237, 641, 1124, 1886, 1040, 1380, 282, 4048, 901, 365, 3247, 1808, 282, 1059, 12, 272, 284, 14, 69, 28383, 398, 1021, 4932, 1685, 8, 1685, 304, 288, 14830, 275, 12718, 480, 23296, 1685, 531, 339, 961, 1059, 883, 506, 26, 398, 627, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 334, 73, 14, 69, 14, 298, 277, 531, 370, 6623, 282, 9133, 881, 5850, 14, 398, 627, 710, 536, 402, 282, 1402, 334, 73, 14, 69, 298, 23296, 1685, 531, 370, 6623, 4573, 1402, 315, 881, 314, 2011, 1145, 14, 398, 627, 1626, 1145, 13, 1302, 436, 1402, 536, 334, 73, 14, 69, 14, 298, 3972, 571, 14, 23296, 1685, 531, 370, 6623, 881, 4573, 1402, 315, 282, 3365, 1145, 14, 339, 982, 314, 1163, 1402, 18699, 1133, 5966, 2757, 6511, 1553, 18871, 282, 1627, 340, 1265, 3984, 1808, 272, 9617, 20045, 1553, 2066, 314, 5850, 7859, 1133, 506, 663, 1536, 5133, 314, 272, 1021, 63, 19260, 4673, 28887, 737, 314, 1284, 402, 1402, 11097, 14, 339, 3439, 365, 314, 1736, 626, 1471, 506, 10585, 5403, 314, 5850, 883, 506, 12152, 14, 272, 408, 272, 327, 2670, 367, 9133, 16109, 272, 340, 5850, 508, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 26, 267, 1145, 63, 1302, 275, 843, 423, 2024, 14, 571, 63, 1302, 267, 1402, 63, 354, 275, 843, 855, 354, 363, 339, 587, 26, 267, 327, 12077, 367, 376, 298, 571, 14, 1685, 2, 5850, 267, 862, 26, 288, 1145, 63, 1302, 12, 1402, 63, 354, 275, 5850, 14, 1294, 15857, 267, 871, 1722, 26, 288, 327, 982, 781, 883, 1133, 3715, 12, 5534, 282, 1402, 315, 1453, 1145, 288, 1145, 63, 1302, 275, 843, 423, 2024, 14, 571, 63, 1302, 288, 1402, 63, 354, 275, 5850, 267, 871, 4281, 26, 288, 327, 982, 652, 3181, 1133, 1172, 282, 3715, 652, 1159, 5965, 282, 1402, 1021, 288, 1145, 63, 1302, 275, 5850, 423, 2024, 14, 571, 63, 1302, 288, 1402, 63, 354, 275, 5850, 423, 2024, 14, 785, 63, 354, 339, 327, 7649, 370, 3648, 1536, 314, 4048, 1402, 12, 436, 340, 652, 1159, 2575, 6511, 7512, 314, 272, 327, 1059, 2451, 13437, 14, 982, 664, 63, 1238, 2529, 488, 12, 652, 4910, 626, 314, 4048, 272, 327, 1402, 5712, 1133, 6511, 5966, 12, 880, 781, 1929, 370, 299, 500, 314, 5850, 5133, 314, 1021, 272, 327, 365, 16318, 14, 272, 1402, 275, 664, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 756, 9, 272, 340, 1402, 26, 267, 3439, 8, 698, 12, 1402, 12, 843, 9, 272, 587, 26, 267, 790, 275, 334, 571, 63, 1302, 12, 1402, 63, 354, 9, 267, 574, 275, 334, 1886, 12, 901, 12, 3439, 9, 267, 9413, 63, 17438, 14, 5486, 8, 498, 12, 15364, 740, 8, 585, 9, 199, 199, 318, 886, 63, 6455, 63, 17438, 8, 8114, 12, 1011, 958, 304, 272, 408, 272, 8690, 1263, 9413, 16109, 370, 314, 10209, 1402, 14, 428, 484, 687, 1021, 63, 19260, 14, 272, 408, 272, 790, 275, 334, 8114, 423, 2024, 14, 571, 63, 1302, 12, 8904, 855, 354, 3368, 272, 367, 843, 12, 901, 12, 3439, 315, 9413, 63, 17438, 14, 1935, 8, 498, 12, 12319, 267, 3439, 8, 698, 12, 8904, 12, 843, 9, 199, 199, 10458, 14, 533, 63, 19260, 14, 2242, 8, 1117, 63, 6455, 63, 17438, 9, 199, 199, 3, 40, 3099, 199, 533, 20116, 792, 8, 785, 304, 272, 347, 28567, 63, 475, 63, 533, 8, 277, 12, 843, 12, 536, 304, 267, 1029, 275, 1613, 8, 13885, 792, 12, 291, 9, 398, 327, 13874, 314, 3999, 367, 4048, 63, 1131, 63, 354, 342, 267, 291, 14, 3291, 275, 843, 423, 2024, 398, 340, 2688, 8, 1961, 12, 283, 388, 999, 63, 475, 63, 533, 735, 288, 1029, 14, 388, 999, 63, 475, 63, 533, 8, 1886, 12, 536, 9, 398, 340, 440, 843, 423, 2024, 14, 6198, 436, 291, 14, 3369, 14, 2407, 63, 354, 26, 288, 291, 14, 3369, 14, 2407, 63, 354, 275, 291, 14, 3369, 14, 2407, 63, 354, 450, 469, 490, 283, 533, 356, 843, 855, 354, 4343, 2325, 1062, 490, 283, 571, 63, 1302, 356, 843, 423, 2024, 14, 571, 63, 1302, 14, 2325, 1062, 355, 789, 398, 1163, 275, 291, 14, 3369, 14, 475, 267, 340, 1228, 8, 1848, 12, 7116, 9, 503, 1163, 423, 2024, 14, 2051, 365, 488, 26, 288, 347, 7512, 63, 2407, 63, 533, 8, 698, 12, 1402, 12, 843, 304, 355, 901, 14, 3369, 14, 475, 275, 1402, 355, 901, 14, 1117, 63, 2407, 63, 533, 8, 1238, 12, 843, 9, 288, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 291, 12, 1163, 12, 7512, 63, 2407, 63, 533, 9, 267, 587, 26, 288, 291, 14, 1117, 63, 2407, 63, 533, 8, 1848, 12, 843, 9, 339, 347, 663, 63, 2987, 63, 504, 63, 3369, 8, 277, 304, 267, 291, 14, 354, 275, 291, 14 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1950, 12, 6197, 12, 6008, 199, 504, 1639, 14, 697, 14, 7765, 492, 4884, 199, 504, 1639, 14, 697, 14, 992, 492, 10166, 12, 664, 63, 1238, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 334, 4378, 12, 5024, 12, 26141, 12, 272, 30245, 3901, 12, 30245, 14640, 12, 29994, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 2407, 492, 20116, 1692, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 63, 1208, 492, 8133, 4590, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 2975, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 5501, 1059, 63, 9419, 12, 26843, 12, 10366, 199, 504, 1639, 14, 1208, 14, 15481, 492, 1094, 651, 199, 504, 1639, 14, 1018, 492, 4967, 199, 504, 1639, 492, 4513, 421, 199, 907, 7013, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 275, 283, 277, 7, 199, 199, 6455, 63, 17438, 275, 1052, 199, 199, 318, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 901, 12, 5850, 12, 3439, 304, 272, 408, 272, 15747, 282, 4237, 641, 1124, 1886, 1040, 1380, 282, 4048, 901, 365, 3247, 1808, 282, 1059, 12, 272, 284, 14, 69, 28383, 398, 1021, 4932, 1685, 8, 1685, 304, 288, 14830, 275, 12718, 480, 23296, 1685, 531, 339, 961, 1059, 883, 506, 26, 398, 627, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 334, 73, 14, 69, 14, 298, 277, 531, 370, 6623, 282, 9133, 881, 5850, 14, 398, 627, 710, 536, 402, 282, 1402, 334, 73, 14, 69, 298, 23296, 1685, 531, 370, 6623, 4573, 1402, 315, 881, 314, 2011, 1145, 14, 398, 627, 1626, 1145, 13, 1302, 436, 1402, 536, 334, 73, 14, 69, 14, 298, 3972, 571, 14, 23296, 1685, 531, 370, 6623, 881, 4573, 1402, 315, 282, 3365, 1145, 14, 339, 982, 314, 1163, 1402, 18699, 1133, 5966, 2757, 6511, 1553, 18871, 282, 1627, 340, 1265, 3984, 1808, 272, 9617, 20045, 1553, 2066, 314, 5850, 7859, 1133, 506, 663, 1536, 5133, 314, 272, 1021, 63, 19260, 4673, 28887, 737, 314, 1284, 402, 1402, 11097, 14, 339, 3439, 365, 314, 1736, 626, 1471, 506, 10585, 5403, 314, 5850, 883, 506, 12152, 14, 272, 408, 272, 327, 2670, 367, 9133, 16109, 272, 340, 5850, 508, 19461, 1230, 2684, 2524, 63, 13604, 2594, 3234, 1772, 63, 25825, 26, 267, 1145, 63, 1302, 275, 843, 423, 2024, 14, 571, 63, 1302, 267, 1402, 63, 354, 275, 843, 855, 354, 363, 339, 587, 26, 267, 327, 12077, 367, 376, 298, 571, 14, 1685, 2, 5850, 267, 862, 26, 288, 1145, 63, 1302, 12, 1402, 63, 354, 275, 5850, 14, 1294, 15857, 267, 871, 1722, 26, 288, 327, 982, 781, 883, 1133, 3715, 12, 5534, 282, 1402, 315, 1453, 1145, 288, 1145, 63, 1302, 275, 843, 423, 2024, 14, 571, 63, 1302, 288, 1402, 63, 354, 275, 5850, 267, 871, 4281, 26, 288, 327, 982, 652, 3181, 1133, 1172, 282, 3715, 652, 1159, 5965, 282, 1402, 1021, 288, 1145, 63, 1302, 275, 5850, 423, 2024, 14, 571, 63, 1302, 288, 1402, 63, 354, 275, 5850, 423, 2024, 14, 785, 63, 354, 339, 327, 7649, 370, 3648, 1536, 314, 4048, 1402, 12, 436, 340, 652, 1159, 2575, 6511, 7512, 314, 272, 327, 1059, 2451, 13437, 14, 982, 664, 63, 1238, 2529, 488, 12, 652, 4910, 626, 314, 4048, 272, 327, 1402, 5712, 1133, 6511, 5966, 12, 880, 781, 1929, 370, 299, 500, 314, 5850, 5133, 314, 1021, 272, 327, 365, 16318, 14, 272, 1402, 275, 664, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 12, 756, 9, 272, 340, 1402, 26, 267, 3439, 8, 698, 12, 1402, 12, 843, 9, 272, 587, 26, 267, 790, 275, 334, 571, 63, 1302, 12, 1402, 63, 354, 9, 267, 574, 275, 334, 1886, 12, 901, 12, 3439, 9, 267, 9413, 63, 17438, 14, 5486, 8, 498, 12, 15364, 740, 8, 585, 9, 199, 199, 318, 886, 63, 6455, 63, 17438, 8, 8114, 12, 1011, 958, 304, 272, 408, 272, 8690, 1263, 9413, 16109, 370, 314, 10209, 1402, 14, 428, 484, 687, 1021, 63, 19260, 14, 272, 408, 272, 790, 275, 334, 8114, 423, 2024, 14, 571, 63, 1302, 12, 8904, 855, 354, 3368, 272, 367, 843, 12, 901, 12, 3439, 315, 9413, 63, 17438, 14, 1935, 8, 498, 12, 12319, 267, 3439, 8, 698, 12, 8904, 12, 843, 9, 199, 199, 10458, 14, 533, 63, 19260, 14, 2242, 8, 1117, 63, 6455, 63, 17438, 9, 199, 199, 3, 40, 3099, 199, 533, 20116, 792, 8, 785, 304, 272, 347, 28567, 63, 475, 63, 533, 8, 277, 12, 843, 12, 536, 304, 267, 1029, 275, 1613, 8, 13885, 792, 12, 291, 9, 398, 327, 13874, 314, 3999, 367, 4048, 63, 1131, 63, 354, 342, 267, 291, 14, 3291, 275, 843, 423, 2024, 398, 340, 2688, 8, 1961, 12, 283, 388, 999, 63, 475, 63, 533, 735, 288, 1029, 14, 388, 999, 63, 475, 63, 533, 8, 1886, 12, 536, 9, 398, 340, 440, 843, 423, 2024, 14, 6198, 436, 291, 14, 3369, 14, 2407, 63, 354, 26, 288, 291, 14, 3369, 14, 2407, 63, 354, 275, 291, 14, 3369, 14, 2407, 63, 354, 450, 469, 490, 283, 533, 356, 843, 855, 354, 4343, 2325, 1062, 490, 283, 571, 63, 1302, 356, 843, 423, 2024, 14, 571, 63, 1302, 14, 2325, 1062, 355, 789, 398, 1163, 275, 291, 14, 3369, 14, 475, 267, 340, 1228, 8, 1848, 12, 7116, 9, 503, 1163, 423, 2024, 14, 2051, 365, 488, 26, 288, 347, 7512, 63, 2407, 63, 533, 8, 698, 12, 1402, 12, 843, 304, 355, 901, 14, 3369, 14, 475, 275, 1402, 355, 901, 14, 1117, 63, 2407, 63, 533, 8, 1238, 12, 843, 9, 288, 1050, 63, 6395, 63, 5690, 8, 1886, 12, 291, 12, 1163, 12, 7512, 63, 2407, 63, 533, 9, 267, 587, 26, 288, 291, 14, 1117, 63, 2407, 63, 533, 8, 1848, 12, 843, 9, 339, 347, 663, 63, 2987, 63, 504, 63, 3369, 8, 277, 304, 267, 291, 14, 354, 275, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
ndn/somacube
python/somacube.py
1
1941
#!/usr/bin/python import sys import argparse from threading import Thread import problems from solver import Solver if __name__ != "__main__": sys.exit() parser = argparse.ArgumentParser(description="Kloetze algorithm.") parser.add_argument("-p", "--problem") parser.add_argument("-a", "--all", action="store_true", help="Solve all problems starting with the given one.") parser.add_argument("-c", "--complete", action="store_true", help="Find all solutions.") parser.add_argument("-j", "--javascript", action="store_true", help="Generate java script arrays for solutions") parser.add_argument("-m", "--multicore", action="store_true", help="Use parallel execution on all cores.") args = parser.parse_args() problems = problems.load() if args.problem == None: print("Specify problem to work on. (0-{})".format(len(problems) - 1)) sys.exit() problem = int(args.problem) assert problem >= 0 and problem < len(problems), "-p or --problem out of range" if args.all: problem_range = range(problem, len(problems)) else: problem_range = range(problem, problem + 1) solutions = [] if args.multicore: # TODO: See what happens on systems where zmq is not installed. import parallel_solver try: for p in problem_range: print("Solving problem {}".format(p)) if not args.multicore: solver = Solver(problems[p], complete=args.complete) solutions.append(solver.solve()) else: solutions.append(parallel_solver.solve(problems[p], args.complete)) except: raise finally: if args.multicore: parallel_solver.quit() print("") if args.javascript: import json with open("../js/solutions.js", "w") as f: f.write("solutions =") f.write(json.dumps(solutions)) f.write(";") with open("../js/problems.js", "w") as f: f.write("problems =") f.write(json.dumps(problems)) f.write(";")
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 984, 199, 646, 7534, 199, 504, 5796, 492, 11086, 199, 199, 646, 8826, 199, 504, 10196, 492, 428, 3725, 199, 199, 692, 636, 354, 363, 1137, 4396, 973, 5727, 272, 984, 14, 2224, 342, 199, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 628, 43, 320, 386, 806, 5563, 2685, 199, 2087, 14, 525, 63, 2094, 6096, 80, 401, 4320, 6462, 531, 199, 2087, 14, 525, 63, 2094, 6096, 65, 401, 4320, 452, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 51, 3344, 1006, 8826, 6617, 543, 314, 1627, 1373, 2685, 199, 2087, 14, 525, 63, 2094, 6096, 67, 401, 4320, 4883, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 6591, 1006, 24886, 2685, 199, 2087, 14, 525, 63, 2094, 6096, 74, 401, 4320, 9554, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 6864, 12120, 2884, 6572, 367, 24886, 531, 199, 2087, 14, 525, 63, 2094, 6096, 77, 401, 4320, 3029, 1018, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 6119, 9861, 6451, 641, 1006, 23857, 2685, 199, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 22959, 275, 8826, 14, 912, 342, 199, 199, 692, 1249, 14, 6462, 508, 488, 26, 272, 870, 480, 17768, 5160, 370, 1736, 641, 14, 334, 16, 24185, 25974, 908, 8, 552, 8, 22959, 9, 446, 413, 430, 272, 984, 14, 2224, 342, 199, 199, 6462, 275, 1109, 8, 589, 14, 6462, 9, 199, 199, 479, 5160, 2356, 378, 436, 5160, 665, 822, 8, 22959, 395, 3905, 80, 503, 1553, 6462, 734, 402, 1425, 2, 199, 199, 692, 1249, 14, 452, 26, 272, 5160, 63, 1842, 275, 1425, 8, 6462, 12, 822, 8, 22959, 430, 199, 2836, 26, 272, 5160, 63, 1842, 275, 1425, 8, 6462, 12, 5160, 435, 413, 9, 199, 199, 27313, 275, 942, 199, 199, 692, 1249, 14, 3029, 1018, 26, 272, 327, 3254, 26, 1666, 4052, 10986, 641, 10460, 2382, 26633, 365, 440, 4903, 14, 272, 492, 9861, 63, 11263, 199, 199, 893, 26, 272, 367, 299, 315, 5160, 63, 1842, 26, 267, 870, 480, 27262, 4007, 5160, 8352, 908, 8, 80, 430, 398, 340, 440, 1249, 14, 3029, 1018, 26, 288, 10196, 275, 428, 3725, 8, 22959, 59, 80, 467, 4890, 29, 589, 14, 4883, 9, 288, 24886, 14, 740, 8, 11263, 14, 11356, 1012, 267, 587, 26, 288, 24886, 14, 740, 8, 11887, 63, 11263, 14, 11356, 8, 22959, 59, 80, 467, 1249, 14, 4883, 430, 199, 199, 2590, 26, 272, 746, 199, 199, 15172, 26, 272, 340, 1249, 14, 3029, 1018, 26, 267, 9861, 63, 11263, 14, 10589, 342, 199, 199, 1361, 10804, 199, 199, 692, 1249, 14, 9554, 26, 272, 492, 2022, 272, 543, 1551, 480, 5093, 3596, 15, 27313, 14, 3596, 401, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 480, 27313, 275, 531, 267, 289, 14, 952, 8, 1001, 14, 4180, 8, 27313, 430, 267, 289, 14, 952, 480, 15027, 339, 543, 1551, 480, 5093, 3596, 15, 22959, 14, 3596, 401, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 480, 22959, 275, 531, 267, 289, 14, 952, 8, 1001, 14, 4180, 8, 22959, 430, 267, 289, 14, 952, 480, 15027, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 984, 199, 646, 7534, 199, 504, 5796, 492, 11086, 199, 199, 646, 8826, 199, 504, 10196, 492, 428, 3725, 199, 199, 692, 636, 354, 363, 1137, 4396, 973, 5727, 272, 984, 14, 2224, 342, 199, 199, 2087, 275, 7534, 14, 10730, 8, 1802, 628, 43, 320, 386, 806, 5563, 2685, 199, 2087, 14, 525, 63, 2094, 6096, 80, 401, 4320, 6462, 531, 199, 2087, 14, 525, 63, 2094, 6096, 65, 401, 4320, 452, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 51, 3344, 1006, 8826, 6617, 543, 314, 1627, 1373, 2685, 199, 2087, 14, 525, 63, 2094, 6096, 67, 401, 4320, 4883, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 6591, 1006, 24886, 2685, 199, 2087, 14, 525, 63, 2094, 6096, 74, 401, 4320, 9554, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 6864, 12120, 2884, 6572, 367, 24886, 531, 199, 2087, 14, 525, 63, 2094, 6096, 77, 401, 4320, 3029, 1018, 401, 1595, 628, 1617, 63, 2052, 401, 1720, 628, 6119, 9861, 6451, 641, 1006, 23857, 2685, 199, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 22959, 275, 8826, 14, 912, 342, 199, 199, 692, 1249, 14, 6462, 508, 488, 26, 272, 870, 480, 17768, 5160, 370, 1736, 641, 14, 334, 16, 24185, 25974, 908, 8, 552, 8, 22959, 9, 446, 413, 430, 272, 984, 14, 2224, 342, 199, 199, 6462, 275, 1109, 8, 589, 14, 6462, 9, 199, 199, 479, 5160, 2356, 378, 436, 5160, 665, 822, 8, 22959, 395, 3905, 80, 503, 1553, 6462, 734, 402, 1425, 2, 199, 199, 692, 1249, 14, 452, 26, 272, 5160, 63, 1842, 275, 1425, 8, 6462, 12, 822, 8, 22959, 430, 199, 2836, 26, 272, 5160, 63, 1842, 275, 1425, 8, 6462, 12, 5160, 435, 413, 9, 199, 199, 27313, 275, 942, 199, 199, 692, 1249, 14, 3029, 1018, 26, 272, 327, 3254, 26, 1666, 4052, 10986, 641, 10460, 2382, 26633, 365, 440, 4903, 14, 272, 492, 9861, 63, 11263, 199, 199, 893, 26, 272, 367, 299, 315, 5160, 63, 1842, 26, 267, 870, 480, 27262, 4007, 5160, 8352, 908, 8, 80, 430, 398, 340, 440, 1249, 14, 3029, 1018, 26, 288, 10196, 275, 428, 3725, 8, 22959, 59, 80, 467, 4890, 29, 589, 14, 4883, 9, 288, 24886, 14, 740, 8, 11263, 14, 11356, 1012, 267, 587, 26, 288, 24886, 14, 740, 8, 11887, 63, 11263, 14, 11356, 8, 22959, 59, 80, 467, 1249, 14, 4883, 430, 199, 199, 2590, 26, 272, 746, 199, 199, 15172, 26, 272, 340, 1249, 14, 3029, 1018, 26, 267, 9861, 63, 11263, 14, 10589, 342, 199, 199, 1361, 10804, 199, 199, 692, 1249, 14, 9554, 26, 272, 492, 2022, 272, 543, 1551, 480, 5093, 3596, 15, 27313, 14, 3596, 401, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 480, 27313, 275, 531, 267, 289, 14, 952, 8, 1001, 14, 4180, 8, 27313, 430, 267, 289, 14, 952, 480, 15027, 339, 543, 1551, 480, 5093, 3596, 15, 22959, 14, 3596, 401, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 480, 22959, 275, 531, 267, 289, 14, 952, 8, 1001, 14, 4180, 8, 22959, 430, 267, 289, 14, 952, 480, 15027, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
RO-ny9/python-for-android
python-modules/twisted/twisted/internet/_sslverify.py
49
24224
# -*- test-case-name: twisted.test.test_sslverify -*- # Copyright (c) 2005 Divmod, Inc. # Copyright (c) 2008 Twisted Matrix Laboratories. # See LICENSE for details. # Copyright (c) 2005-2008 Twisted Matrix Laboratories. import itertools from OpenSSL import SSL, crypto from twisted.python import reflect, util from twisted.python.hashlib import md5 from twisted.internet.defer import Deferred from twisted.internet.error import VerifyError, CertificateError # Private - shared between all OpenSSLCertificateOptions, counts up to provide # a unique session id for each context _sessionCounter = itertools.count().next _x509names = { 'CN': 'commonName', 'commonName': 'commonName', 'O': 'organizationName', 'organizationName': 'organizationName', 'OU': 'organizationalUnitName', 'organizationalUnitName': 'organizationalUnitName', 'L': 'localityName', 'localityName': 'localityName', 'ST': 'stateOrProvinceName', 'stateOrProvinceName': 'stateOrProvinceName', 'C': 'countryName', 'countryName': 'countryName', 'emailAddress': 'emailAddress'} class DistinguishedName(dict): """ Identify and describe an entity. Distinguished names are used to provide a minimal amount of identifying information about a certificate issuer or subject. They are commonly created with one or more of the following fields:: commonName (CN) organizationName (O) organizationalUnitName (OU) localityName (L) stateOrProvinceName (ST) countryName (C) emailAddress """ __slots__ = () def __init__(self, **kw): for k, v in kw.iteritems(): setattr(self, k, v) def _copyFrom(self, x509name): d = {} for name in _x509names: value = getattr(x509name, name, None) if value is not None: setattr(self, name, value) def _copyInto(self, x509name): for k, v in self.iteritems(): setattr(x509name, k, v) def __repr__(self): return '<DN %s>' % (dict.__repr__(self)[1:-1]) def __getattr__(self, attr): try: return self[_x509names[attr]] except KeyError: raise AttributeError(attr) def __setattr__(self, attr, value): assert type(attr) is str if not attr in _x509names: raise AttributeError("%s is not a valid OpenSSL X509 name field" % (attr,)) realAttr = _x509names[attr] value = value.encode('ascii') assert type(value) is str self[realAttr] = value def inspect(self): """ Return a multi-line, human-readable representation of this DN. """ l = [] lablen = 0 def uniqueValues(mapping): return dict.fromkeys(mapping.itervalues()).keys() for k in uniqueValues(_x509names): label = util.nameToLabel(k) lablen = max(len(label), lablen) v = getattr(self, k, None) if v is not None: l.append((label, v)) lablen += 2 for n, (label, attr) in enumerate(l): l[n] = (label.rjust(lablen)+': '+ attr) return '\n'.join(l) DN = DistinguishedName class CertBase: def __init__(self, original): self.original = original def _copyName(self, suffix): dn = DistinguishedName() dn._copyFrom(getattr(self.original, 'get_'+suffix)()) return dn def getSubject(self): """ Retrieve the subject of this certificate. @rtype: L{DistinguishedName} @return: A copy of the subject of this certificate. """ return self._copyName('subject') def _handleattrhelper(Class, transport, methodName): """ (private) Helper for L{Certificate.peerFromTransport} and L{Certificate.hostFromTransport} which checks for incompatible handle types and null certificates and raises the appropriate exception or returns the appropriate certificate object. """ method = getattr(transport.getHandle(), "get_%s_certificate" % (methodName,), None) if method is None: raise CertificateError( "non-TLS transport %r did not have %s certificate" % (transport, methodName)) cert = method() if cert is None: raise CertificateError( "TLS transport %r did not have %s certificate" % (transport, methodName)) return Class(cert) class Certificate(CertBase): """ An x509 certificate. """ def __repr__(self): return '<%s Subject=%s Issuer=%s>' % (self.__class__.__name__, self.getSubject().commonName, self.getIssuer().commonName) def __eq__(self, other): if isinstance(other, Certificate): return self.dump() == other.dump() return False def __ne__(self, other): return not self.__eq__(other) def load(Class, requestData, format=crypto.FILETYPE_ASN1, args=()): """ Load a certificate from an ASN.1- or PEM-format string. @rtype: C{Class} """ return Class(crypto.load_certificate(format, requestData), *args) load = classmethod(load) _load = load def dumpPEM(self): """ Dump this certificate to a PEM-format data string. @rtype: C{str} """ return self.dump(crypto.FILETYPE_PEM) def loadPEM(Class, data): """ Load a certificate from a PEM-format data string. @rtype: C{Class} """ return Class.load(data, crypto.FILETYPE_PEM) loadPEM = classmethod(loadPEM) def peerFromTransport(Class, transport): """ Get the certificate for the remote end of the given transport. @type: L{ISystemHandle} @rtype: C{Class} @raise: L{CertificateError}, if the given transport does not have a peer certificate. """ return _handleattrhelper(Class, transport, 'peer') peerFromTransport = classmethod(peerFromTransport) def hostFromTransport(Class, transport): """ Get the certificate for the local end of the given transport. @param transport: an L{ISystemHandle} provider; the transport we will @rtype: C{Class} @raise: L{CertificateError}, if the given transport does not have a host certificate. """ return _handleattrhelper(Class, transport, 'host') hostFromTransport = classmethod(hostFromTransport) def getPublicKey(self): """ Get the public key for this certificate. @rtype: L{PublicKey} """ return PublicKey(self.original.get_pubkey()) def dump(self, format=crypto.FILETYPE_ASN1): return crypto.dump_certificate(format, self.original) def serialNumber(self): """ Retrieve the serial number of this certificate. @rtype: C{int} """ return self.original.get_serial_number() def digest(self, method='md5'): """ Return a digest hash of this certificate using the specified hash algorithm. @param method: One of C{'md5'} or C{'sha'}. @rtype: C{str} """ return self.original.digest(method) def _inspect(self): return '\n'.join(['Certificate For Subject:', self.getSubject().inspect(), '\nIssuer:', self.getIssuer().inspect(), '\nSerial Number: %d' % self.serialNumber(), 'Digest: %s' % self.digest()]) def inspect(self): """ Return a multi-line, human-readable representation of this Certificate, including information about the subject, issuer, and public key. """ return '\n'.join((self._inspect(), self.getPublicKey().inspect())) def getIssuer(self): """ Retrieve the issuer of this certificate. @rtype: L{DistinguishedName} @return: A copy of the issuer of this certificate. """ return self._copyName('issuer') def options(self, *authorities): raise NotImplementedError('Possible, but doubtful we need this yet') class CertificateRequest(CertBase): """ An x509 certificate request. Certificate requests are given to certificate authorities to be signed and returned resulting in an actual certificate. """ def load(Class, requestData, requestFormat=crypto.FILETYPE_ASN1): req = crypto.load_certificate_request(requestFormat, requestData) dn = DistinguishedName() dn._copyFrom(req.get_subject()) if not req.verify(req.get_pubkey()): raise VerifyError("Can't verify that request for %r is self-signed." % (dn,)) return Class(req) load = classmethod(load) def dump(self, format=crypto.FILETYPE_ASN1): return crypto.dump_certificate_request(format, self.original) class PrivateCertificate(Certificate): """ An x509 certificate and private key. """ def __repr__(self): return Certificate.__repr__(self) + ' with ' + repr(self.privateKey) def _setPrivateKey(self, privateKey): if not privateKey.matches(self.getPublicKey()): raise VerifyError( "Certificate public and private keys do not match.") self.privateKey = privateKey return self def newCertificate(self, newCertData, format=crypto.FILETYPE_ASN1): """ Create a new L{PrivateCertificate} from the given certificate data and this instance's private key. """ return self.load(newCertData, self.privateKey, format) def load(Class, data, privateKey, format=crypto.FILETYPE_ASN1): return Class._load(data, format)._setPrivateKey(privateKey) load = classmethod(load) def inspect(self): return '\n'.join([Certificate._inspect(self), self.privateKey.inspect()]) def dumpPEM(self): """ Dump both public and private parts of a private certificate to PEM-format data. """ return self.dump(crypto.FILETYPE_PEM) + self.privateKey.dump(crypto.FILETYPE_PEM) def loadPEM(Class, data): """ Load both private and public parts of a private certificate from a chunk of PEM-format data. """ return Class.load(data, KeyPair.load(data, crypto.FILETYPE_PEM), crypto.FILETYPE_PEM) loadPEM = classmethod(loadPEM) def fromCertificateAndKeyPair(Class, certificateInstance, privateKey): privcert = Class(certificateInstance.original) return privcert._setPrivateKey(privateKey) fromCertificateAndKeyPair = classmethod(fromCertificateAndKeyPair) def options(self, *authorities): options = dict(privateKey=self.privateKey.original, certificate=self.original) if authorities: options.update(dict(verify=True, requireCertificate=True, caCerts=[auth.original for auth in authorities])) return OpenSSLCertificateOptions(**options) def certificateRequest(self, format=crypto.FILETYPE_ASN1, digestAlgorithm='md5'): return self.privateKey.certificateRequest( self.getSubject(), format, digestAlgorithm) def signCertificateRequest(self, requestData, verifyDNCallback, serialNumber, requestFormat=crypto.FILETYPE_ASN1, certificateFormat=crypto.FILETYPE_ASN1): issuer = self.getSubject() return self.privateKey.signCertificateRequest( issuer, requestData, verifyDNCallback, serialNumber, requestFormat, certificateFormat) def signRequestObject(self, certificateRequest, serialNumber, secondsToExpiry=60 * 60 * 24 * 365, # One year digestAlgorithm='md5'): return self.privateKey.signRequestObject(self.getSubject(), certificateRequest, serialNumber, secondsToExpiry, digestAlgorithm) class PublicKey: def __init__(self, osslpkey): self.original = osslpkey req1 = crypto.X509Req() req1.set_pubkey(osslpkey) self._emptyReq = crypto.dump_certificate_request(crypto.FILETYPE_ASN1, req1) def matches(self, otherKey): return self._emptyReq == otherKey._emptyReq # XXX This could be a useful method, but sometimes it triggers a segfault, # so we'll steer clear for now. # def verifyCertificate(self, certificate): # """ # returns None, or raises a VerifyError exception if the certificate # could not be verified. # """ # if not certificate.original.verify(self.original): # raise VerifyError("We didn't sign that certificate.") def __repr__(self): return '<%s %s>' % (self.__class__.__name__, self.keyHash()) def keyHash(self): """ MD5 hex digest of signature on an empty certificate request with this key. """ return md5(self._emptyReq).hexdigest() def inspect(self): return 'Public Key with Hash: %s' % (self.keyHash(),) class KeyPair(PublicKey): def load(Class, data, format=crypto.FILETYPE_ASN1): return Class(crypto.load_privatekey(format, data)) load = classmethod(load) def dump(self, format=crypto.FILETYPE_ASN1): return crypto.dump_privatekey(format, self.original) def __getstate__(self): return self.dump() def __setstate__(self, state): self.__init__(crypto.load_privatekey(crypto.FILETYPE_ASN1, state)) def inspect(self): t = self.original.type() if t == crypto.TYPE_RSA: ts = 'RSA' elif t == crypto.TYPE_DSA: ts = 'DSA' else: ts = '(Unknown Type!)' L = (self.original.bits(), ts, self.keyHash()) return '%s-bit %s Key Pair with Hash: %s' % L def generate(Class, kind=crypto.TYPE_RSA, size=1024): pkey = crypto.PKey() pkey.generate_key(kind, size) return Class(pkey) def newCertificate(self, newCertData, format=crypto.FILETYPE_ASN1): return PrivateCertificate.load(newCertData, self, format) generate = classmethod(generate) def requestObject(self, distinguishedName, digestAlgorithm='md5'): req = crypto.X509Req() req.set_pubkey(self.original) distinguishedName._copyInto(req.get_subject()) req.sign(self.original, digestAlgorithm) return CertificateRequest(req) def certificateRequest(self, distinguishedName, format=crypto.FILETYPE_ASN1, digestAlgorithm='md5'): """Create a certificate request signed with this key. @return: a string, formatted according to the 'format' argument. """ return self.requestObject(distinguishedName, digestAlgorithm).dump(format) def signCertificateRequest(self, issuerDistinguishedName, requestData, verifyDNCallback, serialNumber, requestFormat=crypto.FILETYPE_ASN1, certificateFormat=crypto.FILETYPE_ASN1, secondsToExpiry=60 * 60 * 24 * 365, # One year digestAlgorithm='md5'): """ Given a blob of certificate request data and a certificate authority's DistinguishedName, return a blob of signed certificate data. If verifyDNCallback returns a Deferred, I will return a Deferred which fires the data when that Deferred has completed. """ hlreq = CertificateRequest.load(requestData, requestFormat) dn = hlreq.getSubject() vval = verifyDNCallback(dn) def verified(value): if not value: raise VerifyError("DN callback %r rejected request DN %r" % (verifyDNCallback, dn)) return self.signRequestObject(issuerDistinguishedName, hlreq, serialNumber, secondsToExpiry, digestAlgorithm).dump(certificateFormat) if isinstance(vval, Deferred): return vval.addCallback(verified) else: return verified(vval) def signRequestObject(self, issuerDistinguishedName, requestObject, serialNumber, secondsToExpiry=60 * 60 * 24 * 365, # One year digestAlgorithm='md5'): """ Sign a CertificateRequest instance, returning a Certificate instance. """ req = requestObject.original dn = requestObject.getSubject() cert = crypto.X509() issuerDistinguishedName._copyInto(cert.get_issuer()) cert.set_subject(req.get_subject()) cert.set_pubkey(req.get_pubkey()) cert.gmtime_adj_notBefore(0) cert.gmtime_adj_notAfter(secondsToExpiry) cert.set_serial_number(serialNumber) cert.sign(self.original, digestAlgorithm) return Certificate(cert) def selfSignedCert(self, serialNumber, **kw): dn = DN(**kw) return PrivateCertificate.fromCertificateAndKeyPair( self.signRequestObject(dn, self.requestObject(dn), serialNumber), self) class OpenSSLCertificateOptions(object): """ A factory for SSL context objects for both SSL servers and clients. """ _context = None # Older versions of PyOpenSSL didn't provide OP_ALL. Fudge it here, just in case. _OP_ALL = getattr(SSL, 'OP_ALL', 0x0000FFFF) # OP_NO_TICKET is not (yet) exposed by PyOpenSSL _OP_NO_TICKET = 0x00004000 method = SSL.TLSv1_METHOD def __init__(self, privateKey=None, certificate=None, method=None, verify=False, caCerts=None, verifyDepth=9, requireCertificate=True, verifyOnce=True, enableSingleUseKeys=True, enableSessions=True, fixBrokenPeers=False, enableSessionTickets=False): """ Create an OpenSSL context SSL connection context factory. @param privateKey: A PKey object holding the private key. @param certificate: An X509 object holding the certificate. @param method: The SSL protocol to use, one of SSLv23_METHOD, SSLv2_METHOD, SSLv3_METHOD, TLSv1_METHOD. Defaults to TLSv1_METHOD. @param verify: If True, verify certificates received from the peer and fail the handshake if verification fails. Otherwise, allow anonymous sessions and sessions with certificates which fail validation. By default this is False. @param caCerts: List of certificate authority certificate objects to use to verify the peer's certificate. Only used if verify is C{True}, and if verify is C{True}, this must be specified. Since verify is C{False} by default, this is C{None} by default. @type caCerts: C{list} of L{OpenSSL.crypto.X509} @param verifyDepth: Depth in certificate chain down to which to verify. If unspecified, use the underlying default (9). @param requireCertificate: If True, do not allow anonymous sessions. @param verifyOnce: If True, do not re-verify the certificate on session resumption. @param enableSingleUseKeys: If True, generate a new key whenever ephemeral DH parameters are used to prevent small subgroup attacks. @param enableSessions: If True, set a session ID on each context. This allows a shortened handshake to be used when a known client reconnects. @param fixBrokenPeers: If True, enable various non-spec protocol fixes for broken SSL implementations. This should be entirely safe, according to the OpenSSL documentation, but YMMV. This option is now off by default, because it causes problems with connections between peers using OpenSSL 0.9.8a. @param enableSessionTickets: If True, enable session ticket extension for session resumption per RFC 5077. Note there is no support for controlling session tickets. This option is off by default, as some server implementations don't correctly process incoming empty session ticket extensions in the hello. """ assert (privateKey is None) == (certificate is None), "Specify neither or both of privateKey and certificate" self.privateKey = privateKey self.certificate = certificate if method is not None: self.method = method self.verify = verify assert ((verify and caCerts) or (not verify)), "Specify client CA certificate information if and only if enabling certificate verification" self.caCerts = caCerts self.verifyDepth = verifyDepth self.requireCertificate = requireCertificate self.verifyOnce = verifyOnce self.enableSingleUseKeys = enableSingleUseKeys self.enableSessions = enableSessions self.fixBrokenPeers = fixBrokenPeers self.enableSessionTickets = enableSessionTickets def __getstate__(self): d = self.__dict__.copy() try: del d['_context'] except KeyError: pass return d def __setstate__(self, state): self.__dict__ = state def getContext(self): """Return a SSL.Context object. """ if self._context is None: self._context = self._makeContext() return self._context def _makeContext(self): ctx = SSL.Context(self.method) if self.certificate is not None and self.privateKey is not None: ctx.use_certificate(self.certificate) ctx.use_privatekey(self.privateKey) # Sanity check ctx.check_privatekey() verifyFlags = SSL.VERIFY_NONE if self.verify: verifyFlags = SSL.VERIFY_PEER if self.requireCertificate: verifyFlags |= SSL.VERIFY_FAIL_IF_NO_PEER_CERT if self.verifyOnce: verifyFlags |= SSL.VERIFY_CLIENT_ONCE if self.caCerts: store = ctx.get_cert_store() for cert in self.caCerts: store.add_cert(cert) # It'd be nice if pyOpenSSL let us pass None here for this behavior (as # the underlying OpenSSL API call allows NULL to be passed). It # doesn't, so we'll supply a function which does the same thing. def _verifyCallback(conn, cert, errno, depth, preverify_ok): return preverify_ok ctx.set_verify(verifyFlags, _verifyCallback) if self.verifyDepth is not None: ctx.set_verify_depth(self.verifyDepth) if self.enableSingleUseKeys: ctx.set_options(SSL.OP_SINGLE_DH_USE) if self.fixBrokenPeers: ctx.set_options(self._OP_ALL) if self.enableSessions: sessionName = md5("%s-%d" % (reflect.qual(self.__class__), _sessionCounter())).hexdigest() ctx.set_session_id(sessionName) if not self.enableSessionTickets: ctx.set_options(self._OP_NO_TICKET) return ctx
apache-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 4266, 4712, 1882, 199, 3, 1898, 334, 67, 9, 11811, 32077, 1494, 12, 3277, 14, 199, 3, 1898, 334, 67, 9, 9079, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 3, 1898, 334, 67, 9, 11811, 13, 9300, 17078, 8449, 26640, 14, 199, 199, 646, 7975, 199, 504, 14296, 492, 7799, 12, 13230, 199, 199, 504, 7390, 14, 1548, 492, 16806, 12, 4884, 199, 504, 7390, 14, 1548, 14, 24722, 492, 6128, 21, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 199, 504, 7390, 14, 4901, 14, 705, 492, 7635, 547, 12, 31953, 199, 199, 3, 18551, 446, 5709, 3382, 1006, 14296, 11414, 4558, 12, 8242, 1536, 370, 5647, 199, 3, 282, 3747, 2351, 1305, 367, 1924, 1067, 199, 63, 1730, 11348, 275, 7975, 14, 835, 1252, 2184, 199, 199, 63, 88, 6576, 1247, 275, 469, 272, 283, 12874, 356, 283, 2330, 985, 297, 272, 283, 2330, 985, 356, 283, 2330, 985, 297, 339, 283, 47, 356, 283, 9071, 985, 297, 272, 283, 9071, 985, 356, 283, 9071, 985, 297, 339, 283, 22050, 356, 283, 9071, 279, 5072, 985, 297, 272, 283, 9071, 279, 5072, 985, 356, 283, 9071, 279, 5072, 985, 297, 339, 283, 44, 356, 283, 1832, 1209, 985, 297, 272, 283, 1832, 1209, 985, 356, 283, 1832, 1209, 985, 297, 339, 283, 840, 356, 283, 929, 2844, 919, 86, 2855, 985, 297, 272, 283, 929, 2844, 919, 86, 2855, 985, 356, 283, 929, 2844, 919, 86, 2855, 985, 297, 339, 283, 35, 356, 283, 6063, 985, 297, 272, 283, 6063, 985, 356, 283, 6063, 985, 297, 339, 283, 2123, 1476, 356, 283, 2123, 1476, 936, 421, 199, 533, 10113, 14659, 4387, 985, 8, 807, 304, 272, 408, 272, 473, 848, 3338, 436, 13743, 376, 4642, 14, 339, 10113, 14659, 4387, 1561, 787, 1202, 370, 5647, 282, 13460, 5982, 402, 21119, 272, 2556, 3595, 282, 5897, 365, 20166, 503, 5420, 14, 221, 9322, 787, 28829, 272, 2737, 543, 1373, 503, 1655, 402, 314, 2569, 1504, 447, 398, 2863, 985, 334, 12874, 9, 267, 13237, 985, 334, 47, 9, 267, 13237, 279, 5072, 985, 334, 22050, 9, 267, 2257, 1209, 985, 334, 44, 9, 267, 1174, 2844, 919, 86, 2855, 985, 334, 840, 9, 267, 9023, 985, 334, 35, 9, 267, 3031, 1476, 272, 408, 272, 636, 7257, 363, 275, 6248, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 367, 1022, 12, 373, 315, 4775, 14, 4611, 837, 288, 5371, 8, 277, 12, 1022, 12, 373, 9, 2378, 347, 485, 1574, 2532, 8, 277, 12, 671, 6576, 354, 304, 267, 366, 275, 1052, 267, 367, 536, 315, 485, 88, 6576, 1247, 26, 288, 574, 275, 2519, 8, 88, 6576, 354, 12, 536, 12, 488, 9, 288, 340, 574, 365, 440, 488, 26, 355, 5371, 8, 277, 12, 536, 12, 574, 9, 2378, 347, 485, 1574, 19448, 8, 277, 12, 671, 6576, 354, 304, 267, 367, 1022, 12, 373, 315, 291, 14, 4611, 837, 288, 5371, 8, 88, 6576, 354, 12, 1022, 12, 373, 9, 2378, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 10872, 450, 83, 3524, 450, 334, 807, 855, 2722, 721, 277, 2788, 17, 6809, 17, 566, 2378, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 291, 13040, 88, 6576, 1247, 59, 962, 2677, 267, 871, 4067, 26, 288, 746, 4281, 8, 962, 9, 2378, 347, 636, 10202, 721, 277, 12, 1921, 12, 574, 304, 267, 702, 730, 8, 962, 9, 365, 620, 267, 340, 440, 1921, 315, 485, 88, 6576, 1247, 26, 288, 746, 4281, 3647, 83, 365, 440, 282, 1686, 14296, 1323, 6576, 536, 901, 2, 450, 334, 962, 4641, 267, 3363, 7144, 275, 485, 88, 6576, 1247, 59, 962, 61, 267, 574, 275, 574, 14, 2143, 360, 4371, 358, 267, 702, 730, 8, 585, 9, 365, 620, 267, 291, 59, 3093, 7144, 61, 275, 574, 2378, 347, 6485, 8, 277, 304, 267, 408, 267, 1432, 282, 3510, 13, 604, 12, 11779, 13, 11875, 6025, 402, 642, 24842, 14, 267, 408, 267, 634, 275, 942, 267, 634, 461, 78, 275, 378, 267, 347, 3747, 6550, 8, 4745, 304, 288, 372, 1211, 14, 19164, 8, 4745, 14, 13012, 8801, 1612, 342, 267, 367, 1022, 315, 3747, 6550, 1547, 88, 6576, 1247, 304, 288, 1768, 275, 4884, 14, 354, 1378, 4314, 8, 75, 9, 288, 634, 461, 78, 275, 1390, 8, 552, 8, 1302, 395, 634, 461, 78, 9, 288, 373, 275, 2519, 8, 277, 12, 1022, 12, 488, 9, 288, 340, 373, 365, 440, 488, 26, 355, 634, 14, 740, 1332, 1302, 12, 373, 430, 267, 634, 461, 78, 847, 499, 267, 367, 302, 12, 334, 1302, 12, 1921, 9, 315, 3874, 8, 76, 304, 288, 634, 59, 78, 61, 275, 334, 1302, 14, 24473, 8, 76, 461, 78, 6393, 356, 6681, 1921, 9, 267, 372, 1557, 78, 1370, 904, 8, 76, 9, 199, 199, 10872, 275, 10113, 14659, 4387, 985, 421, 199, 533, 11002, 84, 1563, 26, 272, 347, 636, 826, 721, 277, 12, 3379, 304, 267, 291, 14, 5043, 275, 3379, 339, 347, 485, 1574, 985, 8, 277, 12, 4739, 304, 267, 14052, 275, 10113, 14659, 4387, 985, 342, 267, 14052, 423, 1574, 2532, 8, 5675, 8, 277, 14, 5043, 12, 283, 362, 20013, 4511, 9, 1012, 267, 372, 14052, 339, 347, 664, 13528, 8, 277, 304, 267, 408, 267, 13939, 314, 5420, 402, 642, 5897, 14, 398, 768, 4500, 26, 491, 91, 12012, 14659, 4387, 985, 93, 267, 768, 1107, 26, 437, 1331, 402, 314, 5420, 402, 642, 5897, 14, 267, 408, 267, 372, 291, 423, 1574, 985, 360, 5875, 358, 4388, 199, 318, 485, 2479, 962, 3676, 8, 2543, 12, 7773, 12, 23352, 304, 272, 408, 272, 334, 4239, 9, 11642, 367, 491, 91, 11414, 14, 7866, 2532, 7836, 93, 436, 272, 491, 91, 11414, 14, 1102, 2532, 7836, 93, 1314, 5920, 367, 18457, 2429, 2943, 272, 436, 2973, 14512, 436, 6534, 314, 5827, 1919, 503, 2529, 314, 272, 5827, 5897, 909, 14, 272, 408, 272, 1083, 275, 2519, 8, 5545, 14, 362, 5940, 1062, 2151, 298, 362 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 4266, 4712, 1882, 199, 3, 1898, 334, 67, 9, 11811, 32077, 1494, 12, 3277, 14, 199, 3, 1898, 334, 67, 9, 9079, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 3, 1898, 334, 67, 9, 11811, 13, 9300, 17078, 8449, 26640, 14, 199, 199, 646, 7975, 199, 504, 14296, 492, 7799, 12, 13230, 199, 199, 504, 7390, 14, 1548, 492, 16806, 12, 4884, 199, 504, 7390, 14, 1548, 14, 24722, 492, 6128, 21, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 199, 504, 7390, 14, 4901, 14, 705, 492, 7635, 547, 12, 31953, 199, 199, 3, 18551, 446, 5709, 3382, 1006, 14296, 11414, 4558, 12, 8242, 1536, 370, 5647, 199, 3, 282, 3747, 2351, 1305, 367, 1924, 1067, 199, 63, 1730, 11348, 275, 7975, 14, 835, 1252, 2184, 199, 199, 63, 88, 6576, 1247, 275, 469, 272, 283, 12874, 356, 283, 2330, 985, 297, 272, 283, 2330, 985, 356, 283, 2330, 985, 297, 339, 283, 47, 356, 283, 9071, 985, 297, 272, 283, 9071, 985, 356, 283, 9071, 985, 297, 339, 283, 22050, 356, 283, 9071, 279, 5072, 985, 297, 272, 283, 9071, 279, 5072, 985, 356, 283, 9071, 279, 5072, 985, 297, 339, 283, 44, 356, 283, 1832, 1209, 985, 297, 272, 283, 1832, 1209, 985, 356, 283, 1832, 1209, 985, 297, 339, 283, 840, 356, 283, 929, 2844, 919, 86, 2855, 985, 297, 272, 283, 929, 2844, 919, 86, 2855, 985, 356, 283, 929, 2844, 919, 86, 2855, 985, 297, 339, 283, 35, 356, 283, 6063, 985, 297, 272, 283, 6063, 985, 356, 283, 6063, 985, 297, 339, 283, 2123, 1476, 356, 283, 2123, 1476, 936, 421, 199, 533, 10113, 14659, 4387, 985, 8, 807, 304, 272, 408, 272, 473, 848, 3338, 436, 13743, 376, 4642, 14, 339, 10113, 14659, 4387, 1561, 787, 1202, 370, 5647, 282, 13460, 5982, 402, 21119, 272, 2556, 3595, 282, 5897, 365, 20166, 503, 5420, 14, 221, 9322, 787, 28829, 272, 2737, 543, 1373, 503, 1655, 402, 314, 2569, 1504, 447, 398, 2863, 985, 334, 12874, 9, 267, 13237, 985, 334, 47, 9, 267, 13237, 279, 5072, 985, 334, 22050, 9, 267, 2257, 1209, 985, 334, 44, 9, 267, 1174, 2844, 919, 86, 2855, 985, 334, 840, 9, 267, 9023, 985, 334, 35, 9, 267, 3031, 1476, 272, 408, 272, 636, 7257, 363, 275, 6248, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 367, 1022, 12, 373, 315, 4775, 14, 4611, 837, 288, 5371, 8, 277, 12, 1022, 12, 373, 9, 2378, 347, 485, 1574, 2532, 8, 277, 12, 671, 6576, 354, 304, 267, 366, 275, 1052, 267, 367, 536, 315, 485, 88, 6576, 1247, 26, 288, 574, 275, 2519, 8, 88, 6576, 354, 12, 536, 12, 488, 9, 288, 340, 574, 365, 440, 488, 26, 355, 5371, 8, 277, 12, 536, 12, 574, 9, 2378, 347, 485, 1574, 19448, 8, 277, 12, 671, 6576, 354, 304, 267, 367, 1022, 12, 373, 315, 291, 14, 4611, 837, 288, 5371, 8, 88, 6576, 354, 12, 1022, 12, 373, 9, 2378, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 10872, 450, 83, 3524, 450, 334, 807, 855, 2722, 721, 277, 2788, 17, 6809, 17, 566, 2378, 347, 636, 5675, 721, 277, 12, 1921, 304, 267, 862, 26, 288, 372, 291, 13040, 88, 6576, 1247, 59, 962, 2677, 267, 871, 4067, 26, 288, 746, 4281, 8, 962, 9, 2378, 347, 636, 10202, 721, 277, 12, 1921, 12, 574, 304, 267, 702, 730, 8, 962, 9, 365, 620, 267, 340, 440, 1921, 315, 485, 88, 6576, 1247, 26, 288, 746, 4281, 3647, 83, 365, 440, 282, 1686, 14296, 1323, 6576, 536, 901, 2, 450, 334, 962, 4641, 267, 3363, 7144, 275, 485, 88, 6576, 1247, 59, 962, 61, 267, 574, 275, 574, 14, 2143, 360, 4371, 358, 267, 702, 730, 8, 585, 9, 365, 620, 267, 291, 59, 3093, 7144, 61, 275, 574, 2378, 347, 6485, 8, 277, 304, 267, 408, 267, 1432, 282, 3510, 13, 604, 12, 11779, 13, 11875, 6025, 402, 642, 24842, 14, 267, 408, 267, 634, 275, 942, 267, 634, 461, 78, 275, 378, 267, 347, 3747, 6550, 8, 4745, 304, 288, 372, 1211, 14, 19164, 8, 4745, 14, 13012, 8801, 1612, 342, 267, 367, 1022, 315, 3747, 6550, 1547, 88, 6576, 1247, 304, 288, 1768, 275, 4884, 14, 354, 1378, 4314, 8, 75, 9, 288, 634, 461, 78, 275, 1390, 8, 552, 8, 1302, 395, 634, 461, 78, 9, 288, 373, 275, 2519, 8, 277, 12, 1022, 12, 488, 9, 288, 340, 373, 365, 440, 488, 26, 355, 634, 14, 740, 1332, 1302, 12, 373, 430, 267, 634, 461, 78, 847, 499, 267, 367, 302, 12, 334, 1302, 12, 1921, 9, 315, 3874, 8, 76, 304, 288, 634, 59, 78, 61, 275, 334, 1302, 14, 24473, 8, 76, 461, 78, 6393, 356, 6681, 1921, 9, 267, 372, 1557, 78, 1370, 904, 8, 76, 9, 199, 199, 10872, 275, 10113, 14659, 4387, 985, 421, 199, 533, 11002, 84, 1563, 26, 272, 347, 636, 826, 721, 277, 12, 3379, 304, 267, 291, 14, 5043, 275, 3379, 339, 347, 485, 1574, 985, 8, 277, 12, 4739, 304, 267, 14052, 275, 10113, 14659, 4387, 985, 342, 267, 14052, 423, 1574, 2532, 8, 5675, 8, 277, 14, 5043, 12, 283, 362, 20013, 4511, 9, 1012, 267, 372, 14052, 339, 347, 664, 13528, 8, 277, 304, 267, 408, 267, 13939, 314, 5420, 402, 642, 5897, 14, 398, 768, 4500, 26, 491, 91, 12012, 14659, 4387, 985, 93, 267, 768, 1107, 26, 437, 1331, 402, 314, 5420, 402, 642, 5897, 14, 267, 408, 267, 372, 291, 423, 1574, 985, 360, 5875, 358, 4388, 199, 318, 485, 2479, 962, 3676, 8, 2543, 12, 7773, 12, 23352, 304, 272, 408, 272, 334, 4239, 9, 11642, 367, 491, 91, 11414, 14, 7866, 2532, 7836, 93, 436, 272, 491, 91, 11414, 14, 1102, 2532, 7836, 93, 1314, 5920, 367, 18457, 2429, 2943, 272, 436, 2973, 14512, 436, 6534, 314, 5827, 1919, 503, 2529, 314, 272, 5827, 5897, 909, 14, 272, 408, 272, 1083, 275, 2519, 8, 5545, 14, 362, 5940, 1062, 2151, 298, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bq-dev/android_kernel_bq_msm8976
tools/perf/scripts/python/check-perf-trace.py
11214
2503
# perf script event handlers, generated by perf script -g python # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # This script tests basic functionality such as flag and symbol # strings, common_xxx() calls back into perf, begin, end, unhandled # events, etc. Basically, if this script runs successfully and # displays expected results, Python scripting support should be ok. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Core import * from perf_trace_context import * unhandled = autodict() def trace_begin(): print "trace_begin" pass def trace_end(): print_unhandled() def irq__softirq_entry(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, vec): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "vec=%s\n" % \ (symbol_str("irq__softirq_entry", "vec", vec)), def kmem__kmalloc(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, call_site, ptr, bytes_req, bytes_alloc, gfp_flags): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "call_site=%u, ptr=%u, bytes_req=%u, " \ "bytes_alloc=%u, gfp_flags=%s\n" % \ (call_site, ptr, bytes_req, bytes_alloc, flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), def trace_unhandled(event_name, context, event_fields_dict): try: unhandled[event_name] += 1 except TypeError: unhandled[event_name] = 1 def print_header(event_name, cpu, secs, nsecs, pid, comm): print "%-20s %5u %05u.%09u %8u %-20s " % \ (event_name, cpu, secs, nsecs, pid, comm), # print trace fields not included in handler args def print_uncommon(context): print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ % (common_pc(context), trace_flag_str(common_flags(context)), \ common_lock_depth(context)) def print_unhandled(): keys = unhandled.keys() if not keys: return print "\nunhandled events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for event_name in keys: print "%-40s %10d\n" % (event_name, unhandled[event_name])
gpl-2.0
[ 3, 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
impl/rbppc-linux
tools/perf/scripts/python/sctop.py
11180
1924
# system call top # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(interval): while 1: clear_term() if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 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 ]
[ 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
codilime/contrail-controller
src/config/svc-monitor/svc_monitor/tests/test_virtual_machine_manager.py
2
12304
import mock import unittest from vnc_api.vnc_api import * from svc_monitor.virtual_machine_manager import VirtualMachineManager from svc_monitor.config_db import * import test_common_utils as test_utils class VirtualMachineManagerTest(unittest.TestCase): def setUp(self): VirtualMachineSM._cassandra = mock.MagicMock() VirtualMachineSM._cassandra.object_read = test_utils.vm_db_read VirtualMachineInterfaceSM._cassandra = mock.MagicMock() VirtualMachineInterfaceSM._cassandra.object_read = test_utils.vmi_db_read InstanceIpSM._cassandra = mock.MagicMock() InstanceIpSM._cassandra.object_read = test_utils.iip_db_read InterfaceRouteTableSM._cassandra = mock.MagicMock() InterfaceRouteTableSM._cassandra.object_read = test_utils.irt_db_read self.mocked_vnc = mock.MagicMock() self.mocked_vnc.fq_name_to_id = test_utils.get_vn_id_for_fq_name self.mocked_vnc.virtual_network_create = test_utils.vn_create self.mocked_vnc.virtual_machine_interface_create = test_utils.vmi_create self.mocked_vnc.instance_ip_create = test_utils.iip_create self.nova_mock = mock.MagicMock() self.mocked_db = mock.MagicMock() self.mocked_args = mock.MagicMock() self.mocked_args.availability_zone = 'default-availability-zone' self.log_mock = mock.MagicMock() self.vm_manager = VirtualMachineManager( db=self.mocked_db, logger=self.log_mock, vnc_lib=self.mocked_vnc, vrouter_scheduler=mock.MagicMock(), nova_client=self.nova_mock, args=self.mocked_args, agent_manager=mock.MagicMock()) def tearDown(self): ServiceTemplateSM.reset() ServiceInstanceSM.reset() InstanceIpSM.reset() VirtualMachineInterfaceSM.reset() VirtualMachineSM.reset() del InterfaceRouteTableSM._cassandra del VirtualMachineSM._cassandra def test_virtual_machine_create(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'servers' and oper == 'create': nova_vm = test_utils.FakeNovaServer('fake-vm-uuid', kwargs['name']) return nova_vm else: return mock.MagicMock() self.nova_mock.oper = nova_oper self.vm_manager.create_service(st, si) self.mocked_vnc.virtual_machine_create.assert_any_call(test_utils.VMObjMatcher(1)) self.mocked_vnc.virtual_machine_create.assert_any_call(test_utils.VMObjMatcher(2)) self.assertTrue(si.availability_zone, 'default-availability-zone') def test_virtual_machine_delete(self): vm = test_utils.create_test_virtual_machine('fake-vm-uuid') self.vm_manager.delete_service(vm) def test_missing_image_in_template(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) st.params['image_name'] = None self.vm_manager.create_service(st, si) self.log_mock.error.assert_called_with("Image not present in %s" % ((':').join(st.fq_name))) def test_missing_image_in_nova(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'images' and oper == 'find': return None else: return mock.MagicMock() self.nova_mock.oper = nova_oper self.vm_manager.create_service(st, si) self.log_mock.error.assert_called_with("Image not found %s" % si.image) def test_nova_vm_create_fail(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'servers' and oper == 'create': return None else: return mock.MagicMock() self.nova_mock.oper = nova_oper self.vm_manager.create_service(st, si) self.log_mock.error.assert_any_call(test_utils.AnyStringWith('Nova vm create failed')) def test_missing_flavor_in_template(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'flavors' and oper == 'find': return None else: return mock.MagicMock() self.nova_mock.oper = nova_oper st.params['flavor'] = None self.vm_manager.create_service(st, si) self.log_mock.error.assert_called_with(test_utils.AnyStringWith("Flavor not found")) def test_availability_zone_setting(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'servers' and oper == 'create': nova_vm = test_utils.FakeNovaServer('fake-vm-uuid', kwargs['name']) return nova_vm else: return mock.MagicMock() self.nova_mock.oper = nova_oper st.params['availability_zone_enable'] = True si.params['availability_zone'] = 'test-availability-zone' self.vm_manager.create_service(st, si) self.assertTrue(si.availability_zone, 'test-availability-zone') def test_network_config_validation(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) st.params['interface_type'] = [] self.vm_manager.create_service(st, si) self.log_mock.notice.assert_called_with("Interface list empty for ST %s SI %s" % ((':').join(st.fq_name), (':').join(si.fq_name))) def test_virtual_machine_exists(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'servers' and oper == 'create': nova_vm = test_utils.FakeNovaServer(kwargs['name'], kwargs['name']) return nova_vm else: return mock.MagicMock() self.nova_mock.oper = nova_oper self.mocked_vnc.virtual_machine_create = test_utils.vm_create self.vm_manager.create_service(st, si) self.log_mock.info.assert_any_call(test_utils.AnyStringWith('Launching VM :')) self.log_mock.info.assert_any_call(test_utils.AnyStringWith('Created VM :')) self.log_mock.info.assert_any_call(test_utils.AnyStringWith(si.name)) self.log_mock.reset_mock() self.vm_manager.create_service(st, si) self.assertTrue(self.log_mock.info.call_count, 1) def test_virtual_machine_static_routes(self): test_utils.create_test_project('fake-domain:fake-project') test_utils.create_test_security_group('fake-domain:fake-project:default') test_utils.create_test_virtual_network('fake-domain:fake-project:left-vn') test_utils.create_test_virtual_network('fake-domain:fake-project:right-vn') st = test_utils.create_test_st(name='vm-template', virt_type='virtual-machine', intf_list=[['management', False], ['left', True, True], ['right', False]]) si = test_utils.create_test_si(name='vm-instance', count=2, intf_list=['', 'left-vn', 'right-vn']) def nova_oper(resource, oper, proj_name, **kwargs): if resource == 'servers' and oper == 'create': nova_vm = test_utils.FakeNovaServer('fake-vm-uuid', kwargs['name']) return nova_vm else: return mock.MagicMock() self.nova_mock.oper = nova_oper self.vm_manager.create_service(st, si) self.mocked_vnc.virtual_machine_create.assert_any_call(test_utils.VMObjMatcher(1)) self.mocked_vnc.virtual_machine_create.assert_any_call(test_utils.VMObjMatcher(2))
apache-2.0
[ 646, 1683, 199, 646, 2882, 199, 504, 373, 7966, 63, 1246, 14, 24093, 63, 1246, 492, 627, 199, 504, 19257, 63, 7157, 14, 2065, 63, 6744, 63, 2609, 492, 13311, 8412, 2988, 199, 504, 19257, 63, 7157, 14, 888, 63, 697, 492, 627, 199, 646, 511, 63, 2330, 63, 1208, 465, 511, 63, 1208, 199, 199, 533, 13311, 8412, 2988, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 13311, 8412, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 13311, 8412, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 2611, 63, 697, 63, 739, 267, 13311, 8412, 4267, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 13311, 8412, 4267, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 2611, 73, 63, 697, 63, 739, 267, 10066, 6583, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 10066, 6583, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 73, 711, 63, 697, 63, 739, 267, 14816, 7161, 3186, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 14816, 7161, 3186, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 8401, 63, 697, 63, 739, 267, 291, 14, 27740, 63, 24093, 275, 1683, 14, 11988, 342, 267, 291, 14, 27740, 63, 24093, 14, 11878, 63, 354, 63, 475, 63, 344, 275, 511, 63, 1208, 14, 362, 63, 6002, 63, 344, 63, 509, 63, 11878, 63, 354, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 1200, 63, 981, 275, 511, 63, 1208, 14, 6002, 63, 981, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 6744, 63, 3266, 63, 981, 275, 511, 63, 1208, 14, 2611, 73, 63, 981, 267, 291, 14, 27740, 63, 24093, 14, 842, 63, 711, 63, 981, 275, 511, 63, 1208, 14, 73, 711, 63, 981, 398, 291, 14, 6765, 63, 1805, 275, 1683, 14, 11988, 342, 267, 291, 14, 27740, 63, 697, 275, 1683, 14, 11988, 342, 398, 291, 14, 27740, 63, 589, 275, 1683, 14, 11988, 342, 267, 291, 14, 27740, 63, 589, 14, 11856, 63, 2619, 275, 283, 885, 13, 11856, 13, 2619, 7, 398, 291, 14, 793, 63, 1805, 275, 1683, 14, 11988, 342, 398, 291, 14, 2611, 63, 2609, 275, 13311, 8412, 2988, 8, 288, 1592, 29, 277, 14, 27740, 63, 697, 12, 2512, 29, 277, 14, 793, 63, 1805, 12, 288, 373, 7966, 63, 773, 29, 277, 14, 27740, 63, 24093, 12, 373, 4995, 63, 8874, 29, 1805, 14, 11988, 1062, 288, 5913, 63, 1258, 29, 277, 14, 6765, 63, 1805, 12, 1249, 29, 277, 14, 27740, 63, 589, 12, 288, 6631, 63, 2609, 29, 1805, 14, 11988, 1012, 339, 347, 6766, 8, 277, 304, 267, 7591, 4231, 4029, 14, 3958, 342, 267, 7591, 3244, 4029, 14, 3958, 342, 267, 10066, 6583, 4029, 14, 3958, 342, 267, 13311, 8412, 4267, 4029, 14, 3958, 342, 267, 13311, 8412, 4029, 14, 3958, 342, 267, 2150, 14816, 7161, 3186, 4029, 423, 67, 22388, 267, 2150, 13311, 8412, 4029, 423, 67, 22388, 339, 347, 511, 63, 2065, 63, 6744, 63, 981, 8, 277, 304, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 1715, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 4416, 63, 923, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 885, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 3039, 13, 6002, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 1019, 13, 6002, 358, 398, 410, 275, 511, 63, 1208, 14, 981, 63, 396, 63, 270, 8, 354, 534, 2611, 13, 1160, 297, 288, 12043, 63, 466, 534, 2065, 13, 6744, 297, 288, 20697, 63, 513, 1524, 459, 8110, 297, 756, 467, 788, 3039, 297, 715, 467, 788, 1019, 297, 756, 3934, 267, 13877, 275, 511, 63, 1208, 14, 981, 63, 396, 63, 338, 8, 354, 534, 2611, 13, 842, 297, 2338, 29, 18, 12, 288, 20697, 63, 513, 2968, 297, 283, 3039, 13, 6002, 297, 283, 1019, 13, 6002, 1105, 398, 347, 5913, 63, 2262, 8, 1927, 12, 1758, 12, 13523, 63, 354, 12, 1011, 958, 304, 288, 340, 2073, 508, 283, 5871, 7, 436, 1758, 508, 283, 981, 356, 355, 5913, 63, 2611, 275, 511, 63, 1208, 14, 8249, 19884, 3120, 360, 3183, 13, 2611, 13, 2580, 297, 2074, 459, 354, 1105, 355, 372, 5913, 63, 2611, 288, 587, 26, 355, 372, 1683, 14, 11988, 342, 267, 291, 14, 6765, 63, 1805, 14, 2262, 275, 5913, 63, 2262, 398, 291, 14, 2611, 63, 2609, 14, 981, 63, 1364, 8, 270, 12, 13877, 9, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 6744, 63, 981, 14, 479, 63, 1629, 63, 1250, 8, 396, 63, 1208, 14, 54, 2679, 468, 16073, 8, 17, 430, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 6744, 63, 981, 14, 479, 63, 1629, 63, 1250, 8, 396, 63, 1208, 14, 54, 2679, 468, 16073, 8, 18, 430, 267, 291, 14, 1815, 8, 338, 14, 11856, 63, 2619, 12, 283, 885, 13, 11856, 13, 2619, 358, 18407, 347, 511, 63, 2065, 63, 6744, 63, 1807, 8, 277, 304, 267, 4169, 275, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 6744, 360, 3183, 13, 2611, 13, 2580, 358, 267, 291, 14, 2611, 63, 2609, 14, 1807, 63, 1364, 8, 2611, 9, 339, 347, 511, 63, 4752, 63, 1569, 63, 262, 63, 1160, 8, 277, 304, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 1715, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 4416, 63, 923, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 885, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 3039, 13, 6002, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26 ]
[ 1683, 199, 646, 2882, 199, 504, 373, 7966, 63, 1246, 14, 24093, 63, 1246, 492, 627, 199, 504, 19257, 63, 7157, 14, 2065, 63, 6744, 63, 2609, 492, 13311, 8412, 2988, 199, 504, 19257, 63, 7157, 14, 888, 63, 697, 492, 627, 199, 646, 511, 63, 2330, 63, 1208, 465, 511, 63, 1208, 199, 199, 533, 13311, 8412, 2988, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 13311, 8412, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 13311, 8412, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 2611, 63, 697, 63, 739, 267, 13311, 8412, 4267, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 13311, 8412, 4267, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 2611, 73, 63, 697, 63, 739, 267, 10066, 6583, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 10066, 6583, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 73, 711, 63, 697, 63, 739, 267, 14816, 7161, 3186, 4029, 423, 67, 22388, 275, 1683, 14, 11988, 342, 267, 14816, 7161, 3186, 4029, 423, 67, 22388, 14, 785, 63, 739, 275, 511, 63, 1208, 14, 8401, 63, 697, 63, 739, 267, 291, 14, 27740, 63, 24093, 275, 1683, 14, 11988, 342, 267, 291, 14, 27740, 63, 24093, 14, 11878, 63, 354, 63, 475, 63, 344, 275, 511, 63, 1208, 14, 362, 63, 6002, 63, 344, 63, 509, 63, 11878, 63, 354, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 1200, 63, 981, 275, 511, 63, 1208, 14, 6002, 63, 981, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 6744, 63, 3266, 63, 981, 275, 511, 63, 1208, 14, 2611, 73, 63, 981, 267, 291, 14, 27740, 63, 24093, 14, 842, 63, 711, 63, 981, 275, 511, 63, 1208, 14, 73, 711, 63, 981, 398, 291, 14, 6765, 63, 1805, 275, 1683, 14, 11988, 342, 267, 291, 14, 27740, 63, 697, 275, 1683, 14, 11988, 342, 398, 291, 14, 27740, 63, 589, 275, 1683, 14, 11988, 342, 267, 291, 14, 27740, 63, 589, 14, 11856, 63, 2619, 275, 283, 885, 13, 11856, 13, 2619, 7, 398, 291, 14, 793, 63, 1805, 275, 1683, 14, 11988, 342, 398, 291, 14, 2611, 63, 2609, 275, 13311, 8412, 2988, 8, 288, 1592, 29, 277, 14, 27740, 63, 697, 12, 2512, 29, 277, 14, 793, 63, 1805, 12, 288, 373, 7966, 63, 773, 29, 277, 14, 27740, 63, 24093, 12, 373, 4995, 63, 8874, 29, 1805, 14, 11988, 1062, 288, 5913, 63, 1258, 29, 277, 14, 6765, 63, 1805, 12, 1249, 29, 277, 14, 27740, 63, 589, 12, 288, 6631, 63, 2609, 29, 1805, 14, 11988, 1012, 339, 347, 6766, 8, 277, 304, 267, 7591, 4231, 4029, 14, 3958, 342, 267, 7591, 3244, 4029, 14, 3958, 342, 267, 10066, 6583, 4029, 14, 3958, 342, 267, 13311, 8412, 4267, 4029, 14, 3958, 342, 267, 13311, 8412, 4029, 14, 3958, 342, 267, 2150, 14816, 7161, 3186, 4029, 423, 67, 22388, 267, 2150, 13311, 8412, 4029, 423, 67, 22388, 339, 347, 511, 63, 2065, 63, 6744, 63, 981, 8, 277, 304, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 1715, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 4416, 63, 923, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 885, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 3039, 13, 6002, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 1019, 13, 6002, 358, 398, 410, 275, 511, 63, 1208, 14, 981, 63, 396, 63, 270, 8, 354, 534, 2611, 13, 1160, 297, 288, 12043, 63, 466, 534, 2065, 13, 6744, 297, 288, 20697, 63, 513, 1524, 459, 8110, 297, 756, 467, 788, 3039, 297, 715, 467, 788, 1019, 297, 756, 3934, 267, 13877, 275, 511, 63, 1208, 14, 981, 63, 396, 63, 338, 8, 354, 534, 2611, 13, 842, 297, 2338, 29, 18, 12, 288, 20697, 63, 513, 2968, 297, 283, 3039, 13, 6002, 297, 283, 1019, 13, 6002, 1105, 398, 347, 5913, 63, 2262, 8, 1927, 12, 1758, 12, 13523, 63, 354, 12, 1011, 958, 304, 288, 340, 2073, 508, 283, 5871, 7, 436, 1758, 508, 283, 981, 356, 355, 5913, 63, 2611, 275, 511, 63, 1208, 14, 8249, 19884, 3120, 360, 3183, 13, 2611, 13, 2580, 297, 2074, 459, 354, 1105, 355, 372, 5913, 63, 2611, 288, 587, 26, 355, 372, 1683, 14, 11988, 342, 267, 291, 14, 6765, 63, 1805, 14, 2262, 275, 5913, 63, 2262, 398, 291, 14, 2611, 63, 2609, 14, 981, 63, 1364, 8, 270, 12, 13877, 9, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 6744, 63, 981, 14, 479, 63, 1629, 63, 1250, 8, 396, 63, 1208, 14, 54, 2679, 468, 16073, 8, 17, 430, 267, 291, 14, 27740, 63, 24093, 14, 2065, 63, 6744, 63, 981, 14, 479, 63, 1629, 63, 1250, 8, 396, 63, 1208, 14, 54, 2679, 468, 16073, 8, 18, 430, 267, 291, 14, 1815, 8, 338, 14, 11856, 63, 2619, 12, 283, 885, 13, 11856, 13, 2619, 358, 18407, 347, 511, 63, 2065, 63, 6744, 63, 1807, 8, 277, 304, 267, 4169, 275, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 6744, 360, 3183, 13, 2611, 13, 2580, 358, 267, 291, 14, 2611, 63, 2609, 14, 1807, 63, 1364, 8, 2611, 9, 339, 347, 511, 63, 4752, 63, 1569, 63, 262, 63, 1160, 8, 277, 304, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 1715, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 4416, 63, 923, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 885, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 26, 3039, 13, 6002, 358, 267, 511, 63, 1208, 14, 981, 63, 396, 63, 2065, 63, 1200, 360, 3183, 13, 2261, 26, 3183, 13, 1715, 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, 1 ]
david-ragazzi/nupic
examples/network/temporal_anomaly_network_demo.py
8
3405
#!/usr/bin/env python # ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2015, 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/ # ---------------------------------------------------------------------- """ Demonstrates common_networks using hotgym example. Outputs network-demo2-output.csv, which should be identical to the csv outputted by network-api-demo.py (which does not use common_networks). """ import csv import os from pkg_resources import resource_filename from nupic.data.file_record_stream import FileRecordStream from nupic.engine import common_networks _INPUT_FILE_PATH = resource_filename( "nupic.datafiles", "extra/hotgym/rec-center-hourly.csv" ) _OUTPUT_PATH = "network-demo2-output.csv" _NUM_RECORDS = 2000 def runNetwork(network, writer): """Run the network and write output to writer. :param network: a Network instance to run :param writer: a csv.writer instance to write output to """ sensorRegion = network.regions["sensor"] spatialPoolerRegion = network.regions["spatialPoolerRegion"] temporalPoolerRegion = network.regions["temporalPoolerRegion"] anomalyRegion = network.regions["anomalyRegion"] prevPredictedColumns = [] for i in xrange(_NUM_RECORDS): # Run the network for a single iteration network.run(1) # Write out the anomaly score along with the record number and consumption # value. anomalyScore = anomalyRegion.getOutputData("rawAnomalyScore")[0] consumption = sensorRegion.getOutputData("sourceOut")[0] writer.writerow((i, consumption, anomalyScore)) if __name__ == "__main__": inputFilePath = resource_filename( "nupic.datafiles", "extra/hotgym/rec-center-hourly.csv" ) scalarEncoderArgs = { "w": 21, "minval": 0.0, "maxval": 100.0, "periodic": False, "n": 50, "radius": 0, "resolution": 0, "name": "consumption", "verbosity": 0, "clipInput": True, "forced": False, } dateEncoderArgs = { "season": 0, "dayOfWeek": 0, "weekend": 0, "holiday": 0, "timeOfDay": (21, 9.5), "customDays": 0, "name": "timestamp", "forced": True } recordParams = { "inputFilePath": _INPUT_FILE_PATH, "scalarEncoderArgs": scalarEncoderArgs, "dateEncoderArgs": dateEncoderArgs, } network = common_networks.createTemporalAnomaly(recordParams) outputPath = os.path.join(os.path.dirname(__file__), _OUTPUT_PATH) with open(outputPath, "w") as outputFile: writer = csv.writer(outputFile) print "Writing output to %s" % outputPath runNetwork(network, writer)
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, 6900, 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, 624, 199, 872, 2106, 31216, 2863, 63, 7642, 1808, 18469, 4312, 77, 2893, 14, 29206, 199, 1200, 13, 8768, 18, 13, 1199, 14, 4737, 12, 1314, 1077, 506, 13130, 370, 314, 7392, 199, 1199, 471, 701, 2784, 13, 1246, 13, 8768, 14, 647, 334, 6777, 1630, 440, 675, 2863, 63, 7642, 680, 199, 624, 199, 199, 646, 7392, 199, 646, 747, 199, 199, 504, 5496, 63, 4435, 492, 2073, 63, 1501, 199, 199, 504, 26084, 14, 576, 14, 493, 63, 3059, 63, 1745, 492, 3814, 5433, 3296, 199, 504, 26084, 14, 3908, 492, 2863, 63, 7642, 199, 199, 63, 7321, 63, 3817, 63, 3243, 275, 2073, 63, 1501, 8, 523, 298, 14596, 530, 14, 576, 1725, 401, 298, 2911, 15, 8885, 4312, 77, 15, 2761, 13, 4218, 13, 5180, 590, 14, 4737, 2, 199, 9, 199, 63, 8414, 63, 3243, 275, 298, 1200, 13, 8768, 18, 13, 1199, 14, 4737, 2, 199, 63, 7125, 63, 9481, 726, 3177, 275, 12293, 4388, 199, 318, 1255, 4491, 8, 1200, 12, 7060, 304, 523, 408, 2540, 314, 2784, 436, 2218, 1072, 370, 7060, 14, 819, 520, 635, 2784, 26, 282, 7220, 1256, 370, 1255, 523, 520, 635, 7060, 26, 282, 7392, 14, 5491, 1256, 370, 2218, 1072, 370, 523, 408, 523, 8778, 10708, 275, 2784, 14, 11963, 905, 8956, 937, 523, 11469, 48, 1534, 1435, 10708, 275, 2784, 14, 11963, 905, 11679, 48, 1534, 1435, 10708, 937, 523, 16457, 279, 48, 1534, 1435, 10708, 275, 2784, 14, 11963, 905, 30574, 48, 1534, 1435, 10708, 937, 523, 28813, 10708, 275, 2784, 14, 11963, 905, 32048, 10708, 937, 819, 5071, 30096, 15086, 275, 942, 819, 367, 284, 315, 4945, 1547, 7125, 63, 9481, 726, 3177, 304, 272, 327, 3378, 314, 2784, 367, 282, 2849, 8494, 272, 2784, 14, 1065, 8, 17, 9, 339, 327, 6990, 734, 314, 28813, 5396, 3180, 543, 314, 2777, 1329, 436, 13447, 15052, 272, 327, 574, 14, 272, 28813, 12642, 275, 28813, 10708, 14, 362, 2959, 1451, 480, 1773, 2493, 16523, 12642, 9981, 16, 61, 272, 13447, 15052, 275, 8778, 10708, 14, 362, 2959, 1451, 480, 1365, 2204, 9981, 16, 61, 272, 7060, 14, 22686, 1332, 73, 12, 13447, 15052, 12, 28813, 12642, 430, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 1324, 14225, 275, 2073, 63, 1501, 8, 489, 298, 14596, 530, 14, 576, 1725, 401, 298, 2911, 15, 8885, 4312, 77, 15, 2761, 13, 4218, 13, 5180, 590, 14, 4737, 2, 523, 776, 819, 6917, 6679, 6213, 275, 469, 489, 298, 87, 582, 7829, 12, 489, 298, 827, 637, 582, 378, 14, 16, 12, 489, 298, 30909, 582, 2948, 14, 16, 12, 489, 298, 20339, 582, 756, 12, 489, 298, 78, 582, 5238, 12, 489, 298, 8017, 582, 378, 12, 489, 298, 12588, 582, 378, 12, 489, 298, 354, 582, 298, 8704, 15052, 401, 489, 298, 9833, 582, 378, 12, 489, 298, 7548, 3205, 582, 715, 12, 489, 298, 28074, 582, 756, 12, 523, 789, 819, 1434, 6679, 6213, 275, 469, 489, 298, 12605, 582, 378, 12, 489, 298, 2977, 3466, 20995, 582, 378, 12, 489, 298, 6419, 500, 582, 378, 12, 489, 298, 20154, 2977, 582, 378, 12, 489, 298, 521, 3466, 12631, 582, 334, 2025, 12, 1749, 14, 21, 395, 489, 298, 4229, 25589, 582, 378, 12, 489, 298, 354, 582, 298, 3954, 401, 489, 298, 28074, 582, 715, 523, 789, 819, 2777, 6007, 275, 469, 489, 298, 1210, 14225, 582, 485, 7321, 63, 3817, 63, 3243, 12, 489, 298, 7033, 6679, 6213, 582, 6917, 6679, 6213, 12, 489, 298, 602, 6679, 6213, 582, 1434, 6679, 6213, 12, 523, 789, 819, 2784, 275, 2863, 63, 7642, 14, 981, 6530, 19849, 2493, 16523, 8, 3059, 6007, 9, 819, 1072, 2042, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 485, 8414, 63, 3243, 9, 523, 543, 1551, 8, 1199, 2042, 12, 298, 87, 531, 465, 1072, 1173, 26, 272, 7060, 275, 7392, 14, 5491, 8, 1199, 1173, 9, 272, 870, 298, 16646, 1072, 370, 450, 83, 2, 450, 1072, 2042, 272, 1255, 4491, 8, 1200, 12, 7060, 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 ]
[ 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, 6900, 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, 624, 199, 872, 2106, 31216, 2863, 63, 7642, 1808, 18469, 4312, 77, 2893, 14, 29206, 199, 1200, 13, 8768, 18, 13, 1199, 14, 4737, 12, 1314, 1077, 506, 13130, 370, 314, 7392, 199, 1199, 471, 701, 2784, 13, 1246, 13, 8768, 14, 647, 334, 6777, 1630, 440, 675, 2863, 63, 7642, 680, 199, 624, 199, 199, 646, 7392, 199, 646, 747, 199, 199, 504, 5496, 63, 4435, 492, 2073, 63, 1501, 199, 199, 504, 26084, 14, 576, 14, 493, 63, 3059, 63, 1745, 492, 3814, 5433, 3296, 199, 504, 26084, 14, 3908, 492, 2863, 63, 7642, 199, 199, 63, 7321, 63, 3817, 63, 3243, 275, 2073, 63, 1501, 8, 523, 298, 14596, 530, 14, 576, 1725, 401, 298, 2911, 15, 8885, 4312, 77, 15, 2761, 13, 4218, 13, 5180, 590, 14, 4737, 2, 199, 9, 199, 63, 8414, 63, 3243, 275, 298, 1200, 13, 8768, 18, 13, 1199, 14, 4737, 2, 199, 63, 7125, 63, 9481, 726, 3177, 275, 12293, 4388, 199, 318, 1255, 4491, 8, 1200, 12, 7060, 304, 523, 408, 2540, 314, 2784, 436, 2218, 1072, 370, 7060, 14, 819, 520, 635, 2784, 26, 282, 7220, 1256, 370, 1255, 523, 520, 635, 7060, 26, 282, 7392, 14, 5491, 1256, 370, 2218, 1072, 370, 523, 408, 523, 8778, 10708, 275, 2784, 14, 11963, 905, 8956, 937, 523, 11469, 48, 1534, 1435, 10708, 275, 2784, 14, 11963, 905, 11679, 48, 1534, 1435, 10708, 937, 523, 16457, 279, 48, 1534, 1435, 10708, 275, 2784, 14, 11963, 905, 30574, 48, 1534, 1435, 10708, 937, 523, 28813, 10708, 275, 2784, 14, 11963, 905, 32048, 10708, 937, 819, 5071, 30096, 15086, 275, 942, 819, 367, 284, 315, 4945, 1547, 7125, 63, 9481, 726, 3177, 304, 272, 327, 3378, 314, 2784, 367, 282, 2849, 8494, 272, 2784, 14, 1065, 8, 17, 9, 339, 327, 6990, 734, 314, 28813, 5396, 3180, 543, 314, 2777, 1329, 436, 13447, 15052, 272, 327, 574, 14, 272, 28813, 12642, 275, 28813, 10708, 14, 362, 2959, 1451, 480, 1773, 2493, 16523, 12642, 9981, 16, 61, 272, 13447, 15052, 275, 8778, 10708, 14, 362, 2959, 1451, 480, 1365, 2204, 9981, 16, 61, 272, 7060, 14, 22686, 1332, 73, 12, 13447, 15052, 12, 28813, 12642, 430, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 1324, 14225, 275, 2073, 63, 1501, 8, 489, 298, 14596, 530, 14, 576, 1725, 401, 298, 2911, 15, 8885, 4312, 77, 15, 2761, 13, 4218, 13, 5180, 590, 14, 4737, 2, 523, 776, 819, 6917, 6679, 6213, 275, 469, 489, 298, 87, 582, 7829, 12, 489, 298, 827, 637, 582, 378, 14, 16, 12, 489, 298, 30909, 582, 2948, 14, 16, 12, 489, 298, 20339, 582, 756, 12, 489, 298, 78, 582, 5238, 12, 489, 298, 8017, 582, 378, 12, 489, 298, 12588, 582, 378, 12, 489, 298, 354, 582, 298, 8704, 15052, 401, 489, 298, 9833, 582, 378, 12, 489, 298, 7548, 3205, 582, 715, 12, 489, 298, 28074, 582, 756, 12, 523, 789, 819, 1434, 6679, 6213, 275, 469, 489, 298, 12605, 582, 378, 12, 489, 298, 2977, 3466, 20995, 582, 378, 12, 489, 298, 6419, 500, 582, 378, 12, 489, 298, 20154, 2977, 582, 378, 12, 489, 298, 521, 3466, 12631, 582, 334, 2025, 12, 1749, 14, 21, 395, 489, 298, 4229, 25589, 582, 378, 12, 489, 298, 354, 582, 298, 3954, 401, 489, 298, 28074, 582, 715, 523, 789, 819, 2777, 6007, 275, 469, 489, 298, 1210, 14225, 582, 485, 7321, 63, 3817, 63, 3243, 12, 489, 298, 7033, 6679, 6213, 582, 6917, 6679, 6213, 12, 489, 298, 602, 6679, 6213, 582, 1434, 6679, 6213, 12, 523, 789, 819, 2784, 275, 2863, 63, 7642, 14, 981, 6530, 19849, 2493, 16523, 8, 3059, 6007, 9, 819, 1072, 2042, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 485, 8414, 63, 3243, 9, 523, 543, 1551, 8, 1199, 2042, 12, 298, 87, 531, 465, 1072, 1173, 26, 272, 7060, 275, 7392, 14, 5491, 8, 1199, 1173, 9, 272, 870, 298, 16646, 1072, 370, 450, 83, 2, 450, 1072, 2042, 272, 1255, 4491, 8, 1200, 12, 7060, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SalesforceEng/Providence
tests/plugins/__init__.py
8
1491
''' Copyright (c) 2015, Salesforce.com, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Salesforce.com 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 HOLDER 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. '''
bsd-3-clause
[ 2344, 199, 7384, 334, 67, 9, 6900, 12, 428, 7098, 3990, 14, 957, 12, 3277, 14, 199, 2422, 4481, 4644, 14, 199, 199, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 199, 10, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 199, 10, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 199, 10, 11443, 314, 536, 402, 428, 7098, 3990, 14, 957, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 199, 24571, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 2344, 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 ]
[ 199, 7384, 334, 67, 9, 6900, 12, 428, 7098, 3990, 14, 957, 12, 3277, 14, 199, 2422, 4481, 4644, 14, 199, 199, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 199, 10, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 199, 10, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 199, 10, 11443, 314, 536, 402, 428, 7098, 3990, 14, 957, 6590, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 199, 24571, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 2344, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ashang/calibre
src/calibre/gui2/tweak_book/function_replace.py
14
13782
#!/usr/bin/env python2 # vim:fileencoding=utf-8 from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>' import re, io, weakref, sys from cStringIO import StringIO from PyQt5.Qt import ( pyqtSignal, QVBoxLayout, QHBoxLayout, QPlainTextEdit, QLabel, QFontMetrics, QSize, Qt, QApplication, QIcon) from calibre.ebooks.oeb.polish.utils import apply_func_to_match_groups, apply_func_to_html_text from calibre.gui2 import error_dialog from calibre.gui2.complete2 import EditWithComplete from calibre.gui2.tweak_book import dictionaries from calibre.gui2.tweak_book.widgets import Dialog from calibre.gui2.tweak_book.editor.text import TextEdit from calibre.utils.config import JSONConfig from calibre.utils.icu import capitalize, upper, lower, swapcase from calibre.utils.titlecase import titlecase from calibre.utils.localization import localize_user_manual_link user_functions = JSONConfig('editor-search-replace-functions') def compile_code(src, name='<string>'): if not isinstance(src, unicode): match = re.search(r'coding[:=]\s*([-\w.]+)', src[:200]) enc = match.group(1) if match else 'utf-8' src = src.decode(enc) if not src or not src.strip(): src = EMPTY_FUNC # Python complains if there is a coding declaration in a unicode string src = re.sub(r'^#.*coding\s*[:=]\s*([-\w.]+)', '#', src, flags=re.MULTILINE) # Translate newlines to \n src = io.StringIO(src, newline=None).getvalue() code = compile(src, name, 'exec') namespace = {} exec code in namespace return namespace class Function(object): def __init__(self, name, source=None, func=None): self._source = source self.is_builtin = source is None self.name = name if func is None: self.mod = compile_code(source, name) self.func = self.mod['replace'] else: self.func = func self.mod = None if not callable(self.func): raise ValueError('%r is not a function' % self.func) self.file_order = getattr(self.func, 'file_order', None) def init_env(self, name=''): from calibre.gui2.tweak_book.boss import get_boss self.context_name = name or '' self.match_index = 0 self.boss = get_boss() self.data = {} self.debug_buf = StringIO() self.functions = {name:func.mod for name, func in functions().iteritems() if func.mod is not None} def __hash__(self): return hash(self.name) def __eq__(self, other): return self.name == getattr(other, 'name', None) def __ne__(self, other): return not self.__eq__(other) def __call__(self, match): self.match_index += 1 oo, oe, sys.stdout, sys.stderr = sys.stdout, sys.stderr, self.debug_buf, self.debug_buf try: return self.func(match, self.match_index, self.context_name, self.boss.current_metadata, dictionaries, self.data, self.functions) finally: sys.stdout, sys.stderr = oo, oe @property def source(self): if self.is_builtin: import json return json.loads(P('editor-functions.json', data=True, allow_user_override=False))[self.name] return self._source def end(self): if getattr(self.func, 'call_after_last_match', False): oo, oe, sys.stdout, sys.stderr = sys.stdout, sys.stderr, self.debug_buf, self.debug_buf try: return self.func(None, self.match_index, self.context_name, self.boss.current_metadata, dictionaries, self.data, self.functions) finally: sys.stdout, sys.stderr = oo, oe self.data, self.boss, self.functions = {}, None, {} class DebugOutput(Dialog): def __init__(self, parent=None): Dialog.__init__(self, 'Debug output', 'sr-function-debug-output') self.setAttribute(Qt.WA_DeleteOnClose, False) def setup_ui(self): self.l = l = QVBoxLayout(self) self.text = t = QPlainTextEdit(self) self.log_text = '' l.addWidget(t) l.addWidget(self.bb) self.bb.setStandardButtons(self.bb.Close) self.cb = b = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole) b.clicked.connect(self.copy_to_clipboard) b.setIcon(QIcon(I('edit-copy.png'))) def show_log(self, name, text): self.setWindowTitle(_('Debug output from %s') % name) self.text.setPlainText(self.windowTitle() + '\n\n' + text) self.log_text = text self.show() self.raise_() def sizeHint(self): fm = QFontMetrics(self.text.font()) return QSize(fm.averageCharWidth() * 120, 400) def copy_to_clipboard(self): QApplication.instance().clipboard().setText(self.log_text) def builtin_functions(): for name, obj in globals().iteritems(): if name.startswith('replace_') and callable(obj) and hasattr(obj, 'imports'): yield obj _functions = None def functions(refresh=False): global _functions if _functions is None or refresh: ans = _functions = {} for func in builtin_functions(): ans[func.name] = Function(func.name, func=func) for name, source in user_functions.iteritems(): try: f = Function(name, source=source) except Exception: continue ans[f.name] = f return _functions def remove_function(name, gui_parent=None): funcs = functions() if not name: return False if name not in funcs: error_dialog(gui_parent, _('No such function'), _( 'There is no function named %s') % name, show=True) return False if name not in user_functions: error_dialog(gui_parent, _('Cannot remove builtin function'), _( 'The function %s is a builtin function, it cannot be removed.') % name, show=True) del user_functions[name] functions(refresh=True) refresh_boxes() return True boxes = [] def refresh_boxes(): for ref in boxes: box = ref() if box is not None: box.refresh() class FunctionBox(EditWithComplete): save_search = pyqtSignal() show_saved_searches = pyqtSignal() def __init__(self, parent=None, show_saved_search_actions=False): EditWithComplete.__init__(self, parent) self.set_separator(None) self.show_saved_search_actions = show_saved_search_actions self.refresh() self.setToolTip(_('Choose a function to run on matched text (by name)')) boxes.append(weakref.ref(self)) def refresh(self): self.update_items_cache(set(functions())) def contextMenuEvent(self, event): menu = self.lineEdit().createStandardContextMenu() if self.show_saved_search_actions: menu.addSeparator() menu.addAction(_('Save current search'), self.save_search.emit) menu.addAction(_('Show saved searches'), self.show_saved_searches.emit) menu.exec_(event.globalPos()) class FunctionEditor(Dialog): def __init__(self, func_name='', parent=None): self._func_name = func_name Dialog.__init__(self, _('Create/edit a function'), 'edit-sr-func', parent=parent) def setup_ui(self): self.l = l = QVBoxLayout(self) self.h = h = QHBoxLayout() l.addLayout(h) self.la1 = la = QLabel(_('F&unction name:')) h.addWidget(la) self.fb = fb = FunctionBox(self) la.setBuddy(fb) h.addWidget(fb, stretch=10) self.la3 = la = QLabel(_('&Code:')) self.source_code = TextEdit(self) self.source_code.load_text('', 'python') la.setBuddy(self.source_code) l.addWidget(la), l.addWidget(self.source_code) if self._func_name: self.fb.setText(self._func_name) func = functions().get(self._func_name) if func is not None: self.source_code.setPlainText(func.source or ('\n' + EMPTY_FUNC)) else: self.source_code.setPlainText('\n' + EMPTY_FUNC) self.la2 = la = QLabel(_( 'For help with creating functions, see the <a href="%s">User Manual</a>') % localize_user_manual_link('http://manual.calibre-ebook.com/function_mode.html')) la.setOpenExternalLinks(True) l.addWidget(la) l.addWidget(self.bb) def sizeHint(self): fm = QFontMetrics(self.font()) return QSize(fm.averageCharWidth() * 120, 600) @property def func_name(self): return self.fb.text().strip() @property def source(self): return self.source_code.toPlainText() def accept(self): if not self.func_name: return error_dialog(self, _('Must specify name'), _( 'You must specify a name for this function.'), show=True) source = self.source try: mod = compile_code(source, self.func_name) except Exception as err: return error_dialog(self, _('Invalid python code'), _( 'The code you created is not valid python code, with error: %s') % err, show=True) if not callable(mod.get('replace')): return error_dialog(self, _('No replace function'), _( 'You must create a python function named replace in your code'), show=True) user_functions[self.func_name] = source functions(refresh=True) refresh_boxes() Dialog.accept(self) # Builtin functions ########################################################## def builtin(name, *args): def f(func): func.name = name func.imports = args return func return f EMPTY_FUNC = '''\ def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): return '' ''' @builtin('Upper-case text', upper, apply_func_to_match_groups) def replace_uppercase(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Make matched text upper case. If the regular expression contains groups, only the text in the groups will be changed, otherwise the entire text is changed.''' return apply_func_to_match_groups(match, upper) @builtin('Lower-case text', lower, apply_func_to_match_groups) def replace_lowercase(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Make matched text lower case. If the regular expression contains groups, only the text in the groups will be changed, otherwise the entire text is changed.''' return apply_func_to_match_groups(match, lower) @builtin('Capitalize text', capitalize, apply_func_to_match_groups) def replace_capitalize(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Capitalize matched text. If the regular expression contains groups, only the text in the groups will be changed, otherwise the entire text is changed.''' return apply_func_to_match_groups(match, capitalize) @builtin('Title-case text', titlecase, apply_func_to_match_groups) def replace_titlecase(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Title-case matched text. If the regular expression contains groups, only the text in the groups will be changed, otherwise the entire text is changed.''' return apply_func_to_match_groups(match, titlecase) @builtin('Swap the case of text', swapcase, apply_func_to_match_groups) def replace_swapcase(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Swap the case of the matched text. If the regular expression contains groups, only the text in the groups will be changed, otherwise the entire text is changed.''' return apply_func_to_match_groups(match, swapcase) @builtin('Upper-case text (ignore tags)', upper, apply_func_to_html_text) def replace_uppercase_ignore_tags(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Make matched text upper case, ignoring the text inside tag definitions.''' return apply_func_to_html_text(match, upper) @builtin('Lower-case text (ignore tags)', lower, apply_func_to_html_text) def replace_lowercase_ignore_tags(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Make matched text lower case, ignoring the text inside tag definitions.''' return apply_func_to_html_text(match, lower) @builtin('Capitalize text (ignore tags)', capitalize, apply_func_to_html_text) def replace_capitalize_ignore_tags(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Capitalize matched text, ignoring the text inside tag definitions.''' return apply_func_to_html_text(match, capitalize) @builtin('Title-case text (ignore tags)', titlecase, apply_func_to_html_text) def replace_titlecase_ignore_tags(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Title-case matched text, ignoring the text inside tag definitions.''' return apply_func_to_html_text(match, titlecase) @builtin('Swap the case of text (ignore tags)', swapcase, apply_func_to_html_text) def replace_swapcase_ignore_tags(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): '''Swap the case of the matched text, ignoring the text inside tag definitions.''' return apply_func_to_html_text(match, swapcase) if __name__ == '__main__': app = QApplication([]) FunctionEditor().exec_() del app
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 1624, 13, 24, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7280, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 737, 20817, 5017, 1939, 31876, 14, 846, 3524, 199, 199, 646, 295, 12, 5890, 12, 13852, 12, 984, 199, 504, 15073, 492, 5228, 199, 199, 504, 14084, 21, 14, 4238, 492, 334, 272, 27149, 11274, 12, 1413, 54, 18536, 12, 1413, 40, 18536, 12, 1413, 20711, 1872, 4685, 12, 1413, 4314, 12, 1413, 6986, 17213, 12, 272, 1413, 2320, 12, 3959, 12, 29469, 12, 1413, 8954, 9, 199, 199, 504, 19238, 14, 69, 8858, 14, 79, 2871, 14, 555, 1891, 14, 1208, 492, 4838, 63, 1532, 63, 475, 63, 1431, 63, 2634, 12, 4838, 63, 1532, 63, 475, 63, 1360, 63, 505, 199, 504, 19238, 14, 5885, 18, 492, 1125, 63, 7196, 199, 504, 19238, 14, 5885, 18, 14, 4883, 18, 492, 16407, 3007, 14175, 199, 504, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 492, 11196, 199, 504, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 14, 8583, 492, 30631, 199, 504, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 14, 7515, 14, 505, 492, 4516, 4685, 199, 504, 19238, 14, 1208, 14, 888, 492, 4840, 2028, 199, 504, 19238, 14, 1208, 14, 530, 85, 492, 17094, 794, 12, 7008, 12, 5117, 12, 11413, 2546, 199, 504, 19238, 14, 1208, 14, 1213, 2546, 492, 2538, 2546, 199, 504, 19238, 14, 1208, 14, 1832, 2072, 492, 2257, 794, 63, 751, 63, 9285, 63, 1073, 199, 199, 751, 63, 5777, 275, 4840, 2028, 360, 7515, 13, 1733, 13, 1814, 13, 5777, 358, 199, 199, 318, 6555, 63, 600, 8, 2164, 12, 536, 15829, 875, 30, 735, 272, 340, 440, 1228, 8, 2164, 12, 2649, 304, 267, 1336, 275, 295, 14, 1733, 8, 82, 7, 1523, 1491, 29, 7272, 83, 10, 779, 2696, 87, 14, 28798, 2928, 1491, 1840, 566, 267, 12011, 275, 1336, 14, 923, 8, 17, 9, 340, 1336, 587, 283, 1624, 13, 24, 7, 267, 2928, 275, 2928, 14, 2708, 8, 10945, 9, 272, 340, 440, 2928, 503, 440, 2928, 14, 1913, 837, 267, 2928, 275, 16589, 63, 19587, 272, 327, 2018, 32493, 3617, 340, 2337, 365, 282, 2803, 12560, 315, 282, 2649, 1059, 272, 2928, 275, 295, 14, 954, 8, 82, 4289, 3, 2795, 1523, 60, 83, 10, 1491, 29, 7272, 83, 10, 779, 2696, 87, 14, 28798, 3943, 297, 2928, 12, 3285, 29, 264, 14, 16661, 9, 272, 327, 25540, 14930, 370, 971, 78, 272, 2928, 275, 5890, 14, 6424, 8, 2164, 12, 8057, 29, 403, 680, 7150, 342, 272, 1233, 275, 6555, 8, 2164, 12, 536, 12, 283, 1628, 358, 339, 3231, 275, 1052, 272, 2146, 1233, 315, 3231, 272, 372, 3231, 199, 199, 533, 6801, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1350, 29, 403, 12, 2562, 29, 403, 304, 267, 291, 423, 1365, 275, 1350, 267, 291, 14, 374, 63, 5351, 275, 1350, 365, 488, 267, 291, 14, 354, 275, 536, 267, 340, 2562, 365, 488, 26, 288, 291, 14, 1494, 275, 6555, 63, 600, 8, 1365, 12, 536, 9, 288, 291, 14, 1532, 275, 291, 14, 1494, 459, 1814, 418, 267, 587, 26, 288, 291, 14, 1532, 275, 2562, 288, 291, 14, 1494, 275, 488, 267, 340, 440, 4550, 8, 277, 14, 1532, 304, 288, 746, 1722, 3508, 82, 365, 440, 282, 805, 7, 450, 291, 14, 1532, 9, 267, 291, 14, 493, 63, 1648, 275, 2519, 8, 277, 14, 1532, 12, 283, 493, 63, 1648, 297, 488, 9, 339, 347, 4205, 63, 1813, 8, 277, 12, 536, 9280, 267, 687, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 14, 25020, 492, 664, 63, 25020, 267, 291, 14, 1100, 63, 354, 275, 536, 503, 2125, 267, 291, 14, 1431, 63, 1080, 275, 378, 267, 291, 14, 25020, 275, 664, 63, 25020, 342, 267, 291, 14, 576, 275, 1052, 267, 291, 14, 1757, 63, 1436, 275, 5228, 342, 267, 291, 14, 5777, 275, 469, 354, 26, 1532, 14, 1494, 367, 536, 12, 2562, 315, 3423, 1252, 4611, 342, 340, 2562, 14, 1494, 365, 440, 488, 93, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 277, 14, 354, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 354, 508, 2519, 8, 1848, 12, 283, 354, 297, 488, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 1250, 721, 277, 12, 1336, 304, 267, 291, 14, 1431, 63, 1080, 847, 413, 267, 16390, 12, 312, 69, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 984, 14, 2703, 12, 984, 14, 3083, 12, 291, 14, 1757, 63, 1436, 12, 291, 14, 1757, 63, 1436, 267, 862, 26, 288, 372, 291, 14, 1532, 8, 1431, 12, 291, 14, 1431, 63, 1080, 12, 291, 14, 1100, 63, 354, 12, 291, 14, 25020, 14, 1818, 63, 2343, 12, 11196, 12, 291, 14, 576, 12, 291, 14, 5777, 9, 267, 3753, 26, 288, 984, 14, 2703, 12, 984, 14, 3083, 275, 16390, 12, 312, 69, 339, 768, 1829, 272, 347, 1350, 8, 277, 304, 267, 340, 291, 14, 374, 63, 5351, 26, 288, 492, 2022, 288, 372, 2022, 14, 3640, 8, 48, 360, 7515, 13, 5777, 14, 1001, 297, 666, 29, 549, 12, 2040, 63, 751, 63, 4415, 29, 797, 11515, 277, 14, 354, 61, 267, 372, 291, 423, 1365, 339, 347, 1284, 8, 277, 304, 267, 340, 2519, 8, 277, 14, 1532, 12, 283, 1250, 63, 4399, 63, 2019, 63, 1431, 297, 756, 304, 288, 16390, 12, 312, 69, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 984, 14, 2703, 12, 984, 14, 3083, 12, 291, 14, 1757, 63, 1436, 12, 291, 14, 1757, 63, 1436, 288, 862, 26, 355, 372, 291, 14, 1532, 8, 403, 12, 291, 14, 1431, 63, 1080, 12, 291, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 6695, 26, 493, 2991, 29, 1624, 13, 24, 199, 504, 636, 2443, 363, 492, 334, 2975, 63, 5955, 12, 4629, 12, 3679, 63, 646, 12, 717, 870, 63, 1593, 9, 199, 199, 363, 1682, 363, 275, 283, 12006, 373, 19, 7, 199, 363, 7307, 363, 275, 283, 7280, 12, 1804, 79, 5017, 3971, 31876, 665, 7697, 5017, 737, 20817, 5017, 1939, 31876, 14, 846, 3524, 199, 199, 646, 295, 12, 5890, 12, 13852, 12, 984, 199, 504, 15073, 492, 5228, 199, 199, 504, 14084, 21, 14, 4238, 492, 334, 272, 27149, 11274, 12, 1413, 54, 18536, 12, 1413, 40, 18536, 12, 1413, 20711, 1872, 4685, 12, 1413, 4314, 12, 1413, 6986, 17213, 12, 272, 1413, 2320, 12, 3959, 12, 29469, 12, 1413, 8954, 9, 199, 199, 504, 19238, 14, 69, 8858, 14, 79, 2871, 14, 555, 1891, 14, 1208, 492, 4838, 63, 1532, 63, 475, 63, 1431, 63, 2634, 12, 4838, 63, 1532, 63, 475, 63, 1360, 63, 505, 199, 504, 19238, 14, 5885, 18, 492, 1125, 63, 7196, 199, 504, 19238, 14, 5885, 18, 14, 4883, 18, 492, 16407, 3007, 14175, 199, 504, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 492, 11196, 199, 504, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 14, 8583, 492, 30631, 199, 504, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 14, 7515, 14, 505, 492, 4516, 4685, 199, 504, 19238, 14, 1208, 14, 888, 492, 4840, 2028, 199, 504, 19238, 14, 1208, 14, 530, 85, 492, 17094, 794, 12, 7008, 12, 5117, 12, 11413, 2546, 199, 504, 19238, 14, 1208, 14, 1213, 2546, 492, 2538, 2546, 199, 504, 19238, 14, 1208, 14, 1832, 2072, 492, 2257, 794, 63, 751, 63, 9285, 63, 1073, 199, 199, 751, 63, 5777, 275, 4840, 2028, 360, 7515, 13, 1733, 13, 1814, 13, 5777, 358, 199, 199, 318, 6555, 63, 600, 8, 2164, 12, 536, 15829, 875, 30, 735, 272, 340, 440, 1228, 8, 2164, 12, 2649, 304, 267, 1336, 275, 295, 14, 1733, 8, 82, 7, 1523, 1491, 29, 7272, 83, 10, 779, 2696, 87, 14, 28798, 2928, 1491, 1840, 566, 267, 12011, 275, 1336, 14, 923, 8, 17, 9, 340, 1336, 587, 283, 1624, 13, 24, 7, 267, 2928, 275, 2928, 14, 2708, 8, 10945, 9, 272, 340, 440, 2928, 503, 440, 2928, 14, 1913, 837, 267, 2928, 275, 16589, 63, 19587, 272, 327, 2018, 32493, 3617, 340, 2337, 365, 282, 2803, 12560, 315, 282, 2649, 1059, 272, 2928, 275, 295, 14, 954, 8, 82, 4289, 3, 2795, 1523, 60, 83, 10, 1491, 29, 7272, 83, 10, 779, 2696, 87, 14, 28798, 3943, 297, 2928, 12, 3285, 29, 264, 14, 16661, 9, 272, 327, 25540, 14930, 370, 971, 78, 272, 2928, 275, 5890, 14, 6424, 8, 2164, 12, 8057, 29, 403, 680, 7150, 342, 272, 1233, 275, 6555, 8, 2164, 12, 536, 12, 283, 1628, 358, 339, 3231, 275, 1052, 272, 2146, 1233, 315, 3231, 272, 372, 3231, 199, 199, 533, 6801, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 536, 12, 1350, 29, 403, 12, 2562, 29, 403, 304, 267, 291, 423, 1365, 275, 1350, 267, 291, 14, 374, 63, 5351, 275, 1350, 365, 488, 267, 291, 14, 354, 275, 536, 267, 340, 2562, 365, 488, 26, 288, 291, 14, 1494, 275, 6555, 63, 600, 8, 1365, 12, 536, 9, 288, 291, 14, 1532, 275, 291, 14, 1494, 459, 1814, 418, 267, 587, 26, 288, 291, 14, 1532, 275, 2562, 288, 291, 14, 1494, 275, 488, 267, 340, 440, 4550, 8, 277, 14, 1532, 304, 288, 746, 1722, 3508, 82, 365, 440, 282, 805, 7, 450, 291, 14, 1532, 9, 267, 291, 14, 493, 63, 1648, 275, 2519, 8, 277, 14, 1532, 12, 283, 493, 63, 1648, 297, 488, 9, 339, 347, 4205, 63, 1813, 8, 277, 12, 536, 9280, 267, 687, 19238, 14, 5885, 18, 14, 84, 10350, 63, 2706, 14, 25020, 492, 664, 63, 25020, 267, 291, 14, 1100, 63, 354, 275, 536, 503, 2125, 267, 291, 14, 1431, 63, 1080, 275, 378, 267, 291, 14, 25020, 275, 664, 63, 25020, 342, 267, 291, 14, 576, 275, 1052, 267, 291, 14, 1757, 63, 1436, 275, 5228, 342, 267, 291, 14, 5777, 275, 469, 354, 26, 1532, 14, 1494, 367, 536, 12, 2562, 315, 3423, 1252, 4611, 342, 340, 2562, 14, 1494, 365, 440, 488, 93, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 277, 14, 354, 9, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 291, 14, 354, 508, 2519, 8, 1848, 12, 283, 354, 297, 488, 9, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 347, 636, 1250, 721, 277, 12, 1336, 304, 267, 291, 14, 1431, 63, 1080, 847, 413, 267, 16390, 12, 312, 69, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 984, 14, 2703, 12, 984, 14, 3083, 12, 291, 14, 1757, 63, 1436, 12, 291, 14, 1757, 63, 1436, 267, 862, 26, 288, 372, 291, 14, 1532, 8, 1431, 12, 291, 14, 1431, 63, 1080, 12, 291, 14, 1100, 63, 354, 12, 291, 14, 25020, 14, 1818, 63, 2343, 12, 11196, 12, 291, 14, 576, 12, 291, 14, 5777, 9, 267, 3753, 26, 288, 984, 14, 2703, 12, 984, 14, 3083, 275, 16390, 12, 312, 69, 339, 768, 1829, 272, 347, 1350, 8, 277, 304, 267, 340, 291, 14, 374, 63, 5351, 26, 288, 492, 2022, 288, 372, 2022, 14, 3640, 8, 48, 360, 7515, 13, 5777, 14, 1001, 297, 666, 29, 549, 12, 2040, 63, 751, 63, 4415, 29, 797, 11515, 277, 14, 354, 61, 267, 372, 291, 423, 1365, 339, 347, 1284, 8, 277, 304, 267, 340, 2519, 8, 277, 14, 1532, 12, 283, 1250, 63, 4399, 63, 2019, 63, 1431, 297, 756, 304, 288, 16390, 12, 312, 69, 12, 984, 14, 2703, 12, 984, 14, 3083, 275, 984, 14, 2703, 12, 984, 14, 3083, 12, 291, 14, 1757, 63, 1436, 12, 291, 14, 1757, 63, 1436, 288, 862, 26, 355, 372, 291, 14, 1532, 8, 403, 12, 291, 14, 1431, 63, 1080, 12, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
kimkulling/osre
contrib/gmock-1.7.0/gtest/test/gtest_env_var_test.py
2408
3487
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Verifies that Google Test correctly parses environment variables.""" __author__ = 'wan@google.com (Zhanyong Wan)' import os import gtest_test_utils IS_WINDOWS = os.name == 'nt' IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux' COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_') environ = os.environ.copy() def AssertEq(expected, actual): if expected != actual: print 'Expected: %s' % (expected,) print ' Actual: %s' % (actual,) raise AssertionError def SetEnvVar(env_var, value): """Sets the env variable to 'value'; unsets it when 'value' is None.""" if value is not None: environ[env_var] = value elif env_var in environ: del environ[env_var] def GetFlag(flag): """Runs gtest_env_var_test_ and returns its output.""" args = [COMMAND] if flag is not None: args += [flag] return gtest_test_utils.Subprocess(args, env=environ).output def TestFlag(flag, test_val, default_val): """Verifies that the given flag is affected by the corresponding env var.""" env_var = 'GTEST_' + flag.upper() SetEnvVar(env_var, test_val) AssertEq(test_val, GetFlag(flag)) SetEnvVar(env_var, None) AssertEq(default_val, GetFlag(flag)) class GTestEnvVarTest(gtest_test_utils.TestCase): def testEnvVarAffectsFlag(self): """Tests that environment variable should affect the corresponding flag.""" TestFlag('break_on_failure', '1', '0') TestFlag('color', 'yes', 'auto') TestFlag('filter', 'FooTest.Bar', '*') TestFlag('output', 'xml:tmp/foo.xml', '') TestFlag('print_time', '0', '1') TestFlag('repeat', '999', '1') TestFlag('throw_on_failure', '1', '0') TestFlag('death_test_style', 'threadsafe', 'fast') TestFlag('catch_exceptions', '0', '1') if IS_LINUX: TestFlag('death_test_use_fork', '1', '0') TestFlag('stack_trace_depth', '0', '100') if __name__ == '__main__': gtest_test_utils.Main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 21168, 626, 4475, 1379, 6657, 19953, 3734, 2860, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 1311, 63, 20509, 275, 747, 14, 354, 508, 283, 343, 7, 199, 1311, 63, 26030, 275, 747, 14, 354, 508, 283, 9228, 7, 436, 747, 14, 16040, 3430, 16, 61, 508, 283, 14091, 7, 199, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 1813, 63, 1391, 63, 396, 15452, 199, 199, 2314, 275, 747, 14, 2314, 14, 1574, 342, 421, 199, 318, 10716, 19706, 8, 2062, 12, 3503, 304, 523, 340, 1420, 1137, 3503, 26, 272, 870, 283, 6964, 26, 450, 83, 7, 450, 334, 2062, 4258, 272, 870, 283, 221, 18982, 1061, 26, 450, 83, 7, 450, 334, 6514, 4258, 272, 746, 9070, 421, 199, 318, 30306, 8, 1813, 63, 1391, 12, 574, 304, 523, 408, 9899, 314, 2589, 1750, 370, 283, 585, 13619, 625, 2193, 652, 1380, 283, 585, 7, 365, 488, 1041, 819, 340, 574, 365, 440, 488, 26, 272, 6160, 59, 1813, 63, 1391, 61, 275, 574, 523, 916, 2589, 63, 1391, 315, 6160, 26, 272, 2150, 6160, 59, 1813, 63, 1391, 61, 421, 199, 318, 2372, 5318, 8, 4173, 304, 523, 408, 16291, 9088, 63, 1813, 63, 1391, 63, 396, 63, 436, 2529, 2399, 1072, 1041, 819, 1249, 275, 359, 10761, 61, 523, 340, 3305, 365, 440, 488, 26, 272, 1249, 847, 359, 4173, 61, 523, 372, 9088, 63, 396, 63, 1208, 14, 22299, 8, 589, 12, 2589, 29, 2314, 680, 1199, 421, 199, 318, 1379, 5318, 8, 4173, 12, 511, 63, 637, 12, 849, 63, 637, 304, 523, 408, 21168, 626, 314, 1627, 3305, 365, 16955, 701, 314, 5226, 2589, 2729, 1041, 819, 2589, 63, 1391, 275, 283, 16151, 8650, 435, 3305, 14, 4142, 342, 523, 30306, 8, 1813, 63, 1391, 12, 511, 63, 637, 9, 523, 10716, 19706, 8, 396, 63, 637, 12, 2372, 5318, 8, 4173, 430, 523, 30306, 8, 1813, 63, 1391, 12, 488, 9, 523, 10716, 19706, 8, 885, 63, 637, 12, 2372, 5318, 8, 4173, 430, 421, 199, 533, 598, 774, 19342, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 19342, 33, 5551, 83, 5318, 8, 277, 304, 272, 408, 2925, 626, 3734, 1750, 1077, 12787, 314, 5226, 3305, 1041, 339, 1379, 5318, 360, 4785, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 2326, 297, 283, 5066, 297, 283, 2495, 358, 272, 1379, 5318, 360, 1541, 297, 283, 24676, 14, 5281, 297, 6438, 358, 272, 1379, 5318, 360, 1199, 297, 283, 1652, 26, 2791, 15, 1421, 14, 1652, 297, 4074, 272, 1379, 5318, 360, 1361, 63, 521, 297, 283, 16, 297, 283, 17, 358, 272, 1379, 5318, 360, 8755, 297, 283, 5637, 297, 283, 17, 358, 272, 1379, 5318, 360, 11964, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 23727, 63, 396, 63, 2487, 297, 283, 2671, 3489, 297, 283, 7015, 358, 272, 1379, 5318, 360, 9341, 63, 3924, 297, 283, 16, 297, 283, 17, 358, 339, 340, 2281, 63, 26030, 26, 489, 1379, 5318, 360, 23727, 63, 396, 63, 1180, 63, 11796, 297, 283, 17, 297, 283, 16, 358, 489, 1379, 5318, 360, 2340, 63, 3446, 63, 4631, 297, 283, 16, 297, 283, 1960, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 9088, 63, 396, 63, 1208, 14, 6756, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 21168, 626, 4475, 1379, 6657, 19953, 3734, 2860, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 9088, 63, 396, 63, 1208, 421, 199, 1311, 63, 20509, 275, 747, 14, 354, 508, 283, 343, 7, 199, 1311, 63, 26030, 275, 747, 14, 354, 508, 283, 9228, 7, 436, 747, 14, 16040, 3430, 16, 61, 508, 283, 14091, 7, 199, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 1813, 63, 1391, 63, 396, 15452, 199, 199, 2314, 275, 747, 14, 2314, 14, 1574, 342, 421, 199, 318, 10716, 19706, 8, 2062, 12, 3503, 304, 523, 340, 1420, 1137, 3503, 26, 272, 870, 283, 6964, 26, 450, 83, 7, 450, 334, 2062, 4258, 272, 870, 283, 221, 18982, 1061, 26, 450, 83, 7, 450, 334, 6514, 4258, 272, 746, 9070, 421, 199, 318, 30306, 8, 1813, 63, 1391, 12, 574, 304, 523, 408, 9899, 314, 2589, 1750, 370, 283, 585, 13619, 625, 2193, 652, 1380, 283, 585, 7, 365, 488, 1041, 819, 340, 574, 365, 440, 488, 26, 272, 6160, 59, 1813, 63, 1391, 61, 275, 574, 523, 916, 2589, 63, 1391, 315, 6160, 26, 272, 2150, 6160, 59, 1813, 63, 1391, 61, 421, 199, 318, 2372, 5318, 8, 4173, 304, 523, 408, 16291, 9088, 63, 1813, 63, 1391, 63, 396, 63, 436, 2529, 2399, 1072, 1041, 819, 1249, 275, 359, 10761, 61, 523, 340, 3305, 365, 440, 488, 26, 272, 1249, 847, 359, 4173, 61, 523, 372, 9088, 63, 396, 63, 1208, 14, 22299, 8, 589, 12, 2589, 29, 2314, 680, 1199, 421, 199, 318, 1379, 5318, 8, 4173, 12, 511, 63, 637, 12, 849, 63, 637, 304, 523, 408, 21168, 626, 314, 1627, 3305, 365, 16955, 701, 314, 5226, 2589, 2729, 1041, 819, 2589, 63, 1391, 275, 283, 16151, 8650, 435, 3305, 14, 4142, 342, 523, 30306, 8, 1813, 63, 1391, 12, 511, 63, 637, 9, 523, 10716, 19706, 8, 396, 63, 637, 12, 2372, 5318, 8, 4173, 430, 523, 30306, 8, 1813, 63, 1391, 12, 488, 9, 523, 10716, 19706, 8, 885, 63, 637, 12, 2372, 5318, 8, 4173, 430, 421, 199, 533, 598, 774, 19342, 774, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 347, 511, 19342, 33, 5551, 83, 5318, 8, 277, 304, 272, 408, 2925, 626, 3734, 1750, 1077, 12787, 314, 5226, 3305, 1041, 339, 1379, 5318, 360, 4785, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 2326, 297, 283, 5066, 297, 283, 2495, 358, 272, 1379, 5318, 360, 1541, 297, 283, 24676, 14, 5281, 297, 6438, 358, 272, 1379, 5318, 360, 1199, 297, 283, 1652, 26, 2791, 15, 1421, 14, 1652, 297, 4074, 272, 1379, 5318, 360, 1361, 63, 521, 297, 283, 16, 297, 283, 17, 358, 272, 1379, 5318, 360, 8755, 297, 283, 5637, 297, 283, 17, 358, 272, 1379, 5318, 360, 11964, 63, 265, 63, 5328, 297, 283, 17, 297, 283, 16, 358, 272, 1379, 5318, 360, 23727, 63, 396, 63, 2487, 297, 283, 2671, 3489, 297, 283, 7015, 358, 272, 1379, 5318, 360, 9341, 63, 3924, 297, 283, 16, 297, 283, 17, 358, 339, 340, 2281, 63, 26030, 26, 489, 1379, 5318, 360, 23727, 63, 396, 63, 1180, 63, 11796, 297, 283, 17, 297, 283, 16, 358, 489, 1379, 5318, 360, 2340, 63, 3446, 63, 4631, 297, 283, 16, 297, 283, 1960, 358, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 9088, 63, 396, 63, 1208, 14, 6756, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
prohaska7/ft-index
scripts/run.stress-tests.py
32
33186
#!/usr/bin/env python """ A script for running our stress tests repeatedly to see if any fail. Runs a list of stress tests in parallel, reporting passes and collecting failure scenarios until killed. Runs with different table sizes, cachetable sizes, and numbers of threads. Suitable for running on a dev branch, or a release branch, or main. Just run the script from within a branch you want to test. By default, we stop everything, update from git, rebuild, and restart the tests once a day. """ import logging import os import re import stat import sys import time from email.mime.text import MIMEText from glob import glob from logging import debug, info, warning, error, exception from optparse import OptionGroup, OptionParser from Queue import Queue from random import randrange, shuffle from resource import setrlimit, RLIMIT_CORE from shutil import copy, copytree, move, rmtree from signal import signal, SIGHUP, SIGINT, SIGPIPE, SIGALRM, SIGTERM from smtplib import SMTP from socket import gethostname from subprocess import call, Popen, PIPE, STDOUT from traceback import format_exc from tempfile import mkdtemp, mkstemp from threading import Event, Thread, Timer __version__ = '$Id$' __copyright__ = """Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.""" # relpath implementation for python <2.6 # from http://unittest-ext.googlecode.com/hg-history/1df911640f7be239e58fb185b06ac2a8489dcdc4/unittest2/unittest2/compatibility.py if not hasattr(os.path, 'relpath'): if os.path is sys.modules.get('ntpath'): def relpath(path, start=os.path.curdir): """Return a relative version of a path""" if not path: raise ValueError("no path specified") start_list = os.path.abspath(start).split(os.path.sep) path_list = os.path.abspath(path).split(os.path.sep) if start_list[0].lower() != path_list[0].lower(): unc_path, rest = os.path.splitunc(path) unc_start, rest = os.path.splitunc(start) if bool(unc_path) ^ bool(unc_start): raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)" % (path, start)) else: raise ValueError("path is on drive %s, start on drive %s" % (path_list[0], start_list[0])) # Work out how much of the filepath is shared by start and path. for i in range(min(len(start_list), len(path_list))): if start_list[i].lower() != path_list[i].lower(): break else: i += 1 rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: return os.path.curdir return os.path.join(*rel_list) else: # default to posixpath definition def relpath(path, start=os.path.curdir): """Return a relative version of a path""" if not path: raise ValueError("no path specified") start_list = os.path.abspath(start).split(os.path.sep) path_list = os.path.abspath(path).split(os.path.sep) # Work out how much of the filepath is shared by start and path. i = len(os.path.commonprefix([start_list, path_list])) rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: return os.path.curdir return os.path.join(*rel_list) os.path.relpath = relpath def setlimits(): setrlimit(RLIMIT_CORE, (-1, -1)) os.nice(7) class TestFailure(Exception): pass class Killed(Exception): pass class TestRunnerBase(object): def __init__(self, scheduler, builddir, rev, execf, tsize, csize, default_test_time, savedir): self.scheduler = scheduler self.builddir = builddir self.rev = rev self.execf = execf self.tsize = tsize self.csize = csize self.default_test_time = default_test_time self.long_test_index = randrange(16) self.savedir = savedir self.env = os.environ self.nruns = 0 self.num_ptquery = 1 self.num_update = 1 self.rundir = None self.outf = None self.times = [0, 0] self.is_large = (tsize >= 10000000) self.oldversionstr = 'noupgrade' def __str__(self): return (self.__class__.__name__ + '<%(execf)s, %(tsize)d, %(csize)d, %(oldversionstr)s>') % self def __getitem__(self, k): return self.__getattribute__(k) def infostr(self): return '\t'.join(['%(execf)s', '%(rev)s', '%(tsize)d', '%(csize)d', '%(oldversionstr)s', '%(num_ptquery)d', '%(num_update)d', '%(time)d']) % self @property def time(self): if self.times[0] != 0 and self.times[1] != 0: return self.times[1] - self.times[0] else: return 0 @property def test_time(self): if self.nruns % 16 == self.long_test_index: return 3600 else: return self.default_test_time @property def envdir(self): return os.path.join(self.rundir, 'envdir') @property def prepareloc(self): preparename = 'dir.%(execf)s-%(tsize)d-%(csize)d' % self return os.path.join(self.builddir, 'src', 'tests', preparename) def prepare(self): if os.path.isdir(self.prepareloc): debug('%s found existing environment.', self) copytree(self.prepareloc, self.envdir) else: debug('%s preparing an environment.', self) self.run_prepare() self.save_prepared_envdir() def save_prepared_envdir(self): debug('%s copying environment to %s.', self, self.prepareloc) copytree(self.envdir, self.prepareloc) def run(self): if self.nruns % 2 < 1: self.num_ptquery = 1 else: self.num_ptquery = randrange(16) if self.nruns % 4 < 2: self.num_update = 1 else: self.num_update = randrange(16) srctests = os.path.join(self.builddir, 'src', 'tests') self.rundir = mkdtemp(dir=srctests) try: outname = os.path.join(self.rundir, 'output.txt') self.outf = open(outname, 'w') try: self.prepare() debug('%s testing.', self) self.times[0] = time.time() self.run_test() self.times[1] = time.time() debug('%s done.', self) except Killed: pass except TestFailure: self.times[1] = time.time() savepfx = '%(execf)s-%(rev)s-%(tsize)d-%(csize)d-%(num_ptquery)d-%(num_update)d-%(phase)s-' % self if not os.path.exists(self.savedir): os.mkdir(self.savedir) savedir = mkdtemp(dir=self.savedir, prefix=savepfx) tarfile = '%s.tar' % savedir commands = '' try: f = open(os.path.join(self.rundir, 'commands.txt')) commands = f.read() f.close() except: pass output = '' try: f = open(os.path.join(self.rundir, 'output.txt')) output = f.read() f.close() except: pass self.scheduler.email_failure(self, tarfile, commands, output) self.save(savedir, tarfile) self.scheduler.report_failure(self) warning('Saved environment to %s', tarfile) else: self.scheduler.report_success(self) finally: self.outf.close() rmtree(self.rundir) self.rundir = None self.times = [0, 0] self.nruns += 1 def save(self, savedir, tarfile): def targetfor(path): return os.path.join(savedir, os.path.basename(path)) for f in glob(os.path.join(self.rundir, '*')): if os.path.isdir(f): copytree(f, targetfor(f)) else: copy(f, targetfor(f)) fullexecf = os.path.join(self.builddir, 'src', 'tests', self.execf) copy(fullexecf, targetfor(fullexecf)) # TODO: Leif was lazy and did this in bash, it should be done in python for portability os.system("for l in $(ldd %(fullexecf)s | sed 's/\ *(0x[0-9a-f]*)$//;s/.*=>\ \?//;s/^\ *|\ *$//' | grep -v '^$'); do mkdir -p %(savedir)s/$(dirname $l); cp $l %(savedir)s/$l; done" % {'fullexecf': fullexecf, 'savedir': savedir}) r = call(['tar', 'cf', os.path.basename(tarfile), os.path.basename(savedir)], cwd=os.path.dirname(savedir)) if r != 0: error('tarring up %s failed.' % savedir) sys.exit(r) os.chmod(tarfile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) def waitfor(self, proc): while proc.poll() is None: self.scheduler.stopping.wait(1) if self.scheduler.stopping.isSet(): os.kill(proc.pid, SIGTERM) raise Killed() def spawn_child(self, args): logging.debug('%s spawning %s', self, ' '.join([self.execf] + args)) commandsf = open(os.path.join(self.rundir, 'commands.txt'), 'a') print >>commandsf, ' '.join([self.execf] + args) commandsf.close() proc = Popen([self.execf] + args, executable=os.path.join('..', self.execf), env=self.env, cwd=self.rundir, preexec_fn=setlimits, stdout=self.outf, stderr=STDOUT) self.waitfor(proc) return proc.returncode @property def extraargs(self): # for overriding return [] @property def prepareargs(self): return ['-v', '--envdir', 'envdir', '--num_elements', str(self.tsize), '--cachetable_size', str(self.csize)] + self.extraargs @property def testargs(self): return ['--num_seconds', str(self.test_time), '--join_timeout', str(60 * 60 * 12), '--no-crash_on_operation_failure', '--num_ptquery_threads', str(self.num_ptquery), '--num_update_threads', str(self.num_update)] + self.prepareargs class TestRunner(TestRunnerBase): def run_prepare(self): self.phase = "create" if self.spawn_child(['--only_create'] + self.prepareargs) != 0: raise TestFailure('%s crashed during --only_create.' % self.execf) def run_test(self): self.phase = "stress" if self.spawn_child(['--only_stress'] + self.testargs) != 0: raise TestFailure('%s crashed during --only_stress.' % self.execf) class RecoverTestRunner(TestRunnerBase): def run_prepare(self): self.phase = "create" if self.spawn_child(['--only_create', '--test'] + self.prepareargs) != 0: raise TestFailure('%s crashed during --only_create --test.' % self.execf) def run_test(self): self.phase = "test" if self.spawn_child(['--only_stress', '--test'] + self.testargs) == 0: raise TestFailure('%s did not crash during --only_stress --test' % self.execf) self.phase = "recover" if self.spawn_child(['--recover'] + self.prepareargs) != 0: raise TestFailure('%s crashed during --recover' % self.execf) class UpgradeTestRunnerMixin(TestRunnerBase): def __init__(self, old_environments_dir, version, pristine_or_stressed, **kwargs): super(UpgradeTestRunnerMixin, self).__init__(**kwargs) self.version = version self.pristine_or_stressed = pristine_or_stressed self.old_env_dirs = os.path.join(old_environments_dir, version) self.oldversionstr = '%(version)s-%(pristine_or_stressed)s' % self @property def extraargs(self): return ['--num_DBs', '1'] @property def old_envdir(self): oldname = 'saved%(pristine_or_stressed)s-%(tsize)d-dir' % self logging.debug('%s using old version environment %s from %s.', self, oldname, self.old_env_dirs) return os.path.join(self.old_env_dirs, oldname) def save_prepared_envdir(self): # no need to do this pass def run_prepare(self): self.phase = "create" copytree(self.old_envdir, self.envdir) class DoubleTestRunnerMixin(TestRunnerBase): """Runs the test phase twice in a row. Good for upgrade tests, to run the test once to upgrade it and then again to make sure the upgrade left it in a good state. """ def run_test(self): super(DoubleTestRunnerMixin, self).run_test() super(DoubleTestRunnerMixin, self).run_test() class UpgradeTestRunner(UpgradeTestRunnerMixin, TestRunner): pass class UpgradeRecoverTestRunner(UpgradeTestRunnerMixin, RecoverTestRunner): pass class DoubleUpgradeTestRunner(DoubleTestRunnerMixin, UpgradeTestRunner): pass class DoubleUpgradeRecoverTestRunner(DoubleTestRunnerMixin, UpgradeRecoverTestRunner): pass class Worker(Thread): def __init__(self, scheduler): super(Worker, self).__init__() self.scheduler = scheduler def run(self): debug('%s starting.' % self) while not self.scheduler.stopping.isSet(): test_runner = self.scheduler.get() if test_runner.is_large: if self.scheduler.nlarge + 1 > self.scheduler.maxlarge: debug('%s pulled a large test, but there are already %d running. Putting it back.', self, self.scheduler.nlarge) self.scheduler.put(test_runner) continue self.scheduler.nlarge += 1 try: test_runner.run() except Exception, e: exception('Fatal error in worker thread.') info('Killing all workers.') self.scheduler.error = format_exc() self.scheduler.stop() if test_runner.is_large: self.scheduler.nlarge -= 1 if not self.scheduler.stopping.isSet(): self.scheduler.put(test_runner) debug('%s exiting.' % self) class Scheduler(Queue): def __init__(self, nworkers, maxlarge, logger, email, branch): Queue.__init__(self) info('Initializing scheduler with %d jobs.', nworkers) self.nworkers = nworkers self.logger = logger self.maxlarge = maxlarge self.nlarge = 0 # not thread safe, don't really care right now self.passed = 0 self.failed = 0 self.workers = [] self.stopping = Event() self.timer = None self.error = None self.email = email self.branch = branch def run(self, timeout): info('Starting workers.') self.stopping.clear() for i in range(self.nworkers): w = Worker(self) self.workers.append(w) w.start() if timeout != 0: self.timer = Timer(timeout, self.stop) self.timer.start() while not self.stopping.isSet(): try: for w in self.workers: if self.stopping.isSet(): break w.join(timeout=1.0) except (KeyboardInterrupt, SystemExit): debug('Scheduler interrupted. Stopping and joining threads.') self.stop() self.join() sys.exit(0) else: debug('Scheduler stopped by someone else. Joining threads.') self.join() if self.error: send_mail(self.email, 'Stress tests scheduler stopped by something, on %s' % gethostname(), self.error) sys.exit(77) def join(self): if self.timer is not None: self.timer.cancel() while len(self.workers) > 0: self.workers.pop().join() def stop(self): info('Stopping workers.') self.stopping.set() def __getitem__(self, k): return self.__dict__[k] def reportstr(self): return '[PASS=%(passed)d FAIL=%(failed)d]' % self def report_success(self, runner): self.passed += 1 self.logger.info('PASSED %s', runner.infostr()) info('%s PASSED %s', self.reportstr(), runner.infostr()) def report_failure(self, runner): self.failed += 1 self.logger.warning('FAILED %s', runner.infostr()) warning('%s FAILED %s', self.reportstr(), runner.infostr()) def email_failure(self, runner, savedtarfile, commands, output): if self.email is None: return h = gethostname() if isinstance(runner, UpgradeTestRunnerMixin): upgradestr = ''' The test was upgrading from %s.''' % runner.oldversionstr else: upgradestr = '' send_mail(self.email, 'Stress test failure on %(hostname)s running %(branch)s.' % { 'hostname': h, 'branch': self.branch }, ('''A stress test failed on %(hostname)s running %(branch)s at revision %(rev)s after %(test_duration)d seconds.%(upgradestr)s Its environment is saved to %(tarfile)s on that machine. The test configuration was: testname: %(execf)s num_elements: %(tsize)d cachetable_size: %(csize)d num_ptquery_threads: %(num_ptquery)d num_update_threads: %(num_update)d Commands run: %(commands)s Test output: %(output)s ''' % { 'hostname': h, 'rev': runner.rev, 'test_duration': runner.time, 'upgradestr': upgradestr, 'tarfile': savedtarfile, 'execf': runner.execf, 'tsize': runner.tsize, 'csize': runner.csize, 'num_ptquery': runner.num_ptquery, 'num_update': runner.num_update, 'branch': self.branch, 'commands': commands, 'output': output, })) def send_mail(toaddrs, subject, body): # m = MIMEText(body) # fromaddr = 'dev-private@percona.com' # m['From'] = fromaddr # m['To'] = ', '.join(toaddrs) # m['Subject'] = subject # s = SMTP('192.168.1.114') # s.sendmail(fromaddr, toaddrs, str(m)) # s.quit() info(subject); info(body); def update(tokudb): info('Updating from git.') devnull = open(os.devnull, 'w') call(['git', 'pull'], stdout=devnull, stderr=STDOUT, cwd=tokudb) devnull.close() def rebuild(tokudb, builddir, tokudb_data, cc, cxx, tests): info('Building tokudb.') if not os.path.exists(builddir): os.mkdir(builddir) newenv = os.environ newenv['CC'] = cc newenv['CXX'] = cxx r = call(['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DUSE_GTAGS=OFF', '-DUSE_CTAGS=OFF', '-DUSE_ETAGS=OFF', '-DUSE_CSCOPE=OFF', '-DTOKUDB_DATA=%s' % tokudb_data, tokudb], env=newenv, cwd=builddir) if r != 0: send_mail(['dev-private@percona.com'], 'Stress tests on %s failed to build.' % gethostname(), '') error('Building the tests failed.') sys.exit(r) r = call(['make', '-j8'], cwd=builddir) if r != 0: send_mail(['dev-private@percona.com'], 'Stress tests on %s failed to build.' % gethostname(), '') error('Building the tests failed.') sys.exit(r) def revfor(tokudb): proc = Popen("git describe --tags", shell=True, cwd=tokudb, stdout=PIPE) (out, err) = proc.communicate() rev = out.strip() info('Using tokudb at r%s.', rev) return rev def main(opts): builddir = os.path.join(opts.tokudb, 'build') if opts.build: rebuild(opts.tokudb, builddir, opts.tokudb_data, opts.cc, opts.cxx, opts.testnames + opts.recover_testnames) rev = revfor(opts.tokudb) if not os.path.exists(opts.savedir): os.mkdir(opts.savedir) logger = logging.getLogger('stress') logger.propagate = False logger.setLevel(logging.INFO) logger.addHandler(logging.FileHandler(opts.log)) info('Saving pass/fail logs to %s.', opts.log) info('Saving failure environments to %s.', opts.savedir) scheduler = Scheduler(opts.jobs, opts.maxlarge, logger, opts.email, opts.branch) runners = [] for tsize in [2000, 200000, 50000000]: for csize in [50 * tsize, 1000 ** 3]: kwargs = { 'scheduler': scheduler, 'builddir': builddir, 'rev': rev, 'tsize': tsize, 'csize': csize, 'default_test_time': opts.test_time, 'savedir': opts.savedir } for test in opts.testnames: if opts.run_non_upgrade: runners.append(TestRunner(execf=test, **kwargs)) # never run test_stress_openclose.tdb on existing # environments, it doesn't want them if opts.run_upgrade and test != 'test_stress_openclose.tdb': for version in opts.old_versions: for pristine_or_stressed in ['pristine', 'stressed']: upgrade_kwargs = { 'old_environments_dir': opts.old_environments_dir, 'version': version, 'pristine_or_stressed': pristine_or_stressed } upgrade_kwargs.update(kwargs) # skip running test_stress4.tdb on any env # that has already been stressed, as that # breaks its assumptions if opts.double_upgrade and test != 'test_stress4.tdb': runners.append(DoubleUpgradeTestRunner( execf=test, **upgrade_kwargs)) elif not (test == 'test_stress4.tdb' and pristine_or_stressed == 'stressed'): runners.append(UpgradeTestRunner( execf=test, **upgrade_kwargs)) for test in opts.recover_testnames: if opts.run_non_upgrade: runners.append(RecoverTestRunner(execf=test, **kwargs)) if opts.run_upgrade: for version in opts.old_versions: for pristine_or_stressed in ['pristine', 'stressed']: upgrade_kwargs = { 'old_environments_dir': opts.old_environments_dir, 'version': version, 'pristine_or_stressed': pristine_or_stressed } upgrade_kwargs.update(kwargs) if opts.double_upgrade: runners.append(DoubleUpgradeRecoverTestRunner( execf=test, **upgrade_kwargs)) else: runners.append(UpgradeRecoverTestRunner( execf=test, **upgrade_kwargs)) shuffle(runners) for runner in runners: scheduler.put(runner) try: while scheduler.error is None: scheduler.run(opts.rebuild_period) if scheduler.error is not None: error('Scheduler reported an error.') raise scheduler.error update(opts.tokudb) rebuild(opts.tokudb, builddir, opts.tokudb_data, opts.cc, opts.cxx, opts.testnames + opts.recover_testnames) rev = revfor(opts.tokudb) for runner in runners: runner.rev = rev except (KeyboardInterrupt, SystemExit): sys.exit(0) except Exception, e: exception('Unhandled exception caught in main.') send_mail(['dev-private@percona.com'], 'Stress tests caught unhandled exception in main, on %s' % gethostname(), format_exc()) raise e if __name__ == '__main__': a0 = os.path.abspath(sys.argv[0]) usage = '%prog [options]\n' + __doc__ parser = OptionParser(usage=usage) parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='show build status, passing tests, and other info') parser.add_option('-d', '--debug', action='store_true', dest='debug', default=False, help='show debugging info') parser.add_option('-l', '--log', type='string', dest='log', default='/tmp/run.stress-tests.log', help='where to save logfiles') parser.add_option('-s', '--savedir', type='string', dest='savedir', default='/tmp/run.stress-tests.failures', help='where to save environments and extra data for failed tests') parser.add_option('--email', action='append', type='string', dest='email', default=[], help='where to send emails') parser.add_option('--no-email', action='store_false', dest='send_emails', default=True, help='suppress emails on failure') default_toplevel = os.path.dirname(os.path.dirname(a0)) parser.add_option('--tokudb', type='string', dest='tokudb', default=default_toplevel, help=('top of the tokudb tree (contains ft/ and src/) [default=%s]' % os.path.relpath(default_toplevel))) toplevel_basename = os.path.basename(default_toplevel) if toplevel_basename == 'tokudb': maybe_absolute_branchpath = os.path.dirname(default_toplevel) if os.path.basename(os.path.dirname(maybe_absolute_branchpath)) == 'mysql.branches': default_branchname = os.path.basename(maybe_absolute_branchpath) else: default_branchname = 'mainline' elif toplevel_basename[:7] == 'tokudb.': default_branchname = toplevel_basename[7:] else: default_branchname = 'unknown branch' parser.add_option('--branch', type='string', dest='branch', default=default_branchname, help=('what to call this branch [default=%s]' % default_branchname)) test_group = OptionGroup(parser, 'Scheduler Options', 'Control how the scheduler runs jobs.') test_group.add_option('-t', '--test_time', type='int', dest='test_time', default=60, help='time to run each test, in seconds [default=60]'), test_group.add_option('-j', '--jobs', type='int', dest='jobs', default=8, help='how many concurrent tests to run [default=8]') test_group.add_option('--maxlarge', type='int', dest='maxlarge', default=2, help='maximum number of large tests to run concurrently (helps prevent swapping) [default=2]') parser.add_option_group(test_group) default_testnames = ['test_stress0.tdb', 'test_stress1.tdb', 'test_stress2.tdb', 'test_stress3.tdb', 'test_stress4.tdb', 'test_stress5.tdb', 'test_stress6.tdb', 'test_stress7.tdb', 'test_stress_hot_indexing.tdb', 'test_stress_with_verify.tdb', 'test_stress_openclose.tdb'] default_recover_testnames = ['recover-test_stress1.tdb', 'recover-test_stress2.tdb', 'recover-test_stress3.tdb', 'recover-child-rollback.tdb', 'recover-test_stress_openclose.tdb'] build_group = OptionGroup(parser, 'Build Options', 'Control how the fractal tree and tests get built.') build_group.add_option('--skip_build', action='store_false', dest='build', default=True, help='skip the git pull and build phase before testing [default=False]') build_group.add_option('--rebuild_period', type='int', dest='rebuild_period', default=60 * 60 * 24, help='how many seconds between doing an git pull and rebuild, 0 means never rebuild [default=24 hours]') default_tokudb_data = os.path.abspath(os.path.join(default_toplevel, '..', 'tokudb.data')) build_group.add_option('--tokudb_data', type='string', dest='tokudb_data', default=default_tokudb_data, help='passed to cmake as TOKUDB_DATA [default=%s]' % default_tokudb_data) build_group.add_option('--cc', type='string', dest='cc', default='gcc47', help='which compiler to use [default=gcc47]') build_group.add_option('--cxx', type='string', dest='cxx', default='g++47', help='which compiler to use [default=g++47]') build_group.add_option('--add_test', action='append', type='string', dest='testnames', default=default_testnames, help=('add a stress test to run [default=%r]' % default_testnames)) build_group.add_option('--add_recover_test', action='append', type='string', dest='recover_testnames', default=default_recover_testnames, help=('add a recover stress test to run [default=%r]' % default_recover_testnames)) parser.add_option_group(build_group) upgrade_group = OptionGroup(parser, 'Upgrade Options', 'Also run on environments from old versions of tokudb.') upgrade_group.add_option('--run_upgrade', action='store_true', dest='run_upgrade', default=False, help='run the tests on old dictionaries as well, to test upgrade [default=False]') upgrade_group.add_option('--skip_non_upgrade', action='store_false', dest='run_non_upgrade', default=True, help="skip the tests that don't involve upgrade [default=False]") upgrade_group.add_option('--double_upgrade', action='store_true', dest='double_upgrade', default=False, help='run the upgrade tests twice in a row [default=False]') upgrade_group.add_option('--add_old_version', action='append', type='choice', dest='old_versions', choices=['4.2.0', '5.0.8', '5.2.7', '6.0.0', '6.1.0', '6.5.1', '6.6.3', '7.0.1','7.1.6','v26','7.5.0'], help='which old versions to use for running the stress tests in upgrade mode. can be specified multiple times [options=4.2.0, 5.0.8, 5.2.7, 6.0.0, 6.1.0, 6.5.1, 6.6.3, 7.1.0, 7.1.6, v26, 7.5.0]') upgrade_group.add_option('--old_environments_dir', type='string', dest='old_environments_dir', default=('%s/old-stress-test-envs' % default_tokudb_data), help='directory containing old version environments (should contain 5.0.8/, 5.2.7/, etc, and the environments should be in those) [default=../../tokudb.data/stress_environments]') parser.add_option_group(upgrade_group) (opts, args) = parser.parse_args() if len(args) > 0: parser.error('Invalid arguments: %r' % args) if opts.old_versions is not None and len(opts.old_versions) > 0: opts.run_upgrade = True if opts.run_upgrade: if not os.path.isdir(opts.old_environments_dir): parser.error('You specified --run_upgrade but did not specify an --old_environments_dir that exists.') if len(opts.old_versions) < 1: parser.error('You specified --run_upgrade but gave no --old_versions to run against.') for version in opts.old_versions: version_dir = os.path.join(opts.old_environments_dir, version) if not os.path.isdir(version_dir): parser.error('You specified --run_upgrade but %s is not a directory.' % version_dir) if not opts.send_emails: opts.email = None elif len(opts.email) == 0: opts.email.append('dev-private@percona.com') if opts.debug: logging.basicConfig(level=logging.DEBUG) elif opts.verbose: logging.basicConfig(level=logging.INFO) else: logging.basicConfig(level=logging.WARNING) main(opts)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 199, 33, 2884, 367, 3879, 4154, 31692, 2295, 27714, 370, 1937, 340, 1263, 2449, 14, 199, 199, 16291, 282, 769, 402, 31692, 2295, 315, 9861, 12, 17290, 14933, 436, 32223, 199, 5328, 28444, 5133, 26659, 14, 221, 23773, 543, 3365, 1817, 10627, 12, 199, 20138, 386, 461, 10627, 12, 436, 5579, 402, 7183, 14, 199, 199, 51, 10020, 367, 3879, 641, 282, 4866, 5246, 12, 503, 282, 4683, 5246, 12, 503, 2446, 14, 199, 199, 22850, 1255, 314, 2884, 687, 4453, 282, 5246, 1265, 2934, 370, 511, 14, 199, 199, 2175, 849, 12, 781, 3631, 8137, 12, 1678, 687, 6135, 12, 22110, 12, 436, 11004, 314, 199, 2219, 5403, 282, 5382, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 5672, 199, 646, 984, 199, 646, 900, 199, 199, 504, 3031, 14, 7626, 14, 505, 492, 603, 26567, 199, 504, 5739, 492, 5739, 199, 504, 2050, 492, 3105, 12, 2256, 12, 5721, 12, 1125, 12, 1919, 199, 504, 8691, 492, 3207, 2448, 12, 13491, 199, 504, 10703, 492, 10703, 199, 504, 2196, 492, 10261, 1842, 12, 13031, 199, 504, 2073, 492, 663, 82, 3097, 12, 820, 13387, 63, 24428, 199, 504, 5145, 492, 1331, 12, 1331, 2350, 12, 4057, 12, 20978, 199, 504, 4673, 492, 4673, 12, 428, 13454, 2160, 12, 15522, 2919, 12, 15522, 6089, 12, 15522, 748, 11026, 12, 15522, 16718, 199, 504, 30475, 492, 19810, 199, 504, 2838, 492, 2312, 15157, 354, 199, 504, 3873, 492, 1240, 12, 13995, 12, 22773, 12, 4384, 12619, 199, 504, 5190, 492, 1475, 63, 2804, 199, 504, 5549, 492, 31781, 12, 333, 6080, 808, 199, 504, 5796, 492, 6763, 12, 11086, 12, 22287, 199, 199, 363, 1023, 363, 257, 275, 4505, 1304, 12913, 199, 363, 7307, 363, 275, 408, 7384, 334, 67, 9, 8315, 12, 6900, 12, 3492, 388, 65, 436, 15, 269, 2399, 29172, 2335, 14, 2900, 4481, 4644, 1041, 199, 199, 3, 20700, 4514, 367, 2366, 665, 18, 14, 22, 199, 3, 687, 1455, 921, 2796, 13, 832, 14, 31864, 14, 957, 15, 9208, 13, 5570, 15, 17, 1587, 25, 845, 12021, 70, 23, 1235, 9803, 69, 2010, 4675, 10233, 66, 1690, 645, 18, 65, 1349, 1407, 68, 25193, 20, 15, 2796, 18, 15, 2796, 18, 15, 15390, 14, 647, 199, 692, 440, 2688, 8, 736, 14, 515, 12, 283, 12405, 735, 272, 340, 747, 14, 515, 365, 984, 14, 3112, 14, 362, 360, 343, 515, 735, 267, 347, 20700, 8, 515, 12, 1343, 29, 736, 14, 515, 14, 15594, 304, 288, 408, 1767, 282, 3847, 1015, 402, 282, 931, 624, 953, 340, 440, 931, 26, 355, 746, 1722, 480, 889, 931, 2013, 531, 288, 1343, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 928, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 288, 931, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 515, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 288, 340, 1343, 63, 513, 59, 16, 1055, 2325, 342, 1137, 931, 63, 513, 59, 16, 1055, 2325, 837, 355, 625, 67, 63, 515, 12, 4618, 275, 747, 14, 515, 14, 1294, 1097, 8, 515, 9, 355, 625, 67, 63, 928, 12, 4618, 275, 747, 14, 515, 14, 1294, 1097, 8, 928, 9, 355, 340, 2155, 8, 1097, 63, 515, 9, 7167, 2155, 8, 1097, 63, 928, 304, 490, 746, 1722, 480, 6612, 13667, 738, 6389, 436, 2222, 13, 17192, 3792, 4366, 83, 436, 450, 83, 2924, 6684, 263, 450, 334, 515, 12, 1343, 430, 355, 587, 26, 490, 746, 1722, 480, 515, 365, 641, 12912, 450, 83, 12, 1343, 641, 12912, 450, 83, 2, 9144, 450, 334, 515, 63, 513, 59, 16, 467, 1343, 63, 513, 59, 16, 2459, 288, 327, 9361, 734, 4212, 8298, 402, 314, 9911, 365, 5709, 701, 1343, 436, 931, 14, 288, 367, 284, 315, 1425, 8, 827, 8, 552, 8, 928, 63, 513, 395, 822, 8, 515, 63, 513, 15206, 355, 340, 1343, 63, 513, 59, 73, 1055, 2325, 342, 1137, 931, 63, 513, 59, 73, 1055, 2325, 837, 490, 2059, 288, 587, 26, 355, 284, 847, 413, 953, 4668, 63, 513, 275, 359, 736, 14, 515, 14, 21386, 61, 627, 334, 552, 8, 928, 63, 513, 7216, 73, 9, 435, 931, 63, 513, 59, 73, 2938, 288, 340, 440, 4668, 63, 513, 26, 355, 372, 747, 14, 515, 14, 15594, 288, 372, 747, 14, 515, 14, 904, 2031, 3369, 63, 513, 9, 339, 587, 26, 267, 327, 849, 370, 15454, 5492, 267, 347, 20700, 8, 515, 12, 1343, 29, 736, 14, 515, 14, 15594, 304, 288, 408, 1767, 282, 3847, 1015, 402, 282, 931, 624, 953, 340, 440, 931, 26, 355, 746, 1722, 480, 889, 931, 2013, 531, 953, 1343, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 928, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 288, 931, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 515, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 953, 327, 9361, 734, 4212, 8298, 402, 314, 9911, 365, 5709, 701, 1343, 436, 931, 14, 288, 284, 275, 822, 8, 736, 14, 515, 14, 2330, 1861, 779, 928, 63, 513, 12, 931, 63, 513, 2459, 953, 4668, 63, 513, 275, 359, 736, 14, 515, 14, 21386, 61, 627, 334, 552, 8, 928, 63, 513, 7216, 73, 9, 435, 931, 63, 513, 59, 73, 2938, 288, 340, 440, 4668, 63, 513, 26, 355, 372, 747, 14, 515, 14, 15594, 288, 372, 747, 14, 515, 14, 904, 2031, 3369, 63, 513, 9, 339, 747, 14, 515, 14, 12405, 275, 20700, 199, 199, 318, 663, 9368, 837, 272, 663, 82, 3097, 8, 2431, 4372, 63, 24428, 12, 5868, 17, 12, 446, 17, 430, 272, 747, 14, 22746, 8, 23, 9, 199, 199, 533, 1379, 6782, 8, 1726, 304, 272, 986, 199, 199, 533, 1804, 14535, 8, 1726, 304, 272, 986, 199, 199, 533, 1379, 7446, 1563, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 11899, 12, 1900, 694, 12, 6822, 12, 2146, 70, 12, 307, 890, 12, 286, 890, 12, 849, 63, 396, 63, 521, 12, 3354, 694, 304, 267, 291, 14, 8874, 275, 11899 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 199, 33, 2884, 367, 3879, 4154, 31692, 2295, 27714, 370, 1937, 340, 1263, 2449, 14, 199, 199, 16291, 282, 769, 402, 31692, 2295, 315, 9861, 12, 17290, 14933, 436, 32223, 199, 5328, 28444, 5133, 26659, 14, 221, 23773, 543, 3365, 1817, 10627, 12, 199, 20138, 386, 461, 10627, 12, 436, 5579, 402, 7183, 14, 199, 199, 51, 10020, 367, 3879, 641, 282, 4866, 5246, 12, 503, 282, 4683, 5246, 12, 503, 2446, 14, 199, 199, 22850, 1255, 314, 2884, 687, 4453, 282, 5246, 1265, 2934, 370, 511, 14, 199, 199, 2175, 849, 12, 781, 3631, 8137, 12, 1678, 687, 6135, 12, 22110, 12, 436, 11004, 314, 199, 2219, 5403, 282, 5382, 14, 199, 624, 199, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 5672, 199, 646, 984, 199, 646, 900, 199, 199, 504, 3031, 14, 7626, 14, 505, 492, 603, 26567, 199, 504, 5739, 492, 5739, 199, 504, 2050, 492, 3105, 12, 2256, 12, 5721, 12, 1125, 12, 1919, 199, 504, 8691, 492, 3207, 2448, 12, 13491, 199, 504, 10703, 492, 10703, 199, 504, 2196, 492, 10261, 1842, 12, 13031, 199, 504, 2073, 492, 663, 82, 3097, 12, 820, 13387, 63, 24428, 199, 504, 5145, 492, 1331, 12, 1331, 2350, 12, 4057, 12, 20978, 199, 504, 4673, 492, 4673, 12, 428, 13454, 2160, 12, 15522, 2919, 12, 15522, 6089, 12, 15522, 748, 11026, 12, 15522, 16718, 199, 504, 30475, 492, 19810, 199, 504, 2838, 492, 2312, 15157, 354, 199, 504, 3873, 492, 1240, 12, 13995, 12, 22773, 12, 4384, 12619, 199, 504, 5190, 492, 1475, 63, 2804, 199, 504, 5549, 492, 31781, 12, 333, 6080, 808, 199, 504, 5796, 492, 6763, 12, 11086, 12, 22287, 199, 199, 363, 1023, 363, 257, 275, 4505, 1304, 12913, 199, 363, 7307, 363, 275, 408, 7384, 334, 67, 9, 8315, 12, 6900, 12, 3492, 388, 65, 436, 15, 269, 2399, 29172, 2335, 14, 2900, 4481, 4644, 1041, 199, 199, 3, 20700, 4514, 367, 2366, 665, 18, 14, 22, 199, 3, 687, 1455, 921, 2796, 13, 832, 14, 31864, 14, 957, 15, 9208, 13, 5570, 15, 17, 1587, 25, 845, 12021, 70, 23, 1235, 9803, 69, 2010, 4675, 10233, 66, 1690, 645, 18, 65, 1349, 1407, 68, 25193, 20, 15, 2796, 18, 15, 2796, 18, 15, 15390, 14, 647, 199, 692, 440, 2688, 8, 736, 14, 515, 12, 283, 12405, 735, 272, 340, 747, 14, 515, 365, 984, 14, 3112, 14, 362, 360, 343, 515, 735, 267, 347, 20700, 8, 515, 12, 1343, 29, 736, 14, 515, 14, 15594, 304, 288, 408, 1767, 282, 3847, 1015, 402, 282, 931, 624, 953, 340, 440, 931, 26, 355, 746, 1722, 480, 889, 931, 2013, 531, 288, 1343, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 928, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 288, 931, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 515, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 288, 340, 1343, 63, 513, 59, 16, 1055, 2325, 342, 1137, 931, 63, 513, 59, 16, 1055, 2325, 837, 355, 625, 67, 63, 515, 12, 4618, 275, 747, 14, 515, 14, 1294, 1097, 8, 515, 9, 355, 625, 67, 63, 928, 12, 4618, 275, 747, 14, 515, 14, 1294, 1097, 8, 928, 9, 355, 340, 2155, 8, 1097, 63, 515, 9, 7167, 2155, 8, 1097, 63, 928, 304, 490, 746, 1722, 480, 6612, 13667, 738, 6389, 436, 2222, 13, 17192, 3792, 4366, 83, 436, 450, 83, 2924, 6684, 263, 450, 334, 515, 12, 1343, 430, 355, 587, 26, 490, 746, 1722, 480, 515, 365, 641, 12912, 450, 83, 12, 1343, 641, 12912, 450, 83, 2, 9144, 450, 334, 515, 63, 513, 59, 16, 467, 1343, 63, 513, 59, 16, 2459, 288, 327, 9361, 734, 4212, 8298, 402, 314, 9911, 365, 5709, 701, 1343, 436, 931, 14, 288, 367, 284, 315, 1425, 8, 827, 8, 552, 8, 928, 63, 513, 395, 822, 8, 515, 63, 513, 15206, 355, 340, 1343, 63, 513, 59, 73, 1055, 2325, 342, 1137, 931, 63, 513, 59, 73, 1055, 2325, 837, 490, 2059, 288, 587, 26, 355, 284, 847, 413, 953, 4668, 63, 513, 275, 359, 736, 14, 515, 14, 21386, 61, 627, 334, 552, 8, 928, 63, 513, 7216, 73, 9, 435, 931, 63, 513, 59, 73, 2938, 288, 340, 440, 4668, 63, 513, 26, 355, 372, 747, 14, 515, 14, 15594, 288, 372, 747, 14, 515, 14, 904, 2031, 3369, 63, 513, 9, 339, 587, 26, 267, 327, 849, 370, 15454, 5492, 267, 347, 20700, 8, 515, 12, 1343, 29, 736, 14, 515, 14, 15594, 304, 288, 408, 1767, 282, 3847, 1015, 402, 282, 931, 624, 953, 340, 440, 931, 26, 355, 746, 1722, 480, 889, 931, 2013, 531, 953, 1343, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 928, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 288, 931, 63, 513, 275, 747, 14, 515, 14, 4832, 8, 515, 680, 1294, 8, 736, 14, 515, 14, 4127, 9, 953, 327, 9361, 734, 4212, 8298, 402, 314, 9911, 365, 5709, 701, 1343, 436, 931, 14, 288, 284, 275, 822, 8, 736, 14, 515, 14, 2330, 1861, 779, 928, 63, 513, 12, 931, 63, 513, 2459, 953, 4668, 63, 513, 275, 359, 736, 14, 515, 14, 21386, 61, 627, 334, 552, 8, 928, 63, 513, 7216, 73, 9, 435, 931, 63, 513, 59, 73, 2938, 288, 340, 440, 4668, 63, 513, 26, 355, 372, 747, 14, 515, 14, 15594, 288, 372, 747, 14, 515, 14, 904, 2031, 3369, 63, 513, 9, 339, 747, 14, 515, 14, 12405, 275, 20700, 199, 199, 318, 663, 9368, 837, 272, 663, 82, 3097, 8, 2431, 4372, 63, 24428, 12, 5868, 17, 12, 446, 17, 430, 272, 747, 14, 22746, 8, 23, 9, 199, 199, 533, 1379, 6782, 8, 1726, 304, 272, 986, 199, 199, 533, 1804, 14535, 8, 1726, 304, 272, 986, 199, 199, 533, 1379, 7446, 1563, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 11899, 12, 1900, 694, 12, 6822, 12, 2146, 70, 12, 307, 890, 12, 286, 890, 12, 849, 63, 396, 63, 521, 12, 3354, 694, 304, 267, 291, 14, 8874, 275, 11899, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
undefinedv/Jingubang
sqlmap/lib/core/optiondict.py
1
13064
#!/usr/bin/env python """ Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/) See the file 'doc/COPYING' for copying permission """ optDict = { # Format: # Family: { "parameter name": "parameter datatype" }, # Or: # Family: { "parameter name": ("parameter datatype", "category name used for common outputs feature") }, "Target": { "direct": "string", "url": "string", "logFile": "string", "bulkFile": "string", "requestFile": "string", "sessionFile": "string", "googleDork": "string", "configFile": "string", "sitemapUrl": "string", }, "Request": { "method": "string", "data": "string", "paramDel": "string", "cookie": "string", "cookieDel": "string", "loadCookies": "string", "dropSetCookie": "boolean", "agent": "string", "randomAgent": "boolean", "host": "string", "referer": "string", "headers": "string", "authType": "string", "authCred": "string", "authFile": "string", "proxy": "string", "proxyCred": "string", "proxyFile": "string", "ignoreProxy": "boolean", "tor": "boolean", "torPort": "integer", "torType": "string", "checkTor": "boolean", "delay": "float", "timeout": "float", "retries": "integer", "rParam": "string", "safeUrl": "string", "safePost": "string", "safeReqFile": "string", "safeFreq": "integer", "skipUrlEncode": "boolean", "csrfToken": "string", "csrfUrl": "string", "forceSSL": "boolean", "hpp": "boolean", "evalCode": "string", }, "Optimization": { "optimize": "boolean", "predictOutput": "boolean", "keepAlive": "boolean", "nullConnection": "boolean", "threads": "integer", }, "Injection": { "testParameter": "string", "skip": "string", "skipStatic": "boolean", "dbms": "string", "dbmsCred": "string", "os": "string", "invalidBignum": "boolean", "invalidLogical": "boolean", "invalidString": "boolean", "noCast": "boolean", "noEscape": "boolean", "prefix": "string", "suffix": "string", "tamper": "string", }, "Detection": { "level": "integer", "risk": "integer", "string": "string", "notString": "string", "regexp": "string", "code": "integer", "textOnly": "boolean", "titles": "boolean", }, "Techniques": { "tech": "string", "timeSec": "integer", "uCols": "string", "uChar": "string", "uFrom": "string", "dnsName": "string", "secondOrder": "string", }, "Fingerprint": { "extensiveFp": "boolean", }, "Enumeration": { "getAll": "boolean", "getBanner": ("boolean", "Banners"), "getCurrentUser": ("boolean", "Users"), "getCurrentDb": ("boolean", "Databases"), "getHostname": "boolean", "isDba": "boolean", "getUsers": ("boolean", "Users"), "getPasswordHashes": ("boolean", "Passwords"), "getPrivileges": ("boolean", "Privileges"), "getRoles": ("boolean", "Roles"), "getDbs": ("boolean", "Databases"), "getTables": ("boolean", "Tables"), "getColumns": ("boolean", "Columns"), "getSchema": "boolean", "getCount": "boolean", "dumpTable": "boolean", "dumpAll": "boolean", "search": "boolean", "getComments": "boolean", "db": "string", "tbl": "string", "col": "string", "excludeCol": "string", "pivotColumn": "string", "dumpWhere": "string", "user": "string", "excludeSysDbs": "boolean", "limitStart": "integer", "limitStop": "integer", "firstChar": "integer", "lastChar": "integer", "query": "string", "sqlShell": "boolean", "sqlFile": "string", }, "Brute": { "commonTables": "boolean", "commonColumns": "boolean", }, "User-defined function": { "udfInject": "boolean", "shLib": "string", }, "File system": { "rFile": "string", "wFile": "string", "dFile": "string", }, "Takeover": { "osCmd": "string", "osShell": "boolean", "osPwn": "boolean", "osSmb": "boolean", "osBof": "boolean", "privEsc": "boolean", "msfPath": "string", "tmpPath": "string", }, "Windows": { "regRead": "boolean", "regAdd": "boolean", "regDel": "boolean", "regKey": "string", "regVal": "string", "regData": "string", "regType": "string", }, "General": { #"xmlFile": "string", "trafficFile": "string", "batch": "boolean", "binaryFields": "string", "charset": "string", "crawlDepth": "integer", "crawlExclude": "string", "csvDel": "string", "dumpFormat": "string", "eta": "boolean", "flushSession": "boolean", "forms": "boolean", "freshQueries": "boolean", "hexConvert": "boolean", "outputDir": "string", "parseErrors": "boolean", "saveConfig": "string", "scope": "string", "testFilter": "string", "testSkip": "string", "updateAll": "boolean", }, "Miscellaneous": { "alert": "string", "answers": "string", "beep": "boolean", "cleanup": "boolean", "dependencies": "boolean", "disableColoring": "boolean", "googlePage": "integer", "identifyWaf": "boolean", "mobile": "boolean", "offline": "boolean", "pageRank": "boolean", "purgeOutput": "boolean", "skipWaf": "boolean", "smart": "boolean", "tmpDir": "string", "wizard": "boolean", "verbose": "integer", }, "Hidden": { "dummy": "boolean", "disablePrecon": "boolean", "profile": "boolean", "forceDns": "boolean", "ignore401": "boolean", "smokeTest": "boolean", "liveTest": "boolean", "stopFail": "boolean", "runCase": "string", } }
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 7384, 334, 67, 9, 8315, 13, 9261, 3875, 1130, 19782, 334, 1014, 921, 3009, 1130, 14, 1308, 24793, 199, 9295, 314, 570, 283, 1301, 15, 16188, 1206, 7, 367, 16743, 4983, 199, 624, 199, 199, 2992, 2141, 275, 469, 288, 327, 9701, 26, 288, 327, 481, 4632, 26, 263, 469, 298, 5329, 536, 582, 259, 298, 5329, 16048, 2, 1660, 288, 327, 4236, 26, 288, 327, 481, 4632, 26, 263, 469, 298, 5329, 536, 582, 259, 1689, 5329, 16048, 401, 298, 3710, 536, 1202, 367, 2863, 4704, 3878, 531, 1660, 288, 298, 4277, 582, 263, 469, 3044, 298, 2275, 582, 3322, 298, 875, 401, 3044, 298, 633, 582, 5185, 298, 875, 401, 3044, 298, 793, 1173, 582, 3698, 298, 875, 401, 3044, 298, 9377, 1173, 582, 3515, 298, 875, 401, 3044, 298, 1069, 1173, 582, 755, 298, 875, 401, 3044, 298, 1730, 1173, 582, 755, 298, 875, 401, 3044, 298, 3098, 36, 4708, 582, 263, 298, 875, 401, 3044, 298, 888, 1173, 582, 263, 298, 875, 401, 3044, 298, 17205, 6417, 582, 263, 298, 875, 401, 2490, 1660, 953, 298, 2017, 582, 755, 469, 3044, 298, 765, 582, 3322, 298, 875, 401, 3044, 298, 576, 582, 4519, 298, 875, 401, 3044, 298, 635, 6994, 582, 3515, 298, 875, 401, 3044, 298, 5306, 582, 3322, 298, 875, 401, 3044, 298, 5306, 6994, 582, 260, 298, 875, 401, 3044, 298, 912, 967, 5635, 582, 755, 298, 875, 401, 3044, 298, 4824, 1084, 7810, 582, 258, 298, 4871, 401, 3044, 298, 4054, 582, 3777, 298, 875, 401, 3044, 298, 2355, 7788, 582, 755, 298, 4871, 401, 3044, 298, 1102, 582, 4519, 298, 875, 401, 3044, 298, 20996, 582, 3698, 298, 875, 401, 3044, 298, 2139, 582, 3698, 298, 875, 401, 3044, 298, 1178, 804, 582, 3515, 298, 875, 401, 3044, 298, 1178, 35, 581, 582, 3515, 298, 875, 401, 3044, 298, 1178, 1173, 582, 3515, 298, 875, 401, 3044, 298, 3280, 582, 3777, 298, 875, 401, 3044, 298, 3280, 35, 581, 582, 260, 298, 875, 401, 3044, 298, 3280, 1173, 582, 260, 298, 875, 401, 3044, 298, 4247, 4936, 582, 755, 298, 4871, 401, 3044, 298, 8270, 582, 5185, 298, 4871, 401, 3044, 298, 8270, 4313, 582, 3698, 298, 4115, 401, 3044, 298, 8270, 804, 582, 3698, 298, 875, 401, 3044, 298, 1074, 20994, 582, 3515, 298, 4871, 401, 3044, 298, 5814, 582, 3777, 298, 1609, 401, 3044, 298, 2593, 582, 3698, 298, 1609, 401, 3044, 298, 10937, 582, 3698, 298, 4115, 401, 3044, 298, 82, 4098, 582, 3322, 298, 875, 401, 3044, 298, 3489, 6417, 582, 3698, 298, 875, 401, 3044, 298, 3489, 6564, 582, 3515, 298, 875, 401, 3044, 298, 3489, 11981, 1173, 582, 755, 298, 875, 401, 3044, 298, 3489, 13875, 582, 3515, 298, 4115, 401, 3044, 298, 2759, 6417, 9686, 582, 258, 298, 4871, 401, 3044, 298, 10088, 3264, 582, 260, 298, 875, 401, 3044, 298, 10088, 6417, 582, 3698, 298, 875, 401, 3044, 298, 3990, 5413, 582, 3515, 298, 4871, 401, 3044, 298, 72, 802, 582, 5185, 298, 4871, 401, 3044, 298, 2579, 3034, 582, 3515, 298, 875, 401, 2490, 1660, 953, 298, 30661, 582, 221, 469, 3044, 298, 13416, 582, 3515, 298, 4871, 401, 3044, 298, 6892, 2959, 582, 258, 298, 4871, 401, 3044, 298, 3250, 23692, 582, 260, 298, 4871, 401, 3044, 298, 2307, 3225, 582, 259, 298, 4871, 401, 3044, 298, 6962, 582, 3698, 298, 4115, 401, 2490, 1660, 953, 298, 607, 8923, 582, 258, 469, 3044, 298, 396, 4720, 582, 258, 298, 875, 401, 3044, 298, 2759, 582, 4519, 298, 875, 401, 3044, 298, 2759, 9278, 582, 263, 298, 4871, 401, 3044, 298, 697, 706, 582, 4519, 298, 875, 401, 3044, 298, 697, 706, 35, 581, 582, 3515, 298, 875, 401, 3044, 298, 736, 582, 4483, 298, 875, 401, 3044, 298, 3197, 34, 1030, 453, 582, 258, 298, 4871, 401, 3044, 298, 3197, 22455, 582, 259, 298, 4871, 401, 3044, 298, 3197, 1558, 582, 258, 298, 4871, 401, 3044, 298, 889, 24654, 582, 3322, 298, 4871, 401, 3044, 298, 889, 10260, 582, 3515, 298, 4871, 401, 3044, 298, 1861, 582, 3322, 298, 875, 401, 3044, 298, 4511, 582, 3322, 298, 875, 401, 3044, 298, 502, 311, 281, 582, 3322, 298, 875, 401, 2490, 1660, 953, 298, 31198, 582, 258, 469, 3044, 298, 1896, 582, 3777, 298, 4115, 401, 3044, 298, 27473, 582, 4519, 298, 4115, 401, 3044, 298, 875, 582, 3322, 298, 875, 401, 3044, 298, 1397, 1558, 582, 260, 298, 875, 401, 3044, 298, 11191, 582, 3322, 298, 875, 401, 3044, 298, 600, 582, 4519, 298, 4115, 401, 3044, 298, 505, 5903, 582, 3515, 298, 4871, 401, 3044, 298, 8916, 582, 3322, 298, 4871, 401, 2490, 1660, 953, 298, 6301, 11019, 2029, 83, 582, 259, 469, 3044, 298, 15970, 582, 4519, 298, 875, 401, 3044, 298, 521, 4933, 582, 3698, 298, 4115, 401, 3044, 298, 85, 17203, 582, 3777, 298, 875, 401, 3044, 298, 85, 1610, 582, 3777, 298, 875, 401, 3044, 298, 85, 2532, 582, 3777, 298, 875, 401, 3044, 298, 5797, 985, 582, 3698, 298, 875, 401, 3044, 298, 4375, 4738, 582, 755, 298, 875, 401, 2490, 1660, 953, 298, 28521, 582, 257, 469, 3044, 298, 1614, 3398, 38, 80, 582, 755, 298, 4871, 401, 2490, 1660, 953, 298, 13425, 582, 257, 469, 3044, 298, 31359, 582, 3322, 298, 4871, 401, 3044, 298, 362, 22107, 582, 260, 1689, 4871, 401, 298, 34, 27297, 1288, 3044, 298, 16662, 1899, 582, 259, 1689, 4871, 401, 298, 12117, 1288, 3044, 298, 16662, 8882, 582, 420, 1689, 4871, 401, 298, 7243, 83, 1288, 3044, 298, 362, 25680, 582, 755, 298, 4871, 401, 3044, 298, 374, 36, 2470, 582, 3777, 298, 4871, 401, 3044, 298, 362, 12117, 582, 3515, 1689, 4871, 401, 298, 12117, 1288, 3044, 298, 362, 6139, 31660, 582, 1689, 4871, 401, 298, 4986, 3148, 1288, 3044, 298, 362, 4562, 13886, 582, 258, 1689, 4871, 401, 298, 4562, 13886, 1288, 3044, 298, 362, 3863, 2978, 582, 3515, 1689, 4871, 401, 298, 3863, 2978, 1288, 3044, 298, 362, 36, 1533, 582, 3322, 1689, 4871, 401, 298, 7243, 83, 1288, 3044, 298, 362, 18845, 582, 260, 1689, 4871, 401 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 199, 7384, 334, 67, 9, 8315, 13, 9261, 3875, 1130, 19782, 334, 1014, 921, 3009, 1130, 14, 1308, 24793, 199, 9295, 314, 570, 283, 1301, 15, 16188, 1206, 7, 367, 16743, 4983, 199, 624, 199, 199, 2992, 2141, 275, 469, 288, 327, 9701, 26, 288, 327, 481, 4632, 26, 263, 469, 298, 5329, 536, 582, 259, 298, 5329, 16048, 2, 1660, 288, 327, 4236, 26, 288, 327, 481, 4632, 26, 263, 469, 298, 5329, 536, 582, 259, 1689, 5329, 16048, 401, 298, 3710, 536, 1202, 367, 2863, 4704, 3878, 531, 1660, 288, 298, 4277, 582, 263, 469, 3044, 298, 2275, 582, 3322, 298, 875, 401, 3044, 298, 633, 582, 5185, 298, 875, 401, 3044, 298, 793, 1173, 582, 3698, 298, 875, 401, 3044, 298, 9377, 1173, 582, 3515, 298, 875, 401, 3044, 298, 1069, 1173, 582, 755, 298, 875, 401, 3044, 298, 1730, 1173, 582, 755, 298, 875, 401, 3044, 298, 3098, 36, 4708, 582, 263, 298, 875, 401, 3044, 298, 888, 1173, 582, 263, 298, 875, 401, 3044, 298, 17205, 6417, 582, 263, 298, 875, 401, 2490, 1660, 953, 298, 2017, 582, 755, 469, 3044, 298, 765, 582, 3322, 298, 875, 401, 3044, 298, 576, 582, 4519, 298, 875, 401, 3044, 298, 635, 6994, 582, 3515, 298, 875, 401, 3044, 298, 5306, 582, 3322, 298, 875, 401, 3044, 298, 5306, 6994, 582, 260, 298, 875, 401, 3044, 298, 912, 967, 5635, 582, 755, 298, 875, 401, 3044, 298, 4824, 1084, 7810, 582, 258, 298, 4871, 401, 3044, 298, 4054, 582, 3777, 298, 875, 401, 3044, 298, 2355, 7788, 582, 755, 298, 4871, 401, 3044, 298, 1102, 582, 4519, 298, 875, 401, 3044, 298, 20996, 582, 3698, 298, 875, 401, 3044, 298, 2139, 582, 3698, 298, 875, 401, 3044, 298, 1178, 804, 582, 3515, 298, 875, 401, 3044, 298, 1178, 35, 581, 582, 3515, 298, 875, 401, 3044, 298, 1178, 1173, 582, 3515, 298, 875, 401, 3044, 298, 3280, 582, 3777, 298, 875, 401, 3044, 298, 3280, 35, 581, 582, 260, 298, 875, 401, 3044, 298, 3280, 1173, 582, 260, 298, 875, 401, 3044, 298, 4247, 4936, 582, 755, 298, 4871, 401, 3044, 298, 8270, 582, 5185, 298, 4871, 401, 3044, 298, 8270, 4313, 582, 3698, 298, 4115, 401, 3044, 298, 8270, 804, 582, 3698, 298, 875, 401, 3044, 298, 1074, 20994, 582, 3515, 298, 4871, 401, 3044, 298, 5814, 582, 3777, 298, 1609, 401, 3044, 298, 2593, 582, 3698, 298, 1609, 401, 3044, 298, 10937, 582, 3698, 298, 4115, 401, 3044, 298, 82, 4098, 582, 3322, 298, 875, 401, 3044, 298, 3489, 6417, 582, 3698, 298, 875, 401, 3044, 298, 3489, 6564, 582, 3515, 298, 875, 401, 3044, 298, 3489, 11981, 1173, 582, 755, 298, 875, 401, 3044, 298, 3489, 13875, 582, 3515, 298, 4115, 401, 3044, 298, 2759, 6417, 9686, 582, 258, 298, 4871, 401, 3044, 298, 10088, 3264, 582, 260, 298, 875, 401, 3044, 298, 10088, 6417, 582, 3698, 298, 875, 401, 3044, 298, 3990, 5413, 582, 3515, 298, 4871, 401, 3044, 298, 72, 802, 582, 5185, 298, 4871, 401, 3044, 298, 2579, 3034, 582, 3515, 298, 875, 401, 2490, 1660, 953, 298, 30661, 582, 221, 469, 3044, 298, 13416, 582, 3515, 298, 4871, 401, 3044, 298, 6892, 2959, 582, 258, 298, 4871, 401, 3044, 298, 3250, 23692, 582, 260, 298, 4871, 401, 3044, 298, 2307, 3225, 582, 259, 298, 4871, 401, 3044, 298, 6962, 582, 3698, 298, 4115, 401, 2490, 1660, 953, 298, 607, 8923, 582, 258, 469, 3044, 298, 396, 4720, 582, 258, 298, 875, 401, 3044, 298, 2759, 582, 4519, 298, 875, 401, 3044, 298, 2759, 9278, 582, 263, 298, 4871, 401, 3044, 298, 697, 706, 582, 4519, 298, 875, 401, 3044, 298, 697, 706, 35, 581, 582, 3515, 298, 875, 401, 3044, 298, 736, 582, 4483, 298, 875, 401, 3044, 298, 3197, 34, 1030, 453, 582, 258, 298, 4871, 401, 3044, 298, 3197, 22455, 582, 259, 298, 4871, 401, 3044, 298, 3197, 1558, 582, 258, 298, 4871, 401, 3044, 298, 889, 24654, 582, 3322, 298, 4871, 401, 3044, 298, 889, 10260, 582, 3515, 298, 4871, 401, 3044, 298, 1861, 582, 3322, 298, 875, 401, 3044, 298, 4511, 582, 3322, 298, 875, 401, 3044, 298, 502, 311, 281, 582, 3322, 298, 875, 401, 2490, 1660, 953, 298, 31198, 582, 258, 469, 3044, 298, 1896, 582, 3777, 298, 4115, 401, 3044, 298, 27473, 582, 4519, 298, 4115, 401, 3044, 298, 875, 582, 3322, 298, 875, 401, 3044, 298, 1397, 1558, 582, 260, 298, 875, 401, 3044, 298, 11191, 582, 3322, 298, 875, 401, 3044, 298, 600, 582, 4519, 298, 4115, 401, 3044, 298, 505, 5903, 582, 3515, 298, 4871, 401, 3044, 298, 8916, 582, 3322, 298, 4871, 401, 2490, 1660, 953, 298, 6301, 11019, 2029, 83, 582, 259, 469, 3044, 298, 15970, 582, 4519, 298, 875, 401, 3044, 298, 521, 4933, 582, 3698, 298, 4115, 401, 3044, 298, 85, 17203, 582, 3777, 298, 875, 401, 3044, 298, 85, 1610, 582, 3777, 298, 875, 401, 3044, 298, 85, 2532, 582, 3777, 298, 875, 401, 3044, 298, 5797, 985, 582, 3698, 298, 875, 401, 3044, 298, 4375, 4738, 582, 755, 298, 875, 401, 2490, 1660, 953, 298, 28521, 582, 257, 469, 3044, 298, 1614, 3398, 38, 80, 582, 755, 298, 4871, 401, 2490, 1660, 953, 298, 13425, 582, 257, 469, 3044, 298, 31359, 582, 3322, 298, 4871, 401, 3044, 298, 362, 22107, 582, 260, 1689, 4871, 401, 298, 34, 27297, 1288, 3044, 298, 16662, 1899, 582, 259, 1689, 4871, 401, 298, 12117, 1288, 3044, 298, 16662, 8882, 582, 420, 1689, 4871, 401, 298, 7243, 83, 1288, 3044, 298, 362, 25680, 582, 755, 298, 4871, 401, 3044, 298, 374, 36, 2470, 582, 3777, 298, 4871, 401, 3044, 298, 362, 12117, 582, 3515, 1689, 4871, 401, 298, 12117, 1288, 3044, 298, 362, 6139, 31660, 582, 1689, 4871, 401, 298, 4986, 3148, 1288, 3044, 298, 362, 4562, 13886, 582, 258, 1689, 4871, 401, 298, 4562, 13886, 1288, 3044, 298, 362, 3863, 2978, 582, 3515, 1689, 4871, 401, 298, 3863, 2978, 1288, 3044, 298, 362, 36, 1533, 582, 3322, 1689, 4871, 401, 298, 7243, 83, 1288, 3044, 298, 362, 18845, 582, 260, 1689, 4871, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
smn/onadata
onadata/apps/api/migrations/0001_initial.py
20
6989
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'OrganizationProfile' db.create_table('api_organizationprofile', ( ('userprofile_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['main.UserProfile'], unique=True, primary_key=True)), ('is_organization', self.gf('django.db.models.fields.BooleanField')(default=True)), ('creator', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), )) db.send_create_signal('api', ['OrganizationProfile']) # Adding model 'Team' db.create_table('api_team', ( ('group_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.Group'], unique=True, primary_key=True)), ('organization', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), )) db.send_create_signal('api', ['Team']) def backwards(self, orm): # Deleting model 'OrganizationProfile' db.delete_table('api_organizationprofile') # Deleting model 'Team' db.delete_table('api_team') models = { 'api.organizationprofile': { 'Meta': {'object_name': 'OrganizationProfile', '_ormbases': ['main.UserProfile']}, 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'is_organization': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'userprofile_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['main.UserProfile']", 'unique': 'True', 'primary_key': 'True'}) }, 'api.team': { 'Meta': {'object_name': 'Team', '_ormbases': ['auth.Group']}, 'group_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.Group']", 'unique': 'True', 'primary_key': 'True'}), 'organization': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}), 'projects': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['models.Project']", 'symmetrical': 'False'}) }, 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'main.userprofile': { 'Meta': {'object_name': 'UserProfile'}, 'address': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'city': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'country': ('django.db.models.fields.CharField', [], {'max_length': '2', 'blank': 'True'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'home_page': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'organization': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'phonenumber': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'require_auth': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'twitter': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['auth.User']"}) }, 'models.project': { 'Meta': {'object_name': 'Project'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) } } complete_apps = ['api']
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 15928, 5736, 7, 267, 1592, 14, 981, 63, 1224, 360, 1246, 63, 9071, 2913, 297, 334, 288, 661, 25784, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 973, 14, 23544, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 374, 63, 9071, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 1826, 288, 661, 9986, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 1246, 297, 788, 15928, 5736, 1105, 398, 327, 12934, 1402, 283, 13126, 7, 267, 1592, 14, 981, 63, 1224, 360, 1246, 63, 5969, 297, 334, 288, 661, 923, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 1178, 14, 2448, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 9071, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 1246, 297, 788, 13126, 1105, 16478, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 15928, 5736, 7, 267, 1592, 14, 1807, 63, 1224, 360, 1246, 63, 9071, 2913, 358, 398, 327, 15920, 1402, 283, 13126, 7, 267, 1592, 14, 1807, 63, 1224, 360, 1246, 63, 5969, 358, 2378, 1709, 275, 469, 267, 283, 1246, 14, 9071, 2913, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 15928, 5736, 297, 2513, 31525, 356, 788, 973, 14, 23544, 14949, 288, 283, 9986, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 1899, 6097, 288, 283, 374, 63, 9071, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 25784, 63, 4695, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 475, 356, 298, 1025, 459, 973, 14, 23544, 6256, 283, 3235, 356, 283, 549, 297, 283, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 1246, 14, 5969, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 13126, 297, 2513, 31525, 356, 788, 1178, 14, 2448, 14949, 288, 283, 923, 63, 4695, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 3235, 356, 283, 549, 297, 283, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 9071, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 1899, 6097, 288, 283, 6776, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 992, 14, 4761, 6256, 283, 10247, 356, 283, 797, 3071, 267, 1660, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 15928, 5736, 7, 267, 1592, 14, 981, 63, 1224, 360, 1246, 63, 9071, 2913, 297, 334, 288, 661, 25784, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 973, 14, 23544, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 374, 63, 9071, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 1826, 288, 661, 9986, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 1246, 297, 788, 15928, 5736, 1105, 398, 327, 12934, 1402, 283, 13126, 7, 267, 1592, 14, 981, 63, 1224, 360, 1246, 63, 5969, 297, 334, 288, 661, 923, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 1178, 14, 2448, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 9071, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 1246, 297, 788, 13126, 1105, 16478, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 15928, 5736, 7, 267, 1592, 14, 1807, 63, 1224, 360, 1246, 63, 9071, 2913, 358, 398, 327, 15920, 1402, 283, 13126, 7, 267, 1592, 14, 1807, 63, 1224, 360, 1246, 63, 5969, 358, 2378, 1709, 275, 469, 267, 283, 1246, 14, 9071, 2913, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 15928, 5736, 297, 2513, 31525, 356, 788, 973, 14, 23544, 14949, 288, 283, 9986, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 1899, 6097, 288, 283, 374, 63, 9071, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 25784, 63, 4695, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 475, 356, 298, 1025, 459, 973, 14, 23544, 6256, 283, 3235, 356, 283, 549, 297, 283, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 1246, 14, 5969, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 13126, 297, 2513, 31525, 356, 788, 1178, 14, 2448, 14949, 288, 283, 923, 63, 4695, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 3235, 356, 283, 549, 297, 283, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 9071, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 1899, 6097, 288, 283, 6776, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 992, 14, 4761, 6256, 283, 10247, 356, 283, 797, 3071, 267, 1660, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kambysese/mne-python
mne/preprocessing/nirs/tests/test_temporal_derivative_distribution_repair.py
12
1068
# Authors: Robert Luke <mail@robertluke.net> # # License: BSD (3-clause) import os.path as op import pytest import numpy as np from mne.datasets.testing import data_path from mne.io import read_raw_nirx from mne.preprocessing.nirs import optical_density, tddr from mne.datasets import testing fname_nirx_15_2 = op.join(data_path(download=False), 'NIRx', 'nirscout', 'nirx_15_2_recording') @testing.requires_testing_data @pytest.mark.parametrize('fname', ([fname_nirx_15_2])) def test_temporal_derivative_distribution_repair(fname, tmpdir): """Test running artifact rejection.""" raw = read_raw_nirx(fname) raw = optical_density(raw) # Add a baseline shift artifact about half way through data max_shift = np.max(np.diff(raw._data[0])) shift_amp = 5 * max_shift raw._data[0, 0:30] = raw._data[0, 0:30] - (shift_amp) assert np.max(np.diff(raw._data[0])) > shift_amp # Ensure that applying the algorithm reduces the step change raw = tddr(raw) assert np.max(np.diff(raw._data[0])) < shift_amp
bsd-3-clause
[ 3, 6642, 26, 6848, 12504, 30936, 415, 665, 1198, 32, 293, 605, 5019, 85, 415, 14, 846, 30, 199, 3, 199, 3, 844, 26, 6289, 334, 19, 13, 8501, 9, 199, 199, 646, 747, 14, 515, 465, 1687, 199, 199, 646, 4613, 199, 646, 2680, 465, 980, 199, 199, 504, 18250, 14, 12281, 14, 4776, 492, 666, 63, 515, 199, 504, 18250, 14, 2308, 492, 1586, 63, 1773, 63, 78, 723, 88, 199, 504, 18250, 14, 21402, 14, 78, 32030, 492, 1687, 3294, 63, 15669, 12, 307, 617, 82, 199, 504, 18250, 14, 12281, 492, 5343, 421, 199, 5252, 63, 78, 723, 88, 63, 1046, 63, 18, 275, 1687, 14, 904, 8, 576, 63, 515, 8, 4249, 29, 797, 395, 2079, 283, 46, 3927, 88, 297, 283, 78, 723, 20845, 337, 297, 283, 78, 723, 88, 63, 1046, 63, 18, 63, 24616, 358, 421, 199, 32, 4776, 14, 6537, 63, 4776, 63, 576, 199, 32, 4462, 14, 1657, 14, 10396, 360, 5252, 297, 7287, 5252, 63, 78, 723, 88, 63, 1046, 63, 18, 2459, 199, 318, 511, 63, 30574, 63, 26851, 63, 4972, 63, 25279, 8, 5252, 12, 12885, 304, 272, 408, 774, 3879, 18115, 295, 8923, 1041, 272, 3066, 275, 1586, 63, 1773, 63, 78, 723, 88, 8, 5252, 9, 272, 3066, 275, 1687, 3294, 63, 15669, 8, 1773, 9, 339, 327, 2654, 282, 18828, 7706, 18115, 3595, 12995, 4340, 4012, 666, 272, 1390, 63, 4723, 275, 980, 14, 988, 8, 1590, 14, 3028, 8, 1773, 423, 576, 59, 16, 2459, 272, 7706, 63, 5282, 275, 959, 627, 1390, 63, 4723, 272, 3066, 423, 576, 59, 16, 12, 378, 26, 1216, 61, 275, 3066, 423, 576, 59, 16, 12, 378, 26, 1216, 61, 446, 334, 4723, 63, 5282, 9, 272, 702, 980, 14, 988, 8, 1590, 14, 3028, 8, 1773, 423, 576, 59, 16, 2459, 690, 7706, 63, 5282, 272, 327, 7523, 626, 18876, 314, 5563, 295, 10569, 314, 3650, 1570, 272, 3066, 275, 307, 617, 82, 8, 1773, 9, 272, 702, 980, 14, 988, 8, 1590, 14, 3028, 8, 1773, 423, 576, 59, 16, 2459, 665, 7706, 63, 5282, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6642, 26, 6848, 12504, 30936, 415, 665, 1198, 32, 293, 605, 5019, 85, 415, 14, 846, 30, 199, 3, 199, 3, 844, 26, 6289, 334, 19, 13, 8501, 9, 199, 199, 646, 747, 14, 515, 465, 1687, 199, 199, 646, 4613, 199, 646, 2680, 465, 980, 199, 199, 504, 18250, 14, 12281, 14, 4776, 492, 666, 63, 515, 199, 504, 18250, 14, 2308, 492, 1586, 63, 1773, 63, 78, 723, 88, 199, 504, 18250, 14, 21402, 14, 78, 32030, 492, 1687, 3294, 63, 15669, 12, 307, 617, 82, 199, 504, 18250, 14, 12281, 492, 5343, 421, 199, 5252, 63, 78, 723, 88, 63, 1046, 63, 18, 275, 1687, 14, 904, 8, 576, 63, 515, 8, 4249, 29, 797, 395, 2079, 283, 46, 3927, 88, 297, 283, 78, 723, 20845, 337, 297, 283, 78, 723, 88, 63, 1046, 63, 18, 63, 24616, 358, 421, 199, 32, 4776, 14, 6537, 63, 4776, 63, 576, 199, 32, 4462, 14, 1657, 14, 10396, 360, 5252, 297, 7287, 5252, 63, 78, 723, 88, 63, 1046, 63, 18, 2459, 199, 318, 511, 63, 30574, 63, 26851, 63, 4972, 63, 25279, 8, 5252, 12, 12885, 304, 272, 408, 774, 3879, 18115, 295, 8923, 1041, 272, 3066, 275, 1586, 63, 1773, 63, 78, 723, 88, 8, 5252, 9, 272, 3066, 275, 1687, 3294, 63, 15669, 8, 1773, 9, 339, 327, 2654, 282, 18828, 7706, 18115, 3595, 12995, 4340, 4012, 666, 272, 1390, 63, 4723, 275, 980, 14, 988, 8, 1590, 14, 3028, 8, 1773, 423, 576, 59, 16, 2459, 272, 7706, 63, 5282, 275, 959, 627, 1390, 63, 4723, 272, 3066, 423, 576, 59, 16, 12, 378, 26, 1216, 61, 275, 3066, 423, 576, 59, 16, 12, 378, 26, 1216, 61, 446, 334, 4723, 63, 5282, 9, 272, 702, 980, 14, 988, 8, 1590, 14, 3028, 8, 1773, 423, 576, 59, 16, 2459, 690, 7706, 63, 5282, 272, 327, 7523, 626, 18876, 314, 5563, 295, 10569, 314, 3650, 1570, 272, 3066, 275, 307, 617, 82, 8, 1773, 9, 272, 702, 980, 14, 988, 8, 1590, 14, 3028, 8, 1773, 423, 576, 59, 16, 2459, 665, 7706, 63, 5282, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
vampirekiss/wechat_message
tests/__init__.py
2
1628
# -*- coding: utf-8 -*- from tornado.testing import IOLoop, AsyncHTTPTestCase as BaseAsyncHTTPTestCase from tornado.gen import coroutine, Return from app.application import Application from urllib import urlencode import mock class TestCaseMixin(object): def get_new_ioloop(self): return IOLoop.instance() def mock_coroutine_object(self, klass): return _CoroutineMockObject(klass) class AsyncHTTPTestCase(BaseAsyncHTTPTestCase, TestCaseMixin): def get_app(self): return Application() def get(self, url, **kwargs): return self.fetch(url, **kwargs) def post(self, url, **kwargs): if 'body' in kwargs and isinstance(kwargs['body'], dict): kwargs['body'] = urlencode(kwargs['body']) return self.fetch(url, method='POST', **kwargs) class _CoroutineMockObject(object): def __init__(self, klass): self.mock_object = mock.patch(klass).start() self.mocked_methods = {} def set_method_result(self, method, result): @coroutine def side_effect(*args, **kwargs): raise Return(result) self.mocked_methods[method] = True self.mock_object[method].side_effect = side_effect def mock_method(self, method, target): @coroutine def side_effect(*args, **kwargs): raise Return(target(*args, **kwargs)) self.mocked_methods[method] = True self.mock_object[method].side_effect = side_effect def __getattr__(self, method): if method in self.mocked_methods: return self.mock_object[method].side_effect return None
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 12148, 14, 4776, 492, 25584, 12, 15223, 2856, 1746, 465, 3523, 12807, 2856, 1746, 199, 504, 12148, 14, 2268, 492, 1970, 13242, 12, 1432, 199, 504, 1145, 14, 3578, 492, 13515, 199, 504, 4011, 492, 16511, 199, 199, 646, 1683, 421, 199, 533, 7640, 4256, 8, 785, 304, 272, 347, 664, 63, 1222, 63, 27212, 8, 277, 304, 267, 372, 25584, 14, 842, 342, 339, 347, 1683, 63, 16675, 63, 785, 8, 277, 12, 8531, 304, 267, 372, 485, 8380, 13242, 3346, 1692, 8, 11645, 9, 421, 199, 533, 15223, 2856, 1746, 8, 1563, 12807, 2856, 1746, 12, 7640, 4256, 304, 272, 347, 664, 63, 571, 8, 277, 304, 267, 372, 13515, 342, 339, 347, 664, 8, 277, 12, 1166, 12, 1011, 958, 304, 267, 372, 291, 14, 3535, 8, 633, 12, 1011, 958, 9, 339, 347, 2963, 8, 277, 12, 1166, 12, 1011, 958, 304, 267, 340, 283, 2030, 7, 315, 2074, 436, 1228, 8, 958, 459, 2030, 995, 1211, 304, 288, 2074, 459, 2030, 418, 275, 16511, 8, 958, 459, 2030, 1105, 267, 372, 291, 14, 3535, 8, 633, 12, 1083, 534, 4030, 297, 1011, 958, 9, 421, 199, 533, 485, 8380, 13242, 3346, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8531, 304, 267, 291, 14, 1805, 63, 785, 275, 1683, 14, 2068, 8, 11645, 680, 928, 342, 267, 291, 14, 27740, 63, 2474, 275, 1052, 339, 347, 663, 63, 765, 63, 1099, 8, 277, 12, 1083, 12, 754, 304, 267, 768, 16675, 267, 347, 5366, 63, 5881, 2031, 589, 12, 1011, 958, 304, 288, 746, 1432, 8, 1099, 9, 267, 291, 14, 27740, 63, 2474, 59, 765, 61, 275, 715, 267, 291, 14, 1805, 63, 785, 59, 765, 1055, 2441, 63, 5881, 275, 5366, 63, 5881, 339, 347, 1683, 63, 765, 8, 277, 12, 1083, 12, 1347, 304, 267, 768, 16675, 267, 347, 5366, 63, 5881, 2031, 589, 12, 1011, 958, 304, 288, 746, 1432, 8, 1375, 2031, 589, 12, 1011, 958, 430, 267, 291, 14, 27740, 63, 2474, 59, 765, 61, 275, 715, 267, 291, 14, 1805, 63, 785, 59, 765, 1055, 2441, 63, 5881, 275, 5366, 63, 5881, 339, 347, 636, 5675, 721, 277, 12, 1083, 304, 267, 340, 1083, 315, 291, 14, 27740, 63, 2474, 26, 288, 372, 291, 14, 1805, 63, 785, 59, 765, 1055, 2441, 63, 5881, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 12148, 14, 4776, 492, 25584, 12, 15223, 2856, 1746, 465, 3523, 12807, 2856, 1746, 199, 504, 12148, 14, 2268, 492, 1970, 13242, 12, 1432, 199, 504, 1145, 14, 3578, 492, 13515, 199, 504, 4011, 492, 16511, 199, 199, 646, 1683, 421, 199, 533, 7640, 4256, 8, 785, 304, 272, 347, 664, 63, 1222, 63, 27212, 8, 277, 304, 267, 372, 25584, 14, 842, 342, 339, 347, 1683, 63, 16675, 63, 785, 8, 277, 12, 8531, 304, 267, 372, 485, 8380, 13242, 3346, 1692, 8, 11645, 9, 421, 199, 533, 15223, 2856, 1746, 8, 1563, 12807, 2856, 1746, 12, 7640, 4256, 304, 272, 347, 664, 63, 571, 8, 277, 304, 267, 372, 13515, 342, 339, 347, 664, 8, 277, 12, 1166, 12, 1011, 958, 304, 267, 372, 291, 14, 3535, 8, 633, 12, 1011, 958, 9, 339, 347, 2963, 8, 277, 12, 1166, 12, 1011, 958, 304, 267, 340, 283, 2030, 7, 315, 2074, 436, 1228, 8, 958, 459, 2030, 995, 1211, 304, 288, 2074, 459, 2030, 418, 275, 16511, 8, 958, 459, 2030, 1105, 267, 372, 291, 14, 3535, 8, 633, 12, 1083, 534, 4030, 297, 1011, 958, 9, 421, 199, 533, 485, 8380, 13242, 3346, 1692, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 8531, 304, 267, 291, 14, 1805, 63, 785, 275, 1683, 14, 2068, 8, 11645, 680, 928, 342, 267, 291, 14, 27740, 63, 2474, 275, 1052, 339, 347, 663, 63, 765, 63, 1099, 8, 277, 12, 1083, 12, 754, 304, 267, 768, 16675, 267, 347, 5366, 63, 5881, 2031, 589, 12, 1011, 958, 304, 288, 746, 1432, 8, 1099, 9, 267, 291, 14, 27740, 63, 2474, 59, 765, 61, 275, 715, 267, 291, 14, 1805, 63, 785, 59, 765, 1055, 2441, 63, 5881, 275, 5366, 63, 5881, 339, 347, 1683, 63, 765, 8, 277, 12, 1083, 12, 1347, 304, 267, 768, 16675, 267, 347, 5366, 63, 5881, 2031, 589, 12, 1011, 958, 304, 288, 746, 1432, 8, 1375, 2031, 589, 12, 1011, 958, 430, 267, 291, 14, 27740, 63, 2474, 59, 765, 61, 275, 715, 267, 291, 14, 1805, 63, 785, 59, 765, 1055, 2441, 63, 5881, 275, 5366, 63, 5881, 339, 347, 636, 5675, 721, 277, 12, 1083, 304, 267, 340, 1083, 315, 291, 14, 27740, 63, 2474, 26, 288, 372, 291, 14, 1805, 63, 785, 59, 765, 1055, 2441, 63, 5881, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
luiseduardohdbackup/odoo
addons/product_visible_discount/product_visible_discount.py
165
5466
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv from openerp.tools.translate import _ class product_pricelist(osv.osv): _inherit = 'product.pricelist' _columns ={ 'visible_discount': fields.boolean('Visible Discount'), } _defaults = { 'visible_discount': True, } class sale_order_line(osv.osv): _inherit = "sale.order.line" def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None): def get_real_price_curency(res_dict, product_id, qty, uom, pricelist): """Retrieve the price before applying the pricelist""" item_obj = self.pool.get('product.pricelist.item') price_type_obj = self.pool.get('product.price.type') product_obj = self.pool.get('product.product') field_name = 'list_price' rule_id = res_dict.get(pricelist) and res_dict[pricelist][1] or False currency_id = None if rule_id: item_base = item_obj.read(cr, uid, [rule_id], ['base'])[0]['base'] if item_base > 0: price_type = price_type_obj.browse(cr, uid, item_base) field_name = price_type.field currency_id = price_type.currency_id product = product_obj.browse(cr, uid, product_id, context) product_read = product_obj.read(cr, uid, [product_id], [field_name], context=context)[0] if not currency_id: currency_id = product.company_id.currency_id.id factor = 1.0 if uom and uom != product.uom_id.id: # the unit price is in a different uom factor = self.pool['product.uom']._compute_qty(cr, uid, uom, 1.0, product.uom_id.id) return product_read[field_name] * factor, currency_id def get_real_price(res_dict, product_id, qty, uom, pricelist): return get_real_price_curency(res_dict, product_id, qty, uom, pricelist)[0] res=super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context) context = {'lang': lang, 'partner_id': partner_id} result=res['value'] pricelist_obj=self.pool.get('product.pricelist') product_obj = self.pool.get('product.product') if product and pricelist and self.pool.get('res.users').has_group(cr, uid, 'sale.group_discount_per_so_line'): if result.get('price_unit',False): price=result['price_unit'] else: return res uom = result.get('product_uom', uom) product = product_obj.browse(cr, uid, product, context) pricelist_context = dict(context, uom=uom, date=date_order) list_price = pricelist_obj.price_rule_get(cr, uid, [pricelist], product.id, qty or 1.0, partner_id, context=pricelist_context) so_pricelist = pricelist_obj.browse(cr, uid, pricelist, context=context) new_list_price, currency_id = get_real_price_curency(list_price, product.id, qty, uom, pricelist) if so_pricelist.visible_discount and list_price[pricelist][0] != 0 and new_list_price != 0: if product.company_id and so_pricelist.currency_id.id != product.company_id.currency_id.id: # new_list_price is in company's currency while price in pricelist currency ctx = context.copy() ctx['date'] = date_order new_list_price = self.pool['res.currency'].compute(cr, uid, currency_id.id, so_pricelist.currency_id.id, new_list_price, context=ctx) discount = (new_list_price - price) / new_list_price * 100 if discount > 0: result['price_unit'] = new_list_price result['discount'] = discount else: result['discount'] = 0.0 else: result['discount'] = 0.0 else: result['discount'] = 0.0 return res
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 9300, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 2900, 5924, 5702, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 3336, 63, 17385, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 2558, 14, 17385, 7, 339, 485, 3406, 275, 91, 267, 283, 6604, 63, 15446, 356, 1504, 14, 4871, 360, 14917, 5289, 835, 659, 272, 789, 272, 485, 4322, 275, 469, 268, 283, 6604, 63, 15446, 356, 715, 12, 272, 789, 421, 199, 533, 13590, 63, 1648, 63, 604, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 8515, 14, 1648, 14, 604, 2, 339, 347, 3336, 63, 344, 63, 1461, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 25162, 12, 3336, 12, 13556, 29, 16, 12, 288, 19842, 29, 797, 12, 13556, 63, 20560, 29, 16, 12, 399, 736, 29, 797, 12, 536, 4581, 5854, 63, 344, 29, 797, 12, 288, 6339, 29, 797, 12, 1678, 63, 5530, 29, 549, 12, 1434, 63, 1648, 29, 797, 12, 27369, 29, 797, 12, 288, 18672, 63, 3124, 29, 797, 12, 3305, 29, 797, 12, 1067, 29, 403, 304, 398, 347, 664, 63, 3093, 63, 4777, 63, 67, 608, 12501, 8, 470, 63, 807, 12, 3336, 63, 344, 12, 13556, 12, 19842, 12, 25162, 304, 288, 408, 15310, 314, 8033, 2544, 18876, 314, 25162, 624, 288, 1242, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 17385, 14, 1053, 358, 288, 8033, 63, 466, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 4777, 14, 466, 358, 288, 3336, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 2558, 358, 288, 901, 63, 354, 275, 283, 513, 63, 4777, 7, 288, 2332, 63, 344, 275, 522, 63, 807, 14, 362, 8, 17385, 9, 436, 522, 63, 807, 59, 17385, 1527, 17, 61, 503, 756, 288, 9952, 63, 344, 275, 488, 288, 340, 2332, 63, 344, 26, 355, 1242, 63, 1095, 275, 1242, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 2200, 63, 344, 467, 788, 1095, 25945, 16, 2733, 1095, 418, 355, 340, 1242, 63, 1095, 690, 378, 26, 490, 8033, 63, 466, 275, 8033, 63, 466, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 1242, 63, 1095, 9, 490, 901, 63, 354, 275, 8033, 63, 466, 14, 698, 490, 9952, 63, 344, 275, 8033, 63, 466, 14, 4968, 63, 344, 953, 3336, 275, 3336, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 3336, 63, 344, 12, 1067, 9, 288, 3336, 63, 739, 275, 3336, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 2558, 63, 344, 467, 359, 698, 63, 354, 467, 1067, 29, 1100, 2788, 16, 61, 953, 340, 440, 9952, 63, 344, 26, 355, 9952, 63, 344, 275, 3336, 14, 4627, 63, 344, 14, 4968, 63, 344, 14, 344, 288, 6535, 275, 413, 14, 16, 288, 340, 19842, 436, 19842, 1137, 3336, 14, 7519, 63, 344, 14, 344, 26, 355, 327, 314, 4137, 8033, 365, 315, 282, 3365, 19842, 355, 6535, 275, 291, 14, 2293, 459, 2558, 14, 7519, 26099, 3357, 63, 5643, 8, 1556, 12, 1747, 12, 19842, 12, 413, 14, 16, 12, 3336, 14, 7519, 63, 344, 14, 344, 9, 288, 372, 3336, 63, 739, 59, 698, 63, 354, 61, 627, 6535, 12, 9952, 63, 344, 398, 347, 664, 63, 3093, 63, 4777, 8, 470, 63, 807, 12, 3336, 63, 344, 12, 13556, 12, 19842, 12, 25162, 304, 288, 372, 664, 63, 3093, 63, 4777, 63, 67, 608, 12501, 8, 470, 63, 807, 12, 3336, 63, 344, 12, 13556, 12, 19842, 12, 25162, 2788, 16, 61, 7318, 522, 29, 4792, 8, 8515, 63, 1648, 63, 604, 12, 291, 680, 2558, 63, 344, 63, 1461, 8, 1556, 12, 1747, 12, 2762, 12, 25162, 12, 3336, 12, 13556, 12, 288, 19842, 12, 13556, 63, 20560, 12, 399, 736, 12, 536, 12, 5854, 63, 344, 12, 288, 6339, 12, 1678, 63, 5530, 12, 1434, 63, 1648, 12, 27369, 29, 27796, 12, 18672, 63, 3124, 29, 18646, 63, 3124, 12, 3305, 29, 4173, 12, 1067, 29, 1100, 9, 398, 1067, 275, 791, 4159, 356, 6339, 12, 283, 3899, 63, 344, 356, 5854, 63, 344, 93, 267, 754, 29, 470, 459, 585, 418, 267, 25162, 63, 1113, 29, 277, 14, 2293, 14, 362, 360, 2558, 14, 17385, 358, 267, 3336, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 2558, 358, 267, 340, 3336, 436, 25162, 436, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 1989, 63, 923, 8, 1556, 12, 1747, 12, 283, 8515, 14, 923, 63, 15446, 63, 529, 63, 1152, 63, 604, 735, 288, 340, 754, 14, 362, 360, 4777, 63, 3248, 297, 797, 304, 355, 8033, 29, 1099, 459, 4777, 63, 3248, 418, 288, 587, 26, 355, 372, 522, 288, 19842, 275, 754, 14, 362, 360, 2558, 63, 7519, 297, 19842, 9, 288, 3336 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 9300, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 2900, 5924, 5702, 199, 3, 259, 2672, 1304, 4, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 3336, 63, 17385, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 2558, 14, 17385, 7, 339, 485, 3406, 275, 91, 267, 283, 6604, 63, 15446, 356, 1504, 14, 4871, 360, 14917, 5289, 835, 659, 272, 789, 272, 485, 4322, 275, 469, 268, 283, 6604, 63, 15446, 356, 715, 12, 272, 789, 421, 199, 533, 13590, 63, 1648, 63, 604, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 298, 8515, 14, 1648, 14, 604, 2, 339, 347, 3336, 63, 344, 63, 1461, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 25162, 12, 3336, 12, 13556, 29, 16, 12, 288, 19842, 29, 797, 12, 13556, 63, 20560, 29, 16, 12, 399, 736, 29, 797, 12, 536, 4581, 5854, 63, 344, 29, 797, 12, 288, 6339, 29, 797, 12, 1678, 63, 5530, 29, 549, 12, 1434, 63, 1648, 29, 797, 12, 27369, 29, 797, 12, 288, 18672, 63, 3124, 29, 797, 12, 3305, 29, 797, 12, 1067, 29, 403, 304, 398, 347, 664, 63, 3093, 63, 4777, 63, 67, 608, 12501, 8, 470, 63, 807, 12, 3336, 63, 344, 12, 13556, 12, 19842, 12, 25162, 304, 288, 408, 15310, 314, 8033, 2544, 18876, 314, 25162, 624, 288, 1242, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 17385, 14, 1053, 358, 288, 8033, 63, 466, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 4777, 14, 466, 358, 288, 3336, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 2558, 358, 288, 901, 63, 354, 275, 283, 513, 63, 4777, 7, 288, 2332, 63, 344, 275, 522, 63, 807, 14, 362, 8, 17385, 9, 436, 522, 63, 807, 59, 17385, 1527, 17, 61, 503, 756, 288, 9952, 63, 344, 275, 488, 288, 340, 2332, 63, 344, 26, 355, 1242, 63, 1095, 275, 1242, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 2200, 63, 344, 467, 788, 1095, 25945, 16, 2733, 1095, 418, 355, 340, 1242, 63, 1095, 690, 378, 26, 490, 8033, 63, 466, 275, 8033, 63, 466, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 1242, 63, 1095, 9, 490, 901, 63, 354, 275, 8033, 63, 466, 14, 698, 490, 9952, 63, 344, 275, 8033, 63, 466, 14, 4968, 63, 344, 953, 3336, 275, 3336, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 3336, 63, 344, 12, 1067, 9, 288, 3336, 63, 739, 275, 3336, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 2558, 63, 344, 467, 359, 698, 63, 354, 467, 1067, 29, 1100, 2788, 16, 61, 953, 340, 440, 9952, 63, 344, 26, 355, 9952, 63, 344, 275, 3336, 14, 4627, 63, 344, 14, 4968, 63, 344, 14, 344, 288, 6535, 275, 413, 14, 16, 288, 340, 19842, 436, 19842, 1137, 3336, 14, 7519, 63, 344, 14, 344, 26, 355, 327, 314, 4137, 8033, 365, 315, 282, 3365, 19842, 355, 6535, 275, 291, 14, 2293, 459, 2558, 14, 7519, 26099, 3357, 63, 5643, 8, 1556, 12, 1747, 12, 19842, 12, 413, 14, 16, 12, 3336, 14, 7519, 63, 344, 14, 344, 9, 288, 372, 3336, 63, 739, 59, 698, 63, 354, 61, 627, 6535, 12, 9952, 63, 344, 398, 347, 664, 63, 3093, 63, 4777, 8, 470, 63, 807, 12, 3336, 63, 344, 12, 13556, 12, 19842, 12, 25162, 304, 288, 372, 664, 63, 3093, 63, 4777, 63, 67, 608, 12501, 8, 470, 63, 807, 12, 3336, 63, 344, 12, 13556, 12, 19842, 12, 25162, 2788, 16, 61, 7318, 522, 29, 4792, 8, 8515, 63, 1648, 63, 604, 12, 291, 680, 2558, 63, 344, 63, 1461, 8, 1556, 12, 1747, 12, 2762, 12, 25162, 12, 3336, 12, 13556, 12, 288, 19842, 12, 13556, 63, 20560, 12, 399, 736, 12, 536, 12, 5854, 63, 344, 12, 288, 6339, 12, 1678, 63, 5530, 12, 1434, 63, 1648, 12, 27369, 29, 27796, 12, 18672, 63, 3124, 29, 18646, 63, 3124, 12, 3305, 29, 4173, 12, 1067, 29, 1100, 9, 398, 1067, 275, 791, 4159, 356, 6339, 12, 283, 3899, 63, 344, 356, 5854, 63, 344, 93, 267, 754, 29, 470, 459, 585, 418, 267, 25162, 63, 1113, 29, 277, 14, 2293, 14, 362, 360, 2558, 14, 17385, 358, 267, 3336, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2558, 14, 2558, 358, 267, 340, 3336, 436, 25162, 436, 291, 14, 2293, 14, 362, 360, 470, 14, 3707, 1959, 1989, 63, 923, 8, 1556, 12, 1747, 12, 283, 8515, 14, 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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 ]
scorphus/politicos
politicos/migrations/versions/585774625ec2_create_mandate_events_table.py
1
1328
"""create mandate events table Revision ID: 585774625ec2 Revises: 2cbbef3d8e8f Create Date: 2015-07-06 00:58:44.470013 """ # revision identifiers, used by Alembic. revision = '585774625ec2' down_revision = '2cbbef3d8e8f' from alembic import op import sqlalchemy as sa def upgrade(): op.create_table( 'mandate_events', sa.Column('id', sa.Integer, primary_key=True), sa.Column('date', sa.Date, nullable=False), sa.Column('mandate_id', sa.Integer, nullable=False), sa.Column('mandate_events_type_id', sa.Integer, nullable=False), ) op.create_foreign_key( 'fk_mandate', 'mandate_events', 'mandate', ['mandate_id'], ['id'] ) op.create_foreign_key( 'fk_mandate_events_type', 'mandate_events', 'mandate_events_type', ['mandate_events_type_id'], ['id'] ) op.create_unique_constraint( 'uk_mandate_events', 'mandate_events', ['mandate_id', 'mandate_events_type_id', 'date'] ) def downgrade(): op.drop_constraint('fk_mandate', 'mandate_events', type_='foreignkey') op.drop_constraint( 'fk_mandate_events_type', 'mandate_events', type_='foreignkey' ) op.drop_constraint('uk_mandate_events', 'mandate_events', type_='unique') op.drop_table('mandate_events')
agpl-3.0
[ 624, 981, 333, 460, 323, 4474, 1817, 199, 199, 12714, 2870, 26, 959, 2426, 1138, 2466, 821, 825, 18, 199, 497, 433, 874, 26, 499, 2894, 31945, 19, 68, 24, 69, 24, 70, 199, 2499, 6148, 26, 6900, 13, 1780, 13, 1690, 8733, 26, 2010, 26, 1602, 14, 2417, 24250, 199, 199, 624, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 2010, 13539, 2466, 821, 825, 18, 7, 199, 2110, 63, 5792, 275, 283, 18, 2894, 31945, 19, 68, 24, 69, 24, 70, 7, 199, 199, 504, 30960, 20596, 492, 1687, 199, 646, 8335, 465, 2937, 421, 199, 318, 10754, 837, 272, 1687, 14, 981, 63, 1224, 8, 267, 283, 10333, 323, 63, 4368, 297, 267, 2937, 14, 4547, 360, 344, 297, 2937, 14, 2674, 12, 5062, 63, 498, 29, 549, 395, 267, 2937, 14, 4547, 360, 602, 297, 2937, 14, 2506, 12, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 10333, 323, 63, 344, 297, 2937, 14, 2674, 12, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 10333, 323, 63, 4368, 63, 466, 63, 344, 297, 2937, 14, 2674, 12, 7854, 29, 797, 395, 272, 776, 339, 1687, 14, 981, 63, 6846, 63, 498, 8, 267, 283, 9010, 63, 10333, 323, 297, 267, 283, 10333, 323, 63, 4368, 297, 283, 10333, 323, 297, 267, 788, 10333, 323, 63, 344, 995, 788, 344, 418, 272, 776, 339, 1687, 14, 981, 63, 6846, 63, 498, 8, 267, 283, 9010, 63, 10333, 323, 63, 4368, 63, 466, 297, 267, 283, 10333, 323, 63, 4368, 297, 283, 10333, 323, 63, 4368, 63, 466, 297, 267, 788, 10333, 323, 63, 4368, 63, 466, 63, 344, 995, 788, 344, 418, 272, 776, 339, 1687, 14, 981, 63, 3235, 63, 5631, 8, 267, 283, 3210, 63, 10333, 323, 63, 4368, 297, 267, 283, 10333, 323, 63, 4368, 297, 267, 788, 10333, 323, 63, 344, 297, 283, 10333, 323, 63, 4368, 63, 466, 63, 344, 297, 283, 602, 418, 272, 776, 421, 199, 318, 32498, 837, 272, 1687, 14, 4824, 63, 5631, 360, 9010, 63, 10333, 323, 297, 283, 10333, 323, 63, 4368, 297, 730, 7993, 11766, 358, 272, 1687, 14, 4824, 63, 5631, 8, 267, 283, 9010, 63, 10333, 323, 63, 4368, 63, 466, 297, 283, 10333, 323, 63, 4368, 297, 730, 7993, 11766, 7, 272, 776, 272, 1687, 14, 4824, 63, 5631, 360, 3210, 63, 10333, 323, 63, 4368, 297, 283, 10333, 323, 63, 4368, 297, 730, 7993, 3235, 358, 272, 1687, 14, 4824, 63, 1224, 360, 10333, 323, 63, 4368, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 981, 333, 460, 323, 4474, 1817, 199, 199, 12714, 2870, 26, 959, 2426, 1138, 2466, 821, 825, 18, 199, 497, 433, 874, 26, 499, 2894, 31945, 19, 68, 24, 69, 24, 70, 199, 2499, 6148, 26, 6900, 13, 1780, 13, 1690, 8733, 26, 2010, 26, 1602, 14, 2417, 24250, 199, 199, 624, 199, 199, 3, 6974, 14154, 12, 1202, 701, 6832, 20596, 14, 199, 5792, 275, 283, 2010, 13539, 2466, 821, 825, 18, 7, 199, 2110, 63, 5792, 275, 283, 18, 2894, 31945, 19, 68, 24, 69, 24, 70, 7, 199, 199, 504, 30960, 20596, 492, 1687, 199, 646, 8335, 465, 2937, 421, 199, 318, 10754, 837, 272, 1687, 14, 981, 63, 1224, 8, 267, 283, 10333, 323, 63, 4368, 297, 267, 2937, 14, 4547, 360, 344, 297, 2937, 14, 2674, 12, 5062, 63, 498, 29, 549, 395, 267, 2937, 14, 4547, 360, 602, 297, 2937, 14, 2506, 12, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 10333, 323, 63, 344, 297, 2937, 14, 2674, 12, 7854, 29, 797, 395, 267, 2937, 14, 4547, 360, 10333, 323, 63, 4368, 63, 466, 63, 344, 297, 2937, 14, 2674, 12, 7854, 29, 797, 395, 272, 776, 339, 1687, 14, 981, 63, 6846, 63, 498, 8, 267, 283, 9010, 63, 10333, 323, 297, 267, 283, 10333, 323, 63, 4368, 297, 283, 10333, 323, 297, 267, 788, 10333, 323, 63, 344, 995, 788, 344, 418, 272, 776, 339, 1687, 14, 981, 63, 6846, 63, 498, 8, 267, 283, 9010, 63, 10333, 323, 63, 4368, 63, 466, 297, 267, 283, 10333, 323, 63, 4368, 297, 283, 10333, 323, 63, 4368, 63, 466, 297, 267, 788, 10333, 323, 63, 4368, 63, 466, 63, 344, 995, 788, 344, 418, 272, 776, 339, 1687, 14, 981, 63, 3235, 63, 5631, 8, 267, 283, 3210, 63, 10333, 323, 63, 4368, 297, 267, 283, 10333, 323, 63, 4368, 297, 267, 788, 10333, 323, 63, 344, 297, 283, 10333, 323, 63, 4368, 63, 466, 63, 344, 297, 283, 602, 418, 272, 776, 421, 199, 318, 32498, 837, 272, 1687, 14, 4824, 63, 5631, 360, 9010, 63, 10333, 323, 297, 283, 10333, 323, 63, 4368, 297, 730, 7993, 11766, 358, 272, 1687, 14, 4824, 63, 5631, 8, 267, 283, 9010, 63, 10333, 323, 63, 4368, 63, 466, 297, 283, 10333, 323, 63, 4368, 297, 730, 7993, 11766, 7, 272, 776, 272, 1687, 14, 4824, 63, 5631, 360, 3210, 63, 10333, 323, 63, 4368, 297, 283, 10333, 323, 63, 4368, 297, 730, 7993, 3235, 358, 272, 1687, 14, 4824, 63, 1224, 360, 10333, 323, 63, 4368, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
orekyuu/intellij-community
python/lib/Lib/site-packages/django/contrib/gis/gdal/geomtype.py
404
2967
from django.contrib.gis.gdal.error import OGRException #### OGRGeomType #### class OGRGeomType(object): "Encapulates OGR Geometry Types." wkb25bit = -2147483648 # Dictionary of acceptable OGRwkbGeometryType s and their string names. _types = {0 : 'Unknown', 1 : 'Point', 2 : 'LineString', 3 : 'Polygon', 4 : 'MultiPoint', 5 : 'MultiLineString', 6 : 'MultiPolygon', 7 : 'GeometryCollection', 100 : 'None', 101 : 'LinearRing', 1 + wkb25bit: 'Point25D', 2 + wkb25bit: 'LineString25D', 3 + wkb25bit: 'Polygon25D', 4 + wkb25bit: 'MultiPoint25D', 5 + wkb25bit : 'MultiLineString25D', 6 + wkb25bit : 'MultiPolygon25D', 7 + wkb25bit : 'GeometryCollection25D', } # Reverse type dictionary, keyed by lower-case of the name. _str_types = dict([(v.lower(), k) for k, v in _types.items()]) def __init__(self, type_input): "Figures out the correct OGR Type based upon the input." if isinstance(type_input, OGRGeomType): num = type_input.num elif isinstance(type_input, basestring): type_input = type_input.lower() if type_input == 'geometry': type_input='unknown' num = self._str_types.get(type_input, None) if num is None: raise OGRException('Invalid OGR String Type "%s"' % type_input) elif isinstance(type_input, int): if not type_input in self._types: raise OGRException('Invalid OGR Integer Type: %d' % type_input) num = type_input else: raise TypeError('Invalid OGR input type given.') # Setting the OGR geometry type number. self.num = num def __str__(self): "Returns the value of the name property." return self.name def __eq__(self, other): """ Does an equivalence test on the OGR type with the given other OGRGeomType, the short-hand string, or the integer. """ if isinstance(other, OGRGeomType): return self.num == other.num elif isinstance(other, basestring): return self.name.lower() == other.lower() elif isinstance(other, int): return self.num == other else: return False def __ne__(self, other): return not (self == other) @property def name(self): "Returns a short-hand string form of the OGR Geometry type." return self._types[self.num] @property def django(self): "Returns the Django GeometryField for this OGR Type." s = self.name.replace('25D', '') if s in ('LinearRing', 'None'): return None elif s == 'Unknown': s = 'Geometry' return s + 'Field'
apache-2.0
[ 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 19746, 907, 16010, 199, 199, 381, 25756, 14055, 199, 533, 25756, 8, 785, 304, 272, 298, 1327, 2874, 15409, 10904, 10579, 18851, 2122, 339, 24249, 821, 2075, 275, 446, 22519, 10552, 339, 327, 11932, 402, 14712, 10904, 18914, 6831, 804, 308, 436, 3932, 1059, 1561, 14, 272, 485, 1313, 275, 469, 16, 520, 283, 5912, 297, 1598, 413, 520, 283, 3428, 297, 1598, 499, 520, 283, 22134, 297, 1598, 650, 520, 283, 12367, 297, 1598, 841, 520, 283, 3947, 3428, 297, 1598, 959, 520, 283, 3947, 22134, 297, 1598, 1227, 520, 283, 3947, 12367, 297, 1598, 1520, 520, 283, 6831, 7768, 297, 1598, 2948, 520, 283, 403, 297, 1598, 14313, 520, 283, 10608, 15420, 297, 1598, 413, 435, 24249, 821, 2075, 26, 283, 3428, 821, 36, 297, 1598, 499, 435, 24249, 821, 2075, 26, 283, 22134, 821, 36, 297, 1598, 650, 435, 24249, 821, 2075, 26, 283, 12367, 821, 36, 297, 1598, 841, 435, 24249, 821, 2075, 26, 283, 3947, 3428, 821, 36, 297, 1598, 959, 435, 24249, 821, 2075, 520, 283, 3947, 22134, 821, 36, 297, 1598, 1227, 435, 24249, 821, 2075, 520, 283, 3947, 12367, 821, 36, 297, 1598, 1520, 435, 24249, 821, 2075, 520, 283, 6831, 7768, 821, 36, 297, 1598, 789, 272, 327, 22734, 730, 2600, 12, 19272, 701, 5117, 13, 2546, 402, 314, 536, 14, 272, 485, 495, 63, 1313, 275, 1211, 7694, 86, 14, 2325, 1062, 1022, 9, 367, 1022, 12, 373, 315, 485, 1313, 14, 1744, 9383, 339, 347, 636, 826, 721, 277, 12, 730, 63, 1210, 304, 267, 298, 38, 528, 1482, 734, 314, 3211, 10904, 2434, 4079, 12188, 314, 1324, 2122, 267, 340, 1228, 8, 466, 63, 1210, 12, 25756, 304, 288, 1967, 275, 730, 63, 1210, 14, 1507, 267, 916, 1228, 8, 466, 63, 1210, 12, 7116, 304, 288, 730, 63, 1210, 275, 730, 63, 1210, 14, 2325, 342, 288, 340, 730, 63, 1210, 508, 283, 7660, 356, 730, 63, 1210, 534, 5187, 7, 288, 1967, 275, 291, 423, 495, 63, 1313, 14, 362, 8, 466, 63, 1210, 12, 488, 9, 288, 340, 1967, 365, 488, 26, 355, 746, 19746, 907, 16010, 360, 3364, 10904, 2624, 2434, 2071, 83, 4507, 450, 730, 63, 1210, 9, 267, 916, 1228, 8, 466, 63, 1210, 12, 1109, 304, 288, 340, 440, 730, 63, 1210, 315, 291, 423, 1313, 26, 355, 746, 19746, 907, 16010, 360, 3364, 10904, 7225, 2434, 26, 450, 68, 7, 450, 730, 63, 1210, 9, 288, 1967, 275, 730, 63, 1210, 267, 587, 26, 288, 746, 3146, 360, 3364, 10904, 1324, 730, 1627, 2659, 2728, 327, 13510, 314, 10904, 3400, 730, 1329, 14, 267, 291, 14, 1507, 275, 1967, 339, 347, 636, 495, 721, 277, 304, 267, 298, 3407, 314, 574, 402, 314, 536, 3324, 2122, 267, 372, 291, 14, 354, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 267, 12078, 376, 325, 22810, 511, 641, 314, 10904, 730, 543, 314, 1627, 267, 1163, 25756, 12, 314, 3974, 13, 6868, 1059, 12, 503, 314, 3000, 14, 267, 408, 267, 340, 1228, 8, 1848, 12, 25756, 304, 288, 372, 291, 14, 1507, 508, 1163, 14, 1507, 267, 916, 1228, 8, 1848, 12, 7116, 304, 288, 372, 291, 14, 354, 14, 2325, 342, 508, 1163, 14, 2325, 342, 267, 916, 1228, 8, 1848, 12, 1109, 304, 288, 372, 291, 14, 1507, 508, 1163, 267, 587, 26, 288, 372, 756, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 334, 277, 508, 1163, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 298, 3407, 282, 3974, 13, 6868, 1059, 1824, 402, 314, 10904, 10579, 730, 2122, 267, 372, 291, 423, 1313, 59, 277, 14, 1507, 61, 339, 768, 1829, 272, 347, 1639, 8, 277, 304, 267, 298, 3407, 314, 5634, 30490, 367, 642, 10904, 2434, 2122, 267, 308, 275, 291, 14, 354, 14, 1814, 360, 821, 36, 297, 4074, 267, 340, 308, 315, 661, 10608, 15420, 297, 283, 403, 735, 288, 372, 488, 267, 916, 308, 508, 283, 5912, 356, 288, 308, 275, 283, 6831, 7, 267, 372, 308, 435, 283, 792, 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 ]
[ 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 19746, 907, 16010, 199, 199, 381, 25756, 14055, 199, 533, 25756, 8, 785, 304, 272, 298, 1327, 2874, 15409, 10904, 10579, 18851, 2122, 339, 24249, 821, 2075, 275, 446, 22519, 10552, 339, 327, 11932, 402, 14712, 10904, 18914, 6831, 804, 308, 436, 3932, 1059, 1561, 14, 272, 485, 1313, 275, 469, 16, 520, 283, 5912, 297, 1598, 413, 520, 283, 3428, 297, 1598, 499, 520, 283, 22134, 297, 1598, 650, 520, 283, 12367, 297, 1598, 841, 520, 283, 3947, 3428, 297, 1598, 959, 520, 283, 3947, 22134, 297, 1598, 1227, 520, 283, 3947, 12367, 297, 1598, 1520, 520, 283, 6831, 7768, 297, 1598, 2948, 520, 283, 403, 297, 1598, 14313, 520, 283, 10608, 15420, 297, 1598, 413, 435, 24249, 821, 2075, 26, 283, 3428, 821, 36, 297, 1598, 499, 435, 24249, 821, 2075, 26, 283, 22134, 821, 36, 297, 1598, 650, 435, 24249, 821, 2075, 26, 283, 12367, 821, 36, 297, 1598, 841, 435, 24249, 821, 2075, 26, 283, 3947, 3428, 821, 36, 297, 1598, 959, 435, 24249, 821, 2075, 520, 283, 3947, 22134, 821, 36, 297, 1598, 1227, 435, 24249, 821, 2075, 520, 283, 3947, 12367, 821, 36, 297, 1598, 1520, 435, 24249, 821, 2075, 520, 283, 6831, 7768, 821, 36, 297, 1598, 789, 272, 327, 22734, 730, 2600, 12, 19272, 701, 5117, 13, 2546, 402, 314, 536, 14, 272, 485, 495, 63, 1313, 275, 1211, 7694, 86, 14, 2325, 1062, 1022, 9, 367, 1022, 12, 373, 315, 485, 1313, 14, 1744, 9383, 339, 347, 636, 826, 721, 277, 12, 730, 63, 1210, 304, 267, 298, 38, 528, 1482, 734, 314, 3211, 10904, 2434, 4079, 12188, 314, 1324, 2122, 267, 340, 1228, 8, 466, 63, 1210, 12, 25756, 304, 288, 1967, 275, 730, 63, 1210, 14, 1507, 267, 916, 1228, 8, 466, 63, 1210, 12, 7116, 304, 288, 730, 63, 1210, 275, 730, 63, 1210, 14, 2325, 342, 288, 340, 730, 63, 1210, 508, 283, 7660, 356, 730, 63, 1210, 534, 5187, 7, 288, 1967, 275, 291, 423, 495, 63, 1313, 14, 362, 8, 466, 63, 1210, 12, 488, 9, 288, 340, 1967, 365, 488, 26, 355, 746, 19746, 907, 16010, 360, 3364, 10904, 2624, 2434, 2071, 83, 4507, 450, 730, 63, 1210, 9, 267, 916, 1228, 8, 466, 63, 1210, 12, 1109, 304, 288, 340, 440, 730, 63, 1210, 315, 291, 423, 1313, 26, 355, 746, 19746, 907, 16010, 360, 3364, 10904, 7225, 2434, 26, 450, 68, 7, 450, 730, 63, 1210, 9, 288, 1967, 275, 730, 63, 1210, 267, 587, 26, 288, 746, 3146, 360, 3364, 10904, 1324, 730, 1627, 2659, 2728, 327, 13510, 314, 10904, 3400, 730, 1329, 14, 267, 291, 14, 1507, 275, 1967, 339, 347, 636, 495, 721, 277, 304, 267, 298, 3407, 314, 574, 402, 314, 536, 3324, 2122, 267, 372, 291, 14, 354, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 408, 267, 12078, 376, 325, 22810, 511, 641, 314, 10904, 730, 543, 314, 1627, 267, 1163, 25756, 12, 314, 3974, 13, 6868, 1059, 12, 503, 314, 3000, 14, 267, 408, 267, 340, 1228, 8, 1848, 12, 25756, 304, 288, 372, 291, 14, 1507, 508, 1163, 14, 1507, 267, 916, 1228, 8, 1848, 12, 7116, 304, 288, 372, 291, 14, 354, 14, 2325, 342, 508, 1163, 14, 2325, 342, 267, 916, 1228, 8, 1848, 12, 1109, 304, 288, 372, 291, 14, 1507, 508, 1163, 267, 587, 26, 288, 372, 756, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 334, 277, 508, 1163, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 298, 3407, 282, 3974, 13, 6868, 1059, 1824, 402, 314, 10904, 10579, 730, 2122, 267, 372, 291, 423, 1313, 59, 277, 14, 1507, 61, 339, 768, 1829, 272, 347, 1639, 8, 277, 304, 267, 298, 3407, 314, 5634, 30490, 367, 642, 10904, 2434, 2122, 267, 308, 275, 291, 14, 354, 14, 1814, 360, 821, 36, 297, 4074, 267, 340, 308, 315, 661, 10608, 15420, 297, 283, 403, 735, 288, 372, 488, 267, 916, 308, 508, 283, 5912, 356, 288, 308, 275, 283, 6831, 7, 267, 372, 308, 435, 283, 792, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tima/ansible
lib/ansible/modules/cloud/docker/docker_secret.py
39
8291
#!/usr/bin/python # # Copyright 2016 Red Hat | Ansible # 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: docker_secret short_description: Manage docker secrets. version_added: "2.4" description: - Create and remove Docker secrets in a Swarm environment. Similar to `docker secret create` and `docker secret rm`. - Adds to the metadata of new secrets 'ansible_key', an encrypted hash representation of the data, which is then used - in future runs to test if a secret has changed. - If 'ansible_key is not present, then a secret will not be updated unless the C(force) option is set. - Updates to secrets are performed by removing the secret and creating it again. options: data: description: - String. The value of the secret. Required when state is C(present). required: false labels: description: - "A map of key:value meta data, where both the I(key) and I(value) are expected to be a string." - If new meta data is provided, or existing meta data is modified, the secret will be updated by removing it and creating it again. required: false force: description: - Boolean. Use with state C(present) to always remove and recreate an existing secret. - If I(true), an existing secret will be replaced, even if it has not changed. default: false name: description: - The name of the secret. required: true state: description: - Set to C(present), if the secret should exist, and C(absent), if it should not. required: false default: present choices: - absent - present extends_documentation_fragment: - docker requirements: - "docker-py >= 2.1.0" - "Docker API >= 1.25" author: - Chris Houseknecht (@chouseknecht) ''' EXAMPLES = ''' - name: Create secret foo docker_secret: name: foo data: Hello World! state: present - name: Change the secret data docker_secret: name: foo data: Goodnight everyone! labels: bar: baz one: '1' state: present - name: Add a new label docker_secret: name: foo data: Goodnight everyone! labels: bar: baz one: '1' # Adding a new label will cause a remove/create of the secret two: '2' state: present - name: No change docker_secret: name: foo data: Goodnight everyone! labels: bar: baz one: '1' # Even though 'two' is missing, there is no change to the existing secret state: present - name: Update an existing label docker_secret: name: foo data: Goodnight everyone! labels: bar: monkey # Changing a label will cause a remove/create of the secret one: '1' state: present - name: Force the removal/creation of the secret docker_secret: name: foo data: Goodnight everyone! force: yes state: present - name: Remove secret foo docker_secret: name: foo state: absent ''' RETURN = ''' secret_id: description: - The ID assigned by Docker to the secret object. returned: success type: string sample: 'hzehrmyjigmcp2gb6nlhmjqcv' ''' import hashlib try: from docker.errors import APIError except ImportError: # missing docker-py handled in ansible.module_utils.docker pass from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseClass from ansible.module_utils._text import to_native, to_bytes class SecretManager(DockerBaseClass): def __init__(self, client, results): super(SecretManager, self).__init__() self.client = client self.results = results self.check_mode = self.client.check_mode parameters = self.client.module.params self.name = parameters.get('name') self.state = parameters.get('state') self.data = parameters.get('data') self.labels = parameters.get('labels') self.force = parameters.get('force') self.data_key = None def __call__(self): if self.state == 'present': self.data_key = hashlib.sha224(to_bytes(self.data)).hexdigest() self.present() elif self.state == 'absent': self.absent() def get_secret(self): ''' Find an existing secret. ''' try: secrets = self.client.secrets(filters={'name': self.name}) except APIError as exc: self.client.fail("Error accessing secret %s: %s" % (self.name, to_native(exc))) for secret in secrets: if secret['Spec']['Name'] == self.name: return secret return None def create_secret(self): ''' Create a new secret ''' secret_id = None # We can't see the data after creation, so adding a label we can use for idempotency check labels = { 'ansible_key': self.data_key } if self.labels: labels.update(self.labels) try: if not self.check_mode: secret_id = self.client.create_secret(self.name, self.data, labels=labels) except APIError as exc: self.client.fail("Error creating secret: %s" % to_native(exc)) if isinstance(secret_id, dict): secret_id = secret_id['ID'] return secret_id def present(self): ''' Handles state == 'present', creating or updating the secret ''' secret = self.get_secret() if secret: self.results['secret_id'] = secret['ID'] data_changed = False attrs = secret.get('Spec', {}) if attrs.get('Labels', {}).get('ansible_key'): if attrs['Labels']['ansible_key'] != self.data_key: data_changed = True labels_changed = False if self.labels and attrs.get('Labels'): # check if user requested a label change for label in attrs['Labels']: if self.labels.get(label) and self.labels[label] != attrs['Labels'][label]: labels_changed = True # check if user added a label labels_added = False if self.labels: if attrs.get('Labels'): for label in self.labels: if label not in attrs['Labels']: labels_added = True else: labels_added = True if data_changed or labels_added or labels_changed or self.force: # if something changed or force, delete and re-create the secret self.absent() secret_id = self.create_secret() self.results['changed'] = True self.results['secret_id'] = secret_id else: self.results['changed'] = True self.results['secret_id'] = self.create_secret() def absent(self): ''' Handles state == 'absent', removing the secret ''' secret = self.get_secret() if secret: try: if not self.check_mode: self.client.remove_secret(secret['ID']) except APIError as exc: self.client.fail("Error removing secret %s: %s" % (self.name, to_native(exc))) self.results['changed'] = True def main(): argument_spec = dict( name=dict(type='str', required=True), state=dict(type='str', choices=['absent', 'present'], default='present'), data=dict(type='str', no_log=True), labels=dict(type='dict'), force=dict(type='bool', default=False) ) required_if = [ ('state', 'present', ['data']) ] client = AnsibleDockerClient( argument_spec=argument_spec, supports_check_mode=True, required_if=required_if ) results = dict( changed=False, secret_id='' ) SecretManager(client, results)() client.module.exit_json(**results) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 7800, 9572, 13002, 1204, 2622, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12424, 63, 4731, 199, 199, 3612, 63, 1802, 26, 14944, 12424, 25563, 14, 199, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 199, 1802, 26, 1362, 446, 2790, 436, 2813, 22067, 25563, 315, 282, 428, 10669, 3734, 14, 20046, 370, 658, 9991, 7565, 1218, 64, 436, 658, 9991, 7565, 14267, 2313, 1362, 446, 15747, 370, 314, 3341, 402, 892, 25563, 283, 4853, 63, 498, 297, 376, 14862, 2631, 6025, 402, 314, 666, 12, 1314, 365, 2066, 1202, 1362, 446, 315, 6466, 7858, 370, 511, 340, 282, 7565, 965, 2896, 14, 1362, 446, 982, 283, 4853, 63, 498, 365, 440, 3451, 12, 2066, 282, 7565, 911, 440, 506, 4588, 7444, 314, 445, 8, 3990, 9, 945, 365, 663, 14, 1362, 446, 24663, 370, 25563, 787, 10585, 701, 12881, 314, 7565, 436, 6425, 652, 4020, 14, 199, 1419, 26, 523, 666, 26, 272, 1369, 26, 489, 446, 2624, 14, 710, 574, 402, 314, 7565, 14, 11105, 1380, 1174, 365, 445, 8, 1881, 680, 272, 1415, 26, 3055, 523, 3628, 26, 272, 1369, 26, 489, 446, 298, 33, 2341, 402, 790, 26, 585, 3404, 666, 12, 2382, 3865, 314, 473, 8, 498, 9, 436, 473, 8, 585, 9, 787, 1420, 370, 506, 282, 1059, 2122, 489, 446, 982, 892, 3404, 666, 365, 2741, 12, 503, 3411, 3404, 666, 365, 6042, 12, 314, 7565, 911, 506, 4588, 701, 12881, 652, 436, 6425, 652, 4020, 14, 272, 1415, 26, 3055, 523, 3542, 26, 272, 1369, 26, 489, 446, 9411, 14, 3645, 543, 1174, 445, 8, 1881, 9, 370, 3544, 2813, 436, 23959, 376, 3411, 7565, 14, 489, 446, 982, 473, 8, 2052, 395, 376, 3411, 7565, 911, 506, 8717, 12, 2755, 340, 652, 965, 440, 2896, 14, 272, 849, 26, 3055, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 7565, 14, 272, 1415, 26, 2549, 523, 1174, 26, 272, 1369, 26, 489, 446, 2494, 370, 445, 8, 1881, 395, 340, 314, 7565, 1077, 2187, 12, 436, 445, 8, 5575, 395, 340, 652, 1077, 440, 14, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 9552, 489, 446, 3451, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 12424, 199, 199, 7538, 26, 523, 446, 298, 9991, 13, 647, 2356, 499, 14, 17, 14, 16, 2, 523, 446, 298, 31463, 3261, 2356, 413, 14, 821, 2, 199, 199, 2502, 26, 523, 446, 2799, 5719, 869, 7130, 75, 685, 335, 84, 8593, 335, 7130, 75, 685, 335, 84, 9, 199, 2344, 199, 199, 8918, 275, 1449, 199, 199, 13, 536, 26, 2790, 7565, 3925, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 23833, 13064, 1, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 7743, 314, 7565, 666, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 15507, 489, 1373, 26, 283, 17, 7, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 2654, 282, 892, 1768, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 15507, 489, 1373, 26, 283, 17, 7, 489, 327, 12934, 282, 892, 1768, 911, 7675, 282, 2813, 15, 981, 402, 314, 7565, 489, 2877, 26, 283, 18, 7, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 3091, 1570, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 15507, 489, 1373, 26, 283, 17, 7, 489, 327, 22207, 10617, 283, 5601, 7, 365, 4124, 12, 2337, 365, 949, 1570, 370, 314, 3411, 7565, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 6162, 376, 3411, 1768, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 14198, 257, 327, 27854, 282, 1768, 911, 7675, 282, 2813, 15, 981, 402, 314, 7565, 489, 1373, 26, 283, 17, 7, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 18771, 314, 20055, 15, 8782, 402, 314, 7565, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3542, 26, 9456, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 5852, 7565, 3925, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 1449, 199, 4731, 63, 344, 26, 523, 1369, 26, 272, 446, 710, 2870, 7943, 701, 22067, 370, 314, 7565, 909, 14, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 283, 72, 806, 6271, 1662, 74, 528, 77, 1850, 18, 4908, 22, 7530, 14038, 74, 81, 5107, 7, 199, 2344, 199, 199, 646, 8337, 199, 199, 893, 26, 272, 687, 12424, 14, 2550, 492, 3261, 547, 199, 2590, 3545, 26, 272, 327, 4124, 12424, 13, 647, 8860, 315, 3242, 14, 578, 63, 1208, 14, 9991, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 9991, 63, 2330, 492, 2622, 31463, 3041, 12, 22067, 1563, 2543, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 12, 370, 63, 2394, 421, 199, 533, 23580, 2988, 8, 31463, 1563, 2543, 304, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 2058, 304, 398, 1613, 8, 13790, 2988, 12, 291, 2843, 826, 4533, 398, 291, 14, 1258, 275, 1890, 267, 291, 14, 2604, 275, 2058, 267, 291, 14, 1074, 63, 632 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 7800, 9572, 13002, 1204, 2622, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 12424, 63, 4731, 199, 199, 3612, 63, 1802, 26, 14944, 12424, 25563, 14, 199, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 199, 1802, 26, 1362, 446, 2790, 436, 2813, 22067, 25563, 315, 282, 428, 10669, 3734, 14, 20046, 370, 658, 9991, 7565, 1218, 64, 436, 658, 9991, 7565, 14267, 2313, 1362, 446, 15747, 370, 314, 3341, 402, 892, 25563, 283, 4853, 63, 498, 297, 376, 14862, 2631, 6025, 402, 314, 666, 12, 1314, 365, 2066, 1202, 1362, 446, 315, 6466, 7858, 370, 511, 340, 282, 7565, 965, 2896, 14, 1362, 446, 982, 283, 4853, 63, 498, 365, 440, 3451, 12, 2066, 282, 7565, 911, 440, 506, 4588, 7444, 314, 445, 8, 3990, 9, 945, 365, 663, 14, 1362, 446, 24663, 370, 25563, 787, 10585, 701, 12881, 314, 7565, 436, 6425, 652, 4020, 14, 199, 1419, 26, 523, 666, 26, 272, 1369, 26, 489, 446, 2624, 14, 710, 574, 402, 314, 7565, 14, 11105, 1380, 1174, 365, 445, 8, 1881, 680, 272, 1415, 26, 3055, 523, 3628, 26, 272, 1369, 26, 489, 446, 298, 33, 2341, 402, 790, 26, 585, 3404, 666, 12, 2382, 3865, 314, 473, 8, 498, 9, 436, 473, 8, 585, 9, 787, 1420, 370, 506, 282, 1059, 2122, 489, 446, 982, 892, 3404, 666, 365, 2741, 12, 503, 3411, 3404, 666, 365, 6042, 12, 314, 7565, 911, 506, 4588, 701, 12881, 652, 436, 6425, 652, 4020, 14, 272, 1415, 26, 3055, 523, 3542, 26, 272, 1369, 26, 489, 446, 9411, 14, 3645, 543, 1174, 445, 8, 1881, 9, 370, 3544, 2813, 436, 23959, 376, 3411, 7565, 14, 489, 446, 982, 473, 8, 2052, 395, 376, 3411, 7565, 911, 506, 8717, 12, 2755, 340, 652, 965, 440, 2896, 14, 272, 849, 26, 3055, 523, 536, 26, 272, 1369, 26, 489, 446, 710, 536, 402, 314, 7565, 14, 272, 1415, 26, 2549, 523, 1174, 26, 272, 1369, 26, 489, 446, 2494, 370, 445, 8, 1881, 395, 340, 314, 7565, 1077, 2187, 12, 436, 445, 8, 5575, 395, 340, 652, 1077, 440, 14, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 9552, 489, 446, 3451, 199, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 12424, 199, 199, 7538, 26, 523, 446, 298, 9991, 13, 647, 2356, 499, 14, 17, 14, 16, 2, 523, 446, 298, 31463, 3261, 2356, 413, 14, 821, 2, 199, 199, 2502, 26, 523, 446, 2799, 5719, 869, 7130, 75, 685, 335, 84, 8593, 335, 7130, 75, 685, 335, 84, 9, 199, 2344, 199, 199, 8918, 275, 1449, 199, 199, 13, 536, 26, 2790, 7565, 3925, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 23833, 13064, 1, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 7743, 314, 7565, 666, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 15507, 489, 1373, 26, 283, 17, 7, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 2654, 282, 892, 1768, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 15507, 489, 1373, 26, 283, 17, 7, 489, 327, 12934, 282, 892, 1768, 911, 7675, 282, 2813, 15, 981, 402, 314, 7565, 489, 2877, 26, 283, 18, 7, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 3091, 1570, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 15507, 489, 1373, 26, 283, 17, 7, 489, 327, 22207, 10617, 283, 5601, 7, 365, 4124, 12, 2337, 365, 949, 1570, 370, 314, 3411, 7565, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 6162, 376, 3411, 1768, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3628, 26, 489, 4681, 26, 14198, 257, 327, 27854, 282, 1768, 911, 7675, 282, 2813, 15, 981, 402, 314, 7565, 489, 1373, 26, 283, 17, 7, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 18771, 314, 20055, 15, 8782, 402, 314, 7565, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 666, 26, 22311, 14873, 4036, 368, 1, 272, 3542, 26, 9456, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 5852, 7565, 3925, 523, 12424, 63, 4731, 26, 272, 536, 26, 3925, 272, 1174, 26, 9552, 199, 2344, 199, 199, 9677, 275, 1449, 199, 4731, 63, 344, 26, 523, 1369, 26, 272, 446, 710, 2870, 7943, 701, 22067, 370, 314, 7565, 909, 14, 523, 2138, 26, 3182, 523, 730, 26, 1059, 523, 2690, 26, 283, 72, 806, 6271, 1662, 74, 528, 77, 1850, 18, 4908, 22, 7530, 14038, 74, 81, 5107, 7, 199, 2344, 199, 199, 646, 8337, 199, 199, 893, 26, 272, 687, 12424, 14, 2550, 492, 3261, 547, 199, 2590, 3545, 26, 272, 327, 4124, 12424, 13, 647, 8860, 315, 3242, 14, 578, 63, 1208, 14, 9991, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 9991, 63, 2330, 492, 2622, 31463, 3041, 12, 22067, 1563, 2543, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 12, 370, 63, 2394, 421, 199, 533, 23580, 2988, 8, 31463, 1563, 2543, 304, 339, 347, 636, 826, 721, 277, 12, 1890, 12, 2058, 304, 398, 1613, 8, 13790, 2988, 12, 291, 2843, 826, 4533, 398, 291, 14, 1258, 275, 1890, 267, 291, 14, 2604, 275, 2058, 267, 291, 14, 1074, 63, 632, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chripede/django-js-reverse
django_js_reverse/management/commands/collectstatic_js_reverse.py
2
1127
# -*- coding: utf-8 -*- import os import sys from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.files.base import ContentFile from django.core.files.storage import FileSystemStorage from django.core.management.base import BaseCommand from django_js_reverse.views import urls_js class Command(BaseCommand): help = 'Creates a static urls-js file for django-js-reverse' def handle(self, *args, **options): if not hasattr(settings, 'STATIC_ROOT') or not settings.STATIC_ROOT: raise ImproperlyConfigured('The collectstatic_js_reverse command needs settings.STATIC_ROOT to be set.') location = os.path.join(settings.STATIC_ROOT, 'django_js_reverse', 'js') file = 'reverse.js' fs = FileSystemStorage(location=location) if fs.exists(file): fs.delete(file) content = urls_js() fs.save(file, ContentFile(content)) if len(sys.argv) > 1 and sys.argv[1] in ['collectstatic_js_reverse']: self.stdout.write('js-reverse file written to %s' % (location)) # pragma: no cover
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1095, 492, 6646, 1173, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 23754, 6408, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 199, 504, 1639, 63, 3596, 63, 4471, 14, 4196, 492, 8187, 63, 3596, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 283, 10607, 282, 2955, 8187, 13, 3596, 570, 367, 1639, 13, 3596, 13, 4471, 7, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 340, 440, 2688, 8, 1751, 12, 283, 10449, 63, 5441, 358, 503, 440, 2202, 14, 10449, 63, 5441, 26, 288, 746, 11897, 360, 1918, 8775, 1986, 63, 3596, 63, 4471, 1414, 4839, 2202, 14, 10449, 63, 5441, 370, 506, 663, 2659, 267, 2909, 275, 747, 14, 515, 14, 904, 8, 1751, 14, 10449, 63, 5441, 12, 283, 1176, 63, 3596, 63, 4471, 297, 283, 3596, 358, 267, 570, 275, 283, 4471, 14, 3596, 7, 267, 7449, 275, 23754, 6408, 8, 1985, 29, 1985, 9, 267, 340, 7449, 14, 2444, 8, 493, 304, 288, 7449, 14, 1807, 8, 493, 9, 398, 1564, 275, 8187, 63, 3596, 342, 267, 7449, 14, 2117, 8, 493, 12, 6646, 1173, 8, 1317, 430, 267, 340, 822, 8, 1274, 14, 3020, 9, 690, 413, 436, 984, 14, 3020, 59, 17, 61, 315, 788, 7112, 1986, 63, 3596, 63, 4471, 2565, 288, 291, 14, 2703, 14, 952, 360, 3596, 13, 4471, 570, 5313, 370, 450, 83, 7, 450, 334, 1985, 430, 221, 327, 11942, 26, 949, 8486, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 1725, 14, 1095, 492, 6646, 1173, 199, 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 23754, 6408, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 199, 504, 1639, 63, 3596, 63, 4471, 14, 4196, 492, 8187, 63, 3596, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 283, 10607, 282, 2955, 8187, 13, 3596, 570, 367, 1639, 13, 3596, 13, 4471, 7, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 340, 440, 2688, 8, 1751, 12, 283, 10449, 63, 5441, 358, 503, 440, 2202, 14, 10449, 63, 5441, 26, 288, 746, 11897, 360, 1918, 8775, 1986, 63, 3596, 63, 4471, 1414, 4839, 2202, 14, 10449, 63, 5441, 370, 506, 663, 2659, 267, 2909, 275, 747, 14, 515, 14, 904, 8, 1751, 14, 10449, 63, 5441, 12, 283, 1176, 63, 3596, 63, 4471, 297, 283, 3596, 358, 267, 570, 275, 283, 4471, 14, 3596, 7, 267, 7449, 275, 23754, 6408, 8, 1985, 29, 1985, 9, 267, 340, 7449, 14, 2444, 8, 493, 304, 288, 7449, 14, 1807, 8, 493, 9, 398, 1564, 275, 8187, 63, 3596, 342, 267, 7449, 14, 2117, 8, 493, 12, 6646, 1173, 8, 1317, 430, 267, 340, 822, 8, 1274, 14, 3020, 9, 690, 413, 436, 984, 14, 3020, 59, 17, 61, 315, 788, 7112, 1986, 63, 3596, 63, 4471, 2565, 288, 291, 14, 2703, 14, 952, 360, 3596, 13, 4471, 570, 5313, 370, 450, 83, 7, 450, 334, 1985, 430, 221, 327, 11942, 26, 949, 8486, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ThQ/luigi
test/contrib/pig_test.py
34
6792
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # 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 subprocess import tempfile import luigi from helpers import unittest from luigi.contrib.pig import PigJobError, PigJobTask from mock import patch class SimpleTestJob(PigJobTask): def output(self): return luigi.LocalTarget('simple-output') def pig_script_path(self): return "my_simple_pig_script.pig" class ComplexTestJob(PigJobTask): def output(self): return luigi.LocalTarget('complex-output') def pig_script_path(self): return "my_complex_pig_script.pig" def pig_env_vars(self): return {'PIG_CLASSPATH': '/your/path'} def pig_properties(self): return {'pig.additional.jars': '/path/to/your/jar'} def pig_parameters(self): return {'YOUR_PARAM_NAME': 'Your param value'} def pig_options(self): return ['-x', 'local'] class SimplePigTest(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @patch('subprocess.Popen') def test_run__success(self, mock): arglist_result = [] p = subprocess.Popen subprocess.Popen = _get_fake_Popen(arglist_result, 0) try: job = SimpleTestJob() job.run() self.assertEqual([['/usr/share/pig/bin/pig', '-f', 'my_simple_pig_script.pig']], arglist_result) finally: subprocess.Popen = p @patch('subprocess.Popen') def test_run__fail(self, mock): arglist_result = [] p = subprocess.Popen subprocess.Popen = _get_fake_Popen(arglist_result, 1) try: job = SimpleTestJob() job.run() self.assertEqual([['/usr/share/pig/bin/pig', '-f', 'my_simple_pig_script.pig']], arglist_result) except PigJobError as e: p = e self.assertEqual('stderr', p.err) else: self.fail("Should have thrown PigJobError") finally: subprocess.Popen = p class ComplexPigTest(unittest.TestCase): def setUp(self): pass def tearDown(self): pass @patch('subprocess.Popen') def test_run__success(self, mock): arglist_result = [] p = subprocess.Popen subprocess.Popen = _get_fake_Popen(arglist_result, 0) with tempfile.NamedTemporaryFile(delete=False) as param_file_mock, \ tempfile.NamedTemporaryFile(delete=False) as prop_file_mock, \ patch('luigi.contrib.pig.tempfile.NamedTemporaryFile', side_effect=[param_file_mock, prop_file_mock]): try: job = ComplexTestJob() job.run() self.assertEqual([['/usr/share/pig/bin/pig', '-x', 'local', '-param_file', param_file_mock.name, '-propertyFile', prop_file_mock.name, '-f', 'my_complex_pig_script.pig']], arglist_result) # Check param file with open(param_file_mock.name) as pparams_file: pparams = pparams_file.readlines() self.assertEqual(1, len(pparams)) self.assertEqual('YOUR_PARAM_NAME=Your param value\n', pparams[0]) # Check property file with open(prop_file_mock.name) as pprops_file: pprops = pprops_file.readlines() self.assertEqual(1, len(pprops)) self.assertEqual('pig.additional.jars=/path/to/your/jar\n', pprops[0]) finally: subprocess.Popen = p @patch('subprocess.Popen') def test_run__fail(self, mock): arglist_result = [] p = subprocess.Popen subprocess.Popen = _get_fake_Popen(arglist_result, 1) with tempfile.NamedTemporaryFile(delete=False) as param_file_mock, \ tempfile.NamedTemporaryFile(delete=False) as prop_file_mock, \ patch('luigi.contrib.pig.tempfile.NamedTemporaryFile', side_effect=[param_file_mock, prop_file_mock]): try: job = ComplexTestJob() job.run() except PigJobError as e: p = e self.assertEqual('stderr', p.err) self.assertEqual([['/usr/share/pig/bin/pig', '-x', 'local', '-param_file', param_file_mock.name, '-propertyFile', prop_file_mock.name, '-f', 'my_complex_pig_script.pig']], arglist_result) # Check param file with open(param_file_mock.name) as pparams_file: pparams = pparams_file.readlines() self.assertEqual(1, len(pparams)) self.assertEqual('YOUR_PARAM_NAME=Your param value\n', pparams[0]) # Check property file with open(prop_file_mock.name) as pprops_file: pprops = pprops_file.readlines() self.assertEqual(1, len(pprops)) self.assertEqual('pig.additional.jars=/path/to/your/jar\n', pprops[0]) else: self.fail("Should have thrown PigJobError") finally: subprocess.Popen = p def _get_fake_Popen(arglist_result, return_code, *args, **kwargs): def Popen_fake(arglist, shell=None, stdout=None, stderr=None, env=None, close_fds=True): arglist_result.append(arglist) class P(object): def wait(self): pass def poll(self): return 0 def communicate(self): return 'end' def env(self): return self.env p = P() p.returncode = return_code p.stderr = tempfile.TemporaryFile() p.stdout = tempfile.TemporaryFile() p.stdout.write(b'stdout') p.stderr.write(b'stderr') # Reset temp files so the output can be read. p.stdout.seek(0) p.stderr.seek(0) return p return Popen_fake
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6029, 13, 7806, 428, 555, 3338, 14840, 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, 3873, 199, 646, 5549, 199, 199, 646, 19485, 199, 504, 10897, 492, 2882, 199, 504, 19485, 14, 2828, 14, 31960, 492, 510, 528, 6694, 547, 12, 510, 528, 6694, 4476, 199, 504, 1683, 492, 3371, 421, 199, 533, 5870, 774, 6694, 8, 48, 528, 6694, 4476, 304, 272, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 4129, 13, 1199, 358, 339, 347, 299, 528, 63, 1579, 63, 515, 8, 277, 304, 267, 372, 298, 1662, 63, 4129, 63, 31960, 63, 1579, 14, 31960, 2, 421, 199, 533, 19178, 774, 6694, 8, 48, 528, 6694, 4476, 304, 272, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 5254, 13, 1199, 358, 339, 347, 299, 528, 63, 1579, 63, 515, 8, 277, 304, 267, 372, 298, 1662, 63, 5254, 63, 31960, 63, 1579, 14, 31960, 2, 339, 347, 299, 528, 63, 1813, 63, 2936, 8, 277, 304, 267, 372, 791, 48, 1277, 63, 6885, 3243, 356, 1994, 12695, 15, 515, 936, 339, 347, 299, 528, 63, 3282, 8, 277, 304, 267, 372, 791, 31960, 14, 8460, 14, 32262, 356, 1994, 515, 15, 475, 15, 12695, 15, 7338, 936, 339, 347, 299, 528, 63, 3214, 8, 277, 304, 267, 372, 791, 57, 11237, 63, 7258, 63, 2339, 356, 283, 14398, 1215, 574, 936, 339, 347, 299, 528, 63, 1419, 8, 277, 304, 267, 372, 11573, 88, 297, 283, 1832, 418, 421, 199, 533, 5870, 48, 528, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 768, 2068, 360, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 363, 3742, 8, 277, 12, 1683, 304, 267, 24660, 63, 1099, 275, 942, 267, 299, 275, 3873, 14, 7942, 267, 3873, 14, 7942, 275, 485, 362, 63, 3183, 63, 7942, 8, 26995, 63, 1099, 12, 378, 9, 267, 862, 26, 288, 3906, 275, 5870, 774, 6694, 342, 288, 3906, 14, 1065, 342, 288, 291, 14, 629, 779, 459, 15, 2647, 15, 6251, 15, 31960, 15, 1393, 15, 31960, 297, 2475, 70, 297, 283, 1662, 63, 4129, 63, 31960, 63, 1579, 14, 31960, 2157, 24660, 63, 1099, 9, 267, 3753, 26, 288, 3873, 14, 7942, 275, 299, 339, 768, 2068, 360, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 363, 1633, 8, 277, 12, 1683, 304, 267, 24660, 63, 1099, 275, 942, 267, 299, 275, 3873, 14, 7942, 267, 3873, 14, 7942, 275, 485, 362, 63, 3183, 63, 7942, 8, 26995, 63, 1099, 12, 413, 9, 267, 862, 26, 288, 3906, 275, 5870, 774, 6694, 342, 288, 3906, 14, 1065, 342, 288, 291, 14, 629, 779, 459, 15, 2647, 15, 6251, 15, 31960, 15, 1393, 15, 31960, 297, 2475, 70, 297, 283, 1662, 63, 4129, 63, 31960, 63, 1579, 14, 31960, 2157, 24660, 63, 1099, 9, 267, 871, 510, 528, 6694, 547, 465, 325, 26, 288, 299, 275, 325, 288, 291, 14, 629, 360, 3083, 297, 299, 14, 1508, 9, 267, 587, 26, 288, 291, 14, 1633, 480, 11408, 1172, 14031, 510, 528, 6694, 547, 531, 267, 3753, 26, 288, 3873, 14, 7942, 275, 299, 421, 199, 533, 19178, 48, 528, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 768, 2068, 360, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 363, 3742, 8, 277, 12, 1683, 304, 267, 24660, 63, 1099, 275, 942, 267, 299, 275, 3873, 14, 7942, 267, 3873, 14, 7942, 275, 485, 362, 63, 3183, 63, 7942, 8, 26995, 63, 1099, 12, 378, 9, 398, 543, 5549, 14, 19320, 8, 1807, 29, 797, 9, 465, 1215, 63, 493, 63, 1805, 12, 971, 355, 5549, 14, 19320, 8, 1807, 29, 797, 9, 465, 5931, 63, 493, 63, 1805, 12, 971, 355, 3371, 360, 26795, 14, 2828, 14, 31960, 14, 17336, 14, 19320, 297, 1993, 5366, 63, 5881, 1524, 635, 63, 493, 63, 1805, 12, 5931, 63, 493, 63, 1805, 4682, 288, 862, 26, 355, 3906, 275, 19178, 774, 6694, 342, 355, 3906, 14, 1065, 342, 355, 291, 14, 629, 779, 459, 15, 2647, 15, 6251, 15, 31960, 15, 1393, 15, 31960, 297, 2475, 88, 297, 283, 1832, 297, 3521, 2475, 635, 63, 493, 297, 1215, 63, 493, 63, 1805, 14, 354, 12, 3521, 2475, 1829, 1173, 297, 5931, 63, 493, 63, 1805, 14, 354, 12, 3521, 2475, 70, 297, 283, 1662, 63, 5254, 63, 31960, 63, 1579, 14, 31960, 2157, 639, 24660, 63, 1099, 9, 2234, 327, 2670, 1215, 570, 355, 543, 1551, 8, 635, 63, 493, 63, 1805, 14, 354, 9, 465, 299, 1162, 63, 493, 26, 490, 299, 1162, 275, 299, 1162, 63, 493, 14, 9684, 342, 490, 291, 14, 629, 8, 17, 12, 822, 8, 80, 1162, 430, 490, 291, 14, 629, 360, 57, 11237, 63, 7258, 63, 2339, 29, 14398, 1215, 574, 60, 78, 297, 299, 1162, 59, 16, 566, 2234, 327, 2670, 3324, 570, 355, 543, 1551, 8, 4469, 63, 493, 63, 1805, 14, 354, 9, 465, 299, 6750, 63, 493, 26, 490, 299, 6750, 275, 299, 6750, 63, 493, 14, 9684, 342, 490, 291, 14, 629, 8, 17, 12, 822, 8, 80, 6750, 430, 490, 291, 14, 629, 360, 31960 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6029, 13, 7806, 428, 555, 3338, 14840, 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, 3873, 199, 646, 5549, 199, 199, 646, 19485, 199, 504, 10897, 492, 2882, 199, 504, 19485, 14, 2828, 14, 31960, 492, 510, 528, 6694, 547, 12, 510, 528, 6694, 4476, 199, 504, 1683, 492, 3371, 421, 199, 533, 5870, 774, 6694, 8, 48, 528, 6694, 4476, 304, 272, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 4129, 13, 1199, 358, 339, 347, 299, 528, 63, 1579, 63, 515, 8, 277, 304, 267, 372, 298, 1662, 63, 4129, 63, 31960, 63, 1579, 14, 31960, 2, 421, 199, 533, 19178, 774, 6694, 8, 48, 528, 6694, 4476, 304, 272, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 5254, 13, 1199, 358, 339, 347, 299, 528, 63, 1579, 63, 515, 8, 277, 304, 267, 372, 298, 1662, 63, 5254, 63, 31960, 63, 1579, 14, 31960, 2, 339, 347, 299, 528, 63, 1813, 63, 2936, 8, 277, 304, 267, 372, 791, 48, 1277, 63, 6885, 3243, 356, 1994, 12695, 15, 515, 936, 339, 347, 299, 528, 63, 3282, 8, 277, 304, 267, 372, 791, 31960, 14, 8460, 14, 32262, 356, 1994, 515, 15, 475, 15, 12695, 15, 7338, 936, 339, 347, 299, 528, 63, 3214, 8, 277, 304, 267, 372, 791, 57, 11237, 63, 7258, 63, 2339, 356, 283, 14398, 1215, 574, 936, 339, 347, 299, 528, 63, 1419, 8, 277, 304, 267, 372, 11573, 88, 297, 283, 1832, 418, 421, 199, 533, 5870, 48, 528, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 768, 2068, 360, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 363, 3742, 8, 277, 12, 1683, 304, 267, 24660, 63, 1099, 275, 942, 267, 299, 275, 3873, 14, 7942, 267, 3873, 14, 7942, 275, 485, 362, 63, 3183, 63, 7942, 8, 26995, 63, 1099, 12, 378, 9, 267, 862, 26, 288, 3906, 275, 5870, 774, 6694, 342, 288, 3906, 14, 1065, 342, 288, 291, 14, 629, 779, 459, 15, 2647, 15, 6251, 15, 31960, 15, 1393, 15, 31960, 297, 2475, 70, 297, 283, 1662, 63, 4129, 63, 31960, 63, 1579, 14, 31960, 2157, 24660, 63, 1099, 9, 267, 3753, 26, 288, 3873, 14, 7942, 275, 299, 339, 768, 2068, 360, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 363, 1633, 8, 277, 12, 1683, 304, 267, 24660, 63, 1099, 275, 942, 267, 299, 275, 3873, 14, 7942, 267, 3873, 14, 7942, 275, 485, 362, 63, 3183, 63, 7942, 8, 26995, 63, 1099, 12, 413, 9, 267, 862, 26, 288, 3906, 275, 5870, 774, 6694, 342, 288, 3906, 14, 1065, 342, 288, 291, 14, 629, 779, 459, 15, 2647, 15, 6251, 15, 31960, 15, 1393, 15, 31960, 297, 2475, 70, 297, 283, 1662, 63, 4129, 63, 31960, 63, 1579, 14, 31960, 2157, 24660, 63, 1099, 9, 267, 871, 510, 528, 6694, 547, 465, 325, 26, 288, 299, 275, 325, 288, 291, 14, 629, 360, 3083, 297, 299, 14, 1508, 9, 267, 587, 26, 288, 291, 14, 1633, 480, 11408, 1172, 14031, 510, 528, 6694, 547, 531, 267, 3753, 26, 288, 3873, 14, 7942, 275, 299, 421, 199, 533, 19178, 48, 528, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 768, 2068, 360, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 363, 3742, 8, 277, 12, 1683, 304, 267, 24660, 63, 1099, 275, 942, 267, 299, 275, 3873, 14, 7942, 267, 3873, 14, 7942, 275, 485, 362, 63, 3183, 63, 7942, 8, 26995, 63, 1099, 12, 378, 9, 398, 543, 5549, 14, 19320, 8, 1807, 29, 797, 9, 465, 1215, 63, 493, 63, 1805, 12, 971, 355, 5549, 14, 19320, 8, 1807, 29, 797, 9, 465, 5931, 63, 493, 63, 1805, 12, 971, 355, 3371, 360, 26795, 14, 2828, 14, 31960, 14, 17336, 14, 19320, 297, 1993, 5366, 63, 5881, 1524, 635, 63, 493, 63, 1805, 12, 5931, 63, 493, 63, 1805, 4682, 288, 862, 26, 355, 3906, 275, 19178, 774, 6694, 342, 355, 3906, 14, 1065, 342, 355, 291, 14, 629, 779, 459, 15, 2647, 15, 6251, 15, 31960, 15, 1393, 15, 31960, 297, 2475, 88, 297, 283, 1832, 297, 3521, 2475, 635, 63, 493, 297, 1215, 63, 493, 63, 1805, 14, 354, 12, 3521, 2475, 1829, 1173, 297, 5931, 63, 493, 63, 1805, 14, 354, 12, 3521, 2475, 70, 297, 283, 1662, 63, 5254, 63, 31960, 63, 1579, 14, 31960, 2157, 639, 24660, 63, 1099, 9, 2234, 327, 2670, 1215, 570, 355, 543, 1551, 8, 635, 63, 493, 63, 1805, 14, 354, 9, 465, 299, 1162, 63, 493, 26, 490, 299, 1162, 275, 299, 1162, 63, 493, 14, 9684, 342, 490, 291, 14, 629, 8, 17, 12, 822, 8, 80, 1162, 430, 490, 291, 14, 629, 360, 57, 11237, 63, 7258, 63, 2339, 29, 14398, 1215, 574, 60, 78, 297, 299, 1162, 59, 16, 566, 2234, 327, 2670, 3324, 570, 355, 543, 1551, 8, 4469, 63, 493, 63, 1805, 14, 354, 9, 465, 299, 6750, 63, 493, 26, 490, 299, 6750, 275, 299, 6750, 63, 493, 14, 9684, 342, 490, 291, 14, 629, 8, 17, 12, 822, 8, 80, 6750, 430, 490, 291, 14, 629, 360, 31960, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hofschroeer/gnuradio
docs/doxygen/doxyxml/__init__.py
7
2515
# # Copyright 2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # """ Python interface to contents of doxygen xml documentation. Example use: See the contents of the example folder for the C++ and doxygen-generated xml used in this example. >>> # Parse the doxygen docs. >>> import os >>> this_dir = os.path.dirname(globals()['__file__']) >>> xml_path = this_dir + "/example/xml/" >>> di = DoxyIndex(xml_path) Get a list of all top-level objects. >>> print([mem.name() for mem in di.members()]) [u'Aadvark', u'aadvarky_enough', u'main'] Get all functions. >>> print([mem.name() for mem in di.in_category(DoxyFunction)]) [u'aadvarky_enough', u'main'] Check if an object is present. >>> di.has_member(u'Aadvark') True >>> di.has_member(u'Fish') False Get an item by name and check its properties. >>> aad = di.get_member(u'Aadvark') >>> print(aad.brief_description) Models the mammal Aadvark. >>> print(aad.detailed_description) Sadly the model is incomplete and cannot capture all aspects of an aadvark yet. <BLANKLINE> This line is uninformative and is only to test line breaks in the comments. >>> [mem.name() for mem in aad.members()] [u'aadvarkness', u'print', u'Aadvark', u'get_aadvarkness'] >>> aad.get_member(u'print').brief_description u'Outputs the vital aadvark statistics.' """ from __future__ import unicode_literals from .doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, DoxyFile, DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther def _test(): import os this_dir = os.path.dirname(globals()['__file__']) xml_path = this_dir + "/example/xml/" di = DoxyIndex(xml_path) # Get the Aadvark class aad = di.get_member('Aadvark') aad.brief_description import doctest return doctest.testmod() if __name__ == "__main__": _test()
gpl-3.0
[ 3, 199, 3, 1898, 7129, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 624, 199, 4718, 3217, 370, 4072, 402, 886, 20515, 2748, 3794, 14, 199, 199, 9846, 675, 26, 199, 9295, 314, 4072, 402, 314, 2893, 4922, 367, 314, 445, 4176, 436, 199, 1117, 20515, 13, 10176, 2748, 1202, 315, 642, 2893, 14, 199, 199, 6071, 327, 6077, 314, 886, 20515, 9149, 14, 199, 6071, 492, 747, 199, 6071, 642, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 8473, 12047, 363, 493, 363, 1105, 199, 6071, 2748, 63, 515, 275, 642, 63, 694, 435, 3286, 2694, 15, 1652, 6687, 199, 6071, 487, 275, 4226, 1702, 2681, 8, 1652, 63, 515, 9, 199, 199, 1002, 282, 769, 402, 1006, 2746, 13, 1896, 2251, 14, 199, 199, 6071, 870, 779, 5286, 14, 354, 342, 367, 7573, 315, 487, 14, 6334, 9383, 199, 59, 85, 7, 33, 21650, 1096, 297, 399, 7, 65, 21650, 1096, 89, 63, 30881, 297, 399, 6704, 1581, 418, 199, 199, 1002, 1006, 3423, 14, 199, 199, 6071, 870, 779, 5286, 14, 354, 342, 367, 7573, 315, 487, 14, 262, 63, 3710, 8, 2585, 1702, 3481, 3948, 199, 59, 85, 7, 65, 21650, 1096, 89, 63, 30881, 297, 399, 6704, 1581, 418, 199, 199, 1799, 340, 376, 909, 365, 3451, 14, 199, 199, 6071, 487, 14, 1989, 63, 1114, 8, 85, 7, 33, 21650, 1096, 358, 199, 549, 199, 6071, 487, 14, 1989, 63, 1114, 8, 85, 7, 38, 2453, 358, 199, 797, 199, 199, 1002, 376, 1242, 701, 536, 436, 1104, 2399, 4382, 14, 199, 199, 6071, 282, 350, 275, 487, 14, 362, 63, 1114, 8, 85, 7, 33, 21650, 1096, 358, 199, 6071, 870, 8, 65, 350, 14, 19127, 63, 1802, 9, 199, 20474, 314, 333, 455, 2174, 437, 21650, 1096, 14, 199, 6071, 870, 8, 65, 350, 14, 19170, 63, 1802, 9, 199, 51, 350, 590, 314, 1402, 365, 17110, 436, 3913, 12296, 1006, 17435, 83, 402, 376, 282, 21650, 1096, 5966, 14, 199, 28, 29353, 30, 199, 2765, 1004, 365, 625, 27666, 436, 365, 1454, 370, 511, 1004, 18277, 315, 314, 6786, 14, 199, 6071, 359, 5286, 14, 354, 342, 367, 7573, 315, 282, 350, 14, 6334, 5106, 199, 59, 85, 7, 65, 21650, 1096, 4171, 297, 399, 7, 1361, 297, 399, 7, 33, 21650, 1096, 297, 399, 7, 362, 63, 65, 21650, 1096, 4171, 418, 199, 6071, 282, 350, 14, 362, 63, 1114, 8, 85, 7, 1361, 1959, 19127, 63, 1802, 199, 85, 7, 18669, 314, 373, 6910, 282, 21650, 1096, 11076, 3530, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 1117, 1702, 1080, 492, 4226, 1702, 2681, 12, 4226, 1702, 3481, 12, 4226, 1702, 4098, 12, 4226, 1702, 2543, 12, 4226, 1702, 1173, 12, 4226, 1702, 8814, 12, 4226, 1702, 2448, 12, 4226, 1702, 38, 8528, 12, 4226, 1702, 8632, 199, 199, 318, 485, 396, 837, 272, 492, 747, 272, 642, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 8473, 12047, 363, 493, 363, 1105, 272, 2748, 63, 515, 275, 642, 63, 694, 435, 3286, 2694, 15, 1652, 6687, 272, 487, 275, 4226, 1702, 2681, 8, 1652, 63, 515, 9, 272, 327, 2372, 314, 437, 21650, 1096, 1021, 272, 282, 350, 275, 487, 14, 362, 63, 1114, 360, 33, 21650, 1096, 358, 272, 282, 350, 14, 19127, 63, 1802, 272, 492, 8868, 272, 372, 8868, 14, 29446, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 485, 396, 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 ]
[ 199, 3, 1898, 7129, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 624, 199, 4718, 3217, 370, 4072, 402, 886, 20515, 2748, 3794, 14, 199, 199, 9846, 675, 26, 199, 9295, 314, 4072, 402, 314, 2893, 4922, 367, 314, 445, 4176, 436, 199, 1117, 20515, 13, 10176, 2748, 1202, 315, 642, 2893, 14, 199, 199, 6071, 327, 6077, 314, 886, 20515, 9149, 14, 199, 6071, 492, 747, 199, 6071, 642, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 8473, 12047, 363, 493, 363, 1105, 199, 6071, 2748, 63, 515, 275, 642, 63, 694, 435, 3286, 2694, 15, 1652, 6687, 199, 6071, 487, 275, 4226, 1702, 2681, 8, 1652, 63, 515, 9, 199, 199, 1002, 282, 769, 402, 1006, 2746, 13, 1896, 2251, 14, 199, 199, 6071, 870, 779, 5286, 14, 354, 342, 367, 7573, 315, 487, 14, 6334, 9383, 199, 59, 85, 7, 33, 21650, 1096, 297, 399, 7, 65, 21650, 1096, 89, 63, 30881, 297, 399, 6704, 1581, 418, 199, 199, 1002, 1006, 3423, 14, 199, 199, 6071, 870, 779, 5286, 14, 354, 342, 367, 7573, 315, 487, 14, 262, 63, 3710, 8, 2585, 1702, 3481, 3948, 199, 59, 85, 7, 65, 21650, 1096, 89, 63, 30881, 297, 399, 6704, 1581, 418, 199, 199, 1799, 340, 376, 909, 365, 3451, 14, 199, 199, 6071, 487, 14, 1989, 63, 1114, 8, 85, 7, 33, 21650, 1096, 358, 199, 549, 199, 6071, 487, 14, 1989, 63, 1114, 8, 85, 7, 38, 2453, 358, 199, 797, 199, 199, 1002, 376, 1242, 701, 536, 436, 1104, 2399, 4382, 14, 199, 199, 6071, 282, 350, 275, 487, 14, 362, 63, 1114, 8, 85, 7, 33, 21650, 1096, 358, 199, 6071, 870, 8, 65, 350, 14, 19127, 63, 1802, 9, 199, 20474, 314, 333, 455, 2174, 437, 21650, 1096, 14, 199, 6071, 870, 8, 65, 350, 14, 19170, 63, 1802, 9, 199, 51, 350, 590, 314, 1402, 365, 17110, 436, 3913, 12296, 1006, 17435, 83, 402, 376, 282, 21650, 1096, 5966, 14, 199, 28, 29353, 30, 199, 2765, 1004, 365, 625, 27666, 436, 365, 1454, 370, 511, 1004, 18277, 315, 314, 6786, 14, 199, 6071, 359, 5286, 14, 354, 342, 367, 7573, 315, 282, 350, 14, 6334, 5106, 199, 59, 85, 7, 65, 21650, 1096, 4171, 297, 399, 7, 1361, 297, 399, 7, 33, 21650, 1096, 297, 399, 7, 362, 63, 65, 21650, 1096, 4171, 418, 199, 6071, 282, 350, 14, 362, 63, 1114, 8, 85, 7, 1361, 1959, 19127, 63, 1802, 199, 85, 7, 18669, 314, 373, 6910, 282, 21650, 1096, 11076, 3530, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 1117, 1702, 1080, 492, 4226, 1702, 2681, 12, 4226, 1702, 3481, 12, 4226, 1702, 4098, 12, 4226, 1702, 2543, 12, 4226, 1702, 1173, 12, 4226, 1702, 8814, 12, 4226, 1702, 2448, 12, 4226, 1702, 38, 8528, 12, 4226, 1702, 8632, 199, 199, 318, 485, 396, 837, 272, 492, 747, 272, 642, 63, 694, 275, 747, 14, 515, 14, 3475, 8, 8473, 12047, 363, 493, 363, 1105, 272, 2748, 63, 515, 275, 642, 63, 694, 435, 3286, 2694, 15, 1652, 6687, 272, 487, 275, 4226, 1702, 2681, 8, 1652, 63, 515, 9, 272, 327, 2372, 314, 437, 21650, 1096, 1021, 272, 282, 350, 275, 487, 14, 362, 63, 1114, 360, 33, 21650, 1096, 358, 272, 282, 350, 14, 19127, 63, 1802, 272, 492, 8868, 272, 372, 8868, 14, 29446, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 485, 396, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Crystalnix/bitpop-omaha
run_unit_tests.py
65
3468
#!/usr/bin/python2.4 # # Copyright 2010 Google 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. # ======================================================================== """Runs a set of unit tests and returns success only if they all succeed. This script assumes it is being run from the omaha directory. To run unit tests for Omaha's default set of test directories, just run the file from the command line. """ import dircache import os TEST_EXECUTABLE_RHS = '_unittest.exe' # Build paths that contain tests. STAGING_PATH = 'scons-out\\dbg-win\\staging' TESTS_PATH = 'scons-out\\dbg-win\\tests' def RunTest(test_path): """Runs a test and returns its exit code. Assumes the tests can be run from any directory. In other words, it does not chdir. Args: test_path: Path to test executables. Returns: The exit code from the test process. """ print '\nRunning %s . . .\n' % test_path # Put './' in front of the file name to avoid accidentally running a file with # the same name in some other directory if test_path were just a file name. return os.system(os.path.join('.', test_path)) def RunTests(test_paths): """Runs all tests specified by test_paths. Args: test_paths: A list of paths to test executables. Returns: 0 if all tests are successful. 1 if some tests fail, or if there is an error. """ if not test_paths or len(test_paths) < 1: return 1 print 'Found the following tests to run:' for test in test_paths: print '\t%s' % test # Run all tests and remembers those that failed. failed_tests = [t for t in test_paths if RunTest(t)] print '\n\n%s test executables were run.' % len(test_paths) failed_test_count = len(failed_tests) if failed_test_count: # Lists the executables that failed so the user can investigate them. print 'FAILED!' print 'The following %s tests failed:\n' % failed_test_count for test in failed_tests: print test return 1 else: # No, there is none. if test_paths: print 'All of them PASSED!' return 0 def GetTestsInDirs(test_dirs): """Returns a list of all unit test executables in test_dirs. Does not search subdirectories. Args: test_dirs: A list of directories to search. Returns: List of all unit tests. """ tests = [] for test_dir in test_dirs: # Use dircache.listdir so order is alphabetical and thus deterministic. files = dircache.listdir(test_dir) for test_file in files: if test_file.endswith(TEST_EXECUTABLE_RHS): relative_path = os.path.join(test_dir, test_file) if os.path.isfile(relative_path): tests += [relative_path] return tests # Run a unit test when the module is run directly. if __name__ == '__main__': # List of paths that contain unit tests to run. dirs_containing_tests = [STAGING_PATH, TESTS_PATH] tests_to_run = GetTestsInDirs(dirs_containing_tests) RunTests(tests_to_run)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 7129, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 3, 7819, 18673, 199, 199, 624, 16291, 282, 663, 402, 4137, 2295, 436, 2529, 3182, 1454, 340, 2985, 1006, 17961, 14, 199, 199, 2765, 2884, 15194, 652, 365, 3769, 1255, 687, 314, 312, 391, 2411, 2082, 14, 199, 199, 1378, 1255, 4137, 2295, 367, 593, 391, 2411, 1159, 849, 663, 402, 511, 6602, 12, 2951, 1255, 314, 570, 199, 504, 314, 1414, 1004, 14, 199, 624, 421, 199, 646, 2935, 1637, 199, 646, 747, 199, 199, 2864, 63, 21623, 63, 50, 15467, 275, 2513, 2796, 14, 5803, 7, 199, 199, 3, 6516, 3792, 626, 1395, 2295, 14, 199, 840, 1254, 1206, 63, 3243, 275, 283, 21529, 13, 548, 1103, 16310, 13, 2676, 1103, 26840, 7, 199, 7569, 63, 3243, 275, 283, 21529, 13, 548, 1103, 16310, 13, 2676, 1103, 2219, 7, 421, 199, 318, 3378, 774, 8, 396, 63, 515, 304, 523, 408, 16291, 282, 511, 436, 2529, 2399, 4458, 1233, 14, 339, 30451, 314, 2295, 883, 506, 1255, 687, 1263, 2082, 14, 1010, 1163, 5932, 12, 652, 1630, 440, 272, 13097, 14, 819, 3033, 26, 272, 511, 63, 515, 26, 6912, 370, 511, 31172, 14, 819, 1803, 26, 272, 710, 4458, 1233, 687, 314, 511, 2112, 14, 523, 408, 819, 870, 1557, 78, 9602, 450, 83, 1275, 1275, 1275, 60, 78, 7, 450, 511, 63, 515, 819, 327, 16280, 1987, 4805, 315, 13738, 402, 314, 570, 536, 370, 5126, 24634, 1183, 3879, 282, 570, 543, 523, 327, 314, 2011, 536, 315, 2005, 1163, 2082, 340, 511, 63, 515, 4898, 2951, 282, 570, 536, 14, 523, 372, 747, 14, 2253, 8, 736, 14, 515, 14, 904, 14078, 511, 63, 515, 430, 421, 199, 318, 3378, 2925, 8, 396, 63, 3771, 304, 523, 408, 16291, 1006, 2295, 2013, 701, 511, 63, 3771, 14, 819, 3033, 26, 272, 511, 63, 3771, 26, 437, 769, 402, 3792, 370, 511, 31172, 14, 819, 1803, 26, 272, 378, 340, 1006, 2295, 787, 9512, 14, 272, 413, 340, 2005, 2295, 2449, 12, 503, 340, 2337, 365, 376, 1125, 14, 523, 408, 819, 340, 440, 511, 63, 3771, 503, 822, 8, 396, 63, 3771, 9, 665, 413, 26, 272, 372, 413, 819, 870, 283, 3601, 314, 2569, 2295, 370, 1255, 4881, 523, 367, 511, 315, 511, 63, 3771, 26, 272, 870, 1557, 84, 5, 83, 7, 450, 511, 819, 327, 3378, 1006, 2295, 436, 295, 6334, 5204, 626, 3405, 14, 523, 3405, 63, 2219, 275, 359, 84, 367, 307, 315, 511, 63, 3771, 340, 3378, 774, 8, 84, 1874, 819, 870, 1557, 78, 60, 78, 5, 83, 511, 31172, 4898, 1255, 3530, 450, 822, 8, 396, 63, 3771, 9, 819, 3405, 63, 396, 63, 835, 275, 822, 8, 4892, 63, 2219, 9, 523, 340, 3405, 63, 396, 63, 835, 26, 272, 327, 31289, 314, 31172, 626, 3405, 880, 314, 922, 883, 315, 27174, 323, 3062, 14, 272, 870, 283, 12299, 11213, 272, 870, 283, 1918, 2569, 450, 83, 2295, 3405, 3427, 78, 7, 450, 3405, 63, 396, 63, 835, 272, 367, 511, 315, 3405, 63, 2219, 26, 489, 870, 511, 272, 372, 413, 523, 587, 26, 272, 327, 3091, 12, 2337, 365, 7179, 14, 272, 340, 511, 63, 3771, 26, 489, 870, 283, 2422, 402, 3062, 510, 32032, 11213, 272, 372, 378, 421, 199, 318, 2372, 2925, 607, 17051, 8, 396, 63, 3220, 304, 523, 408, 3407, 282, 769, 402, 1006, 4137, 511, 31172, 315, 511, 63, 3220, 14, 339, 12078, 440, 2754, 24799, 14, 819, 3033, 26, 272, 511, 63, 3220, 26, 437, 769, 402, 6602, 370, 2754, 14, 819, 1803, 26, 272, 3820, 402, 1006, 4137, 2295, 14, 523, 408, 819, 2295, 275, 942, 819, 367, 511, 63, 694, 315, 511, 63, 3220, 26, 272, 327, 3645, 2935, 1637, 14, 7374, 880, 1865, 365, 23331, 3294, 436, 12850, 25286, 14, 272, 1584, 275, 2935, 1637, 14, 7374, 8, 396, 63, 694, 9, 339, 367, 511, 63, 493, 315, 1584, 26, 489, 340, 511, 63, 493, 14, 4130, 8, 2864, 63, 21623, 63, 50, 15467, 304, 267, 3847, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 511, 63, 493, 9, 267, 340, 747, 14, 515, 14, 6292, 8, 6188, 63, 515, 304, 881, 2295, 847, 359, 6188, 63, 515, 61, 819, 372, 2295, 199, 199, 3, 3378, 282, 4137, 511, 1380, 314, 859, 365, 1255, 5370, 14, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 3820, 402, 3792, 626, 1395, 4137, 2295, 370, 1255, 14, 523, 7606, 63, 16133, 63, 2219, 275, 359, 840, 1254, 1206, 63, 3243, 12, 7393, 51, 63, 3243, 61, 819, 2295, 63, 475, 63, 1065, 275, 2372, 2925, 607, 17051, 8, 3220, 63, 16133, 63, 2219, 9, 819, 3378, 2925, 8, 2219, 63, 475, 63, 1065, 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 ]
[ 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 7129, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 3, 7819, 18673, 199, 199, 624, 16291, 282, 663, 402, 4137, 2295, 436, 2529, 3182, 1454, 340, 2985, 1006, 17961, 14, 199, 199, 2765, 2884, 15194, 652, 365, 3769, 1255, 687, 314, 312, 391, 2411, 2082, 14, 199, 199, 1378, 1255, 4137, 2295, 367, 593, 391, 2411, 1159, 849, 663, 402, 511, 6602, 12, 2951, 1255, 314, 570, 199, 504, 314, 1414, 1004, 14, 199, 624, 421, 199, 646, 2935, 1637, 199, 646, 747, 199, 199, 2864, 63, 21623, 63, 50, 15467, 275, 2513, 2796, 14, 5803, 7, 199, 199, 3, 6516, 3792, 626, 1395, 2295, 14, 199, 840, 1254, 1206, 63, 3243, 275, 283, 21529, 13, 548, 1103, 16310, 13, 2676, 1103, 26840, 7, 199, 7569, 63, 3243, 275, 283, 21529, 13, 548, 1103, 16310, 13, 2676, 1103, 2219, 7, 421, 199, 318, 3378, 774, 8, 396, 63, 515, 304, 523, 408, 16291, 282, 511, 436, 2529, 2399, 4458, 1233, 14, 339, 30451, 314, 2295, 883, 506, 1255, 687, 1263, 2082, 14, 1010, 1163, 5932, 12, 652, 1630, 440, 272, 13097, 14, 819, 3033, 26, 272, 511, 63, 515, 26, 6912, 370, 511, 31172, 14, 819, 1803, 26, 272, 710, 4458, 1233, 687, 314, 511, 2112, 14, 523, 408, 819, 870, 1557, 78, 9602, 450, 83, 1275, 1275, 1275, 60, 78, 7, 450, 511, 63, 515, 819, 327, 16280, 1987, 4805, 315, 13738, 402, 314, 570, 536, 370, 5126, 24634, 1183, 3879, 282, 570, 543, 523, 327, 314, 2011, 536, 315, 2005, 1163, 2082, 340, 511, 63, 515, 4898, 2951, 282, 570, 536, 14, 523, 372, 747, 14, 2253, 8, 736, 14, 515, 14, 904, 14078, 511, 63, 515, 430, 421, 199, 318, 3378, 2925, 8, 396, 63, 3771, 304, 523, 408, 16291, 1006, 2295, 2013, 701, 511, 63, 3771, 14, 819, 3033, 26, 272, 511, 63, 3771, 26, 437, 769, 402, 3792, 370, 511, 31172, 14, 819, 1803, 26, 272, 378, 340, 1006, 2295, 787, 9512, 14, 272, 413, 340, 2005, 2295, 2449, 12, 503, 340, 2337, 365, 376, 1125, 14, 523, 408, 819, 340, 440, 511, 63, 3771, 503, 822, 8, 396, 63, 3771, 9, 665, 413, 26, 272, 372, 413, 819, 870, 283, 3601, 314, 2569, 2295, 370, 1255, 4881, 523, 367, 511, 315, 511, 63, 3771, 26, 272, 870, 1557, 84, 5, 83, 7, 450, 511, 819, 327, 3378, 1006, 2295, 436, 295, 6334, 5204, 626, 3405, 14, 523, 3405, 63, 2219, 275, 359, 84, 367, 307, 315, 511, 63, 3771, 340, 3378, 774, 8, 84, 1874, 819, 870, 1557, 78, 60, 78, 5, 83, 511, 31172, 4898, 1255, 3530, 450, 822, 8, 396, 63, 3771, 9, 819, 3405, 63, 396, 63, 835, 275, 822, 8, 4892, 63, 2219, 9, 523, 340, 3405, 63, 396, 63, 835, 26, 272, 327, 31289, 314, 31172, 626, 3405, 880, 314, 922, 883, 315, 27174, 323, 3062, 14, 272, 870, 283, 12299, 11213, 272, 870, 283, 1918, 2569, 450, 83, 2295, 3405, 3427, 78, 7, 450, 3405, 63, 396, 63, 835, 272, 367, 511, 315, 3405, 63, 2219, 26, 489, 870, 511, 272, 372, 413, 523, 587, 26, 272, 327, 3091, 12, 2337, 365, 7179, 14, 272, 340, 511, 63, 3771, 26, 489, 870, 283, 2422, 402, 3062, 510, 32032, 11213, 272, 372, 378, 421, 199, 318, 2372, 2925, 607, 17051, 8, 396, 63, 3220, 304, 523, 408, 3407, 282, 769, 402, 1006, 4137, 511, 31172, 315, 511, 63, 3220, 14, 339, 12078, 440, 2754, 24799, 14, 819, 3033, 26, 272, 511, 63, 3220, 26, 437, 769, 402, 6602, 370, 2754, 14, 819, 1803, 26, 272, 3820, 402, 1006, 4137, 2295, 14, 523, 408, 819, 2295, 275, 942, 819, 367, 511, 63, 694, 315, 511, 63, 3220, 26, 272, 327, 3645, 2935, 1637, 14, 7374, 880, 1865, 365, 23331, 3294, 436, 12850, 25286, 14, 272, 1584, 275, 2935, 1637, 14, 7374, 8, 396, 63, 694, 9, 339, 367, 511, 63, 493, 315, 1584, 26, 489, 340, 511, 63, 493, 14, 4130, 8, 2864, 63, 21623, 63, 50, 15467, 304, 267, 3847, 63, 515, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 511, 63, 493, 9, 267, 340, 747, 14, 515, 14, 6292, 8, 6188, 63, 515, 304, 881, 2295, 847, 359, 6188, 63, 515, 61, 819, 372, 2295, 199, 199, 3, 3378, 282, 4137, 511, 1380, 314, 859, 365, 1255, 5370, 14, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 3820, 402, 3792, 626, 1395, 4137, 2295, 370, 1255, 14, 523, 7606, 63, 16133, 63, 2219, 275, 359, 840, 1254, 1206, 63, 3243, 12, 7393, 51, 63, 3243, 61, 819, 2295, 63, 475, 63, 1065, 275, 2372, 2925, 607, 17051, 8, 3220, 63, 16133, 63, 2219, 9, 819, 3378, 2925, 8, 2219, 63, 475, 63, 1065, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
borysiasty/inasafe
safe/impact_functions/generic/classified_polygon_people/metadata_definitions.py
1
4522
# coding=utf-8 """InaSAFE Disaster risk tool by Australian Aid - Classified Polygon on Land Cover Metadata Definitions. Contact : ole.moller.nielsen@gmail.com .. note:: 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. """ __author__ = 'Samweli Twesa Mwakisambwe "Samweli" <smwltwesa6@gmail.com>' __date__ = '8/6/15' from safe.common.utilities import OrderedDict from safe.impact_functions.impact_function_metadata import \ ImpactFunctionMetadata from safe.definitions import ( area_name_field, area_id_field, exposure_population, hazard_all, hazard_category_single_event, hazard_category_multiple_event, generic_vector_hazard_classes, flood_vector_hazard_classes, layer_mode_classified, layer_mode_continuous, layer_geometry_polygon, count_exposure_unit ) from safe.defaults import ( default_minimum_needs, default_gender_postprocessor, age_postprocessor, minimum_needs_selector) from safe.utilities.i18n import tr class ClassifiedPolygonHazardPolygonPeopleFunctionMetadata( ImpactFunctionMetadata): @staticmethod def as_dict(): """Return metadata as a dictionary. This is a static method. You can use it to get the metadata in dictionary format for an impact function. :returns: A dictionary representing all the metadata for the concrete impact function. :rtype: dict """ dict_meta = { 'id': 'ClassifiedPolygonHazardPolygonPeopleFunction', 'name': tr('Classified polygon hazard on polygon people'), 'impact': tr('Be affected'), 'title': tr('Be affected'), 'function_type': 'qgis2.0', 'author': 'Samweli Twesa Mwakisambwe(smwltwesa6@gmail.com)', 'date_implemented': '06/08/2015', 'overview': tr( 'To assess the impact of each hazard zone on polygon people.'), 'detailed_description': '', 'hazard_input': tr( 'The hazard layer must be a polygon layer. This layer ' 'must have an attribute representing the hazard ' 'zone that can be specified in the impact function options.'), 'exposure_input': tr( 'Vector polygon layer where each ' 'polygon represents a type of area where people lives.'), 'output': tr( 'A vector layer of areas polygons with each tagged ' 'according to the hazard zone in which it falls.'), 'actions': tr( 'Provide details about how big area fall within ' 'each hazard zone.'), 'limitations': [], 'citations': [], 'legend_title': '', 'legend_units': '', 'legend_notes': '', 'map_title': tr('Affected People'), 'layer_name': tr('People affected'), 'layer_requirements': { 'hazard': { 'layer_mode': layer_mode_classified, 'layer_geometries': [layer_geometry_polygon], 'hazard_categories': [ hazard_category_single_event, hazard_category_multiple_event ], 'hazard_types': hazard_all, 'continuous_hazard_units': [], 'vector_hazard_classifications': [ generic_vector_hazard_classes, flood_vector_hazard_classes], 'raster_hazard_classifications': [], 'additional_keywords': [] }, 'exposure': { 'layer_mode': layer_mode_continuous, 'layer_geometries': [layer_geometry_polygon], 'exposure_types': [exposure_population], 'exposure_units': [count_exposure_unit], 'exposure_class_fields': [], 'additional_keywords': [ area_id_field, area_name_field ] } }, 'parameters': OrderedDict([ ('minimum needs', default_minimum_needs())]) } return dict_meta
gpl-3.0
[ 3, 2803, 29, 1624, 13, 24, 199, 624, 607, 65, 27657, 5289, 2311, 22633, 4744, 701, 437, 11409, 25861, 437, 344, 446, 8465, 2608, 1290, 17560, 641, 199, 44, 460, 1849, 422, 16160, 22659, 852, 14, 199, 199, 14499, 520, 312, 274, 14, 16924, 1435, 14, 8445, 352, 2464, 32, 6799, 14, 957, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1362, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1362, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 1362, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 51, 455, 1129, 317, 377, 87, 397, 65, 603, 758, 75, 374, 11020, 1129, 298, 51, 455, 1129, 317, 2, 665, 3300, 87, 4116, 87, 397, 65, 22, 32, 6799, 14, 957, 3524, 199, 363, 602, 363, 275, 283, 24, 15, 22, 15, 1046, 7, 199, 199, 504, 5048, 14, 2330, 14, 16355, 492, 8773, 199, 504, 5048, 14, 31822, 63, 5777, 14, 31822, 63, 1593, 63, 2343, 492, 971, 272, 8362, 2442, 3481, 5142, 199, 504, 5048, 14, 15388, 492, 334, 272, 9150, 63, 354, 63, 698, 12, 272, 9150, 63, 344, 63, 698, 12, 272, 30105, 63, 16003, 12, 272, 394, 32145, 63, 452, 12, 272, 394, 32145, 63, 3710, 63, 4780, 63, 1430, 12, 272, 394, 32145, 63, 3710, 63, 6048, 63, 1430, 12, 272, 7809, 63, 4106, 63, 22133, 1005, 63, 2888, 12, 272, 289, 21703, 63, 4106, 63, 22133, 1005, 63, 2888, 12, 272, 4045, 63, 632, 63, 12334, 1290, 12, 272, 4045, 63, 632, 63, 23458, 12, 272, 4045, 63, 7660, 63, 16295, 12, 272, 2338, 63, 28480, 63, 3248, 199, 9, 199, 504, 5048, 14, 4322, 492, 334, 272, 849, 63, 10700, 63, 10065, 12, 272, 849, 63, 15791, 63, 1932, 6459, 12, 272, 11437, 63, 1932, 6459, 12, 272, 7481, 63, 10065, 63, 6662, 9, 199, 504, 5048, 14, 16355, 14, 73, 1085, 78, 492, 5651, 421, 199, 533, 8465, 2608, 1290, 12367, 40, 32145, 12367, 8070, 7939, 3481, 5142, 8, 267, 8362, 2442, 3481, 5142, 304, 339, 768, 4639, 272, 347, 465, 63, 807, 837, 267, 408, 1767, 3341, 465, 282, 2600, 14, 398, 961, 365, 282, 2955, 1083, 14, 2047, 883, 675, 652, 370, 664, 314, 3341, 315, 267, 2600, 1475, 367, 376, 25568, 805, 14, 398, 520, 5808, 26, 437, 2600, 6144, 1006, 314, 3341, 367, 314, 288, 13801, 25568, 805, 14, 267, 520, 4500, 26, 1211, 267, 408, 267, 1211, 63, 2024, 275, 469, 288, 283, 344, 356, 283, 30722, 1290, 12367, 40, 32145, 12367, 8070, 7939, 3481, 297, 288, 283, 354, 356, 5651, 360, 30722, 1290, 17248, 394, 32145, 641, 17248, 13135, 659, 288, 283, 31822, 356, 5651, 360, 3655, 16955, 659, 288, 283, 1213, 356, 5651, 360, 3655, 16955, 659, 288, 283, 1593, 63, 466, 356, 283, 25325, 18, 14, 16, 297, 288, 283, 2502, 356, 283, 51, 455, 1129, 317, 377, 87, 397, 65, 603, 758, 75, 374, 11020, 1129, 8, 3300, 87, 4116, 87, 397, 65, 22, 32, 6799, 14, 957, 3196, 288, 283, 602, 63, 13825, 356, 283, 1690, 15, 2036, 15, 7806, 297, 288, 283, 21753, 356, 5651, 8, 355, 283, 1378, 465, 5480, 314, 25568, 402, 1924, 394, 32145, 5718, 641, 17248, 13135, 8038, 288, 283, 19170, 63, 1802, 356, 3260, 288, 283, 22133, 1005, 63, 1210, 356, 5651, 8, 355, 283, 1918, 394, 32145, 4045, 1471, 506, 282, 17248, 4045, 14, 961, 4045, 283, 355, 283, 7790, 1172, 376, 2225, 6144, 314, 394, 32145, 283, 355, 283, 2619, 626, 883, 506, 2013, 315, 314, 25568, 805, 1511, 8038, 288, 283, 28480, 63, 1210, 356, 5651, 8, 355, 283, 3646, 17248, 4045, 2382, 1924, 283, 355, 283, 16295, 8469, 282, 730, 402, 9150, 2382, 13135, 27576, 8038, 288, 283, 1199, 356, 5651, 8, 355, 283, 33, 5477, 4045, 402, 787, 305, 30658, 543, 1924, 20018, 283, 355, 283, 645, 5422, 370, 314, 394, 32145, 5718, 315, 1314, 652, 26945, 8038, 288, 283, 3723, 356, 5651, 8, 355, 283, 25107, 2436, 3595, 4212, 7282, 9150, 11264, 4453, 283, 355, 283, 10885, 394, 32145, 5718, 8038, 288, 283, 3097, 1298, 356, 990, 288, 283, 14422, 1298, 356, 990, 288, 283, 10231, 63, 1213, 356, 3260, 288, 283, 10231, 63, 5260, 356, 3260, 288, 283, 10231, 63, 5983, 356, 3260, 288, 283, 1130, 63, 1213, 356, 5651, 360, 19256, 6201, 11379, 7939, 659, 288, 283, 1897, 63, 354, 356, 5651, 360, 8070, 7939, 16955, 659, 288, 283, 1897, 63, 7538, 356, 469, 355, 283, 22133, 1005, 356, 469, 490, 283, 1897, 63, 632, 356, 4045, 63, 632, 63, 12334, 1290, 12, 490, 283, 1897, 63, 21626, 356, 359, 1897, 63, 7660, 63, 16295, 467, 490, 283, 22133, 1005, 63, 8906, 356, 359, 717, 394, 32145, 63, 3710, 63, 4780, 63, 1430, 12, 717, 394, 32145, 63, 3710, 63, 6048, 63, 1430, 490, 2156, 490, 283, 22133, 1005, 63, 1313, 356, 394, 32145, 63, 452, 12, 490, 283, 23458, 63, 22133, 1005, 63, 5260, 356, 990, 490, 283, 4106, 63, 22133, 1005, 63, 14368, 83, 356, 359, 717, 7809, 63, 4106, 63, 22133, 1005, 63, 2888, 12, 717, 289, 21703, 63, 4106, 63, 22133, 1005, 63, 2888, 467, 490, 283, 20876, 63, 22133, 1005, 63, 14368, 83, 356, 990, 490, 283, 8460, 63, 7511, 356, 942, 355, 1660, 355, 283, 28480, 356, 469, 490, 283, 1897, 63, 632, 356, 4045, 63, 632, 63, 23458, 12, 490, 283, 1897, 63, 21626, 356, 359, 1897, 63, 7660, 63, 16295, 467, 490, 283, 28480, 63, 1313, 356, 359, 28480, 63, 16003, 467, 490, 283, 28480, 63, 5260, 356, 359, 835, 63, 28480, 63, 3248, 467, 490, 283, 28480, 63, 533, 63, 955, 356, 990, 490, 283, 8460, 63, 7511, 356, 359, 717, 9150, 63, 344, 63, 698, 12, 717, 9150, 63, 354, 63, 698, 490, 1622, 355, 789, 288, 1660, 288, 283, 3214, 356, 8773, 779, 355, 661, 10700, 4839, 297, 849, 63, 10700, 63, 10065, 30719, 267, 789, 267, 372, 1211, 63, 2024, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 29, 1624, 13, 24, 199, 624, 607, 65, 27657, 5289, 2311, 22633, 4744, 701, 437, 11409, 25861, 437, 344, 446, 8465, 2608, 1290, 17560, 641, 199, 44, 460, 1849, 422, 16160, 22659, 852, 14, 199, 199, 14499, 520, 312, 274, 14, 16924, 1435, 14, 8445, 352, 2464, 32, 6799, 14, 957, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 1362, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 1362, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 1362, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 51, 455, 1129, 317, 377, 87, 397, 65, 603, 758, 75, 374, 11020, 1129, 298, 51, 455, 1129, 317, 2, 665, 3300, 87, 4116, 87, 397, 65, 22, 32, 6799, 14, 957, 3524, 199, 363, 602, 363, 275, 283, 24, 15, 22, 15, 1046, 7, 199, 199, 504, 5048, 14, 2330, 14, 16355, 492, 8773, 199, 504, 5048, 14, 31822, 63, 5777, 14, 31822, 63, 1593, 63, 2343, 492, 971, 272, 8362, 2442, 3481, 5142, 199, 504, 5048, 14, 15388, 492, 334, 272, 9150, 63, 354, 63, 698, 12, 272, 9150, 63, 344, 63, 698, 12, 272, 30105, 63, 16003, 12, 272, 394, 32145, 63, 452, 12, 272, 394, 32145, 63, 3710, 63, 4780, 63, 1430, 12, 272, 394, 32145, 63, 3710, 63, 6048, 63, 1430, 12, 272, 7809, 63, 4106, 63, 22133, 1005, 63, 2888, 12, 272, 289, 21703, 63, 4106, 63, 22133, 1005, 63, 2888, 12, 272, 4045, 63, 632, 63, 12334, 1290, 12, 272, 4045, 63, 632, 63, 23458, 12, 272, 4045, 63, 7660, 63, 16295, 12, 272, 2338, 63, 28480, 63, 3248, 199, 9, 199, 504, 5048, 14, 4322, 492, 334, 272, 849, 63, 10700, 63, 10065, 12, 272, 849, 63, 15791, 63, 1932, 6459, 12, 272, 11437, 63, 1932, 6459, 12, 272, 7481, 63, 10065, 63, 6662, 9, 199, 504, 5048, 14, 16355, 14, 73, 1085, 78, 492, 5651, 421, 199, 533, 8465, 2608, 1290, 12367, 40, 32145, 12367, 8070, 7939, 3481, 5142, 8, 267, 8362, 2442, 3481, 5142, 304, 339, 768, 4639, 272, 347, 465, 63, 807, 837, 267, 408, 1767, 3341, 465, 282, 2600, 14, 398, 961, 365, 282, 2955, 1083, 14, 2047, 883, 675, 652, 370, 664, 314, 3341, 315, 267, 2600, 1475, 367, 376, 25568, 805, 14, 398, 520, 5808, 26, 437, 2600, 6144, 1006, 314, 3341, 367, 314, 288, 13801, 25568, 805, 14, 267, 520, 4500, 26, 1211, 267, 408, 267, 1211, 63, 2024, 275, 469, 288, 283, 344, 356, 283, 30722, 1290, 12367, 40, 32145, 12367, 8070, 7939, 3481, 297, 288, 283, 354, 356, 5651, 360, 30722, 1290, 17248, 394, 32145, 641, 17248, 13135, 659, 288, 283, 31822, 356, 5651, 360, 3655, 16955, 659, 288, 283, 1213, 356, 5651, 360, 3655, 16955, 659, 288, 283, 1593, 63, 466, 356, 283, 25325, 18, 14, 16, 297, 288, 283, 2502, 356, 283, 51, 455, 1129, 317, 377, 87, 397, 65, 603, 758, 75, 374, 11020, 1129, 8, 3300, 87, 4116, 87, 397, 65, 22, 32, 6799, 14, 957, 3196, 288, 283, 602, 63, 13825, 356, 283, 1690, 15, 2036, 15, 7806, 297, 288, 283, 21753, 356, 5651, 8, 355, 283, 1378, 465, 5480, 314, 25568, 402, 1924, 394, 32145, 5718, 641, 17248, 13135, 8038, 288, 283, 19170, 63, 1802, 356, 3260, 288, 283, 22133, 1005, 63, 1210, 356, 5651, 8, 355, 283, 1918, 394, 32145, 4045, 1471, 506, 282, 17248, 4045, 14, 961, 4045, 283, 355, 283, 7790, 1172, 376, 2225, 6144, 314, 394, 32145, 283, 355, 283, 2619, 626, 883, 506, 2013, 315, 314, 25568, 805, 1511, 8038, 288, 283, 28480, 63, 1210, 356, 5651, 8, 355, 283, 3646, 17248, 4045, 2382, 1924, 283, 355, 283, 16295, 8469, 282, 730, 402, 9150, 2382, 13135, 27576, 8038, 288, 283, 1199, 356, 5651, 8, 355, 283, 33, 5477, 4045, 402, 787, 305, 30658, 543, 1924, 20018, 283, 355, 283, 645, 5422, 370, 314, 394, 32145, 5718, 315, 1314, 652, 26945, 8038, 288, 283, 3723, 356, 5651, 8, 355, 283, 25107, 2436, 3595, 4212, 7282, 9150, 11264, 4453, 283, 355, 283, 10885, 394, 32145, 5718, 8038, 288, 283, 3097, 1298, 356, 990, 288, 283, 14422, 1298, 356, 990, 288, 283, 10231, 63, 1213, 356, 3260, 288, 283, 10231, 63, 5260, 356, 3260, 288, 283, 10231, 63, 5983, 356, 3260, 288, 283, 1130, 63, 1213, 356, 5651, 360, 19256, 6201, 11379, 7939, 659, 288, 283, 1897, 63, 354, 356, 5651, 360, 8070, 7939, 16955, 659, 288, 283, 1897, 63, 7538, 356, 469, 355, 283, 22133, 1005, 356, 469, 490, 283, 1897, 63, 632, 356, 4045, 63, 632, 63, 12334, 1290, 12, 490, 283, 1897, 63, 21626, 356, 359, 1897, 63, 7660, 63, 16295, 467, 490, 283, 22133, 1005, 63, 8906, 356, 359, 717, 394, 32145, 63, 3710, 63, 4780, 63, 1430, 12, 717, 394, 32145, 63, 3710, 63, 6048, 63, 1430, 490, 2156, 490, 283, 22133, 1005, 63, 1313, 356, 394, 32145, 63, 452, 12, 490, 283, 23458, 63, 22133, 1005, 63, 5260, 356, 990, 490, 283, 4106, 63, 22133, 1005, 63, 14368, 83, 356, 359, 717, 7809, 63, 4106, 63, 22133, 1005, 63, 2888, 12, 717, 289, 21703, 63, 4106, 63, 22133, 1005, 63, 2888, 467, 490, 283, 20876, 63, 22133, 1005, 63, 14368, 83, 356, 990, 490, 283, 8460, 63, 7511, 356, 942, 355, 1660, 355, 283, 28480, 356, 469, 490, 283, 1897, 63, 632, 356, 4045, 63, 632, 63, 23458, 12, 490, 283, 1897, 63, 21626, 356, 359, 1897, 63, 7660, 63, 16295, 467, 490, 283, 28480, 63, 1313, 356, 359, 28480, 63, 16003, 467, 490, 283, 28480, 63, 5260, 356, 359, 835, 63, 28480, 63, 3248, 467, 490, 283, 28480, 63, 533, 63, 955, 356, 990, 490, 283, 8460, 63, 7511, 356, 359, 717, 9150, 63, 344, 63, 698, 12, 717, 9150, 63, 354, 63, 698, 490, 1622, 355, 789, 288, 1660, 288, 283, 3214, 356, 8773, 779, 355, 661, 10700, 4839, 297, 849, 63, 10700, 63, 10065, 30719, 267, 789, 267, 372, 1211, 63, 2024, 199, 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,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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, 0, 0, 0, 0, 0, 0, 0 ]
kotejante/python-moodle
examples/get_user.py
1
1498
# -*- encoding: utf-8 -*- ############################################################################## # # Moodle Webservice # Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. # Raimon Esteve <resteve@zikzakmedia.com> # Jesus Martín <jmartin@zikzakmedia.com> # $Id$ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from config import * from moodle_ws_client import moodle mdl = moodle.MDL() # xmlrpc Connection print mdl.conn_xmlrpc(server) """ Get user """ criteria = [{'key':'username','value':'usuario'}] print mdl.get_users(server, criteria) # Enrol a user in a course enrols =[{ 'roleid': 1, 'userid': 18, 'courseid': 18, }] print mdl.enrol_users(server, enrols)
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 3930, 364, 274, 6001, 1364, 199, 3, 259, 1898, 334, 67, 9, 7760, 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, 9668, 3898, 1017, 265, 662, 1597, 432, 665, 470, 266, 432, 32, 90, 3258, 90, 1151, 4603, 14, 957, 30, 199, 3, 9668, 1603, 397, 527, 603, 580, 13676, 78, 665, 74, 77, 26788, 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, 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, 1101, 492, 627, 199, 504, 1303, 364, 274, 63, 3569, 63, 1258, 492, 1303, 364, 274, 199, 199, 1064, 76, 275, 1303, 364, 274, 14, 5127, 44, 342, 199, 3, 15432, 8113, 199, 1361, 333, 5030, 14, 1631, 63, 17596, 8, 1000, 9, 199, 199, 624, 199, 1002, 922, 199, 624, 199, 199, 20525, 275, 9016, 498, 5242, 2473, 1673, 585, 5242, 527, 85, 6936, 20623, 199, 1361, 333, 5030, 14, 362, 63, 3707, 8, 1000, 12, 15647, 9, 199, 199, 3, 3447, 8459, 282, 922, 315, 282, 2518, 199, 287, 293, 478, 275, 59, 91, 272, 283, 3756, 344, 356, 413, 12, 272, 283, 19737, 356, 6155, 12, 272, 283, 1972, 344, 356, 6155, 12, 272, 14877, 199, 1361, 333, 5030, 14, 287, 8459, 63, 3707, 8, 1000, 12, 655, 293, 478, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3930, 364, 274, 6001, 1364, 199, 3, 259, 1898, 334, 67, 9, 7760, 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, 9668, 3898, 1017, 265, 662, 1597, 432, 665, 470, 266, 432, 32, 90, 3258, 90, 1151, 4603, 14, 957, 30, 199, 3, 9668, 1603, 397, 527, 603, 580, 13676, 78, 665, 74, 77, 26788, 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, 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, 1101, 492, 627, 199, 504, 1303, 364, 274, 63, 3569, 63, 1258, 492, 1303, 364, 274, 199, 199, 1064, 76, 275, 1303, 364, 274, 14, 5127, 44, 342, 199, 3, 15432, 8113, 199, 1361, 333, 5030, 14, 1631, 63, 17596, 8, 1000, 9, 199, 199, 624, 199, 1002, 922, 199, 624, 199, 199, 20525, 275, 9016, 498, 5242, 2473, 1673, 585, 5242, 527, 85, 6936, 20623, 199, 1361, 333, 5030, 14, 362, 63, 3707, 8, 1000, 12, 15647, 9, 199, 199, 3, 3447, 8459, 282, 922, 315, 282, 2518, 199, 287, 293, 478, 275, 59, 91, 272, 283, 3756, 344, 356, 413, 12, 272, 283, 19737, 356, 6155, 12, 272, 283, 1972, 344, 356, 6155, 12, 272, 14877, 199, 1361, 333, 5030, 14, 287, 8459, 63, 3707, 8, 1000, 12, 655, 293, 478, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
luhanhan/horizon
openstack_dashboard/dashboards/project/data_processing/clusters/tests.py
26
2651
# 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 django.core.urlresolvers import reverse from django import http from mox import IsA # noqa from openstack_dashboard import api from openstack_dashboard.test import helpers as test INDEX_URL = reverse('horizon:project:data_processing.clusters:index') DETAILS_URL = reverse( 'horizon:project:data_processing.clusters:details', args=['id']) class DataProcessingClusterTests(test.TestCase): @test.create_stubs({api.sahara: ('cluster_list',)}) def test_index(self): api.sahara.cluster_list(IsA(http.HttpRequest), {}) \ .AndReturn(self.clusters.list()) self.mox.ReplayAll() res = self.client.get(INDEX_URL) self.assertTemplateUsed( res, 'project/data_processing.clusters/clusters.html') self.assertContains(res, 'Clusters') self.assertContains(res, 'Name') @test.create_stubs({api.sahara: ('cluster_template_list', 'image_list')}) def test_launch_cluster_get_nodata(self): api.sahara.cluster_template_list(IsA(http.HttpRequest)) \ .AndReturn([]) api.sahara.image_list(IsA(http.HttpRequest)) \ .AndReturn([]) self.mox.ReplayAll() url = reverse( 'horizon:project:data_processing.clusters:configure-cluster') res = self.client.get("%s?plugin_name=shoes&hadoop_version=1.1" % url) self.assertContains(res, "No Images Available") self.assertContains(res, "No Templates Available") @test.create_stubs({api.sahara: ('cluster_list', 'cluster_delete')}) def test_delete(self): cluster = self.clusters.first() api.sahara.cluster_list(IsA(http.HttpRequest), {}) \ .AndReturn(self.clusters.list()) api.sahara.cluster_delete(IsA(http.HttpRequest), cluster.id) self.mox.ReplayAll() form_data = {'action': 'clusters__delete__%s' % cluster.id} res = self.client.post(INDEX_URL, form_data) self.assertNoFormErrors(res) self.assertRedirectsNoFollow(res, INDEX_URL) self.assertMessageCount(success=1)
apache-2.0
[ 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 492, 1455, 199, 199, 504, 18610, 492, 29719, 221, 327, 8151, 199, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 421, 199, 10215, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 576, 63, 6338, 14, 9170, 26, 1080, 358, 199, 25081, 51, 63, 2632, 275, 3837, 8, 272, 283, 16561, 26, 1715, 26, 576, 63, 6338, 14, 9170, 26, 5087, 297, 1249, 2968, 344, 1105, 421, 199, 533, 3918, 9589, 9581, 2925, 8, 396, 14, 1746, 304, 272, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 2231, 27314, 26, 661, 4201, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 8, 277, 304, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 5009, 971, 288, 1275, 8572, 8, 277, 14, 9170, 14, 513, 1012, 267, 291, 14, 6625, 14, 12982, 342, 267, 522, 275, 291, 14, 1258, 14, 362, 8, 10215, 63, 2632, 9, 267, 291, 14, 19661, 8, 288, 522, 12, 283, 1715, 15, 576, 63, 6338, 14, 9170, 15, 9170, 14, 1360, 358, 267, 291, 14, 9535, 8, 470, 12, 283, 1968, 6811, 358, 267, 291, 14, 9535, 8, 470, 12, 283, 985, 358, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 2231, 27314, 26, 661, 4201, 63, 1160, 63, 513, 297, 283, 1569, 63, 513, 22220, 272, 347, 511, 63, 9850, 63, 4201, 63, 362, 63, 18950, 419, 8, 277, 304, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 1160, 63, 513, 8, 14104, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 4157, 267, 2986, 14, 2231, 27314, 14, 1569, 63, 513, 8, 14104, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 4157, 267, 291, 14, 6625, 14, 12982, 342, 267, 1166, 275, 3837, 8, 288, 283, 16561, 26, 1715, 26, 576, 63, 6338, 14, 9170, 26, 6472, 13, 4201, 358, 267, 522, 275, 291, 14, 1258, 14, 362, 3647, 83, 31, 2718, 63, 354, 29, 13927, 397, 6, 15449, 63, 1023, 29, 17, 14, 17, 2, 450, 1166, 9, 267, 291, 14, 9535, 8, 470, 12, 298, 1944, 32658, 23840, 531, 267, 291, 14, 9535, 8, 470, 12, 298, 1944, 31273, 23840, 531, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 2231, 27314, 26, 661, 4201, 63, 513, 297, 3660, 283, 4201, 63, 1807, 22220, 272, 347, 511, 63, 1807, 8, 277, 304, 267, 4350, 275, 291, 14, 9170, 14, 2246, 342, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 5009, 971, 288, 1275, 8572, 8, 277, 14, 9170, 14, 513, 1012, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 1807, 8, 14104, 8, 1014, 14, 10441, 395, 4350, 14, 344, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 1824, 63, 576, 275, 791, 1287, 356, 283, 9170, 363, 1807, 363, 5, 83, 7, 450, 4350, 14, 344, 93, 267, 522, 275, 291, 14, 1258, 14, 1932, 8, 10215, 63, 2632, 12, 1824, 63, 576, 9, 398, 291, 14, 22389, 2821, 9298, 8, 470, 9, 267, 291, 14, 17466, 1944, 18696, 8, 470, 12, 17055, 63, 2632, 9, 267, 291, 14, 479, 2209, 2353, 8, 3742, 29, 17, 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 ]
[ 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 492, 1455, 199, 199, 504, 18610, 492, 29719, 221, 327, 8151, 199, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 421, 199, 10215, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 576, 63, 6338, 14, 9170, 26, 1080, 358, 199, 25081, 51, 63, 2632, 275, 3837, 8, 272, 283, 16561, 26, 1715, 26, 576, 63, 6338, 14, 9170, 26, 5087, 297, 1249, 2968, 344, 1105, 421, 199, 533, 3918, 9589, 9581, 2925, 8, 396, 14, 1746, 304, 272, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 2231, 27314, 26, 661, 4201, 63, 513, 9538, 1552, 272, 347, 511, 63, 1080, 8, 277, 304, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 5009, 971, 288, 1275, 8572, 8, 277, 14, 9170, 14, 513, 1012, 267, 291, 14, 6625, 14, 12982, 342, 267, 522, 275, 291, 14, 1258, 14, 362, 8, 10215, 63, 2632, 9, 267, 291, 14, 19661, 8, 288, 522, 12, 283, 1715, 15, 576, 63, 6338, 14, 9170, 15, 9170, 14, 1360, 358, 267, 291, 14, 9535, 8, 470, 12, 283, 1968, 6811, 358, 267, 291, 14, 9535, 8, 470, 12, 283, 985, 358, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 2231, 27314, 26, 661, 4201, 63, 1160, 63, 513, 297, 283, 1569, 63, 513, 22220, 272, 347, 511, 63, 9850, 63, 4201, 63, 362, 63, 18950, 419, 8, 277, 304, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 1160, 63, 513, 8, 14104, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 4157, 267, 2986, 14, 2231, 27314, 14, 1569, 63, 513, 8, 14104, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 4157, 267, 291, 14, 6625, 14, 12982, 342, 267, 1166, 275, 3837, 8, 288, 283, 16561, 26, 1715, 26, 576, 63, 6338, 14, 9170, 26, 6472, 13, 4201, 358, 267, 522, 275, 291, 14, 1258, 14, 362, 3647, 83, 31, 2718, 63, 354, 29, 13927, 397, 6, 15449, 63, 1023, 29, 17, 14, 17, 2, 450, 1166, 9, 267, 291, 14, 9535, 8, 470, 12, 298, 1944, 32658, 23840, 531, 267, 291, 14, 9535, 8, 470, 12, 298, 1944, 31273, 23840, 531, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 2231, 27314, 26, 661, 4201, 63, 513, 297, 3660, 283, 4201, 63, 1807, 22220, 272, 347, 511, 63, 1807, 8, 277, 304, 267, 4350, 275, 291, 14, 9170, 14, 2246, 342, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 513, 8, 14104, 8, 1014, 14, 10441, 395, 5009, 971, 288, 1275, 8572, 8, 277, 14, 9170, 14, 513, 1012, 267, 2986, 14, 2231, 27314, 14, 4201, 63, 1807, 8, 14104, 8, 1014, 14, 10441, 395, 4350, 14, 344, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 1824, 63, 576, 275, 791, 1287, 356, 283, 9170, 363, 1807, 363, 5, 83, 7, 450, 4350, 14, 344, 93, 267, 522, 275, 291, 14, 1258, 14, 1932, 8, 10215, 63, 2632, 12, 1824, 63, 576, 9, 398, 291, 14, 22389, 2821, 9298, 8, 470, 9, 267, 291, 14, 17466, 1944, 18696, 8, 470, 12, 17055, 63, 2632, 9, 267, 291, 14, 479, 2209, 2353, 8, 3742, 29, 17, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jcanizales/grpc
src/python/grpcio_tests/tests/unit/framework/common/__init__.py
1496
1530
# Copyright 2015, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bsd-3-clause
[ 3, 1898, 6900, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
xombiemp/CouchPotatoServer
libs/dateutil/zoneinfo/__init__.py
144
2773
# -*- coding: utf-8 -*- """ Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard Python datetime module. """ from dateutil.tz import tzfile from tarfile import TarFile import os __author__ = "Tomi Pieviläinen <tomi.pievilainen@iki.fi>" __license__ = "Simplified BSD" __all__ = ["setcachesize", "gettz", "rebuild"] CACHE = [] CACHESIZE = 10 class tzfile(tzfile): def __reduce__(self): return (gettz, (self._filename,)) def getzoneinfofile(): filenames = sorted(os.listdir(os.path.join(os.path.dirname(__file__)))) filenames.reverse() for entry in filenames: if entry.startswith("zoneinfo") and ".tar." in entry: return os.path.join(os.path.dirname(__file__), entry) return None ZONEINFOFILE = getzoneinfofile() del getzoneinfofile def setcachesize(size): global CACHESIZE, CACHE CACHESIZE = size del CACHE[size:] def gettz(name): tzinfo = None if ZONEINFOFILE: for cachedname, tzinfo in CACHE: if cachedname == name: break else: tf = TarFile.open(ZONEINFOFILE) try: zonefile = tf.extractfile(name) except KeyError: tzinfo = None else: tzinfo = tzfile(zonefile) tf.close() CACHE.insert(0, (name, tzinfo)) del CACHE[CACHESIZE:] return tzinfo def rebuild(filename, tag=None, format="gz"): import tempfile, shutil tmpdir = tempfile.mkdtemp() zonedir = os.path.join(tmpdir, "zoneinfo") moduledir = os.path.dirname(__file__) if tag: tag = "-"+tag targetname = "zoneinfo%s.tar.%s" % (tag, format) try: tf = TarFile.open(filename) # The "backwards" zone file contains links to other files, so must be # processed as last for name in sorted(tf.getnames(), key=lambda k: k != "backward" and k or "z"): if not (name.endswith(".sh") or name.endswith(".tab") or name == "leapseconds"): tf.extract(name, tmpdir) filepath = os.path.join(tmpdir, name) os.system("zic -d %s %s" % (zonedir, filepath)) tf.close() target = os.path.join(moduledir, targetname) for entry in os.listdir(moduledir): if entry.startswith("zoneinfo") and ".tar." in entry: os.unlink(os.path.join(moduledir, entry)) tf = TarFile.open(target, "w:%s" % format) for entry in os.listdir(zonedir): entrypath = os.path.join(zonedir, entry) tf.add(entrypath, entry) tf.close() finally: shutil.rmtree(tmpdir)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 7384, 334, 67, 9, 13004, 13, 9397, 221, 598, 833, 1214, 79, 653, 1873, 278, 23009, 665, 71, 833, 1214, 79, 32, 78, 1873, 278, 23009, 14, 846, 30, 199, 199, 2765, 859, 32563, 5478, 370, 314, 4465, 2018, 199, 2083, 859, 14, 199, 624, 199, 504, 22208, 14, 3903, 492, 5823, 493, 199, 504, 13608, 492, 30227, 199, 646, 747, 199, 199, 363, 2502, 363, 275, 298, 52, 676, 73, 510, 1873, 29792, 13733, 262, 287, 665, 475, 2664, 14, 1038, 6857, 382, 1581, 287, 32, 11545, 14, 329, 4335, 199, 363, 1682, 363, 275, 298, 51, 3236, 30200, 6289, 2, 199, 199, 363, 452, 363, 275, 2097, 409, 1637, 890, 401, 298, 362, 3903, 401, 298, 19278, 937, 199, 199, 8677, 275, 942, 199, 3263, 1244, 654, 11025, 275, 1616, 199, 199, 533, 5823, 493, 8, 3903, 493, 304, 272, 347, 636, 5270, 721, 277, 304, 267, 372, 334, 362, 3903, 12, 334, 277, 423, 1501, 4641, 199, 199, 318, 664, 2619, 815, 493, 837, 272, 6203, 275, 3355, 8, 736, 14, 7374, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 363, 7845, 272, 6203, 14, 4471, 342, 272, 367, 2397, 315, 6203, 26, 267, 340, 2397, 14, 2460, 480, 2619, 815, 531, 436, 3680, 5369, 2122, 315, 2397, 26, 288, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 2397, 9, 272, 372, 488, 199, 199, 15353, 4531, 3817, 275, 664, 2619, 815, 493, 342, 199, 199, 2264, 664, 2619, 815, 493, 199, 199, 318, 663, 1637, 890, 8, 890, 304, 272, 2288, 7240, 1244, 654, 11025, 12, 7240, 4576, 272, 7240, 1244, 654, 11025, 275, 1568, 272, 2150, 7240, 4576, 59, 890, 2938, 199, 199, 318, 664, 3903, 8, 354, 304, 272, 10313, 275, 488, 272, 340, 3107, 4817, 4531, 3817, 26, 267, 367, 6328, 354, 12, 10313, 315, 7240, 4576, 26, 288, 340, 6328, 354, 508, 536, 26, 355, 2059, 267, 587, 26, 288, 2833, 275, 30227, 14, 1490, 8, 15353, 4531, 3817, 9, 288, 862, 26, 355, 5718, 493, 275, 2833, 14, 5005, 493, 8, 354, 9, 288, 871, 4067, 26, 355, 10313, 275, 488, 288, 587, 26, 355, 10313, 275, 5823, 493, 8, 2619, 493, 9, 288, 2833, 14, 1600, 342, 288, 7240, 4576, 14, 3176, 8, 16, 12, 334, 354, 12, 10313, 430, 288, 2150, 7240, 4576, 59, 3263, 1244, 654, 11025, 2938, 272, 372, 10313, 199, 199, 318, 22110, 8, 1501, 12, 1947, 29, 403, 12, 1475, 628, 6838, 2349, 272, 492, 5549, 12, 5145, 272, 12885, 275, 5549, 14, 11983, 342, 272, 5718, 694, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 298, 2619, 815, 531, 272, 859, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 272, 340, 1947, 26, 1947, 275, 3905, 7709, 1450, 272, 1347, 354, 275, 298, 2619, 815, 5, 83, 14, 5369, 4111, 83, 2, 450, 334, 1450, 12, 1475, 9, 272, 862, 26, 267, 2833, 275, 30227, 14, 1490, 8, 1501, 9, 267, 327, 710, 298, 22269, 2, 5718, 570, 3509, 6220, 370, 1163, 1584, 12, 880, 1471, 506, 267, 327, 7686, 465, 2061, 267, 367, 536, 315, 3355, 8, 3249, 14, 362, 1247, 1062, 2574, 790, 29, 2734, 1022, 26, 1022, 1137, 298, 15457, 2, 436, 1022, 503, 298, 90, 2349, 288, 340, 440, 334, 354, 14, 4130, 9520, 609, 531, 503, 490, 536, 14, 4130, 9520, 2902, 531, 503, 490, 536, 508, 298, 28764, 4515, 2349, 355, 2833, 14, 5005, 8, 354, 12, 12885, 9, 355, 9911, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 536, 9, 355, 747, 14, 2253, 480, 90, 530, 446, 68, 450, 83, 450, 83, 2, 450, 334, 2619, 694, 12, 9911, 430, 267, 2833, 14, 1600, 342, 267, 1347, 275, 747, 14, 515, 14, 904, 8, 578, 694, 12, 1347, 354, 9, 267, 367, 2397, 315, 747, 14, 7374, 8, 578, 694, 304, 288, 340, 2397, 14, 2460, 480, 2619, 815, 531, 436, 3680, 5369, 2122, 315, 2397, 26, 355, 747, 14, 7162, 8, 736, 14, 515, 14, 904, 8, 578, 694, 12, 2397, 430, 267, 2833, 275, 30227, 14, 1490, 8, 1375, 12, 298, 87, 2689, 83, 2, 450, 1475, 9, 267, 367, 2397, 315, 747, 14, 7374, 8, 2619, 694, 304, 288, 2397, 515, 275, 747, 14, 515, 14, 904, 8, 2619, 694, 12, 2397, 9, 288, 2833, 14, 525, 8, 2373, 515, 12, 2397, 9, 267, 2833, 14, 1600, 342, 272, 3753, 26, 267, 5145, 14, 9242, 8, 8616, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 7384, 334, 67, 9, 13004, 13, 9397, 221, 598, 833, 1214, 79, 653, 1873, 278, 23009, 665, 71, 833, 1214, 79, 32, 78, 1873, 278, 23009, 14, 846, 30, 199, 199, 2765, 859, 32563, 5478, 370, 314, 4465, 2018, 199, 2083, 859, 14, 199, 624, 199, 504, 22208, 14, 3903, 492, 5823, 493, 199, 504, 13608, 492, 30227, 199, 646, 747, 199, 199, 363, 2502, 363, 275, 298, 52, 676, 73, 510, 1873, 29792, 13733, 262, 287, 665, 475, 2664, 14, 1038, 6857, 382, 1581, 287, 32, 11545, 14, 329, 4335, 199, 363, 1682, 363, 275, 298, 51, 3236, 30200, 6289, 2, 199, 199, 363, 452, 363, 275, 2097, 409, 1637, 890, 401, 298, 362, 3903, 401, 298, 19278, 937, 199, 199, 8677, 275, 942, 199, 3263, 1244, 654, 11025, 275, 1616, 199, 199, 533, 5823, 493, 8, 3903, 493, 304, 272, 347, 636, 5270, 721, 277, 304, 267, 372, 334, 362, 3903, 12, 334, 277, 423, 1501, 4641, 199, 199, 318, 664, 2619, 815, 493, 837, 272, 6203, 275, 3355, 8, 736, 14, 7374, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 363, 7845, 272, 6203, 14, 4471, 342, 272, 367, 2397, 315, 6203, 26, 267, 340, 2397, 14, 2460, 480, 2619, 815, 531, 436, 3680, 5369, 2122, 315, 2397, 26, 288, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 2397, 9, 272, 372, 488, 199, 199, 15353, 4531, 3817, 275, 664, 2619, 815, 493, 342, 199, 199, 2264, 664, 2619, 815, 493, 199, 199, 318, 663, 1637, 890, 8, 890, 304, 272, 2288, 7240, 1244, 654, 11025, 12, 7240, 4576, 272, 7240, 1244, 654, 11025, 275, 1568, 272, 2150, 7240, 4576, 59, 890, 2938, 199, 199, 318, 664, 3903, 8, 354, 304, 272, 10313, 275, 488, 272, 340, 3107, 4817, 4531, 3817, 26, 267, 367, 6328, 354, 12, 10313, 315, 7240, 4576, 26, 288, 340, 6328, 354, 508, 536, 26, 355, 2059, 267, 587, 26, 288, 2833, 275, 30227, 14, 1490, 8, 15353, 4531, 3817, 9, 288, 862, 26, 355, 5718, 493, 275, 2833, 14, 5005, 493, 8, 354, 9, 288, 871, 4067, 26, 355, 10313, 275, 488, 288, 587, 26, 355, 10313, 275, 5823, 493, 8, 2619, 493, 9, 288, 2833, 14, 1600, 342, 288, 7240, 4576, 14, 3176, 8, 16, 12, 334, 354, 12, 10313, 430, 288, 2150, 7240, 4576, 59, 3263, 1244, 654, 11025, 2938, 272, 372, 10313, 199, 199, 318, 22110, 8, 1501, 12, 1947, 29, 403, 12, 1475, 628, 6838, 2349, 272, 492, 5549, 12, 5145, 272, 12885, 275, 5549, 14, 11983, 342, 272, 5718, 694, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 298, 2619, 815, 531, 272, 859, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 272, 340, 1947, 26, 1947, 275, 3905, 7709, 1450, 272, 1347, 354, 275, 298, 2619, 815, 5, 83, 14, 5369, 4111, 83, 2, 450, 334, 1450, 12, 1475, 9, 272, 862, 26, 267, 2833, 275, 30227, 14, 1490, 8, 1501, 9, 267, 327, 710, 298, 22269, 2, 5718, 570, 3509, 6220, 370, 1163, 1584, 12, 880, 1471, 506, 267, 327, 7686, 465, 2061, 267, 367, 536, 315, 3355, 8, 3249, 14, 362, 1247, 1062, 2574, 790, 29, 2734, 1022, 26, 1022, 1137, 298, 15457, 2, 436, 1022, 503, 298, 90, 2349, 288, 340, 440, 334, 354, 14, 4130, 9520, 609, 531, 503, 490, 536, 14, 4130, 9520, 2902, 531, 503, 490, 536, 508, 298, 28764, 4515, 2349, 355, 2833, 14, 5005, 8, 354, 12, 12885, 9, 355, 9911, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 536, 9, 355, 747, 14, 2253, 480, 90, 530, 446, 68, 450, 83, 450, 83, 2, 450, 334, 2619, 694, 12, 9911, 430, 267, 2833, 14, 1600, 342, 267, 1347, 275, 747, 14, 515, 14, 904, 8, 578, 694, 12, 1347, 354, 9, 267, 367, 2397, 315, 747, 14, 7374, 8, 578, 694, 304, 288, 340, 2397, 14, 2460, 480, 2619, 815, 531, 436, 3680, 5369, 2122, 315, 2397, 26, 355, 747, 14, 7162, 8, 736, 14, 515, 14, 904, 8, 578, 694, 12, 2397, 430, 267, 2833, 275, 30227, 14, 1490, 8, 1375, 12, 298, 87, 2689, 83, 2, 450, 1475, 9, 267, 367, 2397, 315, 747, 14, 7374, 8, 2619, 694, 304, 288, 2397, 515, 275, 747, 14, 515, 14, 904, 8, 2619, 694, 12, 2397, 9, 288, 2833, 14, 525, 8, 2373, 515, 12, 2397, 9, 267, 2833, 14, 1600, 342, 272, 3753, 26, 267, 5145, 14, 9242, 8, 8616, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
artemh/asuswrt-merlin
release/src/router/libxml2/python/tests/xpathret.py
87
1312
#!/usr/bin/python -u import sys import libxml2 #memory debug specific libxml2.debugMemory(1) # # A document hosting the nodes returned from the extension function # mydoc = libxml2.newDoc("1.0") def foo(ctx, str): global mydoc # # test returning a node set works as expected # parent = mydoc.newDocNode(None, 'p', None) mydoc.addChild(parent) node = mydoc.newDocText(str) parent.addChild(node) return [parent] doc = libxml2.parseFile("tst.xml") ctxt = doc.xpathNewContext() libxml2.registerXPathFunction(ctxt._o, "foo", None, foo) res = ctxt.xpathEval("foo('hello')") if type(res) != type([]): print "Failed to return a nodeset" sys.exit(1) if len(res) != 1: print "Unexpected nodeset size" sys.exit(1) node = res[0] if node.name != 'p': print "Unexpected nodeset element result" sys.exit(1) node = node.children if node.type != 'text': print "Unexpected nodeset element children type" sys.exit(1) if node.content != 'hello': print "Unexpected nodeset element children content" sys.exit(1) doc.freeDoc() mydoc.freeDoc() ctxt.xpathFreeContext() #memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: print "OK" else: print "Memory leak %d bytes" % (libxml2.debugMemory(1)) libxml2.dumpMemory()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 446, 85, 199, 646, 984, 199, 646, 15404, 18, 199, 199, 3, 4844, 3105, 2488, 199, 773, 1652, 18, 14, 1757, 8628, 8, 17, 9, 199, 199, 3, 199, 3, 437, 2213, 1591, 316, 314, 3380, 2138, 687, 314, 3329, 805, 199, 3, 199, 1662, 1301, 275, 15404, 18, 14, 1222, 3768, 480, 17, 14, 16, 531, 199, 199, 318, 3925, 8, 3799, 12, 620, 304, 272, 2288, 3002, 1301, 339, 327, 272, 327, 511, 8152, 282, 1031, 663, 5419, 465, 1420, 272, 327, 272, 1676, 275, 3002, 1301, 14, 1222, 3768, 1716, 8, 403, 12, 283, 80, 297, 488, 9, 272, 3002, 1301, 14, 23897, 8, 1708, 9, 272, 1031, 275, 3002, 1301, 14, 1222, 3768, 1872, 8, 495, 9, 272, 1676, 14, 23897, 8, 932, 9, 272, 372, 359, 1708, 61, 199, 199, 1301, 275, 15404, 18, 14, 1122, 1173, 480, 84, 270, 14, 1652, 531, 199, 6725, 275, 1382, 14, 8006, 4665, 2998, 342, 199, 773, 1652, 18, 14, 2683, 27645, 3481, 8, 6725, 423, 79, 12, 298, 1421, 401, 488, 12, 3925, 9, 199, 470, 275, 11216, 14, 8006, 10006, 480, 1421, 360, 5006, 26530, 199, 692, 730, 8, 470, 9, 1137, 730, 779, 4682, 272, 870, 298, 4276, 370, 372, 282, 1031, 409, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 822, 8, 470, 9, 1137, 413, 26, 272, 870, 298, 8708, 1031, 409, 1568, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 932, 275, 522, 59, 16, 61, 199, 692, 1031, 14, 354, 1137, 283, 80, 356, 272, 870, 298, 8708, 1031, 409, 1819, 754, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 932, 275, 1031, 14, 3223, 199, 692, 1031, 14, 466, 1137, 283, 505, 356, 272, 870, 298, 8708, 1031, 409, 1819, 4978, 730, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 1031, 14, 1317, 1137, 283, 5006, 356, 272, 870, 298, 8708, 1031, 409, 1819, 4978, 1564, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1301, 14, 4624, 3768, 342, 199, 1662, 1301, 14, 4624, 3768, 342, 199, 6725, 14, 8006, 10146, 2998, 342, 199, 199, 3, 4844, 3105, 2488, 199, 773, 1652, 18, 14, 7661, 2842, 342, 199, 692, 15404, 18, 14, 1757, 8628, 8, 17, 9, 508, 378, 26, 272, 870, 298, 3593, 2, 199, 2836, 26, 272, 870, 298, 8628, 25831, 450, 68, 2783, 2, 450, 334, 773, 1652, 18, 14, 1757, 8628, 8, 17, 430, 272, 15404, 18, 14, 2724, 8628, 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 ]
[ 2647, 15, 1393, 15, 1548, 446, 85, 199, 646, 984, 199, 646, 15404, 18, 199, 199, 3, 4844, 3105, 2488, 199, 773, 1652, 18, 14, 1757, 8628, 8, 17, 9, 199, 199, 3, 199, 3, 437, 2213, 1591, 316, 314, 3380, 2138, 687, 314, 3329, 805, 199, 3, 199, 1662, 1301, 275, 15404, 18, 14, 1222, 3768, 480, 17, 14, 16, 531, 199, 199, 318, 3925, 8, 3799, 12, 620, 304, 272, 2288, 3002, 1301, 339, 327, 272, 327, 511, 8152, 282, 1031, 663, 5419, 465, 1420, 272, 327, 272, 1676, 275, 3002, 1301, 14, 1222, 3768, 1716, 8, 403, 12, 283, 80, 297, 488, 9, 272, 3002, 1301, 14, 23897, 8, 1708, 9, 272, 1031, 275, 3002, 1301, 14, 1222, 3768, 1872, 8, 495, 9, 272, 1676, 14, 23897, 8, 932, 9, 272, 372, 359, 1708, 61, 199, 199, 1301, 275, 15404, 18, 14, 1122, 1173, 480, 84, 270, 14, 1652, 531, 199, 6725, 275, 1382, 14, 8006, 4665, 2998, 342, 199, 773, 1652, 18, 14, 2683, 27645, 3481, 8, 6725, 423, 79, 12, 298, 1421, 401, 488, 12, 3925, 9, 199, 470, 275, 11216, 14, 8006, 10006, 480, 1421, 360, 5006, 26530, 199, 692, 730, 8, 470, 9, 1137, 730, 779, 4682, 272, 870, 298, 4276, 370, 372, 282, 1031, 409, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 822, 8, 470, 9, 1137, 413, 26, 272, 870, 298, 8708, 1031, 409, 1568, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 932, 275, 522, 59, 16, 61, 199, 692, 1031, 14, 354, 1137, 283, 80, 356, 272, 870, 298, 8708, 1031, 409, 1819, 754, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 932, 275, 1031, 14, 3223, 199, 692, 1031, 14, 466, 1137, 283, 505, 356, 272, 870, 298, 8708, 1031, 409, 1819, 4978, 730, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 692, 1031, 14, 1317, 1137, 283, 5006, 356, 272, 870, 298, 8708, 1031, 409, 1819, 4978, 1564, 2, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 1301, 14, 4624, 3768, 342, 199, 1662, 1301, 14, 4624, 3768, 342, 199, 6725, 14, 8006, 10146, 2998, 342, 199, 199, 3, 4844, 3105, 2488, 199, 773, 1652, 18, 14, 7661, 2842, 342, 199, 692, 15404, 18, 14, 1757, 8628, 8, 17, 9, 508, 378, 26, 272, 870, 298, 3593, 2, 199, 2836, 26, 272, 870, 298, 8628, 25831, 450, 68, 2783, 2, 450, 334, 773, 1652, 18, 14, 1757, 8628, 8, 17, 430, 272, 15404, 18, 14, 2724, 8628, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kushalbhola/MyStuff
Practice/PythonApplication/env/Lib/site-packages/pandas/tests/indexes/multi/test_contains.py
2
3306
import numpy as np import pytest from pandas.compat import PYPY import pandas as pd from pandas import MultiIndex import pandas.util.testing as tm def test_contains_top_level(): midx = MultiIndex.from_product([["A", "B"], [1, 2]]) assert "A" in midx assert "A" not in midx._engine def test_contains_with_nat(): # MI with a NaT mi = MultiIndex( levels=[["C"], pd.date_range("2012-01-01", periods=5)], codes=[[0, 0, 0, 0, 0, 0], [-1, 0, 1, 2, 3, 4]], names=[None, "B"], ) assert ("C", pd.Timestamp("2012-01-01")) in mi for val in mi.values: assert val in mi def test_contains(idx): assert ("foo", "two") in idx assert ("bar", "two") not in idx assert None not in idx @pytest.mark.skipif(not PYPY, reason="tuples cmp recursively on PyPy") def test_isin_nan_pypy(): idx = MultiIndex.from_arrays([["foo", "bar"], [1.0, np.nan]]) tm.assert_numpy_array_equal(idx.isin([("bar", np.nan)]), np.array([False, True])) tm.assert_numpy_array_equal( idx.isin([("bar", float("nan"))]), np.array([False, True]) ) def test_isin(): values = [("foo", 2), ("bar", 3), ("quux", 4)] idx = MultiIndex.from_arrays([["qux", "baz", "foo", "bar"], np.arange(4)]) result = idx.isin(values) expected = np.array([False, False, True, True]) tm.assert_numpy_array_equal(result, expected) # empty, return dtype bool idx = MultiIndex.from_arrays([[], []]) result = idx.isin(values) assert len(result) == 0 assert result.dtype == np.bool_ @pytest.mark.skipif(PYPY, reason="tuples cmp recursively on PyPy") def test_isin_nan_not_pypy(): idx = MultiIndex.from_arrays([["foo", "bar"], [1.0, np.nan]]) tm.assert_numpy_array_equal(idx.isin([("bar", np.nan)]), np.array([False, False])) tm.assert_numpy_array_equal( idx.isin([("bar", float("nan"))]), np.array([False, False]) ) def test_isin_level_kwarg(): idx = MultiIndex.from_arrays([["qux", "baz", "foo", "bar"], np.arange(4)]) vals_0 = ["foo", "bar", "quux"] vals_1 = [2, 3, 10] expected = np.array([False, False, True, True]) tm.assert_numpy_array_equal(expected, idx.isin(vals_0, level=0)) tm.assert_numpy_array_equal(expected, idx.isin(vals_0, level=-2)) tm.assert_numpy_array_equal(expected, idx.isin(vals_1, level=1)) tm.assert_numpy_array_equal(expected, idx.isin(vals_1, level=-1)) msg = "Too many levels: Index has only 2 levels, not 6" with pytest.raises(IndexError, match=msg): idx.isin(vals_0, level=5) msg = "Too many levels: Index has only 2 levels, -5 is not a valid level number" with pytest.raises(IndexError, match=msg): idx.isin(vals_0, level=-5) with pytest.raises(KeyError, match=r"'Level 1\.0 not found'"): idx.isin(vals_0, level=1.0) with pytest.raises(KeyError, match=r"'Level -1\.0 not found'"): idx.isin(vals_1, level=-1.0) with pytest.raises(KeyError, match="'Level A not found'"): idx.isin(vals_1, level="A") idx.names = ["A", "B"] tm.assert_numpy_array_equal(expected, idx.isin(vals_0, level="A")) tm.assert_numpy_array_equal(expected, idx.isin(vals_1, level="B")) with pytest.raises(KeyError, match="'Level C not found'"): idx.isin(vals_1, level="C")
apache-2.0
[ 646, 2680, 465, 980, 199, 646, 4613, 199, 199, 504, 10634, 14, 5819, 492, 7843, 4521, 199, 199, 646, 10634, 465, 6454, 199, 504, 10634, 492, 6879, 2681, 199, 646, 10634, 14, 1974, 14, 4776, 465, 7352, 421, 199, 318, 511, 63, 6134, 63, 2119, 63, 1896, 837, 272, 333, 2996, 275, 6879, 2681, 14, 504, 63, 2558, 779, 905, 33, 401, 298, 34, 2255, 359, 17, 12, 499, 3934, 272, 702, 298, 33, 2, 315, 333, 2996, 272, 702, 298, 33, 2, 440, 315, 333, 2996, 423, 3908, 421, 199, 318, 511, 63, 6134, 63, 1045, 63, 9468, 837, 272, 327, 603, 41, 543, 282, 11290, 52, 272, 10684, 275, 6879, 2681, 8, 267, 11106, 1524, 905, 35, 2255, 6454, 14, 602, 63, 1842, 480, 7409, 13, 614, 13, 614, 401, 17382, 29, 21, 4360, 267, 9479, 16025, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 467, 5243, 17, 12, 378, 12, 413, 12, 499, 12, 650, 12, 841, 2365, 267, 1561, 1524, 403, 12, 298, 34, 2255, 272, 776, 272, 702, 1689, 35, 401, 6454, 14, 10239, 480, 7409, 13, 614, 13, 614, 2237, 315, 10684, 272, 367, 1139, 315, 10684, 14, 1459, 26, 267, 702, 1139, 315, 10684, 421, 199, 318, 511, 63, 6134, 8, 2996, 304, 272, 702, 1689, 1421, 401, 298, 5601, 531, 315, 4280, 272, 702, 1689, 1700, 401, 298, 5601, 531, 440, 315, 4280, 272, 702, 488, 440, 315, 4280, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 1397, 7843, 4521, 12, 4499, 628, 11760, 10467, 15035, 641, 1611, 2713, 531, 199, 318, 511, 63, 25184, 63, 4304, 63, 20233, 837, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 1421, 401, 298, 1700, 2255, 359, 17, 14, 16, 12, 980, 14, 4304, 3934, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2996, 14, 25184, 27187, 1700, 401, 980, 14, 4304, 16636, 980, 14, 1144, 779, 797, 12, 715, 2459, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 267, 4280, 14, 25184, 27187, 1700, 401, 2069, 480, 4304, 2237, 2522, 980, 14, 1144, 779, 797, 12, 715, 566, 272, 776, 421, 199, 318, 511, 63, 25184, 837, 272, 1338, 275, 10003, 1421, 401, 499, 395, 1689, 1700, 401, 650, 395, 1689, 32050, 401, 841, 1874, 339, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 27519, 401, 298, 6185, 401, 298, 1421, 401, 298, 1700, 2255, 980, 14, 5605, 8, 20, 3948, 272, 754, 275, 4280, 14, 25184, 8, 1459, 9, 272, 1420, 275, 980, 14, 1144, 779, 797, 12, 756, 12, 715, 12, 715, 566, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 1099, 12, 1420, 9, 339, 327, 2701, 12, 372, 2152, 2155, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 4038, 467, 942, 566, 272, 754, 275, 4280, 14, 25184, 8, 1459, 9, 272, 702, 822, 8, 1099, 9, 508, 378, 272, 702, 754, 14, 2271, 508, 980, 14, 2245, 63, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 4521, 4521, 12, 4499, 628, 11760, 10467, 15035, 641, 1611, 2713, 531, 199, 318, 511, 63, 25184, 63, 4304, 63, 1397, 63, 20233, 837, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 1421, 401, 298, 1700, 2255, 359, 17, 14, 16, 12, 980, 14, 4304, 3934, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2996, 14, 25184, 27187, 1700, 401, 980, 14, 4304, 16636, 980, 14, 1144, 779, 797, 12, 756, 2459, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 267, 4280, 14, 25184, 27187, 1700, 401, 2069, 480, 4304, 2237, 2522, 980, 14, 1144, 779, 797, 12, 756, 566, 272, 776, 421, 199, 318, 511, 63, 25184, 63, 1896, 63, 12745, 837, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 27519, 401, 298, 6185, 401, 298, 1421, 401, 298, 1700, 2255, 980, 14, 5605, 8, 20, 3948, 339, 5322, 63, 16, 275, 2097, 1421, 401, 298, 1700, 401, 298, 32050, 937, 272, 5322, 63, 17, 275, 359, 18, 12, 650, 12, 1616, 61, 339, 1420, 275, 980, 14, 1144, 779, 797, 12, 756, 12, 715, 12, 715, 566, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 29, 16, 430, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 4022, 18, 430, 339, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 29, 17, 430, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 4022, 17, 430, 339, 1499, 275, 298, 13749, 5002, 11106, 26, 5499, 965, 1454, 499, 11106, 12, 440, 1227, 2, 272, 543, 4613, 14, 3536, 8, 12129, 12, 1336, 29, 1328, 304, 267, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 29, 21, 9, 272, 1499, 275, 298, 13749, 5002, 11106, 26, 5499, 965, 1454, 499, 11106, 12, 446, 21, 365, 440, 282, 1686, 2166, 1329, 2, 272, 543, 4613, 14, 3536, 8, 12129, 12, 1336, 29, 1328, 304, 267, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 4022, 21, 9, 339, 543, 4613, 14, 3536, 8, 10230, 12, 1336, 29, 82, 4507, 4670, 413, 4537, 16, 440, 1911, 7, 2349, 267, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 29, 17, 14, 16, 9, 272, 543, 4613, 14, 3536, 8, 10230, 12, 1336, 29, 82, 4507, 4670, 446, 17, 4537, 16, 440, 1911, 7, 2349, 267, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 4022, 17, 14, 16, 9, 272, 543, 4613, 14, 3536, 8, 10230, 12, 1336, 26957, 4670, 437, 440, 1911, 7, 2349, 267, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 628, 33, 531, 339, 4280, 14, 1247, 275, 2097, 33, 401, 298, 34, 937, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 628, 33, 2237 ]
[ 2680, 465, 980, 199, 646, 4613, 199, 199, 504, 10634, 14, 5819, 492, 7843, 4521, 199, 199, 646, 10634, 465, 6454, 199, 504, 10634, 492, 6879, 2681, 199, 646, 10634, 14, 1974, 14, 4776, 465, 7352, 421, 199, 318, 511, 63, 6134, 63, 2119, 63, 1896, 837, 272, 333, 2996, 275, 6879, 2681, 14, 504, 63, 2558, 779, 905, 33, 401, 298, 34, 2255, 359, 17, 12, 499, 3934, 272, 702, 298, 33, 2, 315, 333, 2996, 272, 702, 298, 33, 2, 440, 315, 333, 2996, 423, 3908, 421, 199, 318, 511, 63, 6134, 63, 1045, 63, 9468, 837, 272, 327, 603, 41, 543, 282, 11290, 52, 272, 10684, 275, 6879, 2681, 8, 267, 11106, 1524, 905, 35, 2255, 6454, 14, 602, 63, 1842, 480, 7409, 13, 614, 13, 614, 401, 17382, 29, 21, 4360, 267, 9479, 16025, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 467, 5243, 17, 12, 378, 12, 413, 12, 499, 12, 650, 12, 841, 2365, 267, 1561, 1524, 403, 12, 298, 34, 2255, 272, 776, 272, 702, 1689, 35, 401, 6454, 14, 10239, 480, 7409, 13, 614, 13, 614, 2237, 315, 10684, 272, 367, 1139, 315, 10684, 14, 1459, 26, 267, 702, 1139, 315, 10684, 421, 199, 318, 511, 63, 6134, 8, 2996, 304, 272, 702, 1689, 1421, 401, 298, 5601, 531, 315, 4280, 272, 702, 1689, 1700, 401, 298, 5601, 531, 440, 315, 4280, 272, 702, 488, 440, 315, 4280, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 1397, 7843, 4521, 12, 4499, 628, 11760, 10467, 15035, 641, 1611, 2713, 531, 199, 318, 511, 63, 25184, 63, 4304, 63, 20233, 837, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 1421, 401, 298, 1700, 2255, 359, 17, 14, 16, 12, 980, 14, 4304, 3934, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2996, 14, 25184, 27187, 1700, 401, 980, 14, 4304, 16636, 980, 14, 1144, 779, 797, 12, 715, 2459, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 267, 4280, 14, 25184, 27187, 1700, 401, 2069, 480, 4304, 2237, 2522, 980, 14, 1144, 779, 797, 12, 715, 566, 272, 776, 421, 199, 318, 511, 63, 25184, 837, 272, 1338, 275, 10003, 1421, 401, 499, 395, 1689, 1700, 401, 650, 395, 1689, 32050, 401, 841, 1874, 339, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 27519, 401, 298, 6185, 401, 298, 1421, 401, 298, 1700, 2255, 980, 14, 5605, 8, 20, 3948, 272, 754, 275, 4280, 14, 25184, 8, 1459, 9, 272, 1420, 275, 980, 14, 1144, 779, 797, 12, 756, 12, 715, 12, 715, 566, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 1099, 12, 1420, 9, 339, 327, 2701, 12, 372, 2152, 2155, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 4038, 467, 942, 566, 272, 754, 275, 4280, 14, 25184, 8, 1459, 9, 272, 702, 822, 8, 1099, 9, 508, 378, 272, 702, 754, 14, 2271, 508, 980, 14, 2245, 63, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 4521, 4521, 12, 4499, 628, 11760, 10467, 15035, 641, 1611, 2713, 531, 199, 318, 511, 63, 25184, 63, 4304, 63, 1397, 63, 20233, 837, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 1421, 401, 298, 1700, 2255, 359, 17, 14, 16, 12, 980, 14, 4304, 3934, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2996, 14, 25184, 27187, 1700, 401, 980, 14, 4304, 16636, 980, 14, 1144, 779, 797, 12, 756, 2459, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 267, 4280, 14, 25184, 27187, 1700, 401, 2069, 480, 4304, 2237, 2522, 980, 14, 1144, 779, 797, 12, 756, 566, 272, 776, 421, 199, 318, 511, 63, 25184, 63, 1896, 63, 12745, 837, 272, 4280, 275, 6879, 2681, 14, 504, 63, 10095, 779, 905, 27519, 401, 298, 6185, 401, 298, 1421, 401, 298, 1700, 2255, 980, 14, 5605, 8, 20, 3948, 339, 5322, 63, 16, 275, 2097, 1421, 401, 298, 1700, 401, 298, 32050, 937, 272, 5322, 63, 17, 275, 359, 18, 12, 650, 12, 1616, 61, 339, 1420, 275, 980, 14, 1144, 779, 797, 12, 756, 12, 715, 12, 715, 566, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 29, 16, 430, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 4022, 18, 430, 339, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 29, 17, 430, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 4022, 17, 430, 339, 1499, 275, 298, 13749, 5002, 11106, 26, 5499, 965, 1454, 499, 11106, 12, 440, 1227, 2, 272, 543, 4613, 14, 3536, 8, 12129, 12, 1336, 29, 1328, 304, 267, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 29, 21, 9, 272, 1499, 275, 298, 13749, 5002, 11106, 26, 5499, 965, 1454, 499, 11106, 12, 446, 21, 365, 440, 282, 1686, 2166, 1329, 2, 272, 543, 4613, 14, 3536, 8, 12129, 12, 1336, 29, 1328, 304, 267, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 4022, 21, 9, 339, 543, 4613, 14, 3536, 8, 10230, 12, 1336, 29, 82, 4507, 4670, 413, 4537, 16, 440, 1911, 7, 2349, 267, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 29, 17, 14, 16, 9, 272, 543, 4613, 14, 3536, 8, 10230, 12, 1336, 29, 82, 4507, 4670, 446, 17, 4537, 16, 440, 1911, 7, 2349, 267, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 4022, 17, 14, 16, 9, 272, 543, 4613, 14, 3536, 8, 10230, 12, 1336, 26957, 4670, 437, 440, 1911, 7, 2349, 267, 4280, 14, 25184, 8, 3643, 63, 17, 12, 2166, 628, 33, 531, 339, 4280, 14, 1247, 275, 2097, 33, 401, 298, 34, 937, 272, 7352, 14, 479, 63, 4714, 63, 1144, 63, 1452, 8, 2062, 12, 4280, 14, 25184, 8, 3643, 63, 16, 12, 2166, 628, 33, 2237, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
slonik-az/cython
tests/run/withstat_py.py
29
4281
import sys def typename(t): name = type(t).__name__ if sys.version_info < (2,5): if name == 'classobj' and issubclass(t, MyException): name = 'type' elif name == 'instance' and isinstance(t, MyException): name = 'MyException' return "<type '%s'>" % name class MyException(Exception): pass class ContextManager(object): def __init__(self, value, exit_ret = None): self.value = value self.exit_ret = exit_ret def __exit__(self, a, b, tb): print("exit %s %s %s" % (typename(a), typename(b), typename(tb))) return self.exit_ret def __enter__(self): print("enter") return self.value def no_as(): """ >>> no_as() enter hello exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> """ with ContextManager("value"): print("hello") def basic(): """ >>> basic() enter value exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> """ with ContextManager("value") as x: print(x) def with_pass(): """ >>> with_pass() enter exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> """ with ContextManager("value") as x: pass def with_return(): """ >>> print(with_return()) enter exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> value """ with ContextManager("value") as x: return x def with_break(): """ >>> print(with_break()) enter exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> a """ for c in list("abc"): with ContextManager("value") as x: break print("FAILED") return c def with_continue(): """ >>> print(with_continue()) enter exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> enter exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> enter exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> c """ for c in list("abc"): with ContextManager("value") as x: continue print("FAILED") return c def with_exception(exit_ret): """ >>> with_exception(None) enter value exit <type 'type'> <type 'MyException'> <type 'traceback'> outer except >>> with_exception(True) enter value exit <type 'type'> <type 'MyException'> <type 'traceback'> """ try: with ContextManager("value", exit_ret=exit_ret) as value: print(value) raise MyException() except: print("outer except") def with_real_lock(): """ >>> with_real_lock() about to acquire lock holding lock lock no longer held """ from threading import Lock lock = Lock() print("about to acquire lock") with lock: print("holding lock") print("lock no longer held") def functions_in_with(): """ >>> f = functions_in_with() enter exit <type 'type'> <type 'MyException'> <type 'traceback'> outer except >>> f(1)[0] 1 >>> print(f(1)[1]) value """ try: with ContextManager("value") as value: def f(x): return x, value make = lambda x:x() raise make(MyException) except: print("outer except") return f def multitarget(): """ >>> multitarget() enter 1 2 3 4 5 exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> """ with ContextManager((1, 2, (3, (4, 5)))) as (a, b, (c, (d, e))): print('%s %s %s %s %s' % (a, b, c, d, e)) def tupletarget(): """ >>> tupletarget() enter (1, 2, (3, (4, 5))) exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> """ with ContextManager((1, 2, (3, (4, 5)))) as t: print(t) class GetManager(object): def get(self, *args): return ContextManager(*args) def manager_from_expression(): """ >>> manager_from_expression() enter 1 exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> enter 2 exit <type 'NoneType'> <type 'NoneType'> <type 'NoneType'> """ with GetManager().get(1) as x: print(x) g = GetManager() with g.get(2) as x: print(x)
apache-2.0
[ 646, 984, 421, 199, 318, 19151, 8, 84, 304, 272, 536, 275, 730, 8, 84, 2843, 354, 363, 272, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 21, 304, 267, 340, 536, 508, 283, 533, 1113, 7, 436, 11602, 8, 84, 12, 4932, 1726, 304, 288, 536, 275, 283, 466, 7, 267, 916, 536, 508, 283, 842, 7, 436, 1228, 8, 84, 12, 4932, 1726, 304, 288, 536, 275, 283, 5713, 1726, 7, 272, 372, 3886, 466, 1543, 83, 7, 4335, 450, 536, 421, 199, 533, 4932, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 9470, 2988, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 574, 12, 4458, 63, 3292, 275, 488, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 2224, 63, 3292, 275, 4458, 63, 3292, 339, 347, 636, 2224, 721, 277, 12, 282, 12, 330, 12, 7070, 304, 267, 870, 480, 2224, 450, 83, 450, 83, 450, 83, 2, 450, 334, 18596, 8, 65, 395, 19151, 8, 66, 395, 19151, 8, 5842, 1724, 267, 372, 291, 14, 2224, 63, 3292, 339, 347, 636, 4200, 721, 277, 304, 267, 870, 480, 4200, 531, 267, 372, 291, 14, 585, 421, 199, 318, 949, 63, 305, 837, 272, 408, 272, 1306, 949, 63, 305, 342, 272, 9509, 272, 16509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 480, 585, 2349, 267, 870, 480, 5006, 531, 421, 199, 318, 5678, 837, 272, 408, 272, 1306, 5678, 342, 272, 9509, 272, 574, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 267, 870, 8, 88, 9, 421, 199, 318, 543, 63, 1529, 837, 272, 408, 272, 1306, 543, 63, 1529, 342, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 267, 986, 421, 199, 318, 543, 63, 1107, 837, 272, 408, 272, 1306, 870, 8, 1045, 63, 1107, 1012, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 574, 272, 408, 272, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 267, 372, 671, 421, 199, 318, 543, 63, 4785, 837, 272, 408, 272, 1306, 870, 8, 1045, 63, 4785, 1012, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 282, 272, 408, 272, 367, 286, 315, 769, 480, 3175, 2349, 267, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 288, 2059, 267, 870, 480, 12299, 531, 272, 372, 286, 421, 199, 318, 543, 63, 6958, 837, 272, 408, 272, 1306, 870, 8, 1045, 63, 6958, 1012, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 286, 272, 408, 272, 367, 286, 315, 769, 480, 3175, 2349, 267, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 288, 1980, 267, 870, 480, 12299, 531, 272, 372, 286, 421, 199, 318, 543, 63, 1971, 8, 2224, 63, 3292, 304, 272, 408, 272, 1306, 543, 63, 1971, 8, 403, 9, 272, 9509, 272, 574, 272, 4458, 665, 466, 283, 466, 8423, 665, 466, 283, 5713, 1726, 8423, 665, 466, 283, 6894, 8423, 272, 6890, 871, 272, 1306, 543, 63, 1971, 8, 549, 9, 272, 9509, 272, 574, 272, 4458, 665, 466, 283, 466, 8423, 665, 466, 283, 5713, 1726, 8423, 665, 466, 283, 6894, 8423, 272, 408, 272, 862, 26, 267, 543, 9470, 2988, 480, 585, 401, 4458, 63, 3292, 29, 2224, 63, 3292, 9, 465, 574, 26, 288, 870, 8, 585, 9, 288, 746, 4932, 1726, 342, 272, 871, 26, 267, 870, 480, 7837, 871, 531, 421, 199, 318, 543, 63, 3093, 63, 831, 837, 272, 408, 272, 1306, 543, 63, 3093, 63, 831, 342, 272, 3595, 370, 16919, 4650, 272, 17573, 4650, 272, 4650, 949, 8088, 23608, 272, 408, 272, 687, 5796, 492, 15536, 272, 4650, 275, 15536, 342, 339, 870, 480, 10254, 370, 16919, 4650, 531, 339, 543, 4650, 26, 267, 870, 480, 72, 13122, 4650, 531, 339, 870, 480, 831, 949, 8088, 23608, 531, 421, 199, 318, 3423, 63, 262, 63, 1045, 837, 272, 408, 272, 1306, 289, 275, 3423, 63, 262, 63, 1045, 342, 272, 9509, 272, 4458, 665, 466, 283, 466, 8423, 665, 466, 283, 5713, 1726, 8423, 665, 466, 283, 6894, 8423, 272, 6890, 871, 272, 1306, 289, 8, 17, 2788, 16, 61, 272, 413, 272, 1306, 870, 8, 70, 8, 17, 2788, 17, 566, 272, 574, 272, 408, 272, 862, 26, 267, 543, 9470, 2988, 480, 585, 531, 465, 574, 26, 288, 347, 289, 8, 88, 304, 372, 671, 12, 574, 288, 1852, 275, 2400, 671, 26, 88, 342, 288, 746, 1852, 8, 5713, 1726, 9, 272, 871, 26, 267, 870, 480, 7837, 871, 531, 272, 372, 289, 421, 199, 318, 3510, 1375, 837, 272, 408, 272, 1306, 3510, 1375, 342, 272, 9509, 272, 413, 499, 650, 841, 959, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 1332, 17, 12, 499, 12, 334, 19, 12, 334, 20, 12, 959, 7845, 465, 334, 65, 12, 330, 12, 334, 67, 12, 334, 68, 12, 325, 15206, 267, 870, 3508, 83, 450, 83, 450, 83, 450, 83, 450, 83, 7, 450, 334, 65, 12, 330, 12, 286, 12, 366, 12, 325, 430, 421, 199, 318, 2008, 1375, 837, 272, 408, 272, 1306, 2008, 1375, 342, 272, 9509, 272, 334, 17, 12, 499, 12, 334, 19, 12, 334, 20, 12, 959, 1724, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470 ]
[ 984, 421, 199, 318, 19151, 8, 84, 304, 272, 536, 275, 730, 8, 84, 2843, 354, 363, 272, 340, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 21, 304, 267, 340, 536, 508, 283, 533, 1113, 7, 436, 11602, 8, 84, 12, 4932, 1726, 304, 288, 536, 275, 283, 466, 7, 267, 916, 536, 508, 283, 842, 7, 436, 1228, 8, 84, 12, 4932, 1726, 304, 288, 536, 275, 283, 5713, 1726, 7, 272, 372, 3886, 466, 1543, 83, 7, 4335, 450, 536, 421, 199, 533, 4932, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 9470, 2988, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 574, 12, 4458, 63, 3292, 275, 488, 304, 267, 291, 14, 585, 275, 574, 267, 291, 14, 2224, 63, 3292, 275, 4458, 63, 3292, 339, 347, 636, 2224, 721, 277, 12, 282, 12, 330, 12, 7070, 304, 267, 870, 480, 2224, 450, 83, 450, 83, 450, 83, 2, 450, 334, 18596, 8, 65, 395, 19151, 8, 66, 395, 19151, 8, 5842, 1724, 267, 372, 291, 14, 2224, 63, 3292, 339, 347, 636, 4200, 721, 277, 304, 267, 870, 480, 4200, 531, 267, 372, 291, 14, 585, 421, 199, 318, 949, 63, 305, 837, 272, 408, 272, 1306, 949, 63, 305, 342, 272, 9509, 272, 16509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 480, 585, 2349, 267, 870, 480, 5006, 531, 421, 199, 318, 5678, 837, 272, 408, 272, 1306, 5678, 342, 272, 9509, 272, 574, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 267, 870, 8, 88, 9, 421, 199, 318, 543, 63, 1529, 837, 272, 408, 272, 1306, 543, 63, 1529, 342, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 267, 986, 421, 199, 318, 543, 63, 1107, 837, 272, 408, 272, 1306, 870, 8, 1045, 63, 1107, 1012, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 574, 272, 408, 272, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 267, 372, 671, 421, 199, 318, 543, 63, 4785, 837, 272, 408, 272, 1306, 870, 8, 1045, 63, 4785, 1012, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 282, 272, 408, 272, 367, 286, 315, 769, 480, 3175, 2349, 267, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 288, 2059, 267, 870, 480, 12299, 531, 272, 372, 286, 421, 199, 318, 543, 63, 6958, 837, 272, 408, 272, 1306, 870, 8, 1045, 63, 6958, 1012, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 9509, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 286, 272, 408, 272, 367, 286, 315, 769, 480, 3175, 2349, 267, 543, 9470, 2988, 480, 585, 531, 465, 671, 26, 288, 1980, 267, 870, 480, 12299, 531, 272, 372, 286, 421, 199, 318, 543, 63, 1971, 8, 2224, 63, 3292, 304, 272, 408, 272, 1306, 543, 63, 1971, 8, 403, 9, 272, 9509, 272, 574, 272, 4458, 665, 466, 283, 466, 8423, 665, 466, 283, 5713, 1726, 8423, 665, 466, 283, 6894, 8423, 272, 6890, 871, 272, 1306, 543, 63, 1971, 8, 549, 9, 272, 9509, 272, 574, 272, 4458, 665, 466, 283, 466, 8423, 665, 466, 283, 5713, 1726, 8423, 665, 466, 283, 6894, 8423, 272, 408, 272, 862, 26, 267, 543, 9470, 2988, 480, 585, 401, 4458, 63, 3292, 29, 2224, 63, 3292, 9, 465, 574, 26, 288, 870, 8, 585, 9, 288, 746, 4932, 1726, 342, 272, 871, 26, 267, 870, 480, 7837, 871, 531, 421, 199, 318, 543, 63, 3093, 63, 831, 837, 272, 408, 272, 1306, 543, 63, 3093, 63, 831, 342, 272, 3595, 370, 16919, 4650, 272, 17573, 4650, 272, 4650, 949, 8088, 23608, 272, 408, 272, 687, 5796, 492, 15536, 272, 4650, 275, 15536, 342, 339, 870, 480, 10254, 370, 16919, 4650, 531, 339, 543, 4650, 26, 267, 870, 480, 72, 13122, 4650, 531, 339, 870, 480, 831, 949, 8088, 23608, 531, 421, 199, 318, 3423, 63, 262, 63, 1045, 837, 272, 408, 272, 1306, 289, 275, 3423, 63, 262, 63, 1045, 342, 272, 9509, 272, 4458, 665, 466, 283, 466, 8423, 665, 466, 283, 5713, 1726, 8423, 665, 466, 283, 6894, 8423, 272, 6890, 871, 272, 1306, 289, 8, 17, 2788, 16, 61, 272, 413, 272, 1306, 870, 8, 70, 8, 17, 2788, 17, 566, 272, 574, 272, 408, 272, 862, 26, 267, 543, 9470, 2988, 480, 585, 531, 465, 574, 26, 288, 347, 289, 8, 88, 304, 372, 671, 12, 574, 288, 1852, 275, 2400, 671, 26, 88, 342, 288, 746, 1852, 8, 5713, 1726, 9, 272, 871, 26, 267, 870, 480, 7837, 871, 531, 272, 372, 289, 421, 199, 318, 3510, 1375, 837, 272, 408, 272, 1306, 3510, 1375, 342, 272, 9509, 272, 413, 499, 650, 841, 959, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 2988, 1332, 17, 12, 499, 12, 334, 19, 12, 334, 20, 12, 959, 7845, 465, 334, 65, 12, 330, 12, 334, 67, 12, 334, 68, 12, 325, 15206, 267, 870, 3508, 83, 450, 83, 450, 83, 450, 83, 450, 83, 7, 450, 334, 65, 12, 330, 12, 286, 12, 366, 12, 325, 430, 421, 199, 318, 2008, 1375, 837, 272, 408, 272, 1306, 2008, 1375, 342, 272, 9509, 272, 334, 17, 12, 499, 12, 334, 19, 12, 334, 20, 12, 959, 1724, 272, 4458, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 665, 466, 283, 26855, 8423, 272, 408, 272, 543, 9470, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
darkdukey/sdkbox-facebook-sample-v2
tools/cocos2d-console/console/cocos2d.py
4
2601
#!/usr/bin/python # ---------------------------------------------------------------------------- # cocos2d-console: command line tool manager for cocos2d # # Author: Ricardo Quesada # Copyright 2013 (C) Zynga, Inc # # License: MIT # ---------------------------------------------------------------------------- ''' Command line tool manager for cocos2d ''' __docformat__ = 'restructuredtext' # python import sys import re import ConfigParser import os COCOS2D_CONSOLE_VERSION = '0.1' # # Plugins should be a sublass of CCJSPlugin # class CCPlugin(object): # returns help @staticmethod def brief_description(self): pass # Constructor def __init__(self): pass # Run it def run(self, argv): pass # get_class from: http://stackoverflow.com/a/452981 def get_class(kls): parts = kls.split('.') module = ".".join(parts[:-1]) if len(parts) == 1: m = sys.modules[__name__] m = getattr(m, parts[0]) else: m = __import__(module) for comp in parts[1:]: m = getattr(m, comp) return m def parse_plugins(): classes = {} cp = ConfigParser.ConfigParser() # read global config file cocos2d_path = os.path.dirname(os.path.abspath(sys.argv[0])) cp.read(os.path.join(cocos2d_path, "cocos2d.ini")) # override it with local config cp.read("~/.cocos2d-js/cocos2d.ini") for s in cp.sections(): if s.startswith('plugin '): pluginname = re.match('plugin\s+"?(\w+)"?', s) if pluginname: key = pluginname.group(1) for o in cp.options(s): classname = cp.get(s, o) classes[key] = get_class(classname) return classes def help(): print "\n%s %s - cocos2d console: A command line tool for cocos2d" % (sys.argv[0], COCOS2D_CONSOLE_VERSION) print "\nAvailable commands:" classes = parse_plugins() for key in classes.keys(): print "\t%s" % classes[key].brief_description() print "\t" print "\nExample:" print "\t%s new --help" % sys.argv[0] print "\t%s jscompile --help" % sys.argv[0] print "\t%s luacompile --help" % sys.argv[0] sys.exit(-1) if __name__ == "__main__": if len(sys.argv) == 1 or sys.argv[1] == '-h': help() command = sys.argv[1] argv = sys.argv[2:] plugins = parse_plugins() if command in plugins: plugin = plugins[command] plugin().run(argv) else: print "Error: argument '%s' not found" % command print "Try with %s -h" % sys.argv[0]
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 27103, 199, 3, 512, 5197, 18, 68, 13, 6614, 26, 1414, 1004, 4744, 5256, 367, 512, 5197, 18, 68, 199, 3, 199, 3, 6529, 26, 820, 530, 1005, 79, 1413, 10138, 10641, 199, 3, 1898, 6171, 334, 35, 9, 3107, 1236, 5294, 12, 3277, 199, 3, 199, 3, 844, 26, 10697, 199, 3, 27103, 199, 2344, 199, 3110, 1004, 4744, 5256, 367, 512, 5197, 18, 68, 199, 2344, 199, 199, 363, 21841, 363, 275, 283, 26854, 7, 421, 199, 3, 2366, 199, 646, 984, 199, 646, 295, 199, 646, 14196, 199, 646, 747, 199, 199, 1439, 1439, 51, 18, 36, 63, 31774, 63, 4612, 275, 283, 16, 14, 17, 7, 421, 199, 3, 199, 3, 30317, 1077, 506, 282, 1007, 4297, 402, 17586, 11378, 5061, 199, 3, 199, 533, 445, 2890, 76, 1632, 8, 785, 304, 339, 327, 2529, 1720, 272, 768, 4639, 272, 347, 29226, 63, 1802, 8, 277, 304, 267, 986, 339, 327, 20297, 272, 347, 636, 826, 721, 277, 304, 267, 986, 339, 327, 3378, 652, 272, 347, 1255, 8, 277, 12, 9238, 304, 267, 986, 421, 199, 3, 664, 63, 533, 687, 26, 1455, 921, 23153, 14, 957, 15, 65, 15, 2322, 1398, 2835, 199, 318, 664, 63, 533, 8, 75, 478, 304, 272, 4184, 275, 1022, 478, 14, 1294, 7563, 272, 859, 275, 32443, 904, 8, 4181, 4439, 17, 566, 272, 340, 822, 8, 4181, 9, 508, 413, 26, 267, 333, 275, 984, 14, 3112, 28894, 354, 22705, 267, 333, 275, 2519, 8, 77, 12, 4184, 59, 16, 566, 272, 587, 26, 267, 333, 275, 636, 646, 721, 578, 9, 267, 367, 1013, 315, 4184, 59, 17, 10688, 288, 333, 275, 2519, 8, 77, 12, 1013, 9, 272, 372, 333, 421, 199, 318, 2198, 63, 5265, 837, 272, 3992, 275, 1052, 272, 7667, 275, 14196, 14, 15218, 342, 339, 327, 1586, 2288, 1101, 570, 272, 512, 5197, 18, 68, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 1274, 14, 3020, 59, 16, 2459, 272, 7667, 14, 739, 8, 736, 14, 515, 14, 904, 8, 331, 5197, 18, 68, 63, 515, 12, 298, 331, 5197, 18, 68, 14, 2730, 2237, 339, 327, 4278, 652, 543, 2257, 1101, 272, 7667, 14, 739, 20793, 8083, 331, 5197, 18, 68, 13, 3596, 15, 331, 5197, 18, 68, 14, 2730, 531, 339, 367, 308, 315, 7667, 14, 7786, 837, 267, 340, 308, 14, 2460, 360, 2718, 18927, 288, 3589, 354, 275, 295, 14, 1431, 360, 2718, 60, 83, 5207, 31, 2961, 87, 20415, 7044, 308, 9, 288, 340, 3589, 354, 26, 355, 790, 275, 3589, 354, 14, 923, 8, 17, 9, 355, 367, 312, 315, 7667, 14, 1419, 8, 83, 304, 490, 15876, 275, 7667, 14, 362, 8, 83, 12, 312, 9, 490, 3992, 59, 498, 61, 275, 664, 63, 533, 8, 19851, 9, 272, 372, 3992, 421, 199, 318, 1720, 837, 272, 870, 1867, 78, 5, 83, 450, 83, 446, 512, 5197, 18, 68, 8559, 26, 437, 1414, 1004, 4744, 367, 512, 5197, 18, 68, 2, 450, 334, 1274, 14, 3020, 59, 16, 467, 5099, 1439, 51, 18, 36, 63, 31774, 63, 4612, 9, 272, 870, 1867, 78, 11464, 3718, 5424, 272, 3992, 275, 2198, 63, 5265, 342, 272, 367, 790, 315, 3992, 14, 1612, 837, 267, 870, 1867, 84, 5, 83, 2, 450, 3992, 59, 498, 1055, 19127, 63, 1802, 342, 272, 870, 1867, 84, 2, 272, 870, 1867, 78, 9846, 5424, 272, 870, 1867, 84, 5, 83, 892, 1553, 3437, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 870, 1867, 84, 5, 83, 8586, 2014, 1553, 3437, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 870, 1867, 84, 5, 83, 634, 1458, 2014, 1553, 3437, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 2801, 17, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 503, 984, 14, 3020, 59, 17, 61, 508, 2475, 72, 356, 267, 1720, 342, 339, 1414, 275, 984, 14, 3020, 59, 17, 61, 272, 9238, 275, 984, 14, 3020, 59, 18, 2938, 272, 8963, 275, 2198, 63, 5265, 342, 272, 340, 1414, 315, 8963, 26, 267, 3589, 275, 8963, 59, 1531, 61, 267, 3589, 1252, 1065, 8, 3020, 9, 272, 587, 26, 267, 870, 298, 547, 26, 1423, 1543, 83, 7, 440, 1911, 2, 450, 1414, 267, 870, 298, 12357, 543, 450, 83, 446, 72, 2, 450, 984, 14, 3020, 59, 16, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 27103, 199, 3, 512, 5197, 18, 68, 13, 6614, 26, 1414, 1004, 4744, 5256, 367, 512, 5197, 18, 68, 199, 3, 199, 3, 6529, 26, 820, 530, 1005, 79, 1413, 10138, 10641, 199, 3, 1898, 6171, 334, 35, 9, 3107, 1236, 5294, 12, 3277, 199, 3, 199, 3, 844, 26, 10697, 199, 3, 27103, 199, 2344, 199, 3110, 1004, 4744, 5256, 367, 512, 5197, 18, 68, 199, 2344, 199, 199, 363, 21841, 363, 275, 283, 26854, 7, 421, 199, 3, 2366, 199, 646, 984, 199, 646, 295, 199, 646, 14196, 199, 646, 747, 199, 199, 1439, 1439, 51, 18, 36, 63, 31774, 63, 4612, 275, 283, 16, 14, 17, 7, 421, 199, 3, 199, 3, 30317, 1077, 506, 282, 1007, 4297, 402, 17586, 11378, 5061, 199, 3, 199, 533, 445, 2890, 76, 1632, 8, 785, 304, 339, 327, 2529, 1720, 272, 768, 4639, 272, 347, 29226, 63, 1802, 8, 277, 304, 267, 986, 339, 327, 20297, 272, 347, 636, 826, 721, 277, 304, 267, 986, 339, 327, 3378, 652, 272, 347, 1255, 8, 277, 12, 9238, 304, 267, 986, 421, 199, 3, 664, 63, 533, 687, 26, 1455, 921, 23153, 14, 957, 15, 65, 15, 2322, 1398, 2835, 199, 318, 664, 63, 533, 8, 75, 478, 304, 272, 4184, 275, 1022, 478, 14, 1294, 7563, 272, 859, 275, 32443, 904, 8, 4181, 4439, 17, 566, 272, 340, 822, 8, 4181, 9, 508, 413, 26, 267, 333, 275, 984, 14, 3112, 28894, 354, 22705, 267, 333, 275, 2519, 8, 77, 12, 4184, 59, 16, 566, 272, 587, 26, 267, 333, 275, 636, 646, 721, 578, 9, 267, 367, 1013, 315, 4184, 59, 17, 10688, 288, 333, 275, 2519, 8, 77, 12, 1013, 9, 272, 372, 333, 421, 199, 318, 2198, 63, 5265, 837, 272, 3992, 275, 1052, 272, 7667, 275, 14196, 14, 15218, 342, 339, 327, 1586, 2288, 1101, 570, 272, 512, 5197, 18, 68, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 8, 1274, 14, 3020, 59, 16, 2459, 272, 7667, 14, 739, 8, 736, 14, 515, 14, 904, 8, 331, 5197, 18, 68, 63, 515, 12, 298, 331, 5197, 18, 68, 14, 2730, 2237, 339, 327, 4278, 652, 543, 2257, 1101, 272, 7667, 14, 739, 20793, 8083, 331, 5197, 18, 68, 13, 3596, 15, 331, 5197, 18, 68, 14, 2730, 531, 339, 367, 308, 315, 7667, 14, 7786, 837, 267, 340, 308, 14, 2460, 360, 2718, 18927, 288, 3589, 354, 275, 295, 14, 1431, 360, 2718, 60, 83, 5207, 31, 2961, 87, 20415, 7044, 308, 9, 288, 340, 3589, 354, 26, 355, 790, 275, 3589, 354, 14, 923, 8, 17, 9, 355, 367, 312, 315, 7667, 14, 1419, 8, 83, 304, 490, 15876, 275, 7667, 14, 362, 8, 83, 12, 312, 9, 490, 3992, 59, 498, 61, 275, 664, 63, 533, 8, 19851, 9, 272, 372, 3992, 421, 199, 318, 1720, 837, 272, 870, 1867, 78, 5, 83, 450, 83, 446, 512, 5197, 18, 68, 8559, 26, 437, 1414, 1004, 4744, 367, 512, 5197, 18, 68, 2, 450, 334, 1274, 14, 3020, 59, 16, 467, 5099, 1439, 51, 18, 36, 63, 31774, 63, 4612, 9, 272, 870, 1867, 78, 11464, 3718, 5424, 272, 3992, 275, 2198, 63, 5265, 342, 272, 367, 790, 315, 3992, 14, 1612, 837, 267, 870, 1867, 84, 5, 83, 2, 450, 3992, 59, 498, 1055, 19127, 63, 1802, 342, 272, 870, 1867, 84, 2, 272, 870, 1867, 78, 9846, 5424, 272, 870, 1867, 84, 5, 83, 892, 1553, 3437, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 870, 1867, 84, 5, 83, 8586, 2014, 1553, 3437, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 870, 1867, 84, 5, 83, 634, 1458, 2014, 1553, 3437, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 2801, 17, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 503, 984, 14, 3020, 59, 17, 61, 508, 2475, 72, 356, 267, 1720, 342, 339, 1414, 275, 984, 14, 3020, 59, 17, 61, 272, 9238, 275, 984, 14, 3020, 59, 18, 2938, 272, 8963, 275, 2198, 63, 5265, 342, 272, 340, 1414, 315, 8963, 26, 267, 3589, 275, 8963, 59, 1531, 61, 267, 3589, 1252, 1065, 8, 3020, 9, 272, 587, 26, 267, 870, 298, 547, 26, 1423, 1543, 83, 7, 440, 1911, 2, 450, 1414, 267, 870, 298, 12357, 543, 450, 83, 446, 72, 2, 450, 984, 14, 3020, 59, 16, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mendersoftware/meta-mender-qemu
scripts/list-all-org-repos.py
1
1955
#!/usr/bin/python3 import argparse import json import re import subprocess import sys parser = argparse.ArgumentParser() parser.add_argument( "--token", help="Github Personal Access token, get it from https://github.com/settings/tokens.", ) parser.add_argument( "--org", default="mendersoftware", help="Organization to get repositories for. Defaults to mendersoftware", ) args = parser.parse_args() def process_response(body): # Cut headers. body = body[body.find("\r\n\r\n") + 4 :] repos = json.loads(body) for repo in repos: print(repo["ssh_url"]) base_curl_args = [ "curl", "-si", "-H", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "--compressed", ] if args.token: base_curl_args += ["-H", "Authorization: bearer %s" % args.token] else: sys.stderr.write( "Warning: Running without token, private repositories will not be listed.\n" ) url = "https://api.github.com/orgs/%s/repos" % args.org output = None try: while True: output = subprocess.check_output(base_curl_args + [url]).decode() process_response(output) # Example header (typically the one you are requesting is not present): # Link: <https://api.github.com/organizations/15040539/repos?page=1>; rel="prev", <https://api.github.com/organizations/15040539/repos?page=3>; rel="next", <https://api.github.com/organizations/15040539/repos?page=3>; rel="last", <https://api.github.com/organizations/15040539/repos?page=1>; rel="first" link_header = re.search( r'^link:.*<([^>]*)>\s*;\s*rel="next"\s*,\s*<([^>]*)>\s*;\s*rel="last"', output, flags=re.MULTILINE | re.IGNORECASE, ) if link_header is None or url == link_header.group(2): break url = link_header.group(1) except: print("Got exception, last response was:") print(output) raise
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 199, 2087, 275, 7534, 14, 10730, 342, 199, 2087, 14, 525, 63, 2094, 8, 272, 4320, 1418, 401, 272, 1720, 628, 14772, 8028, 279, 11003, 1526, 12, 664, 652, 687, 4178, 921, 5031, 14, 957, 15, 1751, 15, 4504, 4765, 199, 9, 199, 2087, 14, 525, 63, 2094, 8, 272, 4320, 1308, 401, 272, 849, 628, 1410, 424, 15619, 401, 272, 1720, 628, 15928, 370, 664, 23737, 367, 14, 7827, 370, 12953, 424, 15619, 401, 199, 9, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 421, 199, 318, 2112, 63, 1310, 8, 2030, 304, 272, 327, 445, 337, 2323, 14, 272, 2396, 275, 2396, 59, 2030, 14, 1623, 4582, 82, 60, 78, 60, 82, 60, 78, 531, 435, 841, 12228, 339, 20416, 275, 2022, 14, 3640, 8, 2030, 9, 272, 367, 3831, 315, 20416, 26, 267, 870, 8, 3417, 905, 5510, 63, 633, 3135, 421, 199, 1095, 63, 17096, 63, 589, 275, 359, 272, 298, 17096, 401, 272, 3905, 338, 401, 272, 3905, 40, 401, 272, 298, 8422, 26, 1318, 15, 1360, 12, 3578, 15, 12909, 11, 1652, 12, 3578, 15, 1652, 27, 81, 29, 16, 14, 25, 12, 1569, 15, 2520, 80, 19166, 6331, 27, 81, 29, 16, 14, 24, 401, 272, 4320, 10895, 401, 199, 61, 199, 692, 1249, 14, 1418, 26, 272, 1300, 63, 17096, 63, 589, 847, 16984, 40, 401, 298, 11626, 26, 506, 21462, 450, 83, 2, 450, 1249, 14, 1418, 61, 199, 2836, 26, 272, 984, 14, 3083, 14, 952, 8, 267, 298, 3849, 26, 26848, 1928, 1526, 12, 5726, 23737, 911, 440, 506, 10532, 3134, 78, 2, 272, 776, 199, 199, 633, 275, 298, 2859, 921, 1246, 14, 5031, 14, 957, 15, 30146, 3149, 83, 15, 11857, 2, 450, 1249, 14, 1308, 199, 1199, 275, 488, 199, 893, 26, 272, 1830, 715, 26, 267, 1072, 275, 3873, 14, 1074, 63, 1199, 8, 1095, 63, 17096, 63, 589, 435, 359, 633, 6575, 2708, 342, 267, 2112, 63, 1310, 8, 1199, 9, 398, 327, 5679, 1406, 334, 32251, 314, 1373, 1265, 787, 23502, 365, 440, 3451, 304, 267, 327, 10967, 26, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 17, 30, 27, 4668, 628, 5701, 401, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 19, 30, 27, 4668, 628, 2184, 401, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 19, 30, 27, 4668, 628, 2019, 401, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 17, 30, 27, 4668, 628, 2246, 2, 267, 2142, 63, 1291, 275, 295, 14, 1733, 8, 288, 519, 4289, 1073, 26, 2795, 28, 7059, 30, 23849, 3072, 83, 10, 3779, 83, 10, 3369, 628, 2184, 3212, 83, 10, 4202, 83, 10, 28, 7059, 30, 23849, 3072, 83, 10, 3779, 83, 10, 3369, 628, 2019, 6949, 288, 1072, 12, 288, 3285, 29, 264, 14, 16661, 1204, 295, 14, 15434, 12, 267, 776, 267, 340, 2142, 63, 1291, 365, 488, 503, 1166, 508, 2142, 63, 1291, 14, 923, 8, 18, 304, 288, 2059, 267, 1166, 275, 2142, 63, 1291, 14, 923, 8, 17, 9, 199, 2590, 26, 272, 870, 480, 13662, 1919, 12, 2061, 1177, 1990, 9107, 272, 870, 8, 1199, 9, 272, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 19, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 199, 2087, 275, 7534, 14, 10730, 342, 199, 2087, 14, 525, 63, 2094, 8, 272, 4320, 1418, 401, 272, 1720, 628, 14772, 8028, 279, 11003, 1526, 12, 664, 652, 687, 4178, 921, 5031, 14, 957, 15, 1751, 15, 4504, 4765, 199, 9, 199, 2087, 14, 525, 63, 2094, 8, 272, 4320, 1308, 401, 272, 849, 628, 1410, 424, 15619, 401, 272, 1720, 628, 15928, 370, 664, 23737, 367, 14, 7827, 370, 12953, 424, 15619, 401, 199, 9, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 421, 199, 318, 2112, 63, 1310, 8, 2030, 304, 272, 327, 445, 337, 2323, 14, 272, 2396, 275, 2396, 59, 2030, 14, 1623, 4582, 82, 60, 78, 60, 82, 60, 78, 531, 435, 841, 12228, 339, 20416, 275, 2022, 14, 3640, 8, 2030, 9, 272, 367, 3831, 315, 20416, 26, 267, 870, 8, 3417, 905, 5510, 63, 633, 3135, 421, 199, 1095, 63, 17096, 63, 589, 275, 359, 272, 298, 17096, 401, 272, 3905, 338, 401, 272, 3905, 40, 401, 272, 298, 8422, 26, 1318, 15, 1360, 12, 3578, 15, 12909, 11, 1652, 12, 3578, 15, 1652, 27, 81, 29, 16, 14, 25, 12, 1569, 15, 2520, 80, 19166, 6331, 27, 81, 29, 16, 14, 24, 401, 272, 4320, 10895, 401, 199, 61, 199, 692, 1249, 14, 1418, 26, 272, 1300, 63, 17096, 63, 589, 847, 16984, 40, 401, 298, 11626, 26, 506, 21462, 450, 83, 2, 450, 1249, 14, 1418, 61, 199, 2836, 26, 272, 984, 14, 3083, 14, 952, 8, 267, 298, 3849, 26, 26848, 1928, 1526, 12, 5726, 23737, 911, 440, 506, 10532, 3134, 78, 2, 272, 776, 199, 199, 633, 275, 298, 2859, 921, 1246, 14, 5031, 14, 957, 15, 30146, 3149, 83, 15, 11857, 2, 450, 1249, 14, 1308, 199, 1199, 275, 488, 199, 893, 26, 272, 1830, 715, 26, 267, 1072, 275, 3873, 14, 1074, 63, 1199, 8, 1095, 63, 17096, 63, 589, 435, 359, 633, 6575, 2708, 342, 267, 2112, 63, 1310, 8, 1199, 9, 398, 327, 5679, 1406, 334, 32251, 314, 1373, 1265, 787, 23502, 365, 440, 3451, 304, 267, 327, 10967, 26, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 17, 30, 27, 4668, 628, 5701, 401, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 19, 30, 27, 4668, 628, 2184, 401, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 19, 30, 27, 4668, 628, 2019, 401, 665, 2859, 921, 1246, 14, 5031, 14, 957, 15, 19916, 12270, 15, 1046, 966, 1717, 1355, 15, 11857, 31, 1606, 29, 17, 30, 27, 4668, 628, 2246, 2, 267, 2142, 63, 1291, 275, 295, 14, 1733, 8, 288, 519, 4289, 1073, 26, 2795, 28, 7059, 30, 23849, 3072, 83, 10, 3779, 83, 10, 3369, 628, 2184, 3212, 83, 10, 4202, 83, 10, 28, 7059, 30, 23849, 3072, 83, 10, 3779, 83, 10, 3369, 628, 2019, 6949, 288, 1072, 12, 288, 3285, 29, 264, 14, 16661, 1204, 295, 14, 15434, 12, 267, 776, 267, 340, 2142, 63, 1291, 365, 488, 503, 1166, 508, 2142, 63, 1291, 14, 923, 8, 18, 304, 288, 2059, 267, 1166, 275, 2142, 63, 1291, 14, 923, 8, 17, 9, 199, 2590, 26, 272, 870, 480, 13662, 1919, 12, 2061, 1177, 1990, 9107, 272, 870, 8, 1199, 9, 272, 746, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
subho007/androguard
androguard/session.py
14
4216
import hashlib import collections from androguard.core import androconf from androguard.core.bytecodes.apk import * from androguard.core.bytecodes.dvm import * from androguard.core.analysis.analysis import * from androguard.decompiler.decompiler import * from androguard.misc import save_session, load_session class Session(object): def __init__(self): self.setupObjects() def save(self, filename): save_session([self.analyzed_files, self.analyzed_digest, self.analyzed_apk, self.analyzed_dex], filename) def load(self, filename): self.analyzed_files, self.analyzed_digest, self.analyzed_apk, self.analyzed_dex = load_session(filename) def setupObjects(self): self.analyzed_files = collections.OrderedDict() self.analyzed_digest = {} self.analyzed_apk = {} self.analyzed_dex = {} def reset(self): self.setupObjects() def isOpen(self): return self.analyzed_digest != {} def addAPK(self, filename, data): digest = hashlib.sha256(data).hexdigest() androconf.debug("add APK:%s" % digest) apk = APK(data, True) self.analyzed_apk[digest] = apk self.analyzed_files[filename].append(digest) self.analyzed_digest[digest] = filename androconf.debug("added APK:%s" % digest) return (digest, apk) def addDEX(self, filename, data): digest = hashlib.sha256(data).hexdigest() androconf.debug("add DEX:%s" % digest) d = DalvikVMFormat(data) androconf.debug("VMAnalysis ...") dx = newVMAnalysis(d) dx.create_xref() d.set_decompiler(DecompilerDAD(d, dx)) androconf.debug("added DEX:%s" % digest) self.analyzed_dex[digest] = (d, dx) self.analyzed_files[filename].append(digest) self.analyzed_digest[digest] = filename return (digest, d, dx) def add(self, filename, raw_data): ret = is_android_raw(raw_data) if ret: self.analyzed_files[filename] = [] digest = hashlib.sha256(raw_data).hexdigest() if ret == "APK": apk_digest, apk = self.addAPK(filename, raw_data) self.addDEX(filename, apk.get_dex()) elif ret == "DEX": self.addDEX(filename, raw_data) else: return False return True return False def get_classes(self): idx = 0 for filename in self.analyzed_files: for digest in self.analyzed_files[filename]: if digest in self.analyzed_dex: d, _ = self.analyzed_dex[digest] yield idx, filename, digest, d.get_classes() idx += 1 def get_analysis(self, current_class): for digest in self.analyzed_dex: d, dx = self.analyzed_dex[digest] if dx.is_class_present(current_class.get_name()): return dx return None def get_format(self, current_class): for digest in self.analyzed_dex: d, dx = self.analyzed_dex[digest] if dx.is_class_present(current_class.get_name()): return d return None def get_filename_by_class(self, current_class): for digest in self.analyzed_dex: d, dx = self.analyzed_dex[digest] if dx.is_class_present(current_class.get_name()): return self.analyzed_digest[digest] return None def get_digest_by_class(self, current_class): for digest in self.analyzed_dex: d, dx = self.analyzed_dex[digest] if dx.is_class_present(current_class.get_name()): return digest return None def get_strings(self): for digest in self.analyzed_dex: d, dx = self.analyzed_dex[digest] yield digest, self.analyzed_digest[digest], dx.get_strings_analysis() def get_nb_strings(self): nb = 0 for digest in self.analyzed_dex: d, dx = self.analyzed_dex[digest] nb += len(dx.get_strings_analysis()) return nb
apache-2.0
[ 646, 8337, 199, 646, 5055, 199, 199, 504, 436, 293, 15606, 14, 1018, 492, 436, 293, 2190, 199, 504, 436, 293, 15606, 14, 1018, 14, 4414, 6021, 14, 23582, 492, 627, 199, 504, 436, 293, 15606, 14, 1018, 14, 4414, 6021, 14, 68, 2611, 492, 627, 199, 504, 436, 293, 15606, 14, 1018, 14, 10466, 14, 10466, 492, 627, 199, 504, 436, 293, 15606, 14, 271, 5772, 14, 271, 5772, 492, 627, 199, 504, 436, 293, 15606, 14, 9923, 492, 3354, 63, 1730, 12, 2248, 63, 1730, 199, 199, 533, 8596, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2758, 11188, 342, 2378, 347, 3354, 8, 277, 12, 1788, 304, 267, 3354, 63, 1730, 779, 277, 14, 4797, 7068, 63, 1725, 12, 1993, 291, 14, 4797, 7068, 63, 5671, 12, 1993, 291, 14, 4797, 7068, 63, 23582, 12, 1993, 291, 14, 4797, 7068, 63, 731, 467, 1788, 9, 339, 347, 2248, 8, 277, 12, 1788, 304, 267, 291, 14, 4797, 7068, 63, 1725, 12, 291, 14, 4797, 7068, 63, 5671, 12, 291, 14, 4797, 7068, 63, 23582, 12, 291, 14, 4797, 7068, 63, 731, 275, 2248, 63, 1730, 8, 1501, 9, 339, 347, 3272, 11188, 8, 277, 304, 267, 291, 14, 4797, 7068, 63, 1725, 275, 5055, 14, 16882, 342, 267, 291, 14, 4797, 7068, 63, 5671, 275, 1052, 267, 291, 14, 4797, 7068, 63, 23582, 275, 1052, 267, 291, 14, 4797, 7068, 63, 731, 275, 1052, 339, 347, 5305, 8, 277, 304, 267, 291, 14, 2758, 11188, 342, 339, 347, 365, 4299, 8, 277, 304, 267, 372, 291, 14, 4797, 7068, 63, 5671, 1137, 1052, 339, 347, 1050, 1282, 43, 8, 277, 12, 1788, 12, 666, 304, 267, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 11453, 342, 267, 436, 293, 2190, 14, 1757, 480, 525, 437, 8884, 2689, 83, 2, 450, 10017, 9, 267, 31528, 275, 437, 8884, 8, 576, 12, 715, 9, 267, 291, 14, 4797, 7068, 63, 23582, 59, 5671, 61, 275, 31528, 267, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 1055, 740, 8, 5671, 9, 267, 291, 14, 4797, 7068, 63, 5671, 59, 5671, 61, 275, 1788, 267, 436, 293, 2190, 14, 1757, 480, 3270, 437, 8884, 2689, 83, 2, 450, 10017, 9, 267, 372, 334, 5671, 12, 31528, 9, 339, 347, 1050, 7746, 8, 277, 12, 1788, 12, 666, 304, 267, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 11453, 342, 267, 436, 293, 2190, 14, 1757, 480, 525, 577, 1438, 2689, 83, 2, 450, 10017, 9, 398, 366, 275, 577, 279, 433, 75, 6849, 3484, 8, 576, 9, 267, 436, 293, 2190, 14, 1757, 480, 54, 2054, 78, 2618, 2316, 2263, 531, 267, 11868, 275, 892, 54, 2054, 78, 2618, 2316, 8, 68, 9, 267, 11868, 14, 981, 63, 31332, 342, 398, 366, 14, 409, 63, 271, 5772, 8, 872, 5772, 36, 1554, 8, 68, 12, 11868, 430, 398, 436, 293, 2190, 14, 1757, 480, 3270, 577, 1438, 2689, 83, 2, 450, 10017, 9, 398, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 275, 334, 68, 12, 11868, 9, 267, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 1055, 740, 8, 5671, 9, 267, 291, 14, 4797, 7068, 63, 5671, 59, 5671, 61, 275, 1788, 398, 372, 334, 5671, 12, 366, 12, 11868, 9, 339, 347, 1050, 8, 277, 12, 1788, 12, 3066, 63, 576, 304, 267, 2203, 275, 365, 63, 6238, 63, 1773, 8, 1773, 63, 576, 9, 267, 340, 2203, 26, 288, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 61, 275, 942, 288, 10017, 275, 8337, 14, 4835, 3912, 8, 1773, 63, 576, 680, 11453, 342, 288, 340, 2203, 508, 298, 1282, 43, 582, 355, 31528, 63, 5671, 12, 31528, 275, 291, 14, 525, 1282, 43, 8, 1501, 12, 3066, 63, 576, 9, 355, 291, 14, 525, 7746, 8, 1501, 12, 31528, 14, 362, 63, 731, 1012, 288, 916, 2203, 508, 298, 7746, 582, 355, 291, 14, 525, 7746, 8, 1501, 12, 3066, 63, 576, 9, 288, 587, 26, 355, 372, 756, 288, 372, 715, 267, 372, 756, 339, 347, 664, 63, 2888, 8, 277, 304, 267, 4280, 275, 378, 267, 367, 1788, 315, 291, 14, 4797, 7068, 63, 1725, 26, 288, 367, 10017, 315, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 2189, 355, 340, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 490, 366, 12, 485, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 490, 1995, 4280, 12, 1788, 12, 10017, 12, 366, 14, 362, 63, 2888, 342, 288, 4280, 847, 413, 339, 347, 664, 63, 10466, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 11868, 267, 372, 488, 339, 347, 664, 63, 908, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 366, 267, 372, 488, 339, 347, 664, 63, 1501, 63, 991, 63, 533, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 291, 14, 4797, 7068, 63, 5671, 59, 5671, 61, 267, 372, 488, 339, 347, 664, 63, 5671, 63, 991, 63, 533, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 10017, 267, 372, 488, 339, 347, 664, 63, 5465, 8, 277, 304 ]
[ 8337, 199, 646, 5055, 199, 199, 504, 436, 293, 15606, 14, 1018, 492, 436, 293, 2190, 199, 504, 436, 293, 15606, 14, 1018, 14, 4414, 6021, 14, 23582, 492, 627, 199, 504, 436, 293, 15606, 14, 1018, 14, 4414, 6021, 14, 68, 2611, 492, 627, 199, 504, 436, 293, 15606, 14, 1018, 14, 10466, 14, 10466, 492, 627, 199, 504, 436, 293, 15606, 14, 271, 5772, 14, 271, 5772, 492, 627, 199, 504, 436, 293, 15606, 14, 9923, 492, 3354, 63, 1730, 12, 2248, 63, 1730, 199, 199, 533, 8596, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2758, 11188, 342, 2378, 347, 3354, 8, 277, 12, 1788, 304, 267, 3354, 63, 1730, 779, 277, 14, 4797, 7068, 63, 1725, 12, 1993, 291, 14, 4797, 7068, 63, 5671, 12, 1993, 291, 14, 4797, 7068, 63, 23582, 12, 1993, 291, 14, 4797, 7068, 63, 731, 467, 1788, 9, 339, 347, 2248, 8, 277, 12, 1788, 304, 267, 291, 14, 4797, 7068, 63, 1725, 12, 291, 14, 4797, 7068, 63, 5671, 12, 291, 14, 4797, 7068, 63, 23582, 12, 291, 14, 4797, 7068, 63, 731, 275, 2248, 63, 1730, 8, 1501, 9, 339, 347, 3272, 11188, 8, 277, 304, 267, 291, 14, 4797, 7068, 63, 1725, 275, 5055, 14, 16882, 342, 267, 291, 14, 4797, 7068, 63, 5671, 275, 1052, 267, 291, 14, 4797, 7068, 63, 23582, 275, 1052, 267, 291, 14, 4797, 7068, 63, 731, 275, 1052, 339, 347, 5305, 8, 277, 304, 267, 291, 14, 2758, 11188, 342, 339, 347, 365, 4299, 8, 277, 304, 267, 372, 291, 14, 4797, 7068, 63, 5671, 1137, 1052, 339, 347, 1050, 1282, 43, 8, 277, 12, 1788, 12, 666, 304, 267, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 11453, 342, 267, 436, 293, 2190, 14, 1757, 480, 525, 437, 8884, 2689, 83, 2, 450, 10017, 9, 267, 31528, 275, 437, 8884, 8, 576, 12, 715, 9, 267, 291, 14, 4797, 7068, 63, 23582, 59, 5671, 61, 275, 31528, 267, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 1055, 740, 8, 5671, 9, 267, 291, 14, 4797, 7068, 63, 5671, 59, 5671, 61, 275, 1788, 267, 436, 293, 2190, 14, 1757, 480, 3270, 437, 8884, 2689, 83, 2, 450, 10017, 9, 267, 372, 334, 5671, 12, 31528, 9, 339, 347, 1050, 7746, 8, 277, 12, 1788, 12, 666, 304, 267, 10017, 275, 8337, 14, 4835, 3912, 8, 576, 680, 11453, 342, 267, 436, 293, 2190, 14, 1757, 480, 525, 577, 1438, 2689, 83, 2, 450, 10017, 9, 398, 366, 275, 577, 279, 433, 75, 6849, 3484, 8, 576, 9, 267, 436, 293, 2190, 14, 1757, 480, 54, 2054, 78, 2618, 2316, 2263, 531, 267, 11868, 275, 892, 54, 2054, 78, 2618, 2316, 8, 68, 9, 267, 11868, 14, 981, 63, 31332, 342, 398, 366, 14, 409, 63, 271, 5772, 8, 872, 5772, 36, 1554, 8, 68, 12, 11868, 430, 398, 436, 293, 2190, 14, 1757, 480, 3270, 577, 1438, 2689, 83, 2, 450, 10017, 9, 398, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 275, 334, 68, 12, 11868, 9, 267, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 1055, 740, 8, 5671, 9, 267, 291, 14, 4797, 7068, 63, 5671, 59, 5671, 61, 275, 1788, 398, 372, 334, 5671, 12, 366, 12, 11868, 9, 339, 347, 1050, 8, 277, 12, 1788, 12, 3066, 63, 576, 304, 267, 2203, 275, 365, 63, 6238, 63, 1773, 8, 1773, 63, 576, 9, 267, 340, 2203, 26, 288, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 61, 275, 942, 288, 10017, 275, 8337, 14, 4835, 3912, 8, 1773, 63, 576, 680, 11453, 342, 288, 340, 2203, 508, 298, 1282, 43, 582, 355, 31528, 63, 5671, 12, 31528, 275, 291, 14, 525, 1282, 43, 8, 1501, 12, 3066, 63, 576, 9, 355, 291, 14, 525, 7746, 8, 1501, 12, 31528, 14, 362, 63, 731, 1012, 288, 916, 2203, 508, 298, 7746, 582, 355, 291, 14, 525, 7746, 8, 1501, 12, 3066, 63, 576, 9, 288, 587, 26, 355, 372, 756, 288, 372, 715, 267, 372, 756, 339, 347, 664, 63, 2888, 8, 277, 304, 267, 4280, 275, 378, 267, 367, 1788, 315, 291, 14, 4797, 7068, 63, 1725, 26, 288, 367, 10017, 315, 291, 14, 4797, 7068, 63, 1725, 59, 1501, 2189, 355, 340, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 490, 366, 12, 485, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 490, 1995, 4280, 12, 1788, 12, 10017, 12, 366, 14, 362, 63, 2888, 342, 288, 4280, 847, 413, 339, 347, 664, 63, 10466, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 11868, 267, 372, 488, 339, 347, 664, 63, 908, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 366, 267, 372, 488, 339, 347, 664, 63, 1501, 63, 991, 63, 533, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 291, 14, 4797, 7068, 63, 5671, 59, 5671, 61, 267, 372, 488, 339, 347, 664, 63, 5671, 63, 991, 63, 533, 8, 277, 12, 1453, 63, 533, 304, 267, 367, 10017, 315, 291, 14, 4797, 7068, 63, 731, 26, 288, 366, 12, 11868, 275, 291, 14, 4797, 7068, 63, 731, 59, 5671, 61, 288, 340, 11868, 14, 374, 63, 533, 63, 1881, 8, 1818, 63, 533, 14, 362, 63, 354, 5109, 355, 372, 10017, 267, 372, 488, 339, 347, 664, 63, 5465, 8, 277, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
vmthunder/nova
nova/api/openstack/compute/contrib/server_password.py
17
2930
# 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.""" import webob from nova.api.metadata import password from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil from nova import compute from nova import exception authorize = extensions.extension_authorizer('compute', 'server_password') class ServerPasswordTemplate(xmlutil.TemplateBuilder): def construct(self): root = xmlutil.TemplateElement('password', selector='password') root.text = unicode return xmlutil.MasterTemplate(root, 1) class ServerPasswordController(object): """The Server Password API controller for the OpenStack API.""" def __init__(self): self.compute_api = compute.API() def _get_instance(self, context, server_id): try: return self.compute_api.get(context, server_id, want_objects=True) except exception.InstanceNotFound as exp: raise webob.exc.HTTPNotFound(explanation=exp.format_message()) @wsgi.serializers(xml=ServerPasswordTemplate) def index(self, req, server_id): context = req.environ['nova.context'] authorize(context) instance = self._get_instance(context, server_id) passw = password.extract_password(instance) return {'password': passw or ''} @wsgi.response(204) def delete(self, req, server_id): context = req.environ['nova.context'] authorize(context) instance = self._get_instance(context, server_id) meta = password.convert_password(context, None) instance.system_metadata.update(meta) instance.save() class Server_password(extensions.ExtensionDescriptor): """Server password support.""" name = "ServerPassword" alias = "os-server-password" namespace = ("http://docs.openstack.org/compute/ext/" "server-password/api/v2") updated = "2012-11-29T00:00:00Z" def get_resources(self): resources = [] res = extensions.ResourceExtension( 'os-server-password', controller=ServerPasswordController(), collection_actions={'delete': 'DELETE'}, parent=dict(member_name='server', collection_name='servers')) resources.append(res) return resources
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, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 2343, 492, 2505, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2748, 1974, 199, 504, 5913, 492, 4526, 199, 504, 5913, 492, 1919, 421, 199, 14204, 275, 5478, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 1000, 63, 2060, 358, 421, 199, 533, 7146, 6139, 4231, 8, 1652, 1974, 14, 4231, 6437, 304, 272, 347, 6982, 8, 277, 304, 267, 1738, 275, 2748, 1974, 14, 4231, 2162, 360, 2060, 297, 9759, 534, 2060, 358, 267, 1738, 14, 505, 275, 2649, 267, 372, 2748, 1974, 14, 12288, 4231, 8, 1231, 12, 413, 9, 421, 199, 533, 7146, 6139, 7506, 8, 785, 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, 347, 485, 362, 63, 842, 8, 277, 12, 1067, 12, 1654, 63, 344, 304, 267, 862, 26, 288, 372, 291, 14, 3357, 63, 1246, 14, 362, 8, 1100, 12, 1654, 63, 344, 12, 2934, 63, 1462, 29, 549, 9, 267, 871, 1919, 14, 3244, 4667, 465, 1437, 26, 288, 746, 14568, 14, 2804, 14, 26553, 8, 15228, 29, 1474, 14, 908, 63, 1188, 1012, 339, 768, 6508, 14, 12844, 8, 1652, 29, 3120, 6139, 4231, 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, 20210, 8, 1100, 9, 267, 1256, 275, 291, 423, 362, 63, 842, 8, 1100, 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, 6508, 14, 1310, 8, 6686, 9, 272, 347, 3145, 8, 277, 12, 2648, 12, 1654, 63, 344, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 267, 1256, 275, 291, 423, 362, 63, 842, 8, 1100, 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, 63, 2060, 8, 5359, 14, 6382, 4311, 304, 272, 408, 3120, 2505, 2291, 1041, 339, 536, 275, 298, 3120, 6139, 2, 272, 5162, 275, 298, 736, 13, 1000, 13, 2060, 2, 272, 3231, 275, 1689, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 3357, 15, 832, 6687, 326, 298, 1000, 13, 2060, 15, 1246, 15, 86, 18, 531, 272, 4588, 275, 298, 7409, 13, 845, 13, 1398, 52, 383, 26, 383, 26, 383, 58, 2, 339, 347, 664, 63, 4435, 8, 277, 304, 267, 5944, 275, 942, 398, 522, 275, 5478, 14, 4031, 6382, 8, 288, 283, 736, 13, 1000, 13, 2060, 297, 288, 7614, 29, 3120, 6139, 7506, 1062, 288, 3245, 63, 3723, 3713, 1807, 356, 283, 7014, 2267, 288, 1676, 29, 807, 8, 1114, 63, 354, 534, 1000, 297, 3245, 63, 354, 534, 5871, 1333, 267, 5944, 14, 740, 8, 470, 9, 398, 372, 5944, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 14568, 199, 199, 504, 5913, 14, 1246, 14, 2343, 492, 2505, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2748, 1974, 199, 504, 5913, 492, 4526, 199, 504, 5913, 492, 1919, 421, 199, 14204, 275, 5478, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 1000, 63, 2060, 358, 421, 199, 533, 7146, 6139, 4231, 8, 1652, 1974, 14, 4231, 6437, 304, 272, 347, 6982, 8, 277, 304, 267, 1738, 275, 2748, 1974, 14, 4231, 2162, 360, 2060, 297, 9759, 534, 2060, 358, 267, 1738, 14, 505, 275, 2649, 267, 372, 2748, 1974, 14, 12288, 4231, 8, 1231, 12, 413, 9, 421, 199, 533, 7146, 6139, 7506, 8, 785, 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, 347, 485, 362, 63, 842, 8, 277, 12, 1067, 12, 1654, 63, 344, 304, 267, 862, 26, 288, 372, 291, 14, 3357, 63, 1246, 14, 362, 8, 1100, 12, 1654, 63, 344, 12, 2934, 63, 1462, 29, 549, 9, 267, 871, 1919, 14, 3244, 4667, 465, 1437, 26, 288, 746, 14568, 14, 2804, 14, 26553, 8, 15228, 29, 1474, 14, 908, 63, 1188, 1012, 339, 768, 6508, 14, 12844, 8, 1652, 29, 3120, 6139, 4231, 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, 20210, 8, 1100, 9, 267, 1256, 275, 291, 423, 362, 63, 842, 8, 1100, 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, 6508, 14, 1310, 8, 6686, 9, 272, 347, 3145, 8, 277, 12, 2648, 12, 1654, 63, 344, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 267, 1256, 275, 291, 423, 362, 63, 842, 8, 1100, 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, 63, 2060, 8, 5359, 14, 6382, 4311, 304, 272, 408, 3120, 2505, 2291, 1041, 339, 536, 275, 298, 3120, 6139, 2, 272, 5162, 275, 298, 736, 13, 1000, 13, 2060, 2, 272, 3231, 275, 1689, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 3357, 15, 832, 6687, 326, 298, 1000, 13, 2060, 15, 1246, 15, 86, 18, 531, 272, 4588, 275, 298, 7409, 13, 845, 13, 1398, 52, 383, 26, 383, 26, 383, 58, 2, 339, 347, 664, 63, 4435, 8, 277, 304, 267, 5944, 275, 942, 398, 522, 275, 5478, 14, 4031, 6382, 8, 288, 283, 736, 13, 1000, 13, 2060, 297, 288, 7614, 29, 3120, 6139, 7506, 1062, 288, 3245, 63, 3723, 3713, 1807, 356, 283, 7014, 2267, 288, 1676, 29, 807, 8, 1114, 63, 354, 534, 1000, 297, 3245, 63, 354, 534, 5871, 1333, 267, 5944, 14, 740, 8, 470, 9, 398, 372, 5944, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
M4rtinK/anaconda
tests/nosetests/regex_tests/username_test.py
3
3827
#!/usr/bin/python3 # vim:set fileencoding=utf-8 # # Copyright (C) 2010-2013 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # import unittest from regexcheck import regex_match from pyanaconda.core.regexes import GECOS_VALID, NAME_VALID, GROUPLIST_SIMPLE_VALID class UsernameRegexTestCase(unittest.TestCase): def gecos_test(self): """Test a list of possible Full Name values.""" # These are valid full names good_tests = [ '', 'George', 'George Burdell', 'George P. Burdell', 'Ğeorgé P. Burdełl', 'Burdell, George', 'g/p/b' ] # These are invalid full names bad_tests = ['George:Burdell'] if not regex_match(GECOS_VALID, good_tests, bad_tests): self.fail() def username_test(self): """Test a list of possible username values.""" good_tests = [ 'gburdell', 'GBurdell', 'gburdell$', 'g_burdell', '_burdell', 'gggggggggggggggggggggggggburdell', # 32 characters 'ggggggggggggggggggggggggburdell$', '_', 'r', 'ro', 'roo', 'roota', ] bad_tests = [ '', '-gburdell', # can't start with a hyphen 'gburdełl', # invalid character 'g:burdell', 'g burdell', 'g,burdell', 'ggggggggggggggggggggggggggburdell', # 33 characters 'gggggggggggggggggggggggggburdell$', ' gburdell', ':gburdell', '$', '-' ] # The group name checks for the same thing as the user name if not regex_match(NAME_VALID, good_tests, bad_tests): self.fail() def grouplist_simple_test(self): good_tests = [ '', 'gburdell', ' gburdell', ' \tgburdell', 'gburdell ', 'gburdell \t', ' gburdell ', 'gburdell,wheel', 'gburdell, wheel', ' gburdell, wheel', 'gburdell, wheel ', ' gburdell, wheel ', 'gburdell, wheel', 'gburdell,wheel, mock' ] bad_tests = [ ',', '-invalid', 'gburdell, -invalid', 'gburdell,', 'gburdell, ', ',gburdell', ' ,gburdell', ',gburdell,' 'gburdell, wheel,' ] if not regex_match(GROUPLIST_SIMPLE_VALID, good_tests, bad_tests): self.fail()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 199, 3, 6695, 26, 409, 570, 2991, 29, 1624, 13, 24, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 13, 6965, 221, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 1331, 31816, 471, 6285, 365, 6326, 2808, 370, 29165, 13809, 316, 370, 675, 12, 199, 3, 2811, 12, 1331, 12, 503, 3604, 652, 5420, 370, 314, 2895, 436, 3704, 402, 199, 3, 314, 1664, 1696, 1684, 844, 373, 14, 18, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 19147, 503, 2478, 12, 5893, 314, 2478, 3712, 1417, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 199, 3, 1684, 844, 367, 1655, 2436, 14, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 199, 3, 1664, 1696, 1684, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 221, 6184, 9572, 13002, 21032, 10375, 626, 787, 30147, 972, 315, 314, 199, 3, 1350, 1233, 503, 3794, 787, 440, 5420, 370, 314, 1664, 1696, 1684, 199, 3, 844, 436, 1443, 1454, 506, 1202, 503, 32436, 543, 314, 4056, 4983, 402, 199, 3, 9572, 13002, 12, 3277, 14, 199, 3, 199, 646, 2882, 199, 199, 504, 5163, 1074, 492, 5163, 63, 1431, 199, 504, 1134, 28299, 14, 1018, 14, 29283, 492, 8991, 1439, 51, 63, 5600, 12, 13637, 63, 5600, 12, 15443, 4924, 63, 27548, 63, 5600, 199, 199, 533, 29739, 5103, 1746, 8, 2796, 14, 1746, 304, 272, 347, 2312, 5197, 63, 396, 8, 277, 304, 267, 408, 774, 282, 769, 402, 3962, 16579, 2812, 1338, 1041, 267, 327, 5723, 787, 1686, 2615, 1561, 267, 6954, 63, 2219, 275, 359, 355, 3260, 355, 283, 4240, 24591, 297, 355, 283, 4240, 24591, 699, 300, 271, 914, 297, 355, 283, 4240, 24591, 510, 14, 699, 300, 271, 914, 297, 355, 283, 129, 253, 69, 1308, 5741, 510, 14, 699, 300, 271, 130, 225, 76, 297, 355, 283, 34, 300, 271, 914, 12, 5346, 24591, 297, 355, 283, 71, 15, 80, 15, 66, 7, 355, 1622, 398, 327, 5723, 787, 3866, 2615, 1561, 267, 4875, 63, 2219, 275, 788, 4240, 24591, 26, 34, 300, 271, 914, 418, 398, 340, 440, 5163, 63, 1431, 8, 4962, 1439, 51, 63, 5600, 12, 6954, 63, 2219, 12, 4875, 63, 2219, 304, 288, 291, 14, 1633, 342, 339, 347, 3434, 63, 396, 8, 277, 304, 267, 408, 774, 282, 769, 402, 3962, 3434, 1338, 1041, 267, 6954, 63, 2219, 275, 359, 355, 283, 4908, 300, 271, 914, 297, 355, 283, 6487, 300, 271, 914, 297, 355, 283, 4908, 300, 271, 914, 4268, 355, 283, 71, 63, 30735, 271, 914, 297, 355, 2513, 30735, 271, 914, 297, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 4908, 300, 271, 914, 297, 327, 4337, 4110, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 30735, 271, 914, 4268, 355, 25469, 355, 283, 82, 297, 355, 283, 293, 297, 355, 283, 293, 79, 297, 355, 283, 1231, 65, 297, 355, 1622, 398, 4875, 63, 2219, 275, 359, 355, 3260, 355, 2475, 4908, 300, 271, 914, 297, 259, 327, 883, 1133, 1343, 543, 282, 7188, 17579, 355, 283, 4908, 300, 271, 130, 225, 76, 297, 258, 327, 3866, 4528, 355, 283, 71, 26, 30735, 271, 914, 297, 355, 283, 71, 330, 300, 271, 914, 297, 355, 283, 71, 12, 30735, 271, 914, 297, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 30735, 271, 914, 297, 327, 9404, 4110, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 4908, 300, 271, 914, 4268, 355, 283, 25411, 300, 271, 914, 297, 355, 7596, 4908, 300, 271, 914, 297, 355, 283, 4268, 355, 10791, 355, 1622, 398, 327, 710, 1572, 536, 5920, 367, 314, 2011, 8377, 465, 314, 922, 536, 267, 340, 440, 5163, 63, 1431, 8, 2339, 63, 5600, 12, 6954, 63, 2219, 12, 4875, 63, 2219, 304, 288, 291, 14, 1633, 342, 339, 347, 1572, 513, 63, 4129, 63, 396, 8, 277, 304, 267, 6954, 63, 2219, 275, 359, 355, 3260, 355, 283, 4908, 300, 271, 914, 297, 355, 283, 25411, 300, 271, 914, 297, 355, 283, 971, 84, 4908, 300, 271, 914, 297, 355, 283, 4908, 300, 271, 914, 1656, 355, 283, 4908, 300, 271, 914, 971, 84, 297, 355, 283, 221, 25411, 300, 271, 914, 221, 1656, 355, 283, 4908, 300, 271, 914, 12, 11798, 297, 355, 283, 4908, 300, 271, 914, 12, 9989, 297, 355, 283, 221, 25411, 300, 271, 914, 12, 221, 9989, 297, 355, 283, 4908, 300, 271, 914, 12, 221, 9989, 221, 1656, 355, 283, 221, 25411, 300, 271, 914, 12, 221, 9989, 221, 1656, 355, 283, 4908, 300, 271, 914, 12, 221, 9989, 297, 355, 283, 4908, 300, 271, 914, 12, 11798, 12, 1683, 7, 355, 1622, 398, 4875, 63, 2219, 275, 359, 355, 30048, 355, 2475, 3197, 297, 355, 283, 4908, 300, 271, 914, 12, 446, 3197, 297, 355, 283, 4908, 300, 271, 914, 12, 297, 355, 283, 4908, 300, 271, 914, 12, 1656, 355, 1656, 4908, 300, 271, 914, 297, 355, 283, 221, 2360, 4908, 300, 271, 914, 297, 355, 1656, 4908, 300, 271, 914, 2584, 355, 283, 4908, 300, 271, 914, 12, 9989, 2584, 355, 1622, 398, 340, 440, 5163, 63, 1431, 8, 7823, 4924, 63, 27548, 63, 5600, 12, 6954, 63, 2219, 12, 4875, 63, 2219, 304, 288, 291, 14, 1633, 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 ]
[ 2647, 15, 1393, 15, 1548, 19, 199, 3, 6695, 26, 409, 570, 2991, 29, 1624, 13, 24, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 13, 6965, 221, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 1331, 31816, 471, 6285, 365, 6326, 2808, 370, 29165, 13809, 316, 370, 675, 12, 199, 3, 2811, 12, 1331, 12, 503, 3604, 652, 5420, 370, 314, 2895, 436, 3704, 402, 199, 3, 314, 1664, 1696, 1684, 844, 373, 14, 18, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 19147, 503, 2478, 12, 5893, 314, 2478, 3712, 1417, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 199, 3, 1684, 844, 367, 1655, 2436, 14, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 199, 3, 1664, 1696, 1684, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 12, 8217, 14, 221, 6184, 9572, 13002, 21032, 10375, 626, 787, 30147, 972, 315, 314, 199, 3, 1350, 1233, 503, 3794, 787, 440, 5420, 370, 314, 1664, 1696, 1684, 199, 3, 844, 436, 1443, 1454, 506, 1202, 503, 32436, 543, 314, 4056, 4983, 402, 199, 3, 9572, 13002, 12, 3277, 14, 199, 3, 199, 646, 2882, 199, 199, 504, 5163, 1074, 492, 5163, 63, 1431, 199, 504, 1134, 28299, 14, 1018, 14, 29283, 492, 8991, 1439, 51, 63, 5600, 12, 13637, 63, 5600, 12, 15443, 4924, 63, 27548, 63, 5600, 199, 199, 533, 29739, 5103, 1746, 8, 2796, 14, 1746, 304, 272, 347, 2312, 5197, 63, 396, 8, 277, 304, 267, 408, 774, 282, 769, 402, 3962, 16579, 2812, 1338, 1041, 267, 327, 5723, 787, 1686, 2615, 1561, 267, 6954, 63, 2219, 275, 359, 355, 3260, 355, 283, 4240, 24591, 297, 355, 283, 4240, 24591, 699, 300, 271, 914, 297, 355, 283, 4240, 24591, 510, 14, 699, 300, 271, 914, 297, 355, 283, 129, 253, 69, 1308, 5741, 510, 14, 699, 300, 271, 130, 225, 76, 297, 355, 283, 34, 300, 271, 914, 12, 5346, 24591, 297, 355, 283, 71, 15, 80, 15, 66, 7, 355, 1622, 398, 327, 5723, 787, 3866, 2615, 1561, 267, 4875, 63, 2219, 275, 788, 4240, 24591, 26, 34, 300, 271, 914, 418, 398, 340, 440, 5163, 63, 1431, 8, 4962, 1439, 51, 63, 5600, 12, 6954, 63, 2219, 12, 4875, 63, 2219, 304, 288, 291, 14, 1633, 342, 339, 347, 3434, 63, 396, 8, 277, 304, 267, 408, 774, 282, 769, 402, 3962, 3434, 1338, 1041, 267, 6954, 63, 2219, 275, 359, 355, 283, 4908, 300, 271, 914, 297, 355, 283, 6487, 300, 271, 914, 297, 355, 283, 4908, 300, 271, 914, 4268, 355, 283, 71, 63, 30735, 271, 914, 297, 355, 2513, 30735, 271, 914, 297, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 4908, 300, 271, 914, 297, 327, 4337, 4110, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 30735, 271, 914, 4268, 355, 25469, 355, 283, 82, 297, 355, 283, 293, 297, 355, 283, 293, 79, 297, 355, 283, 1231, 65, 297, 355, 1622, 398, 4875, 63, 2219, 275, 359, 355, 3260, 355, 2475, 4908, 300, 271, 914, 297, 259, 327, 883, 1133, 1343, 543, 282, 7188, 17579, 355, 283, 4908, 300, 271, 130, 225, 76, 297, 258, 327, 3866, 4528, 355, 283, 71, 26, 30735, 271, 914, 297, 355, 283, 71, 330, 300, 271, 914, 297, 355, 283, 71, 12, 30735, 271, 914, 297, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 30735, 271, 914, 297, 327, 9404, 4110, 355, 283, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 4908, 300, 271, 914, 4268, 355, 283, 25411, 300, 271, 914, 297, 355, 7596, 4908, 300, 271, 914, 297, 355, 283, 4268, 355, 10791, 355, 1622, 398, 327, 710, 1572, 536, 5920, 367, 314, 2011, 8377, 465, 314, 922, 536, 267, 340, 440, 5163, 63, 1431, 8, 2339, 63, 5600, 12, 6954, 63, 2219, 12, 4875, 63, 2219, 304, 288, 291, 14, 1633, 342, 339, 347, 1572, 513, 63, 4129, 63, 396, 8, 277, 304, 267, 6954, 63, 2219, 275, 359, 355, 3260, 355, 283, 4908, 300, 271, 914, 297, 355, 283, 25411, 300, 271, 914, 297, 355, 283, 971, 84, 4908, 300, 271, 914, 297, 355, 283, 4908, 300, 271, 914, 1656, 355, 283, 4908, 300, 271, 914, 971, 84, 297, 355, 283, 221, 25411, 300, 271, 914, 221, 1656, 355, 283, 4908, 300, 271, 914, 12, 11798, 297, 355, 283, 4908, 300, 271, 914, 12, 9989, 297, 355, 283, 221, 25411, 300, 271, 914, 12, 221, 9989, 297, 355, 283, 4908, 300, 271, 914, 12, 221, 9989, 221, 1656, 355, 283, 221, 25411, 300, 271, 914, 12, 221, 9989, 221, 1656, 355, 283, 4908, 300, 271, 914, 12, 221, 9989, 297, 355, 283, 4908, 300, 271, 914, 12, 11798, 12, 1683, 7, 355, 1622, 398, 4875, 63, 2219, 275, 359, 355, 30048, 355, 2475, 3197, 297, 355, 283, 4908, 300, 271, 914, 12, 446, 3197, 297, 355, 283, 4908, 300, 271, 914, 12, 297, 355, 283, 4908, 300, 271, 914, 12, 1656, 355, 1656, 4908, 300, 271, 914, 297, 355, 283, 221, 2360, 4908, 300, 271, 914, 297, 355, 1656, 4908, 300, 271, 914, 2584, 355, 283, 4908, 300, 271, 914, 12, 9989, 2584, 355, 1622, 398, 340, 440, 5163, 63, 1431, 8, 7823, 4924, 63, 27548, 63, 5600, 12, 6954, 63, 2219, 12, 4875, 63, 2219, 304, 288, 291, 14, 1633, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
asnorkin/sentiment_analysis
site/lib/python2.7/site-packages/numpy/polynomial/tests/test_legendre.py
58
18006
"""Tests for legendre module. """ from __future__ import division, absolute_import, print_function import numpy as np import numpy.polynomial.legendre as leg from numpy.polynomial.polynomial import polyval from numpy.testing import ( TestCase, assert_almost_equal, assert_raises, assert_equal, assert_, run_module_suite) L0 = np.array([1]) L1 = np.array([0, 1]) L2 = np.array([-1, 0, 3])/2 L3 = np.array([0, -3, 0, 5])/2 L4 = np.array([3, 0, -30, 0, 35])/8 L5 = np.array([0, 15, 0, -70, 0, 63])/8 L6 = np.array([-5, 0, 105, 0, -315, 0, 231])/16 L7 = np.array([0, -35, 0, 315, 0, -693, 0, 429])/16 L8 = np.array([35, 0, -1260, 0, 6930, 0, -12012, 0, 6435])/128 L9 = np.array([0, 315, 0, -4620, 0, 18018, 0, -25740, 0, 12155])/128 Llist = [L0, L1, L2, L3, L4, L5, L6, L7, L8, L9] def trim(x): return leg.legtrim(x, tol=1e-6) class TestConstants(TestCase): def test_legdomain(self): assert_equal(leg.legdomain, [-1, 1]) def test_legzero(self): assert_equal(leg.legzero, [0]) def test_legone(self): assert_equal(leg.legone, [1]) def test_legx(self): assert_equal(leg.legx, [0, 1]) class TestArithmetic(TestCase): x = np.linspace(-1, 1, 100) def test_legadd(self): for i in range(5): for j in range(5): msg = "At i=%d, j=%d" % (i, j) tgt = np.zeros(max(i, j) + 1) tgt[i] += 1 tgt[j] += 1 res = leg.legadd([0]*i + [1], [0]*j + [1]) assert_equal(trim(res), trim(tgt), err_msg=msg) def test_legsub(self): for i in range(5): for j in range(5): msg = "At i=%d, j=%d" % (i, j) tgt = np.zeros(max(i, j) + 1) tgt[i] += 1 tgt[j] -= 1 res = leg.legsub([0]*i + [1], [0]*j + [1]) assert_equal(trim(res), trim(tgt), err_msg=msg) def test_legmulx(self): assert_equal(leg.legmulx([0]), [0]) assert_equal(leg.legmulx([1]), [0, 1]) for i in range(1, 5): tmp = 2*i + 1 ser = [0]*i + [1] tgt = [0]*(i - 1) + [i/tmp, 0, (i + 1)/tmp] assert_equal(leg.legmulx(ser), tgt) def test_legmul(self): # check values of result for i in range(5): pol1 = [0]*i + [1] val1 = leg.legval(self.x, pol1) for j in range(5): msg = "At i=%d, j=%d" % (i, j) pol2 = [0]*j + [1] val2 = leg.legval(self.x, pol2) pol3 = leg.legmul(pol1, pol2) val3 = leg.legval(self.x, pol3) assert_(len(pol3) == i + j + 1, msg) assert_almost_equal(val3, val1*val2, err_msg=msg) def test_legdiv(self): for i in range(5): for j in range(5): msg = "At i=%d, j=%d" % (i, j) ci = [0]*i + [1] cj = [0]*j + [1] tgt = leg.legadd(ci, cj) quo, rem = leg.legdiv(tgt, ci) res = leg.legadd(leg.legmul(quo, ci), rem) assert_equal(trim(res), trim(tgt), err_msg=msg) class TestEvaluation(TestCase): # coefficients of 1 + 2*x + 3*x**2 c1d = np.array([2., 2., 2.]) c2d = np.einsum('i,j->ij', c1d, c1d) c3d = np.einsum('i,j,k->ijk', c1d, c1d, c1d) # some random values in [-1, 1) x = np.random.random((3, 5))*2 - 1 y = polyval(x, [1., 2., 3.]) def test_legval(self): #check empty input assert_equal(leg.legval([], [1]).size, 0) #check normal input) x = np.linspace(-1, 1) y = [polyval(x, c) for c in Llist] for i in range(10): msg = "At i=%d" % i tgt = y[i] res = leg.legval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) #check that shape is preserved for i in range(3): dims = [2]*i x = np.zeros(dims) assert_equal(leg.legval(x, [1]).shape, dims) assert_equal(leg.legval(x, [1, 0]).shape, dims) assert_equal(leg.legval(x, [1, 0, 0]).shape, dims) def test_legval2d(self): x1, x2, x3 = self.x y1, y2, y3 = self.y #test exceptions assert_raises(ValueError, leg.legval2d, x1, x2[:2], self.c2d) #test values tgt = y1*y2 res = leg.legval2d(x1, x2, self.c2d) assert_almost_equal(res, tgt) #test shape z = np.ones((2, 3)) res = leg.legval2d(z, z, self.c2d) assert_(res.shape == (2, 3)) def test_legval3d(self): x1, x2, x3 = self.x y1, y2, y3 = self.y #test exceptions assert_raises(ValueError, leg.legval3d, x1, x2, x3[:2], self.c3d) #test values tgt = y1*y2*y3 res = leg.legval3d(x1, x2, x3, self.c3d) assert_almost_equal(res, tgt) #test shape z = np.ones((2, 3)) res = leg.legval3d(z, z, z, self.c3d) assert_(res.shape == (2, 3)) def test_leggrid2d(self): x1, x2, x3 = self.x y1, y2, y3 = self.y #test values tgt = np.einsum('i,j->ij', y1, y2) res = leg.leggrid2d(x1, x2, self.c2d) assert_almost_equal(res, tgt) #test shape z = np.ones((2, 3)) res = leg.leggrid2d(z, z, self.c2d) assert_(res.shape == (2, 3)*2) def test_leggrid3d(self): x1, x2, x3 = self.x y1, y2, y3 = self.y #test values tgt = np.einsum('i,j,k->ijk', y1, y2, y3) res = leg.leggrid3d(x1, x2, x3, self.c3d) assert_almost_equal(res, tgt) #test shape z = np.ones((2, 3)) res = leg.leggrid3d(z, z, z, self.c3d) assert_(res.shape == (2, 3)*3) class TestIntegral(TestCase): def test_legint(self): # check exceptions assert_raises(ValueError, leg.legint, [0], .5) assert_raises(ValueError, leg.legint, [0], -1) assert_raises(ValueError, leg.legint, [0], 1, [0, 0]) # test integration of zero polynomial for i in range(2, 5): k = [0]*(i - 2) + [1] res = leg.legint([0], m=i, k=k) assert_almost_equal(res, [0, 1]) # check single integration with integration constant for i in range(5): scl = i + 1 pol = [0]*i + [1] tgt = [i] + [0]*i + [1/scl] legpol = leg.poly2leg(pol) legint = leg.legint(legpol, m=1, k=[i]) res = leg.leg2poly(legint) assert_almost_equal(trim(res), trim(tgt)) # check single integration with integration constant and lbnd for i in range(5): scl = i + 1 pol = [0]*i + [1] legpol = leg.poly2leg(pol) legint = leg.legint(legpol, m=1, k=[i], lbnd=-1) assert_almost_equal(leg.legval(-1, legint), i) # check single integration with integration constant and scaling for i in range(5): scl = i + 1 pol = [0]*i + [1] tgt = [i] + [0]*i + [2/scl] legpol = leg.poly2leg(pol) legint = leg.legint(legpol, m=1, k=[i], scl=2) res = leg.leg2poly(legint) assert_almost_equal(trim(res), trim(tgt)) # check multiple integrations with default k for i in range(5): for j in range(2, 5): pol = [0]*i + [1] tgt = pol[:] for k in range(j): tgt = leg.legint(tgt, m=1) res = leg.legint(pol, m=j) assert_almost_equal(trim(res), trim(tgt)) # check multiple integrations with defined k for i in range(5): for j in range(2, 5): pol = [0]*i + [1] tgt = pol[:] for k in range(j): tgt = leg.legint(tgt, m=1, k=[k]) res = leg.legint(pol, m=j, k=list(range(j))) assert_almost_equal(trim(res), trim(tgt)) # check multiple integrations with lbnd for i in range(5): for j in range(2, 5): pol = [0]*i + [1] tgt = pol[:] for k in range(j): tgt = leg.legint(tgt, m=1, k=[k], lbnd=-1) res = leg.legint(pol, m=j, k=list(range(j)), lbnd=-1) assert_almost_equal(trim(res), trim(tgt)) # check multiple integrations with scaling for i in range(5): for j in range(2, 5): pol = [0]*i + [1] tgt = pol[:] for k in range(j): tgt = leg.legint(tgt, m=1, k=[k], scl=2) res = leg.legint(pol, m=j, k=list(range(j)), scl=2) assert_almost_equal(trim(res), trim(tgt)) def test_legint_axis(self): # check that axis keyword works c2d = np.random.random((3, 4)) tgt = np.vstack([leg.legint(c) for c in c2d.T]).T res = leg.legint(c2d, axis=0) assert_almost_equal(res, tgt) tgt = np.vstack([leg.legint(c) for c in c2d]) res = leg.legint(c2d, axis=1) assert_almost_equal(res, tgt) tgt = np.vstack([leg.legint(c, k=3) for c in c2d]) res = leg.legint(c2d, k=3, axis=1) assert_almost_equal(res, tgt) class TestDerivative(TestCase): def test_legder(self): # check exceptions assert_raises(ValueError, leg.legder, [0], .5) assert_raises(ValueError, leg.legder, [0], -1) # check that zeroth derivative does nothing for i in range(5): tgt = [0]*i + [1] res = leg.legder(tgt, m=0) assert_equal(trim(res), trim(tgt)) # check that derivation is the inverse of integration for i in range(5): for j in range(2, 5): tgt = [0]*i + [1] res = leg.legder(leg.legint(tgt, m=j), m=j) assert_almost_equal(trim(res), trim(tgt)) # check derivation with scaling for i in range(5): for j in range(2, 5): tgt = [0]*i + [1] res = leg.legder(leg.legint(tgt, m=j, scl=2), m=j, scl=.5) assert_almost_equal(trim(res), trim(tgt)) def test_legder_axis(self): # check that axis keyword works c2d = np.random.random((3, 4)) tgt = np.vstack([leg.legder(c) for c in c2d.T]).T res = leg.legder(c2d, axis=0) assert_almost_equal(res, tgt) tgt = np.vstack([leg.legder(c) for c in c2d]) res = leg.legder(c2d, axis=1) assert_almost_equal(res, tgt) class TestVander(TestCase): # some random values in [-1, 1) x = np.random.random((3, 5))*2 - 1 def test_legvander(self): # check for 1d x x = np.arange(3) v = leg.legvander(x, 3) assert_(v.shape == (3, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], leg.legval(x, coef)) # check for 2d x x = np.array([[1, 2], [3, 4], [5, 6]]) v = leg.legvander(x, 3) assert_(v.shape == (3, 2, 4)) for i in range(4): coef = [0]*i + [1] assert_almost_equal(v[..., i], leg.legval(x, coef)) def test_legvander2d(self): # also tests polyval2d for non-square coefficient array x1, x2, x3 = self.x c = np.random.random((2, 3)) van = leg.legvander2d(x1, x2, [1, 2]) tgt = leg.legval2d(x1, x2, c) res = np.dot(van, c.flat) assert_almost_equal(res, tgt) # check shape van = leg.legvander2d([x1], [x2], [1, 2]) assert_(van.shape == (1, 5, 6)) def test_legvander3d(self): # also tests polyval3d for non-square coefficient array x1, x2, x3 = self.x c = np.random.random((2, 3, 4)) van = leg.legvander3d(x1, x2, x3, [1, 2, 3]) tgt = leg.legval3d(x1, x2, x3, c) res = np.dot(van, c.flat) assert_almost_equal(res, tgt) # check shape van = leg.legvander3d([x1], [x2], [x3], [1, 2, 3]) assert_(van.shape == (1, 5, 24)) class TestFitting(TestCase): def test_legfit(self): def f(x): return x*(x - 1)*(x - 2) def f2(x): return x**4 + x**2 + 1 # Test exceptions assert_raises(ValueError, leg.legfit, [1], [1], -1) assert_raises(TypeError, leg.legfit, [[1]], [1], 0) assert_raises(TypeError, leg.legfit, [], [1], 0) assert_raises(TypeError, leg.legfit, [1], [[[1]]], 0) assert_raises(TypeError, leg.legfit, [1, 2], [1], 0) assert_raises(TypeError, leg.legfit, [1], [1, 2], 0) assert_raises(TypeError, leg.legfit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, leg.legfit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, leg.legfit, [1], [1], [-1,]) assert_raises(ValueError, leg.legfit, [1], [1], [2, -1, 6]) assert_raises(TypeError, leg.legfit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = leg.legfit(x, y, 3) assert_equal(len(coef3), 4) assert_almost_equal(leg.legval(x, coef3), y) coef3 = leg.legfit(x, y, [0, 1, 2, 3]) assert_equal(len(coef3), 4) assert_almost_equal(leg.legval(x, coef3), y) # coef4 = leg.legfit(x, y, 4) assert_equal(len(coef4), 5) assert_almost_equal(leg.legval(x, coef4), y) coef4 = leg.legfit(x, y, [0, 1, 2, 3, 4]) assert_equal(len(coef4), 5) assert_almost_equal(leg.legval(x, coef4), y) # check things still work if deg is not in strict increasing coef4 = leg.legfit(x, y, [2, 3, 4, 1, 0]) assert_equal(len(coef4), 5) assert_almost_equal(leg.legval(x, coef4), y) # coef2d = leg.legfit(x, np.array([y, y]).T, 3) assert_almost_equal(coef2d, np.array([coef3, coef3]).T) coef2d = leg.legfit(x, np.array([y, y]).T, [0, 1, 2, 3]) assert_almost_equal(coef2d, np.array([coef3, coef3]).T) # test weighting w = np.zeros_like(x) yw = y.copy() w[1::2] = 1 y[0::2] = 0 wcoef3 = leg.legfit(x, yw, 3, w=w) assert_almost_equal(wcoef3, coef3) wcoef3 = leg.legfit(x, yw, [0, 1, 2, 3], w=w) assert_almost_equal(wcoef3, coef3) # wcoef2d = leg.legfit(x, np.array([yw, yw]).T, 3, w=w) assert_almost_equal(wcoef2d, np.array([coef3, coef3]).T) wcoef2d = leg.legfit(x, np.array([yw, yw]).T, [0, 1, 2, 3], w=w) assert_almost_equal(wcoef2d, np.array([coef3, coef3]).T) # test scaling with complex values x points whose square # is zero when summed. x = [1, 1j, -1, -1j] assert_almost_equal(leg.legfit(x, x, 1), [0, 1]) assert_almost_equal(leg.legfit(x, x, [0, 1]), [0, 1]) # test fitting only even Legendre polynomials x = np.linspace(-1, 1) y = f2(x) coef1 = leg.legfit(x, y, 4) assert_almost_equal(leg.legval(x, coef1), y) coef2 = leg.legfit(x, y, [0, 2, 4]) assert_almost_equal(leg.legval(x, coef2), y) assert_almost_equal(coef1, coef2) class TestCompanion(TestCase): def test_raises(self): assert_raises(ValueError, leg.legcompanion, []) assert_raises(ValueError, leg.legcompanion, [1]) def test_dimensions(self): for i in range(1, 5): coef = [0]*i + [1] assert_(leg.legcompanion(coef).shape == (i, i)) def test_linear_root(self): assert_(leg.legcompanion([1, 2])[0, 0] == -.5) class TestGauss(TestCase): def test_100(self): x, w = leg.leggauss(100) # test orthogonality. Note that the results need to be normalized, # otherwise the huge values that can arise from fast growing # functions like Laguerre can be very confusing. v = leg.legvander(x, 99) vv = np.dot(v.T * w, v) vd = 1/np.sqrt(vv.diagonal()) vv = vd[:, None] * vv * vd assert_almost_equal(vv, np.eye(100)) # check that the integral of 1 is correct tgt = 2.0 assert_almost_equal(w.sum(), tgt) class TestMisc(TestCase): def test_legfromroots(self): res = leg.legfromroots([]) assert_almost_equal(trim(res), [1]) for i in range(1, 5): roots = np.cos(np.linspace(-np.pi, 0, 2*i + 1)[1::2]) pol = leg.legfromroots(roots) res = leg.legval(roots, pol) tgt = 0 assert_(len(pol) == i + 1) assert_almost_equal(leg.leg2poly(pol)[-1], 1) assert_almost_equal(res, tgt) def test_legroots(self): assert_almost_equal(leg.legroots([1]), []) assert_almost_equal(leg.legroots([1, 2]), [-.5]) for i in range(2, 5): tgt = np.linspace(-1, 1, i) res = leg.legroots(leg.legfromroots(tgt)) assert_almost_equal(trim(res), trim(tgt)) def test_legtrim(self): coef = [2, -1, 1, 0] # Test exceptions assert_raises(ValueError, leg.legtrim, coef, -1) # Test results assert_equal(leg.legtrim(coef), coef[:-1]) assert_equal(leg.legtrim(coef, 1), coef[:-3]) assert_equal(leg.legtrim(coef, 2), [0]) def test_legline(self): assert_equal(leg.legline(3, 4), [3, 4]) def test_leg2poly(self): for i in range(10): assert_almost_equal(leg.leg2poly([0]*i + [1]), Llist[i]) def test_poly2leg(self): for i in range(10): assert_almost_equal(leg.poly2leg(Llist[i]), [0]*i + [1]) def test_weight(self): x = np.linspace(-1, 1, 11) tgt = 1. res = leg.legweight(x) assert_almost_equal(res, tgt) if __name__ == "__main__": run_module_suite()
mit
[ 624, 2925, 367, 15906, 264, 859, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 2680, 14, 22104, 14, 10231, 264, 465, 6768, 199, 504, 2680, 14, 22104, 14, 22104, 492, 8446, 637, 199, 504, 2680, 14, 4776, 492, 334, 272, 7640, 12, 702, 63, 4398, 63, 1452, 12, 702, 63, 3536, 12, 272, 702, 63, 1452, 12, 702, 3131, 1255, 63, 578, 63, 5768, 9, 199, 199, 44, 16, 275, 980, 14, 1144, 779, 17, 566, 199, 44, 17, 275, 980, 14, 1144, 779, 16, 12, 413, 566, 199, 44, 18, 275, 980, 14, 1144, 11468, 17, 12, 378, 12, 650, 23067, 18, 199, 44, 19, 275, 980, 14, 1144, 779, 16, 12, 446, 19, 12, 378, 12, 959, 23067, 18, 199, 44, 20, 275, 980, 14, 1144, 779, 19, 12, 378, 12, 446, 1216, 12, 378, 12, 8685, 23067, 24, 199, 44, 21, 275, 980, 14, 1144, 779, 16, 12, 4114, 12, 378, 12, 446, 2760, 12, 378, 12, 13668, 23067, 24, 199, 44, 22, 275, 980, 14, 1144, 11468, 21, 12, 378, 12, 20462, 12, 378, 12, 446, 9927, 12, 378, 12, 499, 2192, 23067, 975, 199, 44, 23, 275, 980, 14, 1144, 779, 16, 12, 446, 1276, 12, 378, 12, 650, 1046, 12, 378, 12, 446, 27370, 12, 378, 12, 17640, 23067, 975, 199, 44, 24, 275, 980, 14, 1144, 779, 1276, 12, 378, 12, 446, 713, 2259, 12, 378, 12, 14610, 1216, 12, 378, 12, 446, 713, 11533, 12, 378, 12, 5049, 1276, 23067, 3933, 199, 44, 25, 275, 980, 14, 1144, 779, 16, 12, 650, 1046, 12, 378, 12, 446, 2466, 1165, 12, 378, 12, 6155, 12549, 12, 378, 12, 446, 821, 17702, 12, 378, 12, 3144, 11520, 23067, 3933, 199, 199, 44, 513, 275, 359, 44, 16, 12, 491, 17, 12, 491, 18, 12, 491, 19, 12, 491, 20, 12, 491, 21, 12, 491, 22, 12, 491, 23, 12, 491, 24, 12, 491, 25, 61, 421, 199, 318, 11639, 8, 88, 304, 272, 372, 6768, 14, 4170, 12263, 8, 88, 12, 9561, 29, 17, 69, 13, 22, 9, 421, 199, 533, 1379, 22185, 8, 1746, 304, 339, 347, 511, 63, 4170, 2261, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 2261, 12, 5243, 17, 12, 413, 566, 339, 347, 511, 63, 4170, 4262, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 4262, 12, 359, 16, 566, 339, 347, 511, 63, 4170, 368, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 368, 12, 359, 17, 566, 339, 347, 511, 63, 4170, 88, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 88, 12, 359, 16, 12, 413, 566, 421, 199, 533, 1379, 26291, 18764, 8, 1746, 304, 272, 671, 275, 980, 14, 11649, 2801, 17, 12, 413, 12, 2948, 9, 339, 347, 511, 63, 4170, 525, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 367, 1335, 315, 1425, 8, 21, 304, 355, 1499, 275, 298, 1271, 284, 2458, 68, 12, 1335, 2458, 68, 2, 450, 334, 73, 12, 1335, 9, 355, 11967, 275, 980, 14, 4250, 8, 988, 8, 73, 12, 1335, 9, 435, 413, 9, 355, 11967, 59, 73, 61, 847, 413, 355, 11967, 59, 74, 61, 847, 413, 355, 522, 275, 6768, 14, 4170, 525, 779, 16, 3672, 73, 435, 359, 17, 467, 359, 16, 3672, 74, 435, 359, 17, 566, 355, 702, 63, 1452, 8, 12263, 8, 470, 395, 11639, 8, 15328, 395, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 274, 458, 456, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 367, 1335, 315, 1425, 8, 21, 304, 355, 1499, 275, 298, 1271, 284, 2458, 68, 12, 1335, 2458, 68, 2, 450, 334, 73, 12, 1335, 9, 355, 11967, 275, 980, 14, 4250, 8, 988, 8, 73, 12, 1335, 9, 435, 413, 9, 355, 11967, 59, 73, 61, 847, 413, 355, 11967, 59, 74, 61, 4862, 413, 355, 522, 275, 6768, 14, 274, 458, 456, 779, 16, 3672, 73, 435, 359, 17, 467, 359, 16, 3672, 74, 435, 359, 17, 566, 355, 702, 63, 1452, 8, 12263, 8, 470, 395, 11639, 8, 15328, 395, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 4170, 3703, 88, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 3703, 88, 779, 16, 2522, 359, 16, 566, 267, 702, 63, 1452, 8, 4170, 14, 4170, 3703, 88, 779, 17, 2522, 359, 16, 12, 413, 566, 267, 367, 284, 315, 1425, 8, 17, 12, 959, 304, 288, 3529, 275, 499, 10, 73, 435, 413, 288, 8926, 275, 359, 16, 3672, 73, 435, 359, 17, 61, 288, 11967, 275, 359, 16, 3672, 8, 73, 446, 413, 9, 435, 359, 73, 15, 2791, 12, 378, 12, 334, 73, 435, 413, 2447, 2791, 61, 288, 702, 63, 1452, 8, 4170, 14, 4170, 3703, 88, 8, 332, 395, 11967, 9, 339, 347, 511, 63, 4170, 3703, 8, 277, 304, 267, 327, 1104, 1338, 402, 754, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 3708, 17, 275, 359, 16, 3672, 73, 435, 359, 17, 61, 288, 1139, 17, 275, 6768, 14, 4170, 637, 8, 277, 14, 88, 12, 3708, 17, 9, 288, 367, 1335, 315, 1425, 8, 21, 304, 355, 1499, 275, 298, 1271, 284, 2458, 68, 12, 1335, 2458, 68, 2, 450, 334, 73, 12, 1335, 9, 355, 3708, 18, 275, 359, 16, 3672, 74, 435, 359, 17, 61, 355, 1139, 18, 275, 6768, 14, 4170, 637, 8, 277, 14, 88, 12, 3708, 18, 9, 355, 3708, 19, 275, 6768, 14, 4170, 3703, 8, 2515, 17, 12, 3708, 18, 9, 355, 1139, 19, 275, 6768, 14, 4170, 637, 8, 277, 14, 88, 12, 3708, 19, 9, 355, 702, 2531, 552, 8, 2515, 19, 9, 508, 284, 435, 1335, 435, 413, 12, 1499, 9, 355, 702, 63, 4398, 63, 1452, 8, 637, 19, 12, 1139, 17, 10, 637, 18, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 4170, 3015, 8, 277, 304, 267, 367, 284, 315, 1425, 8 ]
[ 2925, 367, 15906, 264, 859, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 646, 2680, 14, 22104, 14, 10231, 264, 465, 6768, 199, 504, 2680, 14, 22104, 14, 22104, 492, 8446, 637, 199, 504, 2680, 14, 4776, 492, 334, 272, 7640, 12, 702, 63, 4398, 63, 1452, 12, 702, 63, 3536, 12, 272, 702, 63, 1452, 12, 702, 3131, 1255, 63, 578, 63, 5768, 9, 199, 199, 44, 16, 275, 980, 14, 1144, 779, 17, 566, 199, 44, 17, 275, 980, 14, 1144, 779, 16, 12, 413, 566, 199, 44, 18, 275, 980, 14, 1144, 11468, 17, 12, 378, 12, 650, 23067, 18, 199, 44, 19, 275, 980, 14, 1144, 779, 16, 12, 446, 19, 12, 378, 12, 959, 23067, 18, 199, 44, 20, 275, 980, 14, 1144, 779, 19, 12, 378, 12, 446, 1216, 12, 378, 12, 8685, 23067, 24, 199, 44, 21, 275, 980, 14, 1144, 779, 16, 12, 4114, 12, 378, 12, 446, 2760, 12, 378, 12, 13668, 23067, 24, 199, 44, 22, 275, 980, 14, 1144, 11468, 21, 12, 378, 12, 20462, 12, 378, 12, 446, 9927, 12, 378, 12, 499, 2192, 23067, 975, 199, 44, 23, 275, 980, 14, 1144, 779, 16, 12, 446, 1276, 12, 378, 12, 650, 1046, 12, 378, 12, 446, 27370, 12, 378, 12, 17640, 23067, 975, 199, 44, 24, 275, 980, 14, 1144, 779, 1276, 12, 378, 12, 446, 713, 2259, 12, 378, 12, 14610, 1216, 12, 378, 12, 446, 713, 11533, 12, 378, 12, 5049, 1276, 23067, 3933, 199, 44, 25, 275, 980, 14, 1144, 779, 16, 12, 650, 1046, 12, 378, 12, 446, 2466, 1165, 12, 378, 12, 6155, 12549, 12, 378, 12, 446, 821, 17702, 12, 378, 12, 3144, 11520, 23067, 3933, 199, 199, 44, 513, 275, 359, 44, 16, 12, 491, 17, 12, 491, 18, 12, 491, 19, 12, 491, 20, 12, 491, 21, 12, 491, 22, 12, 491, 23, 12, 491, 24, 12, 491, 25, 61, 421, 199, 318, 11639, 8, 88, 304, 272, 372, 6768, 14, 4170, 12263, 8, 88, 12, 9561, 29, 17, 69, 13, 22, 9, 421, 199, 533, 1379, 22185, 8, 1746, 304, 339, 347, 511, 63, 4170, 2261, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 2261, 12, 5243, 17, 12, 413, 566, 339, 347, 511, 63, 4170, 4262, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 4262, 12, 359, 16, 566, 339, 347, 511, 63, 4170, 368, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 368, 12, 359, 17, 566, 339, 347, 511, 63, 4170, 88, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 88, 12, 359, 16, 12, 413, 566, 421, 199, 533, 1379, 26291, 18764, 8, 1746, 304, 272, 671, 275, 980, 14, 11649, 2801, 17, 12, 413, 12, 2948, 9, 339, 347, 511, 63, 4170, 525, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 367, 1335, 315, 1425, 8, 21, 304, 355, 1499, 275, 298, 1271, 284, 2458, 68, 12, 1335, 2458, 68, 2, 450, 334, 73, 12, 1335, 9, 355, 11967, 275, 980, 14, 4250, 8, 988, 8, 73, 12, 1335, 9, 435, 413, 9, 355, 11967, 59, 73, 61, 847, 413, 355, 11967, 59, 74, 61, 847, 413, 355, 522, 275, 6768, 14, 4170, 525, 779, 16, 3672, 73, 435, 359, 17, 467, 359, 16, 3672, 74, 435, 359, 17, 566, 355, 702, 63, 1452, 8, 12263, 8, 470, 395, 11639, 8, 15328, 395, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 274, 458, 456, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 367, 1335, 315, 1425, 8, 21, 304, 355, 1499, 275, 298, 1271, 284, 2458, 68, 12, 1335, 2458, 68, 2, 450, 334, 73, 12, 1335, 9, 355, 11967, 275, 980, 14, 4250, 8, 988, 8, 73, 12, 1335, 9, 435, 413, 9, 355, 11967, 59, 73, 61, 847, 413, 355, 11967, 59, 74, 61, 4862, 413, 355, 522, 275, 6768, 14, 274, 458, 456, 779, 16, 3672, 73, 435, 359, 17, 467, 359, 16, 3672, 74, 435, 359, 17, 566, 355, 702, 63, 1452, 8, 12263, 8, 470, 395, 11639, 8, 15328, 395, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 4170, 3703, 88, 8, 277, 304, 267, 702, 63, 1452, 8, 4170, 14, 4170, 3703, 88, 779, 16, 2522, 359, 16, 566, 267, 702, 63, 1452, 8, 4170, 14, 4170, 3703, 88, 779, 17, 2522, 359, 16, 12, 413, 566, 267, 367, 284, 315, 1425, 8, 17, 12, 959, 304, 288, 3529, 275, 499, 10, 73, 435, 413, 288, 8926, 275, 359, 16, 3672, 73, 435, 359, 17, 61, 288, 11967, 275, 359, 16, 3672, 8, 73, 446, 413, 9, 435, 359, 73, 15, 2791, 12, 378, 12, 334, 73, 435, 413, 2447, 2791, 61, 288, 702, 63, 1452, 8, 4170, 14, 4170, 3703, 88, 8, 332, 395, 11967, 9, 339, 347, 511, 63, 4170, 3703, 8, 277, 304, 267, 327, 1104, 1338, 402, 754, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 3708, 17, 275, 359, 16, 3672, 73, 435, 359, 17, 61, 288, 1139, 17, 275, 6768, 14, 4170, 637, 8, 277, 14, 88, 12, 3708, 17, 9, 288, 367, 1335, 315, 1425, 8, 21, 304, 355, 1499, 275, 298, 1271, 284, 2458, 68, 12, 1335, 2458, 68, 2, 450, 334, 73, 12, 1335, 9, 355, 3708, 18, 275, 359, 16, 3672, 74, 435, 359, 17, 61, 355, 1139, 18, 275, 6768, 14, 4170, 637, 8, 277, 14, 88, 12, 3708, 18, 9, 355, 3708, 19, 275, 6768, 14, 4170, 3703, 8, 2515, 17, 12, 3708, 18, 9, 355, 1139, 19, 275, 6768, 14, 4170, 637, 8, 277, 14, 88, 12, 3708, 19, 9, 355, 702, 2531, 552, 8, 2515, 19, 9, 508, 284, 435, 1335, 435, 413, 12, 1499, 9, 355, 702, 63, 4398, 63, 1452, 8, 637, 19, 12, 1139, 17, 10, 637, 18, 12, 2329, 63, 1328, 29, 1328, 9, 339, 347, 511, 63, 4170, 3015, 8, 277, 304, 267, 367, 284, 315, 1425, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
darjeeling/django
tests/m2m_recursive/models.py
90
1029
""" Many-to-many relationships between the same two tables In this example, a ``Person`` can have many friends, who are also ``Person`` objects. Friendship is a symmetrical relationship - if I am your friend, you are my friend. Here, ``friends`` is an example of a symmetrical ``ManyToManyField``. A ``Person`` can also have many idols - but while I may idolize you, you may not think the same of me. Here, ``idols`` is an example of a non-symmetrical ``ManyToManyField``. Only recursive ``ManyToManyField`` fields may be non-symmetrical, and they are symmetrical by default. This test validates that the many-to-many table is created using a mangled name if there is a name clash, and tests that symmetry is preserved where appropriate. """ from django.db import models class Person(models.Model): name = models.CharField(max_length=20) friends = models.ManyToManyField('self') idols = models.ManyToManyField('self', symmetrical=False, related_name='stalkers') def __str__(self): return self.name
bsd-3-clause
[ 624, 199, 4089, 13, 475, 13, 3479, 20045, 3382, 314, 2011, 2877, 6716, 199, 199, 607, 642, 2893, 12, 282, 1124, 7344, 1040, 883, 1172, 5002, 26157, 12, 3963, 787, 2597, 1124, 7344, 1040, 199, 1462, 14, 481, 8528, 3319, 365, 282, 30091, 8931, 446, 340, 473, 8140, 2195, 32506, 12, 1265, 199, 1530, 3002, 32506, 14, 11842, 12, 1124, 18024, 1040, 365, 376, 2893, 402, 282, 30091, 199, 1040, 7624, 4345, 199, 199, 33, 1124, 7344, 1040, 883, 2597, 1172, 5002, 1305, 1446, 446, 1325, 1830, 473, 1443, 284, 1117, 13559, 1265, 12, 1265, 1443, 199, 1397, 13516, 314, 2011, 402, 562, 14, 11842, 12, 1124, 344, 1446, 1040, 365, 376, 2893, 402, 282, 2222, 13, 10247, 199, 1040, 7624, 4345, 5972, 9133, 1124, 7624, 1040, 1504, 1443, 506, 199, 2865, 13, 10247, 12, 436, 2985, 787, 30091, 701, 849, 14, 199, 199, 2765, 511, 29280, 626, 314, 5002, 13, 475, 13, 3479, 1817, 365, 2737, 1808, 282, 333, 22183, 536, 199, 692, 2337, 365, 282, 536, 30109, 12, 436, 2295, 626, 30246, 365, 17731, 2382, 199, 11227, 5655, 14, 199, 624, 199, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 26157, 275, 1709, 14, 7624, 360, 277, 358, 272, 1305, 1446, 275, 1709, 14, 7624, 360, 277, 297, 30091, 29, 797, 12, 4048, 63, 354, 534, 270, 4878, 1192, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 4089, 13, 475, 13, 3479, 20045, 3382, 314, 2011, 2877, 6716, 199, 199, 607, 642, 2893, 12, 282, 1124, 7344, 1040, 883, 1172, 5002, 26157, 12, 3963, 787, 2597, 1124, 7344, 1040, 199, 1462, 14, 481, 8528, 3319, 365, 282, 30091, 8931, 446, 340, 473, 8140, 2195, 32506, 12, 1265, 199, 1530, 3002, 32506, 14, 11842, 12, 1124, 18024, 1040, 365, 376, 2893, 402, 282, 30091, 199, 1040, 7624, 4345, 199, 199, 33, 1124, 7344, 1040, 883, 2597, 1172, 5002, 1305, 1446, 446, 1325, 1830, 473, 1443, 284, 1117, 13559, 1265, 12, 1265, 1443, 199, 1397, 13516, 314, 2011, 402, 562, 14, 11842, 12, 1124, 344, 1446, 1040, 365, 376, 2893, 402, 282, 2222, 13, 10247, 199, 1040, 7624, 4345, 5972, 9133, 1124, 7624, 1040, 1504, 1443, 506, 199, 2865, 13, 10247, 12, 436, 2985, 787, 30091, 701, 849, 14, 199, 199, 2765, 511, 29280, 626, 314, 5002, 13, 475, 13, 3479, 1817, 365, 2737, 1808, 282, 333, 22183, 536, 199, 692, 2337, 365, 282, 536, 30109, 12, 436, 2295, 626, 30246, 365, 17731, 2382, 199, 11227, 5655, 14, 199, 624, 199, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 26157, 275, 1709, 14, 7624, 360, 277, 358, 272, 1305, 1446, 275, 1709, 14, 7624, 360, 277, 297, 30091, 29, 797, 12, 4048, 63, 354, 534, 270, 4878, 1192, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
blacklin/kbengine
kbe/src/lib/python/Lib/lib2to3/fixes/fix_sys_exc.py
203
1034
"""Fixer for sys.exc_{type, value, traceback} sys.exc_type -> sys.exc_info()[0] sys.exc_value -> sys.exc_info()[1] sys.exc_traceback -> sys.exc_info()[2] """ # By Jeff Balogh and Benjamin Peterson # Local imports from .. import fixer_base from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms class FixSysExc(fixer_base.BaseFix): # This order matches the ordering of sys.exc_info(). exc_info = ["exc_type", "exc_value", "exc_traceback"] BM_compatible = True PATTERN = """ power< 'sys' trailer< dot='.' attribute=(%s) > > """ % '|'.join("'%s'" % e for e in exc_info) def transform(self, node, results): sys_attr = results["attribute"][0] index = Number(self.exc_info.index(sys_attr.value)) call = Call(Name("exc_info"), prefix=sys_attr.prefix) attr = Attr(Name("sys"), call) attr[1].children[0].prefix = results["dot"].prefix attr.append(Subscript(index)) return Node(syms.power, attr, prefix=node.prefix)
lgpl-3.0
[ 624, 11985, 281, 367, 984, 14, 2804, 7348, 466, 12, 574, 12, 5190, 93, 199, 199, 1274, 14, 2804, 63, 466, 1035, 984, 14, 2804, 63, 815, 3430, 16, 61, 199, 1274, 14, 2804, 63, 585, 1035, 984, 14, 2804, 63, 815, 3430, 17, 61, 199, 1274, 14, 2804, 63, 6894, 1035, 984, 14, 2804, 63, 815, 3430, 18, 61, 199, 624, 199, 199, 3, 4885, 1603, 3609, 699, 2548, 72, 436, 26844, 16997, 262, 22912, 834, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 20516, 12, 6523, 12, 2812, 12, 4860, 12, 4804, 1579, 12, 5013, 12, 25308, 199, 199, 533, 14811, 11319, 20702, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 272, 327, 961, 1865, 4450, 314, 7794, 402, 984, 14, 2804, 63, 815, 1252, 272, 3178, 63, 815, 275, 2097, 2804, 63, 466, 401, 298, 2804, 63, 585, 401, 298, 2804, 63, 6894, 937, 272, 699, 45, 63, 6490, 275, 715, 272, 31467, 7689, 275, 408, 1598, 7074, 28, 283, 1274, 7, 17357, 28, 6308, 534, 3530, 2225, 2687, 5, 83, 9, 690, 690, 1598, 408, 450, 21590, 904, 21065, 83, 4065, 450, 325, 367, 325, 315, 3178, 63, 815, 9, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 984, 63, 962, 275, 2058, 905, 3215, 9210, 16, 61, 267, 1478, 275, 4860, 8, 277, 14, 2804, 63, 815, 14, 1080, 8, 1274, 63, 962, 14, 585, 430, 398, 1240, 275, 6523, 8, 985, 480, 2804, 63, 815, 1288, 2403, 29, 1274, 63, 962, 14, 1861, 9, 267, 1921, 275, 20516, 8, 985, 480, 1274, 1288, 1240, 9, 267, 1921, 59, 17, 1055, 3223, 59, 16, 1055, 1861, 275, 2058, 905, 3287, 4140, 1861, 267, 1921, 14, 740, 8, 2610, 1579, 8, 1080, 430, 267, 372, 5013, 8, 13807, 14, 5652, 12, 1921, 12, 2403, 29, 932, 14, 1861, 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 ]
[ 11985, 281, 367, 984, 14, 2804, 7348, 466, 12, 574, 12, 5190, 93, 199, 199, 1274, 14, 2804, 63, 466, 1035, 984, 14, 2804, 63, 815, 3430, 16, 61, 199, 1274, 14, 2804, 63, 585, 1035, 984, 14, 2804, 63, 815, 3430, 17, 61, 199, 1274, 14, 2804, 63, 6894, 1035, 984, 14, 2804, 63, 815, 3430, 18, 61, 199, 624, 199, 199, 3, 4885, 1603, 3609, 699, 2548, 72, 436, 26844, 16997, 262, 22912, 834, 199, 199, 3, 10111, 8925, 199, 504, 2508, 492, 24739, 63, 1095, 199, 504, 2508, 25973, 63, 1974, 492, 20516, 12, 6523, 12, 2812, 12, 4860, 12, 4804, 1579, 12, 5013, 12, 25308, 199, 199, 533, 14811, 11319, 20702, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 272, 327, 961, 1865, 4450, 314, 7794, 402, 984, 14, 2804, 63, 815, 1252, 272, 3178, 63, 815, 275, 2097, 2804, 63, 466, 401, 298, 2804, 63, 585, 401, 298, 2804, 63, 6894, 937, 272, 699, 45, 63, 6490, 275, 715, 272, 31467, 7689, 275, 408, 1598, 7074, 28, 283, 1274, 7, 17357, 28, 6308, 534, 3530, 2225, 2687, 5, 83, 9, 690, 690, 1598, 408, 450, 21590, 904, 21065, 83, 4065, 450, 325, 367, 325, 315, 3178, 63, 815, 9, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 984, 63, 962, 275, 2058, 905, 3215, 9210, 16, 61, 267, 1478, 275, 4860, 8, 277, 14, 2804, 63, 815, 14, 1080, 8, 1274, 63, 962, 14, 585, 430, 398, 1240, 275, 6523, 8, 985, 480, 2804, 63, 815, 1288, 2403, 29, 1274, 63, 962, 14, 1861, 9, 267, 1921, 275, 20516, 8, 985, 480, 1274, 1288, 1240, 9, 267, 1921, 59, 17, 1055, 3223, 59, 16, 1055, 1861, 275, 2058, 905, 3287, 4140, 1861, 267, 1921, 14, 740, 8, 2610, 1579, 8, 1080, 430, 267, 372, 5013, 8, 13807, 14, 5652, 12, 1921, 12, 2403, 29, 932, 14, 1861, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kurtrwall/wagtail
wagtail/wagtailsearch/tests/test_elasticsearch_backend.py
2
41987
# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import datetime import json import os import time import unittest import warnings import mock from django.core import management from django.db.models import Q from django.test import TestCase from django.utils.six import StringIO from elasticsearch.serializer import JSONSerializer from wagtail.tests.search import models from wagtail.utils.deprecation import RemovedInWagtail18Warning from wagtail.wagtailsearch.backends import get_search_backend from wagtail.wagtailsearch.backends.elasticsearch import ElasticsearchSearchBackend from .test_backends import BackendTests class TestElasticsearchSearchBackend(BackendTests, TestCase): backend_path = 'wagtail.wagtailsearch.backends.elasticsearch' def test_search_with_spaces_only(self): # Search for some space characters and hope it doesn't crash results = self.backend.search(" ", models.SearchTest) # Queries are lazily evaluated, force it to run list(results) # Didn't crash, yay! def test_filter_on_non_filterindex_field(self): # id is not listed in the search_fields for SearchTest; this should raise a FieldError from wagtail.wagtailsearch.backends.base import FieldError with self.assertRaises(FieldError): list(self.backend.search("Hello", models.SearchTest, filters=dict(id=42))) def test_filter_with_unsupported_lookup_type(self): from wagtail.wagtailsearch.backends.base import FilterError with self.assertRaises(FilterError): list(self.backend.search("Hello", models.SearchTest, filters=dict(title__iregex='h(ea)llo'))) def test_partial_search(self): # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) self.backend.add_type(models.SearchTestChild) # Add some test data obj = models.SearchTest() obj.title = "HelloWorld" obj.live = True obj.save() self.backend.add(obj) # Refresh the index self.backend.refresh_index() # Search and check results = self.backend.search("HelloW", models.SearchTest.objects.all()) self.assertEqual(len(results), 1) self.assertEqual(results[0].id, obj.id) def test_child_partial_search(self): # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) self.backend.add_type(models.SearchTestChild) obj = models.SearchTestChild() obj.title = "WorldHello" obj.subtitle = "HelloWorld" obj.live = True obj.save() self.backend.add(obj) # Refresh the index self.backend.refresh_index() # Search and check results = self.backend.search("HelloW", models.SearchTest.objects.all()) self.assertEqual(len(results), 1) self.assertEqual(results[0].id, obj.id) def test_ascii_folding(self): # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) self.backend.add_type(models.SearchTestChild) # Add some test data obj = models.SearchTest() obj.title = "Ĥéllø" obj.live = True obj.save() self.backend.add(obj) # Refresh the index self.backend.refresh_index() # Search and check results = self.backend.search("Hello", models.SearchTest.objects.all()) self.assertEqual(len(results), 1) self.assertEqual(results[0].id, obj.id) def test_query_analyser(self): """ This is testing that fields that use edgengram_analyzer as their index analyser do not have it also as their query analyser """ # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) self.backend.add_type(models.SearchTestChild) # Add some test data obj = models.SearchTest() obj.title = "Hello" obj.live = True obj.save() self.backend.add(obj) # Refresh the index self.backend.refresh_index() # Test search for "Hello" results = self.backend.search("Hello", models.SearchTest.objects.all()) # Should find the result self.assertEqual(len(results), 1) # Test search for "Horse" results = self.backend.search("Horse", models.SearchTest.objects.all()) # Even though they both start with the letter "H". This should not be considered a match self.assertEqual(len(results), 0) def test_search_with_hyphen(self): """ This tests that punctuation characters are treated the same way in both indexing and querying. See: https://github.com/torchbox/wagtail/issues/937 """ # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) self.backend.add_type(models.SearchTestChild) # Add some test data obj = models.SearchTest() obj.title = "Hello-World" obj.live = True obj.save() self.backend.add(obj) # Refresh the index self.backend.refresh_index() # Test search for "Hello-World" results = self.backend.search("Hello-World", models.SearchTest.objects.all()) # Should find the result self.assertEqual(len(results), 1) def test_custom_ordering(self): # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) # Add some test data # a is more relevant, but b is more recent a = models.SearchTest() a.title = "Hello Hello World" a.live = True a.published_date = datetime.date(2015, 10, 11) a.save() self.backend.add(a) b = models.SearchTest() b.title = "Hello World" b.live = True b.published_date = datetime.date(2015, 10, 12) b.save() self.backend.add(b) # Refresh the index self.backend.refresh_index() # Do a search ordered by relevence results = self.backend.search("Hello", models.SearchTest.objects.all()) self.assertEqual(list(results), [a, b]) # Do a search ordered by published date results = self.backend.search( "Hello", models.SearchTest.objects.order_by('-published_date'), order_by_relevance=False ) self.assertEqual(list(results), [b, a]) def test_and_operator_with_single_field(self): # Testing for bug #1859 # Reset the index self.backend.reset_index() self.backend.add_type(models.SearchTest) a = models.SearchTest() a.title = "Hello World" a.live = True a.published_date = datetime.date(2015, 10, 12) a.save() self.backend.add(a) # Refresh the index self.backend.refresh_index() # Run query with "and" operator and single field results = self.backend.search("Hello World", models.SearchTest, operator='and', fields=['title']) self.assertEqual(list(results), [a]) def test_update_index_command_schema_only(self): # Reset the index, this should clear out the index self.backend.reset_index() # Give Elasticsearch some time to catch up... time.sleep(1) results = self.backend.search(None, models.SearchTest) self.assertEqual(set(results), set()) # Run update_index command with self.ignore_deprecation_warnings(): # ignore any DeprecationWarnings thrown by models with old-style indexed_fields definitions management.call_command( 'update_index', backend_name=self.backend_name, schema_only=True, interactive=False, stdout=StringIO() ) # Unlike the test_update_index_command test. This should not give any results results = self.backend.search(None, models.SearchTest) self.assertEqual(set(results), set()) class TestElasticsearchSearchQuery(TestCase): def assertDictEqual(self, a, b): default = JSONSerializer().default self.assertEqual( json.dumps(a, sort_keys=True, default=default), json.dumps(b, sort_keys=True, default=default) ) query_class = ElasticsearchSearchBackend.query_class def test_simple(self): # Create a query query = self.query_class(models.SearchTest.objects.all(), "Hello") # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}} }} self.assertDictEqual(query.get_query(), expected_result) def test_none_query_string(self): # Create a query query = self.query_class(models.SearchTest.objects.all(), None) # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'match_all': {}} }} self.assertDictEqual(query.get_query(), expected_result) def test_and_operator(self): # Create a query query = self.query_class(models.SearchTest.objects.all(), "Hello", operator='and') # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials'], 'operator': 'and'}} }} self.assertDictEqual(query.get_query(), expected_result) def test_filter(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title="Test"), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'term': {'title_filter': 'Test'}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_and_filter(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title="Test", live=True), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'and': [{'term': {'live_filter': True}}, {'term': {'title_filter': 'Test'}}]} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} # Make sure field filters are sorted (as they can be in any order which may cause false positives) query = query.get_query() field_filters = query['filtered']['filter']['and'][1]['and'] field_filters[:] = sorted(field_filters, key=lambda f: list(f['term'].keys())[0]) self.assertDictEqual(query, expected_result) def test_or_filter(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(Q(title="Test") | Q(live=True)), "Hello") # Make sure field filters are sorted (as they can be in any order which may cause false positives) query = query.get_query() field_filters = query['filtered']['filter']['and'][1]['or'] field_filters[:] = sorted(field_filters, key=lambda f: list(f['term'].keys())[0]) # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'or': [{'term': {'live_filter': True}}, {'term': {'title_filter': 'Test'}}]} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query, expected_result) def test_negated_filter(self): # Create a query query = self.query_class(models.SearchTest.objects.exclude(live=True), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'not': {'term': {'live_filter': True}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_fields(self): # Create a query query = self.query_class(models.SearchTest.objects.all(), "Hello", fields=['title']) # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'match': {'title': 'Hello'}} }} self.assertDictEqual(query.get_query(), expected_result) def test_fields_with_and_operator(self): # Create a query query = self.query_class(models.SearchTest.objects.all(), "Hello", fields=['title'], operator='and') # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'match': {'title': {'query': 'Hello', 'operator': 'and'}}} }} self.assertDictEqual(query.get_query(), expected_result) def test_multiple_fields(self): # Create a query query = self.query_class(models.SearchTest.objects.all(), "Hello", fields=['title', 'content']) # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'multi_match': {'fields': ['title', 'content'], 'query': 'Hello'}} }} self.assertDictEqual(query.get_query(), expected_result) def test_multiple_fields_with_and_operator(self): # Create a query query = self.query_class( models.SearchTest.objects.all(), "Hello", fields=['title', 'content'], operator='and' ) # Check it expected_result = {'filtered': { 'filter': {'prefix': {'content_type': 'searchtests_searchtest'}}, 'query': {'multi_match': {'fields': ['title', 'content'], 'query': 'Hello', 'operator': 'and'}} }} self.assertDictEqual(query.get_query(), expected_result) def test_exact_lookup(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title__exact="Test"), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'term': {'title_filter': 'Test'}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_none_lookup(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title=None), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'missing': {'field': 'title_filter'}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_isnull_true_lookup(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title__isnull=True), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'missing': {'field': 'title_filter'}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_isnull_false_lookup(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title__isnull=False), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'not': {'missing': {'field': 'title_filter'}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_startswith_lookup(self): # Create a query query = self.query_class(models.SearchTest.objects.filter(title__startswith="Test"), "Hello") # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'prefix': {'title_filter': 'Test'}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_gt_lookup(self): # This also tests conversion of python dates to strings # Create a query query = self.query_class( models.SearchTest.objects.filter(published_date__gt=datetime.datetime(2014, 4, 29)), "Hello" ) # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'range': {'published_date_filter': {'gt': '2014-04-29'}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_lt_lookup(self): # Create a query query = self.query_class( models.SearchTest.objects.filter(published_date__lt=datetime.datetime(2014, 4, 29)), "Hello" ) # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'range': {'published_date_filter': {'lt': '2014-04-29'}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_gte_lookup(self): # Create a query query = self.query_class( models.SearchTest.objects.filter(published_date__gte=datetime.datetime(2014, 4, 29)), "Hello" ) # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'range': {'published_date_filter': {'gte': '2014-04-29'}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_lte_lookup(self): # Create a query query = self.query_class( models.SearchTest.objects.filter(published_date__lte=datetime.datetime(2014, 4, 29)), "Hello" ) # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'range': {'published_date_filter': {'lte': '2014-04-29'}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_range_lookup(self): start_date = datetime.datetime(2014, 4, 29) end_date = datetime.datetime(2014, 8, 19) # Create a query query = self.query_class( models.SearchTest.objects.filter(published_date__range=(start_date, end_date)), "Hello" ) # Check it expected_result = {'filtered': {'filter': {'and': [ {'prefix': {'content_type': 'searchtests_searchtest'}}, {'range': {'published_date_filter': {'gte': '2014-04-29', 'lte': '2014-08-19'}}} ]}, 'query': {'multi_match': {'query': 'Hello', 'fields': ['_all', '_partials']}}}} self.assertDictEqual(query.get_query(), expected_result) def test_custom_ordering(self): # Create a query query = self.query_class( models.SearchTest.objects.order_by('published_date'), "Hello", order_by_relevance=False ) # Check it expected_result = [{'published_date_filter': 'asc'}] self.assertDictEqual(query.get_sort(), expected_result) def test_custom_ordering_reversed(self): # Create a query query = self.query_class( models.SearchTest.objects.order_by('-published_date'), "Hello", order_by_relevance=False ) # Check it expected_result = [{'published_date_filter': 'desc'}] self.assertDictEqual(query.get_sort(), expected_result) def test_custom_ordering_multiple(self): # Create a query query = self.query_class( models.SearchTest.objects.order_by('published_date', 'live'), "Hello", order_by_relevance=False ) # Check it expected_result = [{'published_date_filter': 'asc'}, {'live_filter': 'asc'}] self.assertDictEqual(query.get_sort(), expected_result) class TestElasticsearchSearchResults(TestCase): def assertDictEqual(self, a, b): default = JSONSerializer().default self.assertEqual( json.dumps(a, sort_keys=True, default=default), json.dumps ) def setUp(self): self.objects = [] for i in range(3): self.objects.append(models.SearchTest.objects.create(title=str(i))) def get_results(self): backend = ElasticsearchSearchBackend({}) query = mock.MagicMock() query.queryset = models.SearchTest.objects.all() query.get_query.return_value = 'QUERY' query.get_sort.return_value = None return backend.results_class(backend, query) def construct_search_response(self, results): return { '_shards': {'failed': 0, 'successful': 5, 'total': 5}, 'hits': { 'hits': [ { '_id': 'searchtests_searchtest:' + str(result), '_index': 'wagtail', '_score': 1, '_type': 'searchtests_searchtest', 'fields': { 'pk': [str(result)], } } for result in results ], 'max_score': 1, 'total': len(results) }, 'timed_out': False, 'took': 2 } @mock.patch('elasticsearch.Elasticsearch.search') def test_basic_search(self, search): search.return_value = self.construct_search_response([]) results = self.get_results() list(results) # Performs search search.assert_any_call( from_=0, body={'query': 'QUERY'}, _source=False, fields='pk', index='wagtail' ) @mock.patch('elasticsearch.Elasticsearch.search') def test_get_single_item(self, search): # Need to return something to prevent index error search.return_value = self.construct_search_response([self.objects[0].id]) results = self.get_results() results[10] # Performs search search.assert_any_call( from_=10, body={'query': 'QUERY'}, _source=False, fields='pk', index='wagtail', size=1 ) @mock.patch('elasticsearch.Elasticsearch.search') def test_slice_results(self, search): search.return_value = self.construct_search_response([]) results = self.get_results()[1:4] list(results) # Performs search search.assert_any_call( from_=1, body={'query': 'QUERY'}, _source=False, fields='pk', index='wagtail', size=3 ) @mock.patch('elasticsearch.Elasticsearch.search') def test_slice_results_multiple_times(self, search): search.return_value = self.construct_search_response([]) results = self.get_results()[10:][:10] list(results) # Performs search search.assert_any_call( from_=10, body={'query': 'QUERY'}, _source=False, fields='pk', index='wagtail', size=10 ) @mock.patch('elasticsearch.Elasticsearch.search') def test_slice_results_and_get_item(self, search): # Need to return something to prevent index error search.return_value = self.construct_search_response([self.objects[0].id]) results = self.get_results()[10:] results[10] # Performs search search.assert_any_call( from_=20, body={'query': 'QUERY'}, _source=False, fields='pk', index='wagtail', size=1 ) @mock.patch('elasticsearch.Elasticsearch.search') def test_result_returned(self, search): search.return_value = self.construct_search_response([self.objects[0].id]) results = self.get_results() self.assertEqual(results[0], self.objects[0]) @mock.patch('elasticsearch.Elasticsearch.search') def test_len_1(self, search): search.return_value = self.construct_search_response([self.objects[0].id]) results = self.get_results() self.assertEqual(len(results), 1) @mock.patch('elasticsearch.Elasticsearch.search') def test_len_2(self, search): search.return_value = self.construct_search_response([self.objects[0].id, self.objects[1].id]) results = self.get_results() self.assertEqual(len(results), 2) @mock.patch('elasticsearch.Elasticsearch.search') def test_duplicate_results(self, search): # Duplicates will not be removed search.return_value = self.construct_search_response([self.objects[0].id, self.objects[0].id]) results = list(self.get_results()) # Must cast to list so we only create one query self.assertEqual(len(results), 2) self.assertEqual(results[0], self.objects[0]) self.assertEqual(results[1], self.objects[0]) @mock.patch('elasticsearch.Elasticsearch.search') def test_result_order(self, search): search.return_value = self.construct_search_response( [self.objects[0].id, self.objects[1].id, self.objects[2].id] ) results = list(self.get_results()) # Must cast to list so we only create one query self.assertEqual(results[0], self.objects[0]) self.assertEqual(results[1], self.objects[1]) self.assertEqual(results[2], self.objects[2]) @mock.patch('elasticsearch.Elasticsearch.search') def test_result_order_2(self, search): search.return_value = self.construct_search_response( [self.objects[2].id, self.objects[1].id, self.objects[0].id] ) results = list(self.get_results()) # Must cast to list so we only create one query self.assertEqual(results[0], self.objects[2]) self.assertEqual(results[1], self.objects[1]) self.assertEqual(results[2], self.objects[0]) class TestElasticsearchMapping(TestCase): def assertDictEqual(self, a, b): default = JSONSerializer().default self.assertEqual( json.dumps(a, sort_keys=True, default=default), json.dumps(b, sort_keys=True, default=default) ) def setUp(self): # Create ES mapping self.es_mapping = ElasticsearchSearchBackend.mapping_class(models.SearchTest) # Create ES document self.obj = models.SearchTest(title="Hello") self.obj.save() self.obj.tags.add("a tag") def test_get_document_type(self): self.assertEqual(self.es_mapping.get_document_type(), 'searchtests_searchtest') def test_get_mapping(self): # Build mapping mapping = self.es_mapping.get_mapping() # Check expected_result = { 'searchtests_searchtest': { 'properties': { 'pk': {'index': 'not_analyzed', 'type': 'string', 'store': 'yes', 'include_in_all': False}, 'content_type': {'index': 'not_analyzed', 'type': 'string', 'include_in_all': False}, '_partials': {'index_analyzer': 'edgengram_analyzer', 'include_in_all': False, 'type': 'string'}, 'live_filter': {'index': 'not_analyzed', 'type': 'boolean', 'include_in_all': False}, 'published_date_filter': {'index': 'not_analyzed', 'type': 'date', 'include_in_all': False}, 'title': {'type': 'string', 'include_in_all': True, 'index_analyzer': 'edgengram_analyzer'}, 'title_filter': {'index': 'not_analyzed', 'type': 'string', 'include_in_all': False}, 'content': {'type': 'string', 'include_in_all': True}, 'callable_indexed_field': {'type': 'string', 'include_in_all': True}, 'tags': { 'type': 'nested', 'properties': { 'name': {'type': 'string', 'include_in_all': True, 'index_analyzer': 'edgengram_analyzer'}, 'slug_filter': {'index': 'not_analyzed', 'type': 'string', 'include_in_all': False}, } }, } } } self.assertDictEqual(mapping, expected_result) def test_get_document_id(self): self.assertEqual(self.es_mapping.get_document_id(self.obj), 'searchtests_searchtest:' + str(self.obj.pk)) def test_get_document(self): # Get document document = self.es_mapping.get_document(self.obj) # Sort partials if '_partials' in document: document['_partials'].sort() # Check expected_result = { 'pk': str(self.obj.pk), 'content_type': 'searchtests_searchtest', '_partials': ['Hello', 'a tag'], 'live_filter': False, 'published_date_filter': None, 'title': 'Hello', 'title_filter': 'Hello', 'callable_indexed_field': 'Callable', 'content': '', 'tags': [ { 'name': 'a tag', 'slug_filter': 'a-tag', } ], } self.assertDictEqual(document, expected_result) class TestElasticsearchMappingInheritance(TestCase): def assertDictEqual(self, a, b): default = JSONSerializer().default self.assertEqual( json.dumps(a, sort_keys=True, default=default), json.dumps(b, sort_keys=True, default=default) ) def setUp(self): # Create ES mapping self.es_mapping = ElasticsearchSearchBackend.mapping_class(models.SearchTestChild) # Create ES document self.obj = models.SearchTestChild(title="Hello", subtitle="World", page_id=1) self.obj.save() self.obj.tags.add("a tag") def test_get_document_type(self): self.assertEqual(self.es_mapping.get_document_type(), 'searchtests_searchtest_searchtests_searchtestchild') def test_get_mapping(self): # Build mapping mapping = self.es_mapping.get_mapping() # Check expected_result = { 'searchtests_searchtest_searchtests_searchtestchild': { 'properties': { # New 'extra_content': {'type': 'string', 'include_in_all': True}, 'subtitle': {'type': 'string', 'include_in_all': True, 'index_analyzer': 'edgengram_analyzer'}, 'page': { 'type': 'nested', 'properties': { 'title': {'type': 'string', 'include_in_all': True, 'index_analyzer': 'edgengram_analyzer'}, 'search_description': {'type': 'string', 'include_in_all': True}, 'live_filter': {'index': 'not_analyzed', 'type': 'boolean', 'include_in_all': False}, } }, # Inherited 'pk': {'index': 'not_analyzed', 'type': 'string', 'store': 'yes', 'include_in_all': False}, 'content_type': {'index': 'not_analyzed', 'type': 'string', 'include_in_all': False}, '_partials': {'index_analyzer': 'edgengram_analyzer', 'include_in_all': False, 'type': 'string'}, 'live_filter': {'index': 'not_analyzed', 'type': 'boolean', 'include_in_all': False}, 'published_date_filter': {'index': 'not_analyzed', 'type': 'date', 'include_in_all': False}, 'title': {'type': 'string', 'include_in_all': True, 'index_analyzer': 'edgengram_analyzer'}, 'title_filter': {'index': 'not_analyzed', 'type': 'string', 'include_in_all': False}, 'content': {'type': 'string', 'include_in_all': True}, 'callable_indexed_field': {'type': 'string', 'include_in_all': True}, 'tags': { 'type': 'nested', 'properties': { 'name': {'type': 'string', 'include_in_all': True, 'index_analyzer': 'edgengram_analyzer'}, 'slug_filter': {'index': 'not_analyzed', 'type': 'string', 'include_in_all': False}, } }, } } } self.assertDictEqual(mapping, expected_result) def test_get_document_id(self): # This must be tests_searchtest instead of 'tests_searchtest_tests_searchtestchild' # as it uses the contents base content type name. # This prevents the same object being accidentally indexed twice. self.assertEqual(self.es_mapping.get_document_id(self.obj), 'searchtests_searchtest:' + str(self.obj.pk)) def test_get_document(self): # Build document document = self.es_mapping.get_document(self.obj) # Sort partials if '_partials' in document: document['_partials'].sort() # Check expected_result = { # New 'extra_content': '', 'subtitle': 'World', 'page': { 'title': 'Root', 'search_description': '', 'live_filter': True, }, # Changed 'content_type': 'searchtests_searchtest_searchtests_searchtestchild', # Inherited 'pk': str(self.obj.pk), '_partials': ['Hello', 'Root', 'World', 'a tag'], 'live_filter': False, 'published_date_filter': None, 'title': 'Hello', 'title_filter': 'Hello', 'callable_indexed_field': 'Callable', 'content': '', 'tags': [ { 'name': 'a tag', 'slug_filter': 'a-tag', } ], } self.assertDictEqual(document, expected_result) class TestBackendConfiguration(TestCase): def test_default_settings(self): backend = ElasticsearchSearchBackend(params={}) self.assertEqual(len(backend.hosts), 1) self.assertEqual(backend.hosts[0]['host'], 'localhost') self.assertEqual(backend.hosts[0]['port'], 9200) self.assertEqual(backend.hosts[0]['use_ssl'], False) def test_hosts(self): # This tests that HOSTS goes to es_hosts backend = ElasticsearchSearchBackend(params={ 'HOSTS': [ { 'host': '127.0.0.1', 'port': 9300, 'use_ssl': True, 'verify_certs': True, } ] }) self.assertEqual(len(backend.hosts), 1) self.assertEqual(backend.hosts[0]['host'], '127.0.0.1') self.assertEqual(backend.hosts[0]['port'], 9300) self.assertEqual(backend.hosts[0]['use_ssl'], True) def test_urls(self): # This test backwards compatibility with old URLS setting backend = ElasticsearchSearchBackend(params={ 'URLS': [ 'http://localhost:12345', 'https://127.0.0.1:54321', 'http://username:password@elasticsearch.mysite.com', 'https://elasticsearch.mysite.com/hello', ], }) self.assertEqual(len(backend.hosts), 4) self.assertEqual(backend.hosts[0]['host'], 'localhost') self.assertEqual(backend.hosts[0]['port'], 12345) self.assertEqual(backend.hosts[0]['use_ssl'], False) self.assertEqual(backend.hosts[1]['host'], '127.0.0.1') self.assertEqual(backend.hosts[1]['port'], 54321) self.assertEqual(backend.hosts[1]['use_ssl'], True) self.assertEqual(backend.hosts[2]['host'], 'elasticsearch.mysite.com') self.assertEqual(backend.hosts[2]['port'], 80) self.assertEqual(backend.hosts[2]['use_ssl'], False) self.assertEqual(backend.hosts[2]['http_auth'], ('username', 'password')) self.assertEqual(backend.hosts[3]['host'], 'elasticsearch.mysite.com') self.assertEqual(backend.hosts[3]['port'], 443) self.assertEqual(backend.hosts[3]['use_ssl'], True) self.assertEqual(backend.hosts[3]['url_prefix'], '/hello') @unittest.skipUnless(os.environ.get('ELASTICSEARCH_URL', False), "ELASTICSEARCH_URL not set") class TestRebuilder(TestCase): def assertDictEqual(self, a, b): default = JSONSerializer().default self.assertEqual( json.dumps(a, sort_keys=True, default=default), json.dumps(b, sort_keys=True, default=default) ) def setUp(self): self.backend = get_search_backend('elasticsearch') self.es = self.backend.es self.rebuilder = self.backend.get_rebuilder() self.backend.reset_index() def test_start_creates_index(self): # First, make sure the index is deleted try: self.es.indices.delete(self.backend.index_name) except self.NotFoundError: pass self.assertFalse(self.es.indices.exists(self.backend.index_name)) # Run start self.rebuilder.start() # Check the index exists self.assertTrue(self.es.indices.exists(self.backend.index_name)) def test_start_deletes_existing_index(self): # Put an alias into the index so we can check it was deleted self.es.indices.put_alias(name='this_index_should_be_deleted', index=self.backend.index_name) self.assertTrue( self.es.indices.exists_alias(name='this_index_should_be_deleted', index=self.backend.index_name) ) # Run start self.rebuilder.start() # The alias should be gone (proving the index was deleted and recreated) self.assertFalse( self.es.indices.exists_alias(name='this_index_should_be_deleted', index=self.backend.index_name) ) @unittest.skipUnless(os.environ.get('ELASTICSEARCH_URL', False), "ELASTICSEARCH_URL not set") class TestAtomicRebuilder(TestCase): def setUp(self): self.backend = get_search_backend('elasticsearch') self.backend.rebuilder_class = self.backend.atomic_rebuilder_class self.es = self.backend.es self.rebuilder = self.backend.get_rebuilder() self.backend.reset_index() def test_start_creates_new_index(self): # Rebuilder should make up a new index name that doesn't currently exist self.assertFalse(self.es.indices.exists(self.rebuilder.index.name)) # Run start self.rebuilder.start() # Check the index exists self.assertTrue(self.es.indices.exists(self.rebuilder.index.name)) def test_start_doesnt_delete_current_index(self): # Get current index name current_index_name = list(self.es.indices.get_alias(name=self.rebuilder.alias.name).keys())[0] # Run start self.rebuilder.start() # The index should still exist self.assertTrue(self.es.indices.exists(current_index_name)) # And the alias should still point to it self.assertTrue(self.es.indices.exists_alias(name=self.rebuilder.alias.name, index=current_index_name)) def test_finish_updates_alias(self): # Run start self.rebuilder.start() # Check that the alias doesn't point to new index self.assertFalse( self.es.indices.exists_alias(name=self.rebuilder.alias.name, index=self.rebuilder.index.name) ) # Run finish self.rebuilder.finish() # Check that the alias now points to the new index self.assertTrue(self.es.indices.exists_alias(name=self.rebuilder.alias.name, index=self.rebuilder.index.name)) def test_finish_deletes_old_index(self): # Get current index name current_index_name = list(self.es.indices.get_alias(name=self.rebuilder.alias.name).keys())[0] # Run start self.rebuilder.start() # Index should still exist self.assertTrue(self.es.indices.exists(current_index_name)) # Run finish self.rebuilder.finish() # Index should be gone self.assertFalse(self.es.indices.exists(current_index_name)) class TestOldNameDeprecationWarning(TestCase): def test_old_name_deprecation(self): from wagtail.wagtailsearch.backends.elasticsearch import ElasticSearch with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') ElasticSearch({}) self.assertEqual(len(w), 1) self.assertIs(w[0].category, RemovedInWagtail18Warning)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 747, 199, 646, 900, 199, 646, 2882, 199, 646, 3598, 199, 199, 646, 1683, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 4174, 492, 5228, 199, 504, 24380, 1733, 14, 8349, 492, 4840, 7299, 199, 199, 504, 7328, 14, 2219, 14, 1733, 492, 1709, 199, 504, 7328, 14, 1208, 14, 15383, 492, 799, 17920, 55, 6396, 1085, 3849, 199, 504, 7328, 14, 17296, 1733, 14, 7765, 492, 664, 63, 1733, 63, 4620, 199, 504, 7328, 14, 17296, 1733, 14, 7765, 14, 25651, 492, 19509, 1733, 5278, 8447, 199, 199, 504, 1275, 396, 63, 7765, 492, 25674, 2925, 421, 199, 533, 1379, 27822, 1733, 5278, 8447, 8, 8447, 2925, 12, 7640, 304, 272, 4865, 63, 515, 275, 283, 17296, 14, 17296, 1733, 14, 7765, 14, 25651, 7, 339, 347, 511, 63, 1733, 63, 1045, 63, 10749, 63, 2118, 8, 277, 304, 267, 327, 8730, 367, 2005, 4601, 4110, 436, 3661, 652, 3181, 1133, 12420, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 257, 3872, 1709, 14, 5278, 774, 9, 398, 327, 5843, 5460, 787, 29667, 3444, 13006, 12, 3542, 652, 370, 1255, 267, 769, 8, 2604, 9, 398, 327, 29503, 78, 1133, 12420, 12, 612, 1187, 1, 339, 347, 511, 63, 1541, 63, 265, 63, 2865, 63, 1541, 1080, 63, 698, 8, 277, 304, 267, 327, 1305, 365, 440, 10532, 315, 314, 2754, 63, 955, 367, 8730, 774, 27, 642, 1077, 746, 282, 27691, 267, 687, 7328, 14, 17296, 1733, 14, 7765, 14, 1095, 492, 27691, 398, 543, 291, 14, 1855, 8, 792, 547, 304, 288, 769, 8, 277, 14, 4620, 14, 1733, 480, 6257, 401, 1709, 14, 5278, 774, 12, 4766, 29, 807, 8, 344, 29, 2260, 1724, 339, 347, 511, 63, 1541, 63, 1045, 63, 15267, 63, 3892, 63, 466, 8, 277, 304, 267, 687, 7328, 14, 17296, 1733, 14, 7765, 14, 1095, 492, 9388, 547, 398, 543, 291, 14, 1855, 8, 4131, 547, 304, 288, 769, 8, 277, 14, 4620, 14, 1733, 480, 6257, 401, 1709, 14, 5278, 774, 12, 4766, 29, 807, 8, 1213, 363, 3621, 2145, 534, 72, 8, 4489, 9, 76, 320, 7058, 339, 347, 511, 63, 6672, 63, 1733, 8, 277, 304, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 327, 2654, 2005, 511, 666, 267, 1559, 275, 1709, 14, 5278, 774, 342, 267, 1559, 14, 1213, 275, 298, 6257, 15943, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9, 398, 327, 30345, 314, 1478, 267, 291, 14, 4620, 14, 6635, 63, 1080, 342, 398, 327, 8730, 436, 1104, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 6257, 55, 401, 1709, 14, 5278, 774, 14, 1462, 14, 452, 1012, 398, 291, 14, 629, 8, 552, 8, 2604, 395, 413, 9, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 344, 12, 1559, 14, 344, 9, 339, 347, 511, 63, 1739, 63, 6672, 63, 1733, 8, 277, 304, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 1559, 275, 1709, 14, 5278, 774, 3493, 342, 267, 1559, 14, 1213, 275, 298, 15943, 6257, 2, 267, 1559, 14, 14348, 275, 298, 6257, 15943, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9, 398, 327, 30345, 314, 1478, 267, 291, 14, 4620, 14, 6635, 63, 1080, 342, 398, 327, 8730, 436, 1104, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 6257, 55, 401, 1709, 14, 5278, 774, 14, 1462, 14, 452, 1012, 398, 291, 14, 629, 8, 552, 8, 2604, 395, 413, 9, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 344, 12, 1559, 14, 344, 9, 339, 347, 511, 63, 4371, 63, 5900, 1098, 8, 277, 304, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 327, 2654, 2005, 511, 666, 267, 1559, 275, 1709, 14, 5278, 774, 342, 267, 1559, 14, 1213, 275, 298, 129, 98, 5741, 914, 31087, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9, 398, 327, 30345, 314, 1478, 267, 291, 14, 4620, 14, 6635, 63, 1080, 342, 398, 327, 8730, 436, 1104, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 6257, 401, 1709, 14, 5278, 774, 14, 1462, 14, 452, 1012, 398, 291, 14, 629, 8, 552, 8, 2604, 395, 413, 9, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 344, 12, 1559, 14, 344, 9, 339, 347, 511, 63, 1131, 63, 4797, 332, 8, 277, 304, 267, 408, 267, 961, 365, 5343, 626, 1504, 626, 675, 3988, 2268, 1679, 63, 17965, 465, 3932, 1478, 5909, 332, 886, 440, 267, 1172, 652, 2597, 465, 3932, 1827, 5909, 332, 267, 408, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 327, 2654, 2005, 511, 666, 267, 1559, 275, 1709, 14, 5278, 774, 342, 267, 1559, 14, 1213, 275, 298, 6257, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 747, 199, 646, 900, 199, 646, 2882, 199, 646, 3598, 199, 199, 646, 1683, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 1208, 14, 4174, 492, 5228, 199, 504, 24380, 1733, 14, 8349, 492, 4840, 7299, 199, 199, 504, 7328, 14, 2219, 14, 1733, 492, 1709, 199, 504, 7328, 14, 1208, 14, 15383, 492, 799, 17920, 55, 6396, 1085, 3849, 199, 504, 7328, 14, 17296, 1733, 14, 7765, 492, 664, 63, 1733, 63, 4620, 199, 504, 7328, 14, 17296, 1733, 14, 7765, 14, 25651, 492, 19509, 1733, 5278, 8447, 199, 199, 504, 1275, 396, 63, 7765, 492, 25674, 2925, 421, 199, 533, 1379, 27822, 1733, 5278, 8447, 8, 8447, 2925, 12, 7640, 304, 272, 4865, 63, 515, 275, 283, 17296, 14, 17296, 1733, 14, 7765, 14, 25651, 7, 339, 347, 511, 63, 1733, 63, 1045, 63, 10749, 63, 2118, 8, 277, 304, 267, 327, 8730, 367, 2005, 4601, 4110, 436, 3661, 652, 3181, 1133, 12420, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 257, 3872, 1709, 14, 5278, 774, 9, 398, 327, 5843, 5460, 787, 29667, 3444, 13006, 12, 3542, 652, 370, 1255, 267, 769, 8, 2604, 9, 398, 327, 29503, 78, 1133, 12420, 12, 612, 1187, 1, 339, 347, 511, 63, 1541, 63, 265, 63, 2865, 63, 1541, 1080, 63, 698, 8, 277, 304, 267, 327, 1305, 365, 440, 10532, 315, 314, 2754, 63, 955, 367, 8730, 774, 27, 642, 1077, 746, 282, 27691, 267, 687, 7328, 14, 17296, 1733, 14, 7765, 14, 1095, 492, 27691, 398, 543, 291, 14, 1855, 8, 792, 547, 304, 288, 769, 8, 277, 14, 4620, 14, 1733, 480, 6257, 401, 1709, 14, 5278, 774, 12, 4766, 29, 807, 8, 344, 29, 2260, 1724, 339, 347, 511, 63, 1541, 63, 1045, 63, 15267, 63, 3892, 63, 466, 8, 277, 304, 267, 687, 7328, 14, 17296, 1733, 14, 7765, 14, 1095, 492, 9388, 547, 398, 543, 291, 14, 1855, 8, 4131, 547, 304, 288, 769, 8, 277, 14, 4620, 14, 1733, 480, 6257, 401, 1709, 14, 5278, 774, 12, 4766, 29, 807, 8, 1213, 363, 3621, 2145, 534, 72, 8, 4489, 9, 76, 320, 7058, 339, 347, 511, 63, 6672, 63, 1733, 8, 277, 304, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 327, 2654, 2005, 511, 666, 267, 1559, 275, 1709, 14, 5278, 774, 342, 267, 1559, 14, 1213, 275, 298, 6257, 15943, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9, 398, 327, 30345, 314, 1478, 267, 291, 14, 4620, 14, 6635, 63, 1080, 342, 398, 327, 8730, 436, 1104, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 6257, 55, 401, 1709, 14, 5278, 774, 14, 1462, 14, 452, 1012, 398, 291, 14, 629, 8, 552, 8, 2604, 395, 413, 9, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 344, 12, 1559, 14, 344, 9, 339, 347, 511, 63, 1739, 63, 6672, 63, 1733, 8, 277, 304, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 1559, 275, 1709, 14, 5278, 774, 3493, 342, 267, 1559, 14, 1213, 275, 298, 15943, 6257, 2, 267, 1559, 14, 14348, 275, 298, 6257, 15943, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9, 398, 327, 30345, 314, 1478, 267, 291, 14, 4620, 14, 6635, 63, 1080, 342, 398, 327, 8730, 436, 1104, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 6257, 55, 401, 1709, 14, 5278, 774, 14, 1462, 14, 452, 1012, 398, 291, 14, 629, 8, 552, 8, 2604, 395, 413, 9, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 344, 12, 1559, 14, 344, 9, 339, 347, 511, 63, 4371, 63, 5900, 1098, 8, 277, 304, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 327, 2654, 2005, 511, 666, 267, 1559, 275, 1709, 14, 5278, 774, 342, 267, 1559, 14, 1213, 275, 298, 129, 98, 5741, 914, 31087, 2, 267, 1559, 14, 6442, 275, 715, 267, 1559, 14, 2117, 342, 267, 291, 14, 4620, 14, 525, 8, 1113, 9, 398, 327, 30345, 314, 1478, 267, 291, 14, 4620, 14, 6635, 63, 1080, 342, 398, 327, 8730, 436, 1104, 267, 2058, 275, 291, 14, 4620, 14, 1733, 480, 6257, 401, 1709, 14, 5278, 774, 14, 1462, 14, 452, 1012, 398, 291, 14, 629, 8, 552, 8, 2604, 395, 413, 9, 267, 291, 14, 629, 8, 2604, 59, 16, 1055, 344, 12, 1559, 14, 344, 9, 339, 347, 511, 63, 1131, 63, 4797, 332, 8, 277, 304, 267, 408, 267, 961, 365, 5343, 626, 1504, 626, 675, 3988, 2268, 1679, 63, 17965, 465, 3932, 1478, 5909, 332, 886, 440, 267, 1172, 652, 2597, 465, 3932, 1827, 5909, 332, 267, 408, 267, 327, 15510, 314, 1478, 267, 291, 14, 4620, 14, 3958, 63, 1080, 342, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 9, 267, 291, 14, 4620, 14, 525, 63, 466, 8, 992, 14, 5278, 774, 3493, 9, 398, 327, 2654, 2005, 511, 666, 267, 1559, 275, 1709, 14, 5278, 774, 342, 267, 1559, 14, 1213, 275, 298, 6257, 2, 267, 1559, 14, 6442, 275, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
siosio/intellij-community
python/helpers/py3only/docutils/core.py
44
29431
# $Id: core.py 7466 2012-06-25 14:56:51Z milde $ # Author: David Goodger <goodger@python.org> # Copyright: This module has been placed in the public domain. """ Calling the ``publish_*`` convenience functions (or instantiating a `Publisher` object) with component names will result in default behavior. For custom behavior (setting component options), create custom component objects first, and pass *them* to ``publish_*``/`Publisher`. See `The Docutils Publisher`_. .. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html """ __docformat__ = 'reStructuredText' import pprint import sys import docutils.readers.doctree from docutils import __version__, __version_details__, SettingsSpec from docutils import frontend, io, utils, readers, writers from docutils.frontend import OptionParser from docutils.utils.error_reporting import ErrorOutput, ErrorString class Publisher: """ A facade encapsulating the high-level logic of a Docutils system. """ def __init__(self, reader=None, parser=None, writer=None, source=None, source_class=io.FileInput, destination=None, destination_class=io.FileOutput, settings=None): """ Initial setup. If any of `reader`, `parser`, or `writer` are not specified, the corresponding ``set_...`` method should be called with a component name (`set_reader` sets the parser as well). """ self.document = None """The document tree (`docutils.nodes` objects).""" self.reader = reader """A `docutils.readers.Reader` instance.""" self.parser = parser """A `docutils.parsers.Parser` instance.""" self.writer = writer """A `docutils.writers.Writer` instance.""" for component in 'reader', 'parser', 'writer': assert not isinstance(getattr(self, component), str), ( 'passed string "%s" as "%s" parameter; pass an instance, ' 'or use the "%s_name" parameter instead (in ' 'docutils.core.publish_* convenience functions).' % (getattr(self, component), component, component)) self.source = source """The source of input data, a `docutils.io.Input` instance.""" self.source_class = source_class """The class for dynamically created source objects.""" self.destination = destination """The destination for docutils output, a `docutils.io.Output` instance.""" self.destination_class = destination_class """The class for dynamically created destination objects.""" self.settings = settings """An object containing Docutils settings as instance attributes. Set by `self.process_command_line()` or `self.get_settings()`.""" self._stderr = ErrorOutput() def set_reader(self, reader_name, parser, parser_name): """Set `self.reader` by name.""" reader_class = readers.get_reader_class(reader_name) self.reader = reader_class(parser, parser_name) self.parser = self.reader.parser def set_writer(self, writer_name): """Set `self.writer` by name.""" writer_class = writers.get_writer_class(writer_name) self.writer = writer_class() def set_components(self, reader_name, parser_name, writer_name): if self.reader is None: self.set_reader(reader_name, self.parser, parser_name) if self.parser is None: if self.reader.parser is None: self.reader.set_parser(parser_name) self.parser = self.reader.parser if self.writer is None: self.set_writer(writer_name) def setup_option_parser(self, usage=None, description=None, settings_spec=None, config_section=None, **defaults): if config_section: if not settings_spec: settings_spec = SettingsSpec() settings_spec.config_section = config_section parts = config_section.split() if len(parts) > 1 and parts[-1] == 'application': settings_spec.config_section_dependencies = ['applications'] #@@@ Add self.source & self.destination to components in future? option_parser = OptionParser( components=(self.parser, self.reader, self.writer, settings_spec), defaults=defaults, read_config_files=True, usage=usage, description=description) return option_parser def get_settings(self, usage=None, description=None, settings_spec=None, config_section=None, **defaults): """ Set and return default settings (overrides in `defaults` dict). Set components first (`self.set_reader` & `self.set_writer`). Explicitly setting `self.settings` disables command line option processing from `self.publish()`. """ option_parser = self.setup_option_parser( usage, description, settings_spec, config_section, **defaults) self.settings = option_parser.get_default_values() return self.settings def process_programmatic_settings(self, settings_spec, settings_overrides, config_section): if self.settings is None: defaults = (settings_overrides or {}).copy() # Propagate exceptions by default when used programmatically: defaults.setdefault('traceback', True) self.get_settings(settings_spec=settings_spec, config_section=config_section, **defaults) def process_command_line(self, argv=None, usage=None, description=None, settings_spec=None, config_section=None, **defaults): """ Pass an empty list to `argv` to avoid reading `sys.argv` (the default). Set components first (`self.set_reader` & `self.set_writer`). """ option_parser = self.setup_option_parser( usage, description, settings_spec, config_section, **defaults) if argv is None: argv = sys.argv[1:] # converting to Unicode (Python 3 does this automatically): if sys.version_info < (3,0): # TODO: make this failsafe and reversible? argv_encoding = (frontend.locale_encoding or 'ascii') argv = [a.decode(argv_encoding) for a in argv] self.settings = option_parser.parse_args(argv) def set_io(self, source_path=None, destination_path=None): if self.source is None: self.set_source(source_path=source_path) if self.destination is None: self.set_destination(destination_path=destination_path) def set_source(self, source=None, source_path=None): if source_path is None: source_path = self.settings._source else: self.settings._source = source_path # Raise IOError instead of system exit with `tracback == True` # TODO: change io.FileInput's default behaviour and remove this hack try: self.source = self.source_class( source=source, source_path=source_path, encoding=self.settings.input_encoding) except TypeError: self.source = self.source_class( source=source, source_path=source_path, encoding=self.settings.input_encoding) def set_destination(self, destination=None, destination_path=None): if destination_path is None: destination_path = self.settings._destination else: self.settings._destination = destination_path self.destination = self.destination_class( destination=destination, destination_path=destination_path, encoding=self.settings.output_encoding, error_handler=self.settings.output_encoding_error_handler) def apply_transforms(self): self.document.transformer.populate_from_components( (self.source, self.reader, self.reader.parser, self.writer, self.destination)) self.document.transformer.apply_transforms() def publish(self, argv=None, usage=None, description=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False): """ Process command line options and arguments (if `self.settings` not already set), run `self.reader` and then `self.writer`. Return `self.writer`'s output. """ exit = None try: if self.settings is None: self.process_command_line( argv, usage, description, settings_spec, config_section, **(settings_overrides or {})) self.set_io() self.document = self.reader.read(self.source, self.parser, self.settings) self.apply_transforms() output = self.writer.write(self.document, self.destination) self.writer.assemble_parts() except SystemExit as error: exit = 1 exit_status = error.code except Exception as error: if not self.settings: # exception too early to report nicely raise if self.settings.traceback: # Propagate exceptions? self.debugging_dumps() raise self.report_Exception(error) exit = True exit_status = 1 self.debugging_dumps() if (enable_exit_status and self.document and (self.document.reporter.max_level >= self.settings.exit_status_level)): sys.exit(self.document.reporter.max_level + 10) elif exit: sys.exit(exit_status) return output def debugging_dumps(self): if not self.document: return if self.settings.dump_settings: print('\n::: Runtime settings:', file=self._stderr) print(pprint.pformat(self.settings.__dict__), file=self._stderr) if self.settings.dump_internals: print('\n::: Document internals:', file=self._stderr) print(pprint.pformat(self.document.__dict__), file=self._stderr) if self.settings.dump_transforms: print('\n::: Transforms applied:', file=self._stderr) print((' (priority, transform class, ' 'pending node details, keyword args)'), file=self._stderr) print(pprint.pformat( [(priority, '%s.%s' % (xclass.__module__, xclass.__name__), pending and pending.details, kwargs) for priority, xclass, pending, kwargs in self.document.transformer.applied]), file=self._stderr) if self.settings.dump_pseudo_xml: print('\n::: Pseudo-XML:', file=self._stderr) print(self.document.pformat().encode( 'raw_unicode_escape'), file=self._stderr) def report_Exception(self, error): if isinstance(error, utils.SystemMessage): self.report_SystemMessage(error) elif isinstance(error, UnicodeEncodeError): self.report_UnicodeError(error) elif isinstance(error, io.InputError): self._stderr.write('Unable to open source file for reading:\n' ' %s\n' % ErrorString(error)) elif isinstance(error, io.OutputError): self._stderr.write( 'Unable to open destination file for writing:\n' ' %s\n' % ErrorString(error)) else: print('%s' % ErrorString(error), file=self._stderr) print(("""\ Exiting due to error. Use "--traceback" to diagnose. Please report errors to <docutils-users@lists.sf.net>. Include "--traceback" output, Docutils version (%s [%s]), Python version (%s), your OS type & version, and the command line used.""" % (__version__, __version_details__, sys.version.split()[0])), file=self._stderr) def report_SystemMessage(self, error): print(('Exiting due to level-%s (%s) system message.' % (error.level, utils.Reporter.levels[error.level])), file=self._stderr) def report_UnicodeError(self, error): data = error.object[error.start:error.end] self._stderr.write( '%s\n' '\n' 'The specified output encoding (%s) cannot\n' 'handle all of the output.\n' 'Try setting "--output-encoding-error-handler" to\n' '\n' '* "xmlcharrefreplace" (for HTML & XML output);\n' ' the output will contain "%s" and should be usable.\n' '* "backslashreplace" (for other output formats);\n' ' look for "%s" in the output.\n' '* "replace"; look for "?" in the output.\n' '\n' '"--output-encoding-error-handler" is currently set to "%s".\n' '\n' 'Exiting due to error. Use "--traceback" to diagnose.\n' 'If the advice above doesn\'t eliminate the error,\n' 'please report it to <docutils-users@lists.sf.net>.\n' 'Include "--traceback" output, Docutils version (%s),\n' 'Python version (%s), your OS type & version, and the\n' 'command line used.\n' % (ErrorString(error), self.settings.output_encoding, data.encode('ascii', 'xmlcharrefreplace'), data.encode('ascii', 'backslashreplace'), self.settings.output_encoding_error_handler, __version__, sys.version.split()[0])) default_usage = '%prog [options] [<source> [<destination>]]' default_description = ('Reads from <source> (default is stdin) and writes to ' '<destination> (default is stdout). See ' '<http://docutils.sf.net/docs/user/config.html> for ' 'the full reference.') def publish_cmdline(reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=True, argv=None, usage=default_usage, description=default_description): """ Set up & run a `Publisher` for command-line-based file I/O (input and output file paths taken automatically from the command line). Return the encoded string output also. Parameters: see `publish_programmatically` for the remainder. - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. - `usage`: Usage string, output if there's a problem parsing the command line. - `description`: Program description, output for the "--help" option (along with command-line option descriptions). """ pub = Publisher(reader, parser, writer, settings=settings) pub.set_components(reader_name, parser_name, writer_name) output = pub.publish( argv, usage, description, settings_spec, settings_overrides, config_section=config_section, enable_exit_status=enable_exit_status) return output def publish_file(source=None, source_path=None, destination=None, destination_path=None, reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False): """ Set up & run a `Publisher` for programmatic use with file-like I/O. Return the encoded string output also. Parameters: see `publish_programmatically`. """ output, pub = publish_programmatically( source_class=io.FileInput, source=source, source_path=source_path, destination_class=io.FileOutput, destination=destination, destination_path=destination_path, reader=reader, reader_name=reader_name, parser=parser, parser_name=parser_name, writer=writer, writer_name=writer_name, settings=settings, settings_spec=settings_spec, settings_overrides=settings_overrides, config_section=config_section, enable_exit_status=enable_exit_status) return output def publish_string(source, source_path=None, destination_path=None, reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False): """ Set up & run a `Publisher` for programmatic use with string I/O. Return the encoded string or Unicode string output. For encoded string output, be sure to set the 'output_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string output. Here's one way:: publish_string(..., settings_overrides={'output_encoding': 'unicode'}) Similarly for Unicode string input (`source`):: publish_string(..., settings_overrides={'input_encoding': 'unicode'}) Parameters: see `publish_programmatically`. """ output, pub = publish_programmatically( source_class=io.StringInput, source=source, source_path=source_path, destination_class=io.StringOutput, destination=None, destination_path=destination_path, reader=reader, reader_name=reader_name, parser=parser, parser_name=parser_name, writer=writer, writer_name=writer_name, settings=settings, settings_spec=settings_spec, settings_overrides=settings_overrides, config_section=config_section, enable_exit_status=enable_exit_status) return output def publish_parts(source, source_path=None, source_class=io.StringInput, destination_path=None, reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False): """ Set up & run a `Publisher`, and return a dictionary of document parts. Dictionary keys are the names of parts, and values are Unicode strings; encoding is up to the client. For programmatic use with string I/O. For encoded string input, be sure to set the 'input_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string input. Here's how:: publish_parts(..., settings_overrides={'input_encoding': 'unicode'}) Parameters: see `publish_programmatically`. """ output, pub = publish_programmatically( source=source, source_path=source_path, source_class=source_class, destination_class=io.StringOutput, destination=None, destination_path=destination_path, reader=reader, reader_name=reader_name, parser=parser, parser_name=parser_name, writer=writer, writer_name=writer_name, settings=settings, settings_spec=settings_spec, settings_overrides=settings_overrides, config_section=config_section, enable_exit_status=enable_exit_status) return pub.writer.parts def publish_doctree(source, source_path=None, source_class=io.StringInput, reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False): """ Set up & run a `Publisher` for programmatic use with string I/O. Return the document tree. For encoded string input, be sure to set the 'input_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string input. Here's one way:: publish_doctree(..., settings_overrides={'input_encoding': 'unicode'}) Parameters: see `publish_programmatically`. """ pub = Publisher(reader=reader, parser=parser, writer=None, settings=settings, source_class=source_class, destination_class=io.NullOutput) pub.set_components(reader_name, parser_name, 'null') pub.process_programmatic_settings( settings_spec, settings_overrides, config_section) pub.set_source(source, source_path) pub.set_destination(None, None) output = pub.publish(enable_exit_status=enable_exit_status) return pub.document def publish_from_doctree(document, destination_path=None, writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False): """ Set up & run a `Publisher` to render from an existing document tree data structure, for programmatic use with string I/O. Return the encoded string output. Note that document.settings is overridden; if you want to use the settings of the original `document`, pass settings=document.settings. Also, new document.transformer and document.reporter objects are generated. For encoded string output, be sure to set the 'output_encoding' setting to the desired encoding. Set it to 'unicode' for unencoded Unicode string output. Here's one way:: publish_from_doctree( ..., settings_overrides={'output_encoding': 'unicode'}) Parameters: `document` is a `docutils.nodes.document` object, an existing document tree. Other parameters: see `publish_programmatically`. """ reader = docutils.readers.doctree.Reader(parser_name='null') pub = Publisher(reader, None, writer, source=io.DocTreeInput(document), destination_class=io.StringOutput, settings=settings) if not writer and writer_name: pub.set_writer(writer_name) pub.process_programmatic_settings( settings_spec, settings_overrides, config_section) pub.set_destination(None, destination_path) return pub.publish(enable_exit_status=enable_exit_status) def publish_cmdline_to_binary(reader=None, reader_name='standalone', parser=None, parser_name='restructuredtext', writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=True, argv=None, usage=default_usage, description=default_description, destination=None, destination_class=io.BinaryFileOutput ): """ Set up & run a `Publisher` for command-line-based file I/O (input and output file paths taken automatically from the command line). Return the encoded string output also. This is just like publish_cmdline, except that it uses io.BinaryFileOutput instead of io.FileOutput. Parameters: see `publish_programmatically` for the remainder. - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. - `usage`: Usage string, output if there's a problem parsing the command line. - `description`: Program description, output for the "--help" option (along with command-line option descriptions). """ pub = Publisher(reader, parser, writer, settings=settings, destination_class=destination_class) pub.set_components(reader_name, parser_name, writer_name) output = pub.publish( argv, usage, description, settings_spec, settings_overrides, config_section=config_section, enable_exit_status=enable_exit_status) return output def publish_programmatically(source_class, source, source_path, destination_class, destination, destination_path, reader, reader_name, parser, parser_name, writer, writer_name, settings, settings_spec, settings_overrides, config_section, enable_exit_status): """ Set up & run a `Publisher` for custom programmatic use. Return the encoded string output and the Publisher object. Applications should not need to call this function directly. If it does seem to be necessary to call this function directly, please write to the Docutils-develop mailing list <http://docutils.sf.net/docs/user/mailing-lists.html#docutils-develop>. Parameters: * `source_class` **required**: The class for dynamically created source objects. Typically `io.FileInput` or `io.StringInput`. * `source`: Type depends on `source_class`: - If `source_class` is `io.FileInput`: Either a file-like object (must have 'read' and 'close' methods), or ``None`` (`source_path` is opened). If neither `source` nor `source_path` are supplied, `sys.stdin` is used. - If `source_class` is `io.StringInput` **required**: The input string, either an encoded 8-bit string (set the 'input_encoding' setting to the correct encoding) or a Unicode string (set the 'input_encoding' setting to 'unicode'). * `source_path`: Type depends on `source_class`: - `io.FileInput`: Path to the input file, opened if no `source` supplied. - `io.StringInput`: Optional. Path to the file or object that produced `source`. Only used for diagnostic output. * `destination_class` **required**: The class for dynamically created destination objects. Typically `io.FileOutput` or `io.StringOutput`. * `destination`: Type depends on `destination_class`: - `io.FileOutput`: Either a file-like object (must have 'write' and 'close' methods), or ``None`` (`destination_path` is opened). If neither `destination` nor `destination_path` are supplied, `sys.stdout` is used. - `io.StringOutput`: Not used; pass ``None``. * `destination_path`: Type depends on `destination_class`: - `io.FileOutput`: Path to the output file. Opened if no `destination` supplied. - `io.StringOutput`: Path to the file or object which will receive the output; optional. Used for determining relative paths (stylesheets, source links, etc.). * `reader`: A `docutils.readers.Reader` object. * `reader_name`: Name or alias of the Reader class to be instantiated if no `reader` supplied. * `parser`: A `docutils.parsers.Parser` object. * `parser_name`: Name or alias of the Parser class to be instantiated if no `parser` supplied. * `writer`: A `docutils.writers.Writer` object. * `writer_name`: Name or alias of the Writer class to be instantiated if no `writer` supplied. * `settings`: A runtime settings (`docutils.frontend.Values`) object, for dotted-attribute access to runtime settings. It's the end result of the `SettingsSpec`, config file, and option processing. If `settings` is passed, it's assumed to be complete and no further setting/config/option processing is done. * `settings_spec`: A `docutils.SettingsSpec` subclass or object. Provides extra application-specific settings definitions independently of components. In other words, the application becomes a component, and its settings data is processed along with that of the other components. Used only if no `settings` specified. * `settings_overrides`: A dictionary containing application-specific settings defaults that override the defaults of other components. Used only if no `settings` specified. * `config_section`: A string, the name of the configuration file section for this application. Overrides the ``config_section`` attribute defined by `settings_spec`. Used only if no `settings` specified. * `enable_exit_status`: Boolean; enable exit status at end of processing? """ pub = Publisher(reader, parser, writer, settings=settings, source_class=source_class, destination_class=destination_class) pub.set_components(reader_name, parser_name, writer_name) pub.process_programmatic_settings( settings_spec, settings_overrides, config_section) pub.set_source(source, source_path) pub.set_destination(destination, destination_path) output = pub.publish(enable_exit_status=enable_exit_status) return output, pub
apache-2.0
[ 3, 2672, 1304, 26, 6170, 14, 647, 9720, 1272, 6029, 13, 1690, 13, 821, 4329, 26, 1367, 26, 2869, 58, 333, 24446, 2672, 199, 3, 6529, 26, 20232, 22311, 836, 665, 8302, 836, 32, 1548, 14, 1308, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 624, 199, 23796, 314, 1124, 4763, 15192, 1040, 16777, 3423, 334, 269, 9034, 1958, 282, 199, 64, 27341, 64, 909, 9, 543, 3931, 1561, 911, 754, 315, 849, 199, 17537, 14, 221, 2104, 3537, 5953, 334, 6031, 3931, 1511, 395, 1218, 199, 4229, 3931, 2251, 1642, 12, 436, 986, 627, 1589, 77, 10, 370, 199, 1040, 4763, 15192, 1040, 15, 64, 27341, 2313, 221, 1666, 658, 1918, 5454, 1208, 19952, 281, 32578, 199, 199, 703, 485, 1918, 5454, 1208, 19952, 281, 26, 1455, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 1246, 15, 12789, 14, 1360, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 199, 199, 646, 10933, 199, 646, 984, 199, 199, 646, 18382, 14, 27056, 14, 1117, 16970, 199, 504, 18382, 492, 636, 1023, 3108, 636, 1023, 63, 5087, 3108, 13303, 5307, 199, 504, 18382, 492, 22523, 12, 5890, 12, 3778, 12, 7002, 83, 12, 2211, 878, 199, 504, 18382, 14, 18062, 492, 13491, 199, 504, 18382, 14, 1208, 14, 705, 63, 28071, 492, 4520, 2959, 12, 4520, 1558, 421, 199, 533, 19952, 281, 26, 339, 408, 272, 437, 21625, 9587, 22667, 20529, 314, 4721, 13, 1896, 9661, 402, 282, 5454, 1208, 2656, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7002, 29, 403, 12, 1798, 29, 403, 12, 7060, 29, 403, 12, 326, 1350, 29, 403, 12, 1350, 63, 533, 29, 2308, 14, 1173, 3205, 12, 326, 5724, 29, 403, 12, 5724, 63, 533, 29, 2308, 14, 1173, 2959, 12, 326, 2202, 29, 403, 304, 267, 408, 267, 6026, 3272, 14, 221, 982, 1263, 402, 658, 5503, 3559, 658, 2087, 3559, 503, 658, 5491, 64, 787, 440, 267, 2013, 12, 314, 5226, 1124, 409, 63, 1396, 1040, 1083, 1077, 506, 2797, 543, 267, 282, 3931, 536, 13493, 409, 63, 5503, 64, 5951, 314, 1798, 465, 5521, 680, 267, 408, 398, 291, 14, 3554, 275, 488, 267, 408, 1918, 2213, 3123, 13493, 27114, 14, 2415, 64, 2251, 10477, 398, 291, 14, 5503, 275, 7002, 267, 408, 33, 658, 27114, 14, 27056, 14, 5929, 64, 1256, 1041, 398, 291, 14, 2087, 275, 1798, 267, 408, 33, 658, 27114, 14, 11531, 14, 2842, 64, 1256, 1041, 398, 291, 14, 5491, 275, 7060, 267, 408, 33, 658, 27114, 14, 26224, 14, 6261, 64, 1256, 1041, 398, 367, 3931, 315, 283, 5503, 297, 283, 2087, 297, 283, 5491, 356, 288, 702, 440, 1228, 8, 5675, 8, 277, 12, 3931, 395, 620, 395, 334, 355, 283, 12070, 1059, 2071, 83, 2, 465, 2071, 83, 2, 2725, 27, 986, 376, 1256, 12, 283, 355, 283, 269, 675, 314, 2071, 83, 63, 354, 2, 2725, 3140, 334, 262, 283, 355, 283, 27114, 14, 1018, 14, 4763, 15192, 16777, 3423, 28823, 355, 450, 334, 5675, 8, 277, 12, 3931, 395, 3931, 12, 3931, 430, 398, 291, 14, 1365, 275, 1350, 267, 408, 1918, 1350, 402, 1324, 666, 12, 282, 658, 27114, 14, 2308, 14, 3205, 64, 1256, 1041, 398, 291, 14, 1365, 63, 533, 275, 1350, 63, 533, 267, 408, 1918, 1021, 367, 18774, 2737, 1350, 2251, 1041, 398, 291, 14, 6881, 275, 5724, 267, 408, 1918, 5724, 367, 18382, 1072, 12, 282, 658, 27114, 14, 2308, 14, 2959, 64, 267, 1256, 1041, 398, 291, 14, 6881, 63, 533, 275, 5724, 63, 533, 267, 408, 1918, 1021, 367, 18774, 2737, 5724, 2251, 1041, 398, 291, 14, 1751, 275, 2202, 267, 408, 2493, 909, 3035, 5454, 1208, 2202, 465, 1256, 3004, 14, 267, 2494, 701, 658, 277, 14, 1412, 63, 1531, 63, 604, 11995, 503, 658, 277, 14, 362, 63, 1751, 11995, 1041, 398, 291, 423, 3083, 275, 4520, 2959, 342, 339, 347, 663, 63, 5503, 8, 277, 12, 7002, 63, 354, 12, 1798, 12, 1798, 63, 354, 304, 267, 408, 1084, 658, 277, 14, 5503, 64, 701, 536, 1041, 267, 7002, 63, 533, 275, 7002, 83, 14, 362, 63, 5503, 63, 533, 8, 5503, 63, 354, 9, 267, 291, 14, 5503, 275, 7002, 63, 533, 8, 2087, 12, 1798, 63, 354, 9, 267, 291, 14, 2087, 275, 291, 14, 5503, 14, 2087, 339, 347, 663, 63, 5491, 8, 277, 12, 7060, 63, 354, 304, 267, 408, 1084, 658, 277, 14, 5491, 64, 701, 536, 1041, 267, 7060, 63, 533, 275, 2211, 878, 14, 362, 63, 5491, 63, 533, 8, 5491, 63, 354, 9, 267, 291, 14, 5491, 275, 7060, 63, 533, 342, 339, 347, 663, 63, 4608, 8, 277, 12, 7002, 63, 354, 12, 1798, 63, 354, 12, 7060, 63, 354, 304, 267, 340, 291, 14, 5503, 365, 488, 26, 288, 291, 14, 409, 63, 5503, 8, 5503, 63, 354, 12, 291, 14, 2087, 12, 1798, 63, 354, 9, 267, 340, 291, 14, 2087, 365, 488, 26, 288, 340, 291, 14, 5503, 14, 2087, 365, 488, 26, 355, 291, 14, 5503, 14, 409, 63, 2087, 8, 2087, 63, 354, 9, 288, 291, 14, 2087, 275, 291, 14, 5503, 14, 2087, 267, 340, 291, 14, 5491, 365, 488, 26, 288, 291, 14, 409, 63, 5491, 8, 5491, 63, 354, 9, 339, 347, 3272, 63, 1422, 63, 2087, 8, 277, 12, 4503, 29, 403, 12, 1369, 29, 403, 12, 1169, 2202, 63, 1650, 29, 403, 12, 1101, 63, 2792, 29, 403, 12, 1169, 1011, 4322, 304, 267, 340, 1101, 63, 2792, 26, 288, 340, 440, 2202, 63, 1650, 26, 355, 2202, 63, 1650, 275, 13303, 5307, 342, 288, 2202, 63, 1650, 14, 888, 63, 2792, 275, 1101, 63, 2792, 288, 4184, 275, 1101, 63, 2792, 14, 1294, 342, 288, 340, 822, 8, 4181, 9, 690, 413, 436, 4184, 1988, 17, 61, 508, 283, 3578, 356, 355, 2202, 63, 1650, 14, 888, 63, 2792, 63, 5714, 275, 788, 15853, 418, 267, 327, 25673, 2654, 291, 14, 1365, 1253, 291, 14, 6881, 370, 7323, 315, 6466, 31, 267, 945, 63, 2087, 275, 13491, 8, 288, 7323, 2687, 277, 14, 2087, 12, 291 ]
[ 2672, 1304, 26, 6170, 14, 647, 9720, 1272, 6029, 13, 1690, 13, 821, 4329, 26, 1367, 26, 2869, 58, 333, 24446, 2672, 199, 3, 6529, 26, 20232, 22311, 836, 665, 8302, 836, 32, 1548, 14, 1308, 30, 199, 3, 1898, 26, 961, 859, 965, 2757, 15090, 315, 314, 4575, 2881, 14, 199, 199, 624, 199, 23796, 314, 1124, 4763, 15192, 1040, 16777, 3423, 334, 269, 9034, 1958, 282, 199, 64, 27341, 64, 909, 9, 543, 3931, 1561, 911, 754, 315, 849, 199, 17537, 14, 221, 2104, 3537, 5953, 334, 6031, 3931, 1511, 395, 1218, 199, 4229, 3931, 2251, 1642, 12, 436, 986, 627, 1589, 77, 10, 370, 199, 1040, 4763, 15192, 1040, 15, 64, 27341, 2313, 221, 1666, 658, 1918, 5454, 1208, 19952, 281, 32578, 199, 199, 703, 485, 1918, 5454, 1208, 19952, 281, 26, 1455, 921, 27114, 14, 7646, 14, 846, 15, 4757, 15, 1246, 15, 12789, 14, 1360, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 7, 199, 199, 646, 10933, 199, 646, 984, 199, 199, 646, 18382, 14, 27056, 14, 1117, 16970, 199, 504, 18382, 492, 636, 1023, 3108, 636, 1023, 63, 5087, 3108, 13303, 5307, 199, 504, 18382, 492, 22523, 12, 5890, 12, 3778, 12, 7002, 83, 12, 2211, 878, 199, 504, 18382, 14, 18062, 492, 13491, 199, 504, 18382, 14, 1208, 14, 705, 63, 28071, 492, 4520, 2959, 12, 4520, 1558, 421, 199, 533, 19952, 281, 26, 339, 408, 272, 437, 21625, 9587, 22667, 20529, 314, 4721, 13, 1896, 9661, 402, 282, 5454, 1208, 2656, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 7002, 29, 403, 12, 1798, 29, 403, 12, 7060, 29, 403, 12, 326, 1350, 29, 403, 12, 1350, 63, 533, 29, 2308, 14, 1173, 3205, 12, 326, 5724, 29, 403, 12, 5724, 63, 533, 29, 2308, 14, 1173, 2959, 12, 326, 2202, 29, 403, 304, 267, 408, 267, 6026, 3272, 14, 221, 982, 1263, 402, 658, 5503, 3559, 658, 2087, 3559, 503, 658, 5491, 64, 787, 440, 267, 2013, 12, 314, 5226, 1124, 409, 63, 1396, 1040, 1083, 1077, 506, 2797, 543, 267, 282, 3931, 536, 13493, 409, 63, 5503, 64, 5951, 314, 1798, 465, 5521, 680, 267, 408, 398, 291, 14, 3554, 275, 488, 267, 408, 1918, 2213, 3123, 13493, 27114, 14, 2415, 64, 2251, 10477, 398, 291, 14, 5503, 275, 7002, 267, 408, 33, 658, 27114, 14, 27056, 14, 5929, 64, 1256, 1041, 398, 291, 14, 2087, 275, 1798, 267, 408, 33, 658, 27114, 14, 11531, 14, 2842, 64, 1256, 1041, 398, 291, 14, 5491, 275, 7060, 267, 408, 33, 658, 27114, 14, 26224, 14, 6261, 64, 1256, 1041, 398, 367, 3931, 315, 283, 5503, 297, 283, 2087, 297, 283, 5491, 356, 288, 702, 440, 1228, 8, 5675, 8, 277, 12, 3931, 395, 620, 395, 334, 355, 283, 12070, 1059, 2071, 83, 2, 465, 2071, 83, 2, 2725, 27, 986, 376, 1256, 12, 283, 355, 283, 269, 675, 314, 2071, 83, 63, 354, 2, 2725, 3140, 334, 262, 283, 355, 283, 27114, 14, 1018, 14, 4763, 15192, 16777, 3423, 28823, 355, 450, 334, 5675, 8, 277, 12, 3931, 395, 3931, 12, 3931, 430, 398, 291, 14, 1365, 275, 1350, 267, 408, 1918, 1350, 402, 1324, 666, 12, 282, 658, 27114, 14, 2308, 14, 3205, 64, 1256, 1041, 398, 291, 14, 1365, 63, 533, 275, 1350, 63, 533, 267, 408, 1918, 1021, 367, 18774, 2737, 1350, 2251, 1041, 398, 291, 14, 6881, 275, 5724, 267, 408, 1918, 5724, 367, 18382, 1072, 12, 282, 658, 27114, 14, 2308, 14, 2959, 64, 267, 1256, 1041, 398, 291, 14, 6881, 63, 533, 275, 5724, 63, 533, 267, 408, 1918, 1021, 367, 18774, 2737, 5724, 2251, 1041, 398, 291, 14, 1751, 275, 2202, 267, 408, 2493, 909, 3035, 5454, 1208, 2202, 465, 1256, 3004, 14, 267, 2494, 701, 658, 277, 14, 1412, 63, 1531, 63, 604, 11995, 503, 658, 277, 14, 362, 63, 1751, 11995, 1041, 398, 291, 423, 3083, 275, 4520, 2959, 342, 339, 347, 663, 63, 5503, 8, 277, 12, 7002, 63, 354, 12, 1798, 12, 1798, 63, 354, 304, 267, 408, 1084, 658, 277, 14, 5503, 64, 701, 536, 1041, 267, 7002, 63, 533, 275, 7002, 83, 14, 362, 63, 5503, 63, 533, 8, 5503, 63, 354, 9, 267, 291, 14, 5503, 275, 7002, 63, 533, 8, 2087, 12, 1798, 63, 354, 9, 267, 291, 14, 2087, 275, 291, 14, 5503, 14, 2087, 339, 347, 663, 63, 5491, 8, 277, 12, 7060, 63, 354, 304, 267, 408, 1084, 658, 277, 14, 5491, 64, 701, 536, 1041, 267, 7060, 63, 533, 275, 2211, 878, 14, 362, 63, 5491, 63, 533, 8, 5491, 63, 354, 9, 267, 291, 14, 5491, 275, 7060, 63, 533, 342, 339, 347, 663, 63, 4608, 8, 277, 12, 7002, 63, 354, 12, 1798, 63, 354, 12, 7060, 63, 354, 304, 267, 340, 291, 14, 5503, 365, 488, 26, 288, 291, 14, 409, 63, 5503, 8, 5503, 63, 354, 12, 291, 14, 2087, 12, 1798, 63, 354, 9, 267, 340, 291, 14, 2087, 365, 488, 26, 288, 340, 291, 14, 5503, 14, 2087, 365, 488, 26, 355, 291, 14, 5503, 14, 409, 63, 2087, 8, 2087, 63, 354, 9, 288, 291, 14, 2087, 275, 291, 14, 5503, 14, 2087, 267, 340, 291, 14, 5491, 365, 488, 26, 288, 291, 14, 409, 63, 5491, 8, 5491, 63, 354, 9, 339, 347, 3272, 63, 1422, 63, 2087, 8, 277, 12, 4503, 29, 403, 12, 1369, 29, 403, 12, 1169, 2202, 63, 1650, 29, 403, 12, 1101, 63, 2792, 29, 403, 12, 1169, 1011, 4322, 304, 267, 340, 1101, 63, 2792, 26, 288, 340, 440, 2202, 63, 1650, 26, 355, 2202, 63, 1650, 275, 13303, 5307, 342, 288, 2202, 63, 1650, 14, 888, 63, 2792, 275, 1101, 63, 2792, 288, 4184, 275, 1101, 63, 2792, 14, 1294, 342, 288, 340, 822, 8, 4181, 9, 690, 413, 436, 4184, 1988, 17, 61, 508, 283, 3578, 356, 355, 2202, 63, 1650, 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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 ]
suyashphadtare/vestasi-update-erp
erpnext/patches/v4_0/global_defaults_to_system_settings.py
39
1360
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # MIT License. See license.txt from __future__ import unicode_literals import frappe from collections import Counter from frappe.core.doctype.user.user import STANDARD_USERS def execute(): frappe.reload_doc("core", "doctype", "system_settings") system_settings = frappe.get_doc("System Settings") # set values from global_defauls global_defaults = frappe.db.get_value("Global Defaults", None, ["time_zone", "date_format", "number_format", "float_precision", "session_expiry"], as_dict=True) if global_defaults: for key, val in global_defaults.items(): if not system_settings.get(key): system_settings.set(key, val) # language if not system_settings.get("language"): # find most common language lang = frappe.db.sql_list("""select language from `tabUser` where ifnull(language, '')!='' and language not like "Loading%%" and name not in ({standard_users})""".format( standard_users=", ".join(["%s"]*len(STANDARD_USERS))), tuple(STANDARD_USERS)) lang = Counter(lang).most_common(1) lang = (len(lang) > 0) and lang[0][0] or "english" system_settings.language = lang system_settings.ignore_mandatory = True system_settings.save() global_defaults = frappe.get_doc("Global Defaults") global_defaults.ignore_mandatory = True global_defaults.save()
agpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6950, 199, 504, 5055, 492, 14427, 199, 504, 6950, 14, 1018, 14, 6356, 14, 751, 14, 751, 492, 4384, 16938, 63, 28164, 199, 199, 318, 5341, 837, 199, 198, 9098, 14, 9233, 63, 1301, 480, 1018, 401, 298, 6356, 401, 298, 2253, 63, 1751, 531, 199, 198, 2253, 63, 1751, 275, 6950, 14, 362, 63, 1301, 480, 3989, 13303, 531, 421, 198, 3, 663, 1338, 687, 2288, 63, 27205, 83, 199, 198, 2966, 63, 4322, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 7025, 7827, 401, 488, 12, 507, 198, 905, 521, 63, 2619, 401, 298, 602, 63, 908, 401, 298, 1955, 63, 908, 401, 298, 1609, 63, 6833, 401, 298, 1730, 63, 16844, 2255, 465, 63, 807, 29, 549, 9, 421, 198, 692, 2288, 63, 4322, 26, 507, 198, 509, 790, 12, 1139, 315, 2288, 63, 4322, 14, 1744, 837, 686, 198, 692, 440, 2656, 63, 1751, 14, 362, 8, 498, 304, 1585, 198, 2253, 63, 1751, 14, 409, 8, 498, 12, 1139, 9, 421, 198, 3, 2637, 199, 198, 692, 440, 2656, 63, 1751, 14, 362, 480, 3671, 2349, 507, 198, 3, 2342, 4750, 2863, 2637, 507, 198, 4159, 275, 6950, 14, 697, 14, 3009, 63, 513, 4852, 2416, 2637, 687, 658, 2902, 1899, 64, 686, 198, 4509, 340, 2307, 8, 3671, 12, 4074, 1, 19070, 436, 2637, 440, 2839, 298, 19236, 8530, 2, 436, 536, 440, 315, 11459, 6807, 63, 3707, 1552, 23045, 908, 8, 686, 198, 6807, 63, 3707, 11107, 3680, 904, 30387, 83, 937, 10, 552, 8, 19547, 63, 28164, 11508, 2008, 8, 19547, 63, 28164, 430, 507, 198, 4159, 275, 14427, 8, 4159, 680, 2786, 63, 2330, 8, 17, 9, 507, 198, 4159, 275, 334, 552, 8, 4159, 9, 690, 378, 9, 436, 6339, 59, 16, 1527, 16, 61, 503, 298, 17872, 2, 2742, 198, 2253, 63, 1751, 14, 3671, 275, 6339, 421, 198, 2253, 63, 1751, 14, 4247, 63, 19900, 275, 715, 199, 198, 2253, 63, 1751, 14, 2117, 342, 421, 198, 2966, 63, 4322, 275, 6950, 14, 362, 63, 1301, 480, 7025, 7827, 531, 199, 198, 2966, 63, 4322, 14, 4247, 63, 19900, 275, 715, 199, 198, 2966, 63, 4322, 14, 2117, 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 ]
[ 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 10697, 844, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6950, 199, 504, 5055, 492, 14427, 199, 504, 6950, 14, 1018, 14, 6356, 14, 751, 14, 751, 492, 4384, 16938, 63, 28164, 199, 199, 318, 5341, 837, 199, 198, 9098, 14, 9233, 63, 1301, 480, 1018, 401, 298, 6356, 401, 298, 2253, 63, 1751, 531, 199, 198, 2253, 63, 1751, 275, 6950, 14, 362, 63, 1301, 480, 3989, 13303, 531, 421, 198, 3, 663, 1338, 687, 2288, 63, 27205, 83, 199, 198, 2966, 63, 4322, 275, 6950, 14, 697, 14, 362, 63, 585, 480, 7025, 7827, 401, 488, 12, 507, 198, 905, 521, 63, 2619, 401, 298, 602, 63, 908, 401, 298, 1955, 63, 908, 401, 298, 1609, 63, 6833, 401, 298, 1730, 63, 16844, 2255, 465, 63, 807, 29, 549, 9, 421, 198, 692, 2288, 63, 4322, 26, 507, 198, 509, 790, 12, 1139, 315, 2288, 63, 4322, 14, 1744, 837, 686, 198, 692, 440, 2656, 63, 1751, 14, 362, 8, 498, 304, 1585, 198, 2253, 63, 1751, 14, 409, 8, 498, 12, 1139, 9, 421, 198, 3, 2637, 199, 198, 692, 440, 2656, 63, 1751, 14, 362, 480, 3671, 2349, 507, 198, 3, 2342, 4750, 2863, 2637, 507, 198, 4159, 275, 6950, 14, 697, 14, 3009, 63, 513, 4852, 2416, 2637, 687, 658, 2902, 1899, 64, 686, 198, 4509, 340, 2307, 8, 3671, 12, 4074, 1, 19070, 436, 2637, 440, 2839, 298, 19236, 8530, 2, 436, 536, 440, 315, 11459, 6807, 63, 3707, 1552, 23045, 908, 8, 686, 198, 6807, 63, 3707, 11107, 3680, 904, 30387, 83, 937, 10, 552, 8, 19547, 63, 28164, 11508, 2008, 8, 19547, 63, 28164, 430, 507, 198, 4159, 275, 14427, 8, 4159, 680, 2786, 63, 2330, 8, 17, 9, 507, 198, 4159, 275, 334, 552, 8, 4159, 9, 690, 378, 9, 436, 6339, 59, 16, 1527, 16, 61, 503, 298, 17872, 2, 2742, 198, 2253, 63, 1751, 14, 3671, 275, 6339, 421, 198, 2253, 63, 1751, 14, 4247, 63, 19900, 275, 715, 199, 198, 2253, 63, 1751, 14, 2117, 342, 421, 198, 2966, 63, 4322, 275, 6950, 14, 362, 63, 1301, 480, 7025, 7827, 531, 199, 198, 2966, 63, 4322, 14, 4247, 63, 19900, 275, 715, 199, 198, 2966, 63, 4322, 14, 2117, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vityagi/azure-linux-extensions
DSC/test/env.py
8
1260
#!/usr/bin/env python # #CustomScript extension # # Copyright 2014 Microsoft Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import os #append installer directory to sys.path root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(root) manifestFile = os.path.join(root, 'HandlerManifest.json') if os.path.exists(manifestFile): import json jsonData = open(manifestFile) manifest = json.load(jsonData) jsonData.close() extName="{0}-{1}".format(manifest[0]["name"], manifest[0]["version"]) print("Start test: %s" % extName) extDir=os.path.join("/var/lib/waagent", extName) if os.path.isdir(extDir): os.chdir(extDir) print("Switching to dir: %s" % os.getcwd())
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 7223, 5229, 3329, 199, 3, 199, 3, 1898, 6927, 15332, 11098, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 740, 18535, 2082, 370, 984, 14, 515, 199, 1231, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 199, 1274, 14, 515, 14, 740, 8, 1231, 9, 199, 199, 6418, 1173, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 283, 2461, 11038, 14, 1001, 358, 199, 692, 747, 14, 515, 14, 2444, 8, 6418, 1173, 304, 272, 492, 2022, 5591, 2022, 1451, 275, 1551, 8, 6418, 1173, 9, 272, 7712, 275, 2022, 14, 912, 8, 1001, 1451, 9, 272, 2022, 1451, 14, 1600, 342, 272, 1599, 985, 18448, 16, 30289, 17, 5469, 908, 8, 6418, 59, 16, 7541, 354, 2255, 7712, 59, 16, 7541, 1023, 3135, 272, 870, 480, 3162, 511, 26, 450, 83, 2, 450, 1599, 985, 9, 339, 1599, 3567, 29, 736, 14, 515, 14, 904, 4769, 1391, 15, 773, 15, 758, 4054, 401, 1599, 985, 9, 272, 340, 747, 14, 515, 14, 6027, 8, 832, 3567, 304, 267, 747, 14, 8563, 8, 832, 3567, 9, 267, 870, 480, 10167, 316, 370, 2935, 26, 450, 83, 2, 450, 747, 14, 9458, 1012, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 7223, 5229, 3329, 199, 3, 199, 3, 1898, 6927, 15332, 11098, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 646, 984, 199, 646, 747, 199, 199, 3, 740, 18535, 2082, 370, 984, 14, 515, 199, 1231, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 29658, 199, 1274, 14, 515, 14, 740, 8, 1231, 9, 199, 199, 6418, 1173, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 283, 2461, 11038, 14, 1001, 358, 199, 692, 747, 14, 515, 14, 2444, 8, 6418, 1173, 304, 272, 492, 2022, 5591, 2022, 1451, 275, 1551, 8, 6418, 1173, 9, 272, 7712, 275, 2022, 14, 912, 8, 1001, 1451, 9, 272, 2022, 1451, 14, 1600, 342, 272, 1599, 985, 18448, 16, 30289, 17, 5469, 908, 8, 6418, 59, 16, 7541, 354, 2255, 7712, 59, 16, 7541, 1023, 3135, 272, 870, 480, 3162, 511, 26, 450, 83, 2, 450, 1599, 985, 9, 339, 1599, 3567, 29, 736, 14, 515, 14, 904, 4769, 1391, 15, 773, 15, 758, 4054, 401, 1599, 985, 9, 272, 340, 747, 14, 515, 14, 6027, 8, 832, 3567, 304, 267, 747, 14, 8563, 8, 832, 3567, 9, 267, 870, 480, 10167, 316, 370, 2935, 26, 450, 83, 2, 450, 747, 14, 9458, 1012, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Nikea/VisTrails
examples/vtk_examples/Annotation/cubeAxes.py
15
3797
#!/usr/bin/env python # This example demonstrates the use of vtkCubeAxesActor2D to indicate # the position in space that the camera is currently viewing. The # vtkCubeAxesActor2D draws axes on the bounding box of the data set # and labels the axes with x-y-z coordinates. import vtk from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # Create a vtkBYUReader and read in a data set. fohe = vtk.vtkBYUReader() fohe.SetGeometryFileName(VTK_DATA_ROOT + "/Data/teapot.g") # Create a vtkPolyDataNormals filter to calculate the normals of the # data set. normals = vtk.vtkPolyDataNormals() normals.SetInputConnection(fohe.GetOutputPort()) # Set up the associated mapper and actor. foheMapper = vtk.vtkPolyDataMapper() foheMapper.SetInputConnection(normals.GetOutputPort()) foheActor = vtk.vtkLODActor() foheActor.SetMapper(foheMapper) # Create a vtkOutlineFilter to draw the bounding box of the data set. # Also create the associated mapper and actor. outline = vtk.vtkOutlineFilter() outline.SetInputConnection(normals.GetOutputPort()) mapOutline = vtk.vtkPolyDataMapper() mapOutline.SetInputConnection(outline.GetOutputPort()) outlineActor = vtk.vtkActor() outlineActor.SetMapper(mapOutline) outlineActor.GetProperty().SetColor(0, 0, 0) # Create a vtkCamera, and set the camera parameters. camera = vtk.vtkCamera() camera.SetClippingRange(1.60187, 20.0842) camera.SetFocalPoint(0.21406, 1.5, 0) camera.SetPosition(8.3761, 4.94858, 4.12505) camera.SetViewUp(0.180325, 0.549245, -0.815974) # Create a vtkLight, and set the light parameters. light = vtk.vtkLight() light.SetFocalPoint(0.21406, 1.5, 0) light.SetPosition(8.3761, 4.94858, 4.12505) # Create the Renderers. Assign them the appropriate viewport # coordinates, active camera, and light. ren = vtk.vtkRenderer() ren.SetViewport(0, 0, 0.5, 1.0) ren.SetActiveCamera(camera) ren.AddLight(light) ren2 = vtk.vtkRenderer() ren2.SetViewport(0.5, 0, 1.0, 1.0) ren2.SetActiveCamera(camera) ren2.AddLight(light) # Create the RenderWindow and RenderWindowInteractor. renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren) renWin.AddRenderer(ren2) renWin.SetWindowName("VTK - Cube Axes") renWin.SetSize(600, 300) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) # Add the actors to the renderer, and set the background. ren.AddViewProp(foheActor) ren.AddViewProp(outlineActor) ren2.AddViewProp(foheActor) ren2.AddViewProp(outlineActor) ren.SetBackground(0.1, 0.2, 0.4) ren2.SetBackground(0.1, 0.2, 0.4) # Create a text property for both cube axes tprop = vtk.vtkTextProperty() tprop.SetColor(1, 1, 1) tprop.ShadowOn() # Create a vtkCubeAxesActor2D. Use the outer edges of the bounding box to # draw the axes. Add the actor to the renderer. axes = vtk.vtkCubeAxesActor2D() axes.SetInput(normals.GetOutput()) axes.SetCamera(ren.GetActiveCamera()) axes.SetLabelFormat("%6.4g") axes.SetFlyModeToOuterEdges() axes.SetFontFactor(0.8) axes.SetAxisTitleTextProperty(tprop) axes.SetAxisLabelTextProperty(tprop) ren.AddViewProp(axes) # Create a vtkCubeAxesActor2D. Use the closest vertex to the camera to # determine where to draw the axes. Add the actor to the renderer. axes2 = vtk.vtkCubeAxesActor2D() axes2.SetViewProp(foheActor) axes2.SetCamera(ren2.GetActiveCamera()) axes2.SetLabelFormat("%6.4g") axes2.SetFlyModeToClosestTriad() axes2.SetFontFactor(0.8) axes2.ScalingOff() axes2.SetAxisTitleTextProperty(tprop) axes2.SetAxisLabelTextProperty(tprop) ren2.AddViewProp(axes2) # Set up a check for aborting rendering. def CheckAbort(obj, event): # obj will be the object generating the event. In this case it # is renWin. if obj.GetEventPending() != 0: obj.SetAbortRender(1) renWin.AddObserver("AbortCheckEvent", CheckAbort) iren.Initialize() renWin.Render() iren.Start()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 2893, 23789, 31216, 314, 675, 402, 11144, 25043, 20386, 12258, 18, 36, 370, 6623, 199, 3, 314, 3421, 315, 4601, 626, 314, 15177, 365, 5544, 2455, 316, 14, 221, 710, 199, 3, 11144, 25043, 20386, 12258, 18, 36, 5954, 83, 7824, 641, 314, 16842, 5689, 402, 314, 666, 663, 199, 3, 436, 3628, 314, 7824, 543, 671, 13, 89, 13, 90, 8983, 14, 199, 199, 646, 11144, 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, 2790, 282, 11144, 8285, 53, 5929, 436, 1586, 315, 282, 666, 663, 14, 199, 545, 426, 275, 11144, 14, 11919, 8285, 53, 5929, 342, 199, 545, 426, 14, 1084, 6831, 7733, 8, 8156, 43, 63, 3998, 63, 5441, 435, 3286, 1451, 15, 266, 439, 357, 14, 71, 531, 199, 199, 3, 2790, 282, 11144, 12747, 1451, 6241, 83, 2457, 370, 8671, 314, 27421, 402, 314, 199, 3, 666, 663, 14, 199, 21215, 275, 11144, 14, 11919, 12747, 1451, 6241, 83, 342, 199, 21215, 14, 32195, 8, 545, 426, 14, 30810, 1012, 199, 3, 2494, 1536, 314, 4568, 7796, 436, 20318, 14, 199, 545, 426, 11880, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 545, 426, 11880, 14, 32195, 8, 21215, 14, 30810, 1012, 199, 545, 426, 12258, 275, 11144, 14, 11919, 1484, 8980, 630, 342, 199, 545, 426, 12258, 14, 1084, 11880, 8, 545, 426, 11880, 9, 199, 199, 3, 2790, 282, 11144, 21432, 4131, 370, 5954, 314, 16842, 5689, 402, 314, 666, 663, 14, 199, 3, 6121, 1218, 314, 4568, 7796, 436, 20318, 14, 199, 11550, 275, 11144, 14, 11919, 21432, 4131, 342, 199, 11550, 14, 32195, 8, 21215, 14, 30810, 1012, 199, 1130, 21432, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 21432, 14, 32195, 8, 11550, 14, 30810, 1012, 199, 11550, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 11550, 12258, 14, 1084, 11880, 8, 1130, 21432, 9, 199, 11550, 12258, 14, 22845, 1252, 1084, 4117, 8, 16, 12, 378, 12, 378, 9, 199, 199, 3, 2790, 282, 11144, 18425, 12, 436, 663, 314, 15177, 2633, 14, 199, 11928, 275, 11144, 14, 11919, 18425, 342, 199, 11928, 14, 1084, 20653, 3637, 4709, 8, 17, 14, 24539, 1555, 12, 3388, 14, 16, 18931, 9, 199, 11928, 14, 1084, 38, 24560, 3428, 8, 16, 14, 6886, 1690, 12, 413, 14, 21, 12, 378, 9, 199, 11928, 14, 1084, 5625, 8, 24, 14, 1401, 2976, 12, 841, 14, 25, 2006, 2010, 12, 841, 14, 713, 13938, 9, 199, 11928, 14, 1084, 2768, 1721, 8, 16, 14, 7663, 13288, 12, 378, 14, 15419, 11677, 12, 446, 16, 14, 24, 9327, 1342, 9, 199, 199, 3, 2790, 282, 11144, 16393, 12, 436, 663, 314, 10540, 2633, 14, 199, 4040, 275, 11144, 14, 11919, 16393, 342, 199, 4040, 14, 1084, 38, 24560, 3428, 8, 16, 14, 6886, 1690, 12, 413, 14, 21, 12, 378, 9, 199, 4040, 14, 1084, 5625, 8, 24, 14, 1401, 2976, 12, 841, 14, 25, 2006, 2010, 12, 841, 14, 713, 13938, 9, 199, 199, 3, 2790, 314, 10055, 26529, 14, 221, 16927, 3062, 314, 5827, 2455, 719, 199, 3, 8983, 12, 4702, 15177, 12, 436, 10540, 14, 199, 828, 275, 11144, 14, 11919, 11355, 342, 199, 828, 14, 1084, 2768, 719, 8, 16, 12, 378, 12, 378, 14, 21, 12, 413, 14, 16, 9, 199, 828, 14, 1084, 7472, 18425, 8, 11928, 9, 199, 828, 14, 1123, 16393, 8, 4040, 9, 199, 828, 18, 275, 11144, 14, 11919, 11355, 342, 199, 828, 18, 14, 1084, 2768, 719, 8, 16, 14, 21, 12, 378, 12, 413, 14, 16, 12, 413, 14, 16, 9, 199, 828, 18, 14, 1084, 7472, 18425, 8, 11928, 9, 199, 828, 18, 14, 1123, 16393, 8, 4040, 9, 199, 199, 3, 2790, 314, 17769, 4301, 436, 17769, 4301, 607, 2967, 630, 14, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1123, 11355, 8, 828, 9, 199, 828, 8886, 14, 1123, 11355, 8, 828, 18, 9, 199, 828, 8886, 14, 1084, 4301, 985, 480, 8156, 43, 446, 445, 3375, 437, 12908, 531, 199, 828, 8886, 14, 1084, 2320, 8, 6683, 12, 9601, 9, 199, 73, 828, 275, 11144, 14, 11919, 9216, 4301, 607, 2967, 630, 342, 199, 73, 828, 14, 1084, 9216, 4301, 8, 828, 8886, 9, 199, 199, 3, 2654, 314, 282, 13451, 370, 314, 11889, 12, 436, 663, 314, 8020, 14, 199, 828, 14, 1123, 2768, 9955, 8, 545, 426, 12258, 9, 199, 828, 14, 1123, 2768, 9955, 8, 11550, 12258, 9, 199, 828, 18, 14, 1123, 2768, 9955, 8, 545, 426, 12258, 9, 199, 828, 18, 14, 1123, 2768, 9955, 8, 11550, 12258, 9, 199, 199, 828, 14, 1084, 14148, 8, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 20, 9, 199, 828, 18, 14, 1084, 14148, 8, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 20, 9, 199, 199, 3, 2790, 282, 1318, 3324, 367, 3865, 15681, 7824, 199, 84, 4469, 275, 11144, 14, 11919, 1872, 3697, 342, 199, 84, 4469, 14, 1084, 4117, 8, 17, 12, 413, 12, 413, 9, 199, 84, 4469, 14, 23574, 3314, 342, 199, 199, 3, 2790, 282, 11144, 25043, 20386, 12258, 18, 36, 14, 221, 3645, 314, 6890, 8207, 402, 314, 16842, 5689, 370, 199, 3, 5954, 314, 7824, 14, 221, 2654, 314, 20318, 370, 314, 11889, 14, 199, 6402, 275, 11144, 14, 11919, 25043, 20386, 12258, 18, 36, 342, 199, 6402, 14, 24029, 8, 21215, 14, 18614, 1012, 199, 6402, 14, 1084, 18425, 8, 828, 14, 1002, 7472, 18425, 1012, 199, 6402, 14, 1084, 4314, 3484, 3647, 22, 14, 20, 71, 531, 199, 6402, 14, 1084, 38, 590, 1385, 1378, 47, 2699, 24121, 342, 199, 6402, 14, 1084, 6986, 12666, 8, 16, 14, 24, 9, 199, 6402, 14, 1084, 11220, 6888, 1872, 3697, 8, 84, 4469, 9, 199, 6402, 14, 1084, 11220, 4314, 1872, 3697, 8, 84, 4469, 9, 199, 828, 14, 1123, 2768, 9955, 8, 6402, 9, 199, 199, 3, 2790, 282, 11144, 25043, 20386, 12258, 18, 36, 14, 221, 3645 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 961, 2893, 23789, 31216, 314, 675, 402, 11144, 25043, 20386, 12258, 18, 36, 370, 6623, 199, 3, 314, 3421, 315, 4601, 626, 314, 15177, 365, 5544, 2455, 316, 14, 221, 710, 199, 3, 11144, 25043, 20386, 12258, 18, 36, 5954, 83, 7824, 641, 314, 16842, 5689, 402, 314, 666, 663, 199, 3, 436, 3628, 314, 7824, 543, 671, 13, 89, 13, 90, 8983, 14, 199, 199, 646, 11144, 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, 2790, 282, 11144, 8285, 53, 5929, 436, 1586, 315, 282, 666, 663, 14, 199, 545, 426, 275, 11144, 14, 11919, 8285, 53, 5929, 342, 199, 545, 426, 14, 1084, 6831, 7733, 8, 8156, 43, 63, 3998, 63, 5441, 435, 3286, 1451, 15, 266, 439, 357, 14, 71, 531, 199, 199, 3, 2790, 282, 11144, 12747, 1451, 6241, 83, 2457, 370, 8671, 314, 27421, 402, 314, 199, 3, 666, 663, 14, 199, 21215, 275, 11144, 14, 11919, 12747, 1451, 6241, 83, 342, 199, 21215, 14, 32195, 8, 545, 426, 14, 30810, 1012, 199, 3, 2494, 1536, 314, 4568, 7796, 436, 20318, 14, 199, 545, 426, 11880, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 545, 426, 11880, 14, 32195, 8, 21215, 14, 30810, 1012, 199, 545, 426, 12258, 275, 11144, 14, 11919, 1484, 8980, 630, 342, 199, 545, 426, 12258, 14, 1084, 11880, 8, 545, 426, 11880, 9, 199, 199, 3, 2790, 282, 11144, 21432, 4131, 370, 5954, 314, 16842, 5689, 402, 314, 666, 663, 14, 199, 3, 6121, 1218, 314, 4568, 7796, 436, 20318, 14, 199, 11550, 275, 11144, 14, 11919, 21432, 4131, 342, 199, 11550, 14, 32195, 8, 21215, 14, 30810, 1012, 199, 1130, 21432, 275, 11144, 14, 11919, 12747, 1451, 11880, 342, 199, 1130, 21432, 14, 32195, 8, 11550, 14, 30810, 1012, 199, 11550, 12258, 275, 11144, 14, 11919, 12258, 342, 199, 11550, 12258, 14, 1084, 11880, 8, 1130, 21432, 9, 199, 11550, 12258, 14, 22845, 1252, 1084, 4117, 8, 16, 12, 378, 12, 378, 9, 199, 199, 3, 2790, 282, 11144, 18425, 12, 436, 663, 314, 15177, 2633, 14, 199, 11928, 275, 11144, 14, 11919, 18425, 342, 199, 11928, 14, 1084, 20653, 3637, 4709, 8, 17, 14, 24539, 1555, 12, 3388, 14, 16, 18931, 9, 199, 11928, 14, 1084, 38, 24560, 3428, 8, 16, 14, 6886, 1690, 12, 413, 14, 21, 12, 378, 9, 199, 11928, 14, 1084, 5625, 8, 24, 14, 1401, 2976, 12, 841, 14, 25, 2006, 2010, 12, 841, 14, 713, 13938, 9, 199, 11928, 14, 1084, 2768, 1721, 8, 16, 14, 7663, 13288, 12, 378, 14, 15419, 11677, 12, 446, 16, 14, 24, 9327, 1342, 9, 199, 199, 3, 2790, 282, 11144, 16393, 12, 436, 663, 314, 10540, 2633, 14, 199, 4040, 275, 11144, 14, 11919, 16393, 342, 199, 4040, 14, 1084, 38, 24560, 3428, 8, 16, 14, 6886, 1690, 12, 413, 14, 21, 12, 378, 9, 199, 4040, 14, 1084, 5625, 8, 24, 14, 1401, 2976, 12, 841, 14, 25, 2006, 2010, 12, 841, 14, 713, 13938, 9, 199, 199, 3, 2790, 314, 10055, 26529, 14, 221, 16927, 3062, 314, 5827, 2455, 719, 199, 3, 8983, 12, 4702, 15177, 12, 436, 10540, 14, 199, 828, 275, 11144, 14, 11919, 11355, 342, 199, 828, 14, 1084, 2768, 719, 8, 16, 12, 378, 12, 378, 14, 21, 12, 413, 14, 16, 9, 199, 828, 14, 1084, 7472, 18425, 8, 11928, 9, 199, 828, 14, 1123, 16393, 8, 4040, 9, 199, 828, 18, 275, 11144, 14, 11919, 11355, 342, 199, 828, 18, 14, 1084, 2768, 719, 8, 16, 14, 21, 12, 378, 12, 413, 14, 16, 12, 413, 14, 16, 9, 199, 828, 18, 14, 1084, 7472, 18425, 8, 11928, 9, 199, 828, 18, 14, 1123, 16393, 8, 4040, 9, 199, 199, 3, 2790, 314, 17769, 4301, 436, 17769, 4301, 607, 2967, 630, 14, 199, 828, 8886, 275, 11144, 14, 11919, 9216, 4301, 342, 199, 828, 8886, 14, 1123, 11355, 8, 828, 9, 199, 828, 8886, 14, 1123, 11355, 8, 828, 18, 9, 199, 828, 8886, 14, 1084, 4301, 985, 480, 8156, 43, 446, 445, 3375, 437, 12908, 531, 199, 828, 8886, 14, 1084, 2320, 8, 6683, 12, 9601, 9, 199, 73, 828, 275, 11144, 14, 11919, 9216, 4301, 607, 2967, 630, 342, 199, 73, 828, 14, 1084, 9216, 4301, 8, 828, 8886, 9, 199, 199, 3, 2654, 314, 282, 13451, 370, 314, 11889, 12, 436, 663, 314, 8020, 14, 199, 828, 14, 1123, 2768, 9955, 8, 545, 426, 12258, 9, 199, 828, 14, 1123, 2768, 9955, 8, 11550, 12258, 9, 199, 828, 18, 14, 1123, 2768, 9955, 8, 545, 426, 12258, 9, 199, 828, 18, 14, 1123, 2768, 9955, 8, 11550, 12258, 9, 199, 199, 828, 14, 1084, 14148, 8, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 20, 9, 199, 828, 18, 14, 1084, 14148, 8, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 20, 9, 199, 199, 3, 2790, 282, 1318, 3324, 367, 3865, 15681, 7824, 199, 84, 4469, 275, 11144, 14, 11919, 1872, 3697, 342, 199, 84, 4469, 14, 1084, 4117, 8, 17, 12, 413, 12, 413, 9, 199, 84, 4469, 14, 23574, 3314, 342, 199, 199, 3, 2790, 282, 11144, 25043, 20386, 12258, 18, 36, 14, 221, 3645, 314, 6890, 8207, 402, 314, 16842, 5689, 370, 199, 3, 5954, 314, 7824, 14, 221, 2654, 314, 20318, 370, 314, 11889, 14, 199, 6402, 275, 11144, 14, 11919, 25043, 20386, 12258, 18, 36, 342, 199, 6402, 14, 24029, 8, 21215, 14, 18614, 1012, 199, 6402, 14, 1084, 18425, 8, 828, 14, 1002, 7472, 18425, 1012, 199, 6402, 14, 1084, 4314, 3484, 3647, 22, 14, 20, 71, 531, 199, 6402, 14, 1084, 38, 590, 1385, 1378, 47, 2699, 24121, 342, 199, 6402, 14, 1084, 6986, 12666, 8, 16, 14, 24, 9, 199, 6402, 14, 1084, 11220, 6888, 1872, 3697, 8, 84, 4469, 9, 199, 6402, 14, 1084, 11220, 4314, 1872, 3697, 8, 84, 4469, 9, 199, 828, 14, 1123, 2768, 9955, 8, 6402, 9, 199, 199, 3, 2790, 282, 11144, 25043, 20386, 12258, 18, 36, 14, 221, 3645, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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class NoSuchTestError(DigressError): """ Raised when no such test exists. """ class DisabledTestError(DigressError): """ Test is disabled. """ class SkippedTestError(DigressError): """ Test is marked as skipped. """ class DisabledCaseError(DigressError): """ Case is marked as disabled. """ class SkippedCaseError(DigressError): """ Case is marked as skipped. """ class FailedTestError(DigressError): """ Test failed. """ class ComparisonError(DigressError): """ Comparison failed. """ class IncomparableError(DigressError): """ Values cannot be compared. """ class AlreadyRunError(DigressError): """ Test/case has already been run. """ class SCMError(DigressError): """ Error occurred in SCM. """ def __init__(self, message): self.message = message.replace("\n", " ") def __str__(self): return self.message
gpl-2.0
[ 624, 199, 17107, 753, 2552, 14, 199, 624, 199, 199, 533, 22442, 753, 547, 8, 1726, 304, 272, 408, 272, 22442, 753, 1125, 1300, 1021, 14, 272, 408, 199, 199, 533, 23798, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 24997, 1380, 949, 4066, 511, 3495, 14, 272, 408, 199, 199, 533, 5289, 1909, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 365, 6980, 14, 272, 408, 199, 199, 533, 8232, 1915, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 365, 11584, 465, 9645, 14, 272, 408, 199, 199, 533, 5289, 1909, 1538, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 12425, 365, 11584, 465, 6980, 14, 272, 408, 199, 199, 533, 8232, 1915, 1538, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 12425, 365, 11584, 465, 9645, 14, 272, 408, 199, 199, 533, 16277, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 3405, 14, 272, 408, 199, 199, 533, 3599, 5447, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 3599, 5447, 3405, 14, 272, 408, 199, 199, 533, 1010, 863, 19816, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 13468, 3913, 506, 13524, 14, 272, 408, 199, 199, 533, 21086, 2540, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 15, 2546, 965, 2575, 2757, 1255, 14, 272, 408, 199, 199, 533, 428, 9249, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 4520, 8920, 315, 428, 9249, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1245, 304, 267, 291, 14, 1188, 275, 1245, 14, 1814, 4582, 78, 401, 298, 6099, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1188, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 17107, 753, 2552, 14, 199, 624, 199, 199, 533, 22442, 753, 547, 8, 1726, 304, 272, 408, 272, 22442, 753, 1125, 1300, 1021, 14, 272, 408, 199, 199, 533, 23798, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 24997, 1380, 949, 4066, 511, 3495, 14, 272, 408, 199, 199, 533, 5289, 1909, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 365, 6980, 14, 272, 408, 199, 199, 533, 8232, 1915, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 365, 11584, 465, 9645, 14, 272, 408, 199, 199, 533, 5289, 1909, 1538, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 12425, 365, 11584, 465, 6980, 14, 272, 408, 199, 199, 533, 8232, 1915, 1538, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 12425, 365, 11584, 465, 9645, 14, 272, 408, 199, 199, 533, 16277, 774, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 3405, 14, 272, 408, 199, 199, 533, 3599, 5447, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 3599, 5447, 3405, 14, 272, 408, 199, 199, 533, 1010, 863, 19816, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 13468, 3913, 506, 13524, 14, 272, 408, 199, 199, 533, 21086, 2540, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 1379, 15, 2546, 965, 2575, 2757, 1255, 14, 272, 408, 199, 199, 533, 428, 9249, 547, 8, 17107, 753, 547, 304, 272, 408, 272, 4520, 8920, 315, 428, 9249, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1245, 304, 267, 291, 14, 1188, 275, 1245, 14, 1814, 4582, 78, 401, 298, 6099, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1188, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Ensighten/ansible
test/units/playbook/test_playbook.py
290
2230
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com> # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible.compat.tests import unittest from ansible.compat.tests.mock import patch, MagicMock from ansible.errors import AnsibleError, AnsibleParserError from ansible.playbook import Playbook from ansible.vars import VariableManager from units.mock.loader import DictDataLoader class TestPlaybook(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_empty_playbook(self): fake_loader = DictDataLoader({}) p = Playbook(loader=fake_loader) def test_basic_playbook(self): fake_loader = DictDataLoader({ "test_file.yml":""" - hosts: all """, }) p = Playbook.load("test_file.yml", loader=fake_loader) plays = p.get_plays() def test_bad_playbook_files(self): fake_loader = DictDataLoader({ # represents a playbook which is not a list of plays "bad_list.yml": """ foo: bar """, # represents a playbook where a play entry is mis-formatted "bad_entry.yml": """ - - "This should be a mapping..." """, }) vm = VariableManager() self.assertRaises(AnsibleParserError, Playbook.load, "bad_list.yml", vm, fake_loader) self.assertRaises(AnsibleParserError, Playbook.load, "bad_entry.yml", vm, fake_loader)
gpl-3.0
[ 3, 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 12, 10079, 199, 199, 504, 3242, 14, 2550, 492, 13358, 12, 31775, 199, 504, 3242, 14, 14205, 492, 16527, 2706, 199, 504, 3242, 14, 2936, 492, 4905, 2988, 199, 199, 504, 6204, 14, 1805, 14, 3422, 492, 7448, 1451, 5455, 199, 199, 533, 1379, 9651, 2706, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 1667, 63, 14205, 8, 277, 304, 267, 4026, 63, 3422, 275, 7448, 1451, 5455, 14079, 267, 299, 275, 16527, 2706, 8, 3422, 29, 3183, 63, 3422, 9, 339, 347, 511, 63, 4316, 63, 14205, 8, 277, 304, 267, 4026, 63, 3422, 275, 7448, 1451, 5455, 2561, 288, 298, 396, 63, 493, 14, 11714, 582, 624, 288, 446, 7057, 26, 1006, 288, 10327, 267, 3828, 267, 299, 275, 16527, 2706, 14, 912, 480, 396, 63, 493, 14, 11714, 401, 5077, 29, 3183, 63, 3422, 9, 267, 299, 9316, 275, 299, 14, 362, 63, 20591, 342, 339, 347, 511, 63, 4087, 63, 14205, 63, 1725, 8, 277, 304, 267, 4026, 63, 3422, 275, 7448, 1451, 5455, 2561, 288, 327, 8469, 282, 15695, 1314, 365, 440, 282, 769, 402, 299, 9316, 288, 298, 4087, 63, 513, 14, 11714, 582, 408, 288, 3925, 26, 4681, 953, 10327, 288, 327, 8469, 282, 15695, 2382, 282, 5232, 2397, 365, 3201, 13, 15317, 288, 298, 4087, 63, 2373, 14, 11714, 582, 408, 288, 446, 1598, 446, 298, 2765, 1077, 506, 282, 4412, 11500, 953, 10327, 267, 3828, 267, 4169, 275, 4905, 2988, 342, 267, 291, 14, 1855, 8, 10047, 21811, 12, 16527, 2706, 14, 912, 12, 298, 4087, 63, 513, 14, 11714, 401, 4169, 12, 4026, 63, 3422, 9, 267, 291, 14, 1855, 8, 10047, 21811, 12, 16527, 2706, 14, 912, 12, 298, 4087, 63, 2373, 14, 11714, 401, 4169, 12, 4026, 63, 3422, 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 ]
[ 334, 67, 9, 6029, 13, 7280, 12, 16922, 22453, 665, 22333, 14, 24247, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 12, 10079, 199, 199, 504, 3242, 14, 2550, 492, 13358, 12, 31775, 199, 504, 3242, 14, 14205, 492, 16527, 2706, 199, 504, 3242, 14, 2936, 492, 4905, 2988, 199, 199, 504, 6204, 14, 1805, 14, 3422, 492, 7448, 1451, 5455, 199, 199, 533, 1379, 9651, 2706, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 1667, 63, 14205, 8, 277, 304, 267, 4026, 63, 3422, 275, 7448, 1451, 5455, 14079, 267, 299, 275, 16527, 2706, 8, 3422, 29, 3183, 63, 3422, 9, 339, 347, 511, 63, 4316, 63, 14205, 8, 277, 304, 267, 4026, 63, 3422, 275, 7448, 1451, 5455, 2561, 288, 298, 396, 63, 493, 14, 11714, 582, 624, 288, 446, 7057, 26, 1006, 288, 10327, 267, 3828, 267, 299, 275, 16527, 2706, 14, 912, 480, 396, 63, 493, 14, 11714, 401, 5077, 29, 3183, 63, 3422, 9, 267, 299, 9316, 275, 299, 14, 362, 63, 20591, 342, 339, 347, 511, 63, 4087, 63, 14205, 63, 1725, 8, 277, 304, 267, 4026, 63, 3422, 275, 7448, 1451, 5455, 2561, 288, 327, 8469, 282, 15695, 1314, 365, 440, 282, 769, 402, 299, 9316, 288, 298, 4087, 63, 513, 14, 11714, 582, 408, 288, 3925, 26, 4681, 953, 10327, 288, 327, 8469, 282, 15695, 2382, 282, 5232, 2397, 365, 3201, 13, 15317, 288, 298, 4087, 63, 2373, 14, 11714, 582, 408, 288, 446, 1598, 446, 298, 2765, 1077, 506, 282, 4412, 11500, 953, 10327, 267, 3828, 267, 4169, 275, 4905, 2988, 342, 267, 291, 14, 1855, 8, 10047, 21811, 12, 16527, 2706, 14, 912, 12, 298, 4087, 63, 513, 14, 11714, 401, 4169, 12, 4026, 63, 3422, 9, 267, 291, 14, 1855, 8, 10047, 21811, 12, 16527, 2706, 14, 912, 12, 298, 4087, 63, 2373, 14, 11714, 401, 4169, 12, 4026, 63, 3422, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
stdweird/aquilon
lib/python2.6/aquilon/aqdb/shell.py
2
3101
#!/usr/bin/env python2.6 # -*- cpy-indent-level: 4; indent-tabs-mode: nil -*- # ex: set expandtab softtabstop=4 shiftwidth=4: # # Copyright (C) 2008,2009,2010,2011,2012,2013 Contributor # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys _DIR = os.path.dirname(os.path.realpath(__file__)) _LIBDIR = os.path.join(_DIR, '..', '..') if _LIBDIR not in sys.path: sys.path.insert(0, _LIBDIR) import aquilon.aqdb.depends # pylint: disable=W0611 import argparse from ipaddr import IPv4Address, IPv4Network # pylint: disable=W0611 import ms.modulecmd from IPython.config.loader import Config as IPyConfig from IPython.frontend.terminal.embed import InteractiveShellEmbed from aquilon.config import Config # pylint: disable=W0611 # pylint: disable=W0614 from aquilon.aqdb.model import * # pylint: disable=W0401 from aquilon.aqdb.dsdb import * # pylint: disable=W0401 from aquilon.aqdb.db_factory import DbFactory db = DbFactory() Base.metadata.bind = db.engine session = s = db.Session() _banner = '<<<Welcome to the Aquilon shell (courtesy of IPython). Ctrl-D to quit>>>\n' def main(): parser = argparse.ArgumentParser( description='An ipython shell, useful for testing and exploring aqdb') parser.add_argument('-v', action='count', dest='verbose', help='increase verbosity by adding more (-vv), etc.') opts = parser.parse_args() if opts.verbose >= 1: db.engine.echo = True if db.engine.url.drivername == 'sqlite': prompt = str(db.engine.url).split('///')[1] else: # couldn't use the underlying dbapi connection.current_schema # from the engine as it too is '' user = db.engine.url.username or os.environ.get("USER") host = db.engine.url.host or 'LOCALHOST' prompt = '%s@%s' % (user, host) if db.engine.url.database: prompt += '/%s' prompt += '> ' ipycfg = IPyConfig() ipycfg.PromptManager.in_template = prompt ipycfg.PlaintextFormatter.pprint = True ipycfg.InteractiveShell.separate_in = '' ipycfg.InteractiveShell.separate_out = '' ipycfg.InteractiveShell.separate_out2 = '' ipycfg.InteractiveShell.colors = 'Linux' ipshell = InteractiveShellEmbed(config=ipycfg, banner1=_banner) ipshell() def graph_schema(db=db, file_name="/tmp/aqdb_schema"): """ Produces a png image of the schema. """ import aquilon.aqdb.utils.schema2dot as s2d s2d.write_schema_png(db.meta, "%s.png" % file_name) s2d.write_schema_dot(db.meta, "%s.dot" % file_name) if __name__ == '__main__': main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 14, 22, 199, 3, 1882, 286, 647, 13, 3724, 13, 1896, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 32644, 1882, 199, 3, 444, 26, 663, 26414, 25966, 29, 20, 20105, 29, 20, 26, 199, 3, 199, 3, 1898, 334, 35, 9, 9079, 12, 8664, 12, 6542, 12, 8128, 12, 7409, 12, 6965, 221, 17636, 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, 646, 747, 199, 646, 984, 199, 199, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 63, 5617, 3022, 275, 747, 14, 515, 14, 904, 1547, 3022, 12, 19155, 11541, 358, 199, 692, 485, 5617, 3022, 440, 315, 984, 14, 515, 26, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 485, 5617, 3022, 9, 199, 199, 646, 282, 392, 382, 265, 14, 30030, 697, 14, 8912, 221, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 199, 646, 7534, 199, 199, 504, 21249, 492, 6509, 20, 1476, 12, 6509, 20, 4491, 221, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 199, 646, 6605, 14, 578, 1760, 199, 199, 504, 16243, 14, 888, 14, 3422, 492, 4094, 465, 473, 2713, 2028, 199, 504, 16243, 14, 18062, 14, 12010, 14, 6427, 492, 1010, 7502, 8529, 13200, 199, 199, 504, 282, 392, 382, 265, 14, 888, 492, 4094, 221, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 199, 3, 4287, 26, 3507, 29, 55, 1690, 1079, 199, 504, 282, 392, 382, 265, 14, 30030, 697, 14, 1238, 492, 627, 221, 327, 4287, 26, 3507, 29, 55, 28025, 199, 504, 282, 392, 382, 265, 14, 30030, 697, 14, 795, 697, 492, 627, 221, 327, 4287, 26, 3507, 29, 55, 28025, 199, 504, 282, 392, 382, 265, 14, 30030, 697, 14, 697, 63, 3702, 492, 28822, 2927, 199, 199, 697, 275, 28822, 2927, 342, 199, 1563, 14, 2343, 14, 3409, 275, 1592, 14, 3908, 199, 1730, 275, 308, 275, 1592, 14, 4434, 342, 199, 199, 63, 13066, 275, 2650, 8999, 24679, 370, 314, 437, 392, 382, 265, 5218, 334, 25715, 744, 89, 402, 16243, 680, 445, 7245, 13, 36, 370, 17242, 1140, 3072, 78, 7, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 534, 2493, 284, 1548, 5218, 12, 2997, 367, 5343, 436, 29278, 6854, 282, 81, 697, 358, 339, 1798, 14, 525, 63, 2094, 3654, 86, 297, 1595, 534, 835, 297, 2053, 534, 3832, 297, 717, 1720, 534, 31687, 8661, 701, 7791, 1655, 5868, 8958, 395, 5423, 2659, 272, 3999, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 3999, 14, 3832, 2356, 413, 26, 267, 1592, 14, 3908, 14, 7878, 275, 715, 339, 340, 1592, 14, 3908, 14, 633, 14, 3090, 354, 508, 283, 10659, 356, 267, 8457, 275, 620, 8, 697, 14, 3908, 14, 633, 680, 1294, 15079, 15, 5832, 17, 61, 272, 587, 26, 267, 327, 21554, 1133, 675, 314, 8793, 29333, 1950, 14, 1818, 63, 3629, 267, 327, 687, 314, 6869, 465, 652, 4634, 365, 2125, 267, 922, 275, 1592, 14, 3908, 14, 633, 14, 2473, 503, 747, 14, 2314, 14, 362, 480, 3791, 531, 267, 1591, 275, 1592, 14, 3908, 14, 633, 14, 1102, 503, 283, 7486, 5449, 7, 267, 8457, 275, 1543, 83, 19437, 83, 7, 450, 334, 751, 12, 1591, 9, 267, 340, 1592, 14, 3908, 14, 633, 14, 4659, 26, 288, 8457, 847, 1994, 5, 83, 7, 272, 8457, 847, 12696, 283, 339, 284, 647, 4128, 275, 473, 2713, 2028, 342, 272, 284, 647, 4128, 14, 20430, 2988, 14, 262, 63, 1160, 275, 8457, 272, 284, 647, 4128, 14, 20711, 505, 7772, 14, 15380, 275, 715, 272, 284, 647, 4128, 14, 23879, 8529, 14, 24904, 63, 262, 275, 2125, 272, 284, 647, 4128, 14, 23879, 8529, 14, 24904, 63, 548, 275, 2125, 272, 284, 647, 4128, 14, 23879, 8529, 14, 24904, 63, 548, 18, 275, 2125, 272, 284, 647, 4128, 14, 23879, 8529, 14, 7120, 275, 283, 14091, 7, 272, 3384, 5641, 275, 1010, 7502, 8529, 13200, 8, 888, 29, 73, 647, 4128, 12, 20997, 17, 3699, 13066, 9, 272, 3384, 5641, 342, 421, 199, 318, 3343, 63, 3629, 8, 697, 29, 697, 12, 570, 63, 354, 9555, 2791, 15, 30030, 697, 63, 3629, 2349, 272, 408, 2165, 10569, 282, 25296, 1834, 402, 314, 4177, 14, 408, 272, 492, 282, 392, 382, 265, 14, 30030, 697, 14, 1208, 14, 3629, 18, 3287, 465, 308, 18, 68, 272, 308, 18, 68, 14, 952, 63, 3629, 63, 4524, 8, 697, 14, 2024, 12, 2071, 83, 14, 4524, 2, 450, 570, 63, 354, 9, 272, 308, 18, 68, 14, 952, 63, 3629, 63, 3287, 8, 697, 14, 2024, 12, 2071, 83, 14, 3287, 2, 450, 570, 63, 354, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 14, 22, 199, 3, 1882, 286, 647, 13, 3724, 13, 1896, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 32644, 1882, 199, 3, 444, 26, 663, 26414, 25966, 29, 20, 20105, 29, 20, 26, 199, 3, 199, 3, 1898, 334, 35, 9, 9079, 12, 8664, 12, 6542, 12, 8128, 12, 7409, 12, 6965, 221, 17636, 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, 646, 747, 199, 646, 984, 199, 199, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 63, 5617, 3022, 275, 747, 14, 515, 14, 904, 1547, 3022, 12, 19155, 11541, 358, 199, 692, 485, 5617, 3022, 440, 315, 984, 14, 515, 26, 272, 984, 14, 515, 14, 3176, 8, 16, 12, 485, 5617, 3022, 9, 199, 199, 646, 282, 392, 382, 265, 14, 30030, 697, 14, 8912, 221, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 199, 646, 7534, 199, 199, 504, 21249, 492, 6509, 20, 1476, 12, 6509, 20, 4491, 221, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 199, 646, 6605, 14, 578, 1760, 199, 199, 504, 16243, 14, 888, 14, 3422, 492, 4094, 465, 473, 2713, 2028, 199, 504, 16243, 14, 18062, 14, 12010, 14, 6427, 492, 1010, 7502, 8529, 13200, 199, 199, 504, 282, 392, 382, 265, 14, 888, 492, 4094, 221, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 199, 3, 4287, 26, 3507, 29, 55, 1690, 1079, 199, 504, 282, 392, 382, 265, 14, 30030, 697, 14, 1238, 492, 627, 221, 327, 4287, 26, 3507, 29, 55, 28025, 199, 504, 282, 392, 382, 265, 14, 30030, 697, 14, 795, 697, 492, 627, 221, 327, 4287, 26, 3507, 29, 55, 28025, 199, 504, 282, 392, 382, 265, 14, 30030, 697, 14, 697, 63, 3702, 492, 28822, 2927, 199, 199, 697, 275, 28822, 2927, 342, 199, 1563, 14, 2343, 14, 3409, 275, 1592, 14, 3908, 199, 1730, 275, 308, 275, 1592, 14, 4434, 342, 199, 199, 63, 13066, 275, 2650, 8999, 24679, 370, 314, 437, 392, 382, 265, 5218, 334, 25715, 744, 89, 402, 16243, 680, 445, 7245, 13, 36, 370, 17242, 1140, 3072, 78, 7, 421, 199, 318, 2446, 837, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 534, 2493, 284, 1548, 5218, 12, 2997, 367, 5343, 436, 29278, 6854, 282, 81, 697, 358, 339, 1798, 14, 525, 63, 2094, 3654, 86, 297, 1595, 534, 835, 297, 2053, 534, 3832, 297, 717, 1720, 534, 31687, 8661, 701, 7791, 1655, 5868, 8958, 395, 5423, 2659, 272, 3999, 275, 1798, 14, 1122, 63, 589, 342, 339, 340, 3999, 14, 3832, 2356, 413, 26, 267, 1592, 14, 3908, 14, 7878, 275, 715, 339, 340, 1592, 14, 3908, 14, 633, 14, 3090, 354, 508, 283, 10659, 356, 267, 8457, 275, 620, 8, 697, 14, 3908, 14, 633, 680, 1294, 15079, 15, 5832, 17, 61, 272, 587, 26, 267, 327, 21554, 1133, 675, 314, 8793, 29333, 1950, 14, 1818, 63, 3629, 267, 327, 687, 314, 6869, 465, 652, 4634, 365, 2125, 267, 922, 275, 1592, 14, 3908, 14, 633, 14, 2473, 503, 747, 14, 2314, 14, 362, 480, 3791, 531, 267, 1591, 275, 1592, 14, 3908, 14, 633, 14, 1102, 503, 283, 7486, 5449, 7, 267, 8457, 275, 1543, 83, 19437, 83, 7, 450, 334, 751, 12, 1591, 9, 267, 340, 1592, 14, 3908, 14, 633, 14, 4659, 26, 288, 8457, 847, 1994, 5, 83, 7, 272, 8457, 847, 12696, 283, 339, 284, 647, 4128, 275, 473, 2713, 2028, 342, 272, 284, 647, 4128, 14, 20430, 2988, 14, 262, 63, 1160, 275, 8457, 272, 284, 647, 4128, 14, 20711, 505, 7772, 14, 15380, 275, 715, 272, 284, 647, 4128, 14, 23879, 8529, 14, 24904, 63, 262, 275, 2125, 272, 284, 647, 4128, 14, 23879, 8529, 14, 24904, 63, 548, 275, 2125, 272, 284, 647, 4128, 14, 23879, 8529, 14, 24904, 63, 548, 18, 275, 2125, 272, 284, 647, 4128, 14, 23879, 8529, 14, 7120, 275, 283, 14091, 7, 272, 3384, 5641, 275, 1010, 7502, 8529, 13200, 8, 888, 29, 73, 647, 4128, 12, 20997, 17, 3699, 13066, 9, 272, 3384, 5641, 342, 421, 199, 318, 3343, 63, 3629, 8, 697, 29, 697, 12, 570, 63, 354, 9555, 2791, 15, 30030, 697, 63, 3629, 2349, 272, 408, 2165, 10569, 282, 25296, 1834, 402, 314, 4177, 14, 408, 272, 492, 282, 392, 382, 265, 14, 30030, 697, 14, 1208, 14, 3629, 18, 3287, 465, 308, 18, 68, 272, 308, 18, 68, 14, 952, 63, 3629, 63, 4524, 8, 697, 14, 2024, 12, 2071, 83, 14, 4524, 2, 450, 570, 63, 354, 9, 272, 308, 18, 68, 14, 952, 63, 3629, 63, 3287, 8, 697, 14, 2024, 12, 2071, 83, 14, 3287, 2, 450, 570, 63, 354, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pscedu/slash2
utils/ssh.py
2
4852
import paramiko, getpass, logging import os, re from time import sleep log = logging.getLogger("slash2") class SSH(object): """Helpful SSH abstractions for executing remote applications.""" def __init__(self, user, host, password=None, port=22): """Initialize SSH object. Args: user: username. host: hostname of connection. password: user's password. If None, stdin will be prompted for pass. If the user is using auth_keys, an empty string will work. port: port of destination's sshd. Raises: SSHException.""" self.user = user self.host = host self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #Get password from stdin if password is None: password = getpass.getpass("{0}'s password: ".format(user)) #Initialize connection try: self.ssh.connect(host, username=user, password=password, port=port) except Exception: raise paramiko.SSHException def list_screen_socks(self): """Return a list of open screen sockets.""" socks = [] sock_re = re.compile(r"\s+\d+\.(.+?)\s+.*?") sock_ls = self.run("screen -ls", quiet=True)["out"] for sock in sock_ls: sock_match = sock_re.match(sock) if sock_match: socks.append(sock_match.group(1)) return socks def run_screen(self, cmd, sock_name, timeout=None): """Remotely execute a command in a screen session. If timeout is reached, screen will be renamed and kept open. Args: cmd: command string to be executed. sock_name: screen session's socket name. timeout: maximum execution time.""" socks = self.list_screen_socks() #Sock already exists! exists = any([s.startswith(sock_name) for s in socks]) if exists: return False log.debug("Launching screen: {0} at {1}".format(sock_name, self.host)) #Sanitize newlines cmd = cmd.strip("\t\n ;") sane_cmd = "" for line in cmd.splitlines(): sane_cmd += line.strip() + ";" cmd = sane_cmd #Debug -- log the cmds being run [log.debug(c) for c in cmd.split(";")] if timeout: timed_cmd = "" for line in cmd.split(";"): if len(line) > 0: timed_cmd += "timeout --signal=9 {0} {1}; ".format(timeout, line) cmd = timed_cmd #Add return code catch to each command cmd = cmd.replace(";", "; ck; ") #Wrap the command with a bash condition to rename and keep the screen session open shell_script = "ck(){{ c=$?; echo $c; if [[ $c != 0 ]]; then screen -S {0} -X zombie kr; if [[ $c == 137 ]]; then screen -S {0} -X sessionname {0}-timed; else screen -S {0} -X sessionname {0}-error; fi; exit; fi; }}".format(sock_name) cmd = "screen -S {0} -d -L -m $SHELL -c '{2}; {1}'"\ .format(sock_name, cmd, shell_script) chan = self.ssh.get_transport().open_session() chan.exec_command(cmd) print cmd return True def wait_for_screen(self, sock_name, sleep_duration=3): """Blocks until a screen sock is removed or timesout. Args: sock_name: socket to be looking for. sleep_duration: time to sleep inbetween checks. Returns: dict { timedout: true/false finished: true/false errored: error code }""" result = { "timedout": False, "finished": False, "errored": False } #initial rest sleep(sleep_duration) while True: alive = False for sock in self.list_screen_socks(): if sock == sock_name: alive = True break if sock == sock_name + "-timed": #Screen timed out result["timedout"] = True return result elif sock == sock_name + "-error": result["errored"] = True return result #If it is still running, sleep for a second if alive: sleep(sleep_duration) else: result["finished"] = True return result def run(self, cmd, timeout=None, quiet=False): """Remotely execute a command. Args: cmd: command string to be executed. timeout: maximum execution time. Returns: dict { out: stdout. err: stderr. exit: exit code of the cmd. timeout returns 137. }""" #Sanitize newlines cmd = cmd.replace("\n", ";") #Debug -- log the cmds being run if not quiet: [log.debug(c) for c in cmd.split(";")] if timeout: cmd = "timeout --signal=9 {0} {1}".format(timeout, cmd) chan = self.ssh.get_transport().open_session() chan.exec_command(cmd) result = { "out" : list(chan.makefile("rb")), "err" : list(chan.makefile_stderr("rb")), "exit": chan.recv_exit_status() } return result
gpl-2.0
[ 646, 26162, 12, 18354, 12, 2050, 199, 646, 747, 12, 295, 199, 199, 504, 900, 492, 9435, 199, 199, 793, 275, 2050, 14, 5572, 480, 7001, 18, 531, 199, 199, 533, 12027, 8, 785, 304, 523, 408, 8673, 1893, 12027, 2236, 14183, 2452, 367, 14043, 3982, 13103, 1041, 819, 347, 636, 826, 721, 277, 12, 922, 12, 1591, 12, 2505, 29, 403, 12, 1844, 29, 1081, 304, 272, 408, 9345, 12027, 909, 14, 2541, 3033, 26, 267, 922, 26, 3434, 14, 267, 1591, 26, 6246, 402, 1950, 14, 267, 2505, 26, 922, 1159, 2505, 14, 982, 488, 12, 9009, 911, 506, 21652, 471, 367, 986, 14, 2116, 982, 314, 922, 365, 1808, 1790, 63, 1612, 12, 376, 2701, 1059, 911, 1736, 14, 267, 1844, 26, 1844, 402, 5724, 1159, 8635, 68, 14, 489, 6218, 26, 12027, 1726, 1041, 339, 291, 14, 751, 275, 922, 272, 291, 14, 1102, 275, 1591, 272, 291, 14, 5510, 275, 26162, 14, 13716, 3041, 342, 272, 291, 14, 5510, 14, 409, 63, 4752, 63, 1102, 63, 498, 63, 3185, 8, 635, 16625, 14, 3358, 1123, 4845, 1012, 339, 327, 1002, 2505, 687, 9009, 272, 340, 2505, 365, 488, 26, 489, 2505, 275, 18354, 14, 27481, 13076, 16, 6834, 83, 2505, 26, 3680, 908, 8, 751, 430, 339, 327, 9345, 1950, 272, 862, 26, 267, 291, 14, 5510, 14, 2242, 8, 1102, 12, 3434, 29, 751, 12, 2505, 29, 2060, 12, 1844, 29, 719, 9, 272, 871, 2186, 26, 267, 746, 26162, 14, 13716, 1726, 819, 347, 769, 63, 5410, 63, 21234, 8, 277, 304, 272, 408, 1767, 282, 769, 402, 1551, 6426, 18772, 1041, 339, 6771, 83, 275, 942, 272, 6771, 63, 264, 275, 295, 14, 2014, 8, 82, 3212, 83, 7896, 68, 11, 4537, 28149, 2862, 83, 11, 6697, 531, 272, 6771, 63, 478, 275, 291, 14, 1065, 480, 5410, 446, 478, 401, 11971, 29, 549, 26332, 548, 937, 272, 367, 6771, 315, 6771, 63, 478, 26, 267, 6771, 63, 1431, 275, 6771, 63, 264, 14, 1431, 8, 5096, 9, 267, 340, 6771, 63, 1431, 26, 881, 6771, 83, 14, 740, 8, 5096, 63, 1431, 14, 923, 8, 17, 430, 339, 372, 6771, 83, 819, 347, 1255, 63, 5410, 8, 277, 12, 2088, 12, 6771, 63, 354, 12, 2653, 29, 403, 304, 272, 408, 6713, 590, 5341, 282, 1414, 315, 282, 6426, 2351, 14, 982, 2653, 365, 13075, 12, 6426, 911, 506, 17864, 436, 16204, 1551, 14, 2541, 3033, 26, 267, 2088, 26, 1414, 1059, 370, 506, 7934, 14, 267, 6771, 63, 354, 26, 6426, 2351, 1159, 2838, 536, 14, 267, 2653, 26, 5696, 6451, 900, 1041, 339, 6771, 83, 275, 291, 14, 513, 63, 5410, 63, 21234, 342, 339, 327, 51, 766, 2575, 3495, 1, 272, 3495, 275, 1263, 779, 83, 14, 2460, 8, 5096, 63, 354, 9, 367, 308, 315, 6771, 83, 566, 272, 340, 3495, 26, 489, 372, 756, 339, 943, 14, 1757, 480, 18543, 316, 6426, 26, 469, 16, 93, 737, 469, 17, 5469, 908, 8, 5096, 63, 354, 12, 291, 14, 1102, 430, 339, 327, 51, 12531, 14930, 272, 2088, 275, 2088, 14, 1913, 4582, 84, 60, 78, 8700, 531, 272, 31648, 63, 1760, 275, 3087, 272, 367, 1004, 315, 2088, 14, 7644, 837, 489, 31648, 63, 1760, 847, 1004, 14, 1913, 342, 435, 28045, 339, 2088, 275, 31648, 63, 1760, 339, 327, 7084, 1553, 943, 314, 11465, 3769, 1255, 272, 359, 793, 14, 1757, 8, 67, 9, 367, 286, 315, 2088, 14, 1294, 480, 27, 11323, 339, 340, 2653, 26, 489, 18590, 63, 1760, 275, 3087, 489, 367, 1004, 315, 2088, 14, 1294, 480, 27, 2349, 267, 340, 822, 8, 604, 9, 690, 378, 26, 881, 18590, 63, 1760, 847, 298, 2593, 1553, 4653, 29, 25, 469, 16, 93, 469, 17, 12084, 3680, 908, 8, 2593, 12, 1004, 9, 489, 2088, 275, 18590, 63, 1760, 339, 327, 1123, 372, 1233, 8579, 370, 1924, 1414, 272, 2088, 275, 2088, 14, 1814, 480, 17259, 28036, 22030, 27, 6099, 339, 327, 15991, 314, 1414, 543, 282, 20387, 5558, 370, 11441, 436, 4215, 314, 6426, 2351, 1551, 272, 5218, 63, 1579, 275, 298, 346, 342, 3638, 286, 28617, 31, 27, 11343, 2672, 67, 27, 340, 3474, 2672, 67, 1137, 378, 1622, 11566, 2066, 6426, 446, 51, 469, 16, 93, 446, 56, 1315, 24370, 1873, 1022, 82, 27, 340, 3474, 2672, 67, 508, 27750, 1622, 11566, 2066, 6426, 446, 51, 469, 16, 93, 446, 56, 2351, 354, 469, 16, 17063, 26687, 27, 587, 6426, 446, 51, 469, 16, 93, 446, 56, 2351, 354, 469, 16, 17063, 705, 27, 5883, 27, 4458, 27, 5883, 27, 3586, 1674, 908, 8, 5096, 63, 354, 9, 339, 2088, 275, 298, 5410, 446, 51, 469, 16, 93, 446, 68, 446, 44, 446, 77, 2672, 29085, 446, 67, 5041, 18, 12084, 469, 17, 6834, 3212, 267, 1275, 908, 8, 5096, 63, 354, 12, 2088, 12, 5218, 63, 1579, 9, 339, 15985, 275, 291, 14, 5510, 14, 362, 63, 5545, 1252, 1490, 63, 1730, 342, 272, 15985, 14, 1628, 63, 1531, 8, 1760, 9, 339, 870, 2088, 339, 372, 715, 819, 347, 3618, 63, 509, 63, 5410, 8, 277, 12, 6771, 63, 354, 12, 9435, 63, 5553, 29, 19, 304, 272, 408, 24996, 5133, 282, 6426, 6771, 365, 4829, 503, 5431, 548, 14, 339, 3033, 26, 489, 6771, 63, 354, 26, 2838, 370, 506, 10023, 367, 14, 489, 9435, 63, 5553, 26, 900, 370, 9435, 315, 13007, 5920, 14, 272, 1803, 26, 489, 1211, 469, 267, 18590, 548, 26, 2549, 15, 3910, 267, 9158, 26, 2549, 15, 3910, 267, 9266, 20878, 26, 1125, 1233, 489, 789, 624, 339, 754, 275, 469, 489, 298, 26687, 548, 582, 756, 12, 489, 298, 8669, 582, 756, 12, 489, 298, 281, 20878, 582, 756, 272, 789, 339, 327, 2747, 4618, 272, 9435, 8, 4532, 63, 5553, 9, 339, 1830, 715, 26, 489, 19708, 275, 756, 489, 367, 6771, 315, 291, 14, 513, 63, 5410, 63, 21234, 837, 267, 340, 6771, 508, 6771, 63, 354, 26, 881, 19708, 275, 715, 881, 2059, 398, 340, 6771, 508, 6771, 63, 354, 435, 3905, 26687, 582, 881, 327, 9616, 18590, 734, 881, 754, 905, 26687, 548, 937, 275, 715, 881, 372, 754 ]
[ 26162, 12, 18354, 12, 2050, 199, 646, 747, 12, 295, 199, 199, 504, 900, 492, 9435, 199, 199, 793, 275, 2050, 14, 5572, 480, 7001, 18, 531, 199, 199, 533, 12027, 8, 785, 304, 523, 408, 8673, 1893, 12027, 2236, 14183, 2452, 367, 14043, 3982, 13103, 1041, 819, 347, 636, 826, 721, 277, 12, 922, 12, 1591, 12, 2505, 29, 403, 12, 1844, 29, 1081, 304, 272, 408, 9345, 12027, 909, 14, 2541, 3033, 26, 267, 922, 26, 3434, 14, 267, 1591, 26, 6246, 402, 1950, 14, 267, 2505, 26, 922, 1159, 2505, 14, 982, 488, 12, 9009, 911, 506, 21652, 471, 367, 986, 14, 2116, 982, 314, 922, 365, 1808, 1790, 63, 1612, 12, 376, 2701, 1059, 911, 1736, 14, 267, 1844, 26, 1844, 402, 5724, 1159, 8635, 68, 14, 489, 6218, 26, 12027, 1726, 1041, 339, 291, 14, 751, 275, 922, 272, 291, 14, 1102, 275, 1591, 272, 291, 14, 5510, 275, 26162, 14, 13716, 3041, 342, 272, 291, 14, 5510, 14, 409, 63, 4752, 63, 1102, 63, 498, 63, 3185, 8, 635, 16625, 14, 3358, 1123, 4845, 1012, 339, 327, 1002, 2505, 687, 9009, 272, 340, 2505, 365, 488, 26, 489, 2505, 275, 18354, 14, 27481, 13076, 16, 6834, 83, 2505, 26, 3680, 908, 8, 751, 430, 339, 327, 9345, 1950, 272, 862, 26, 267, 291, 14, 5510, 14, 2242, 8, 1102, 12, 3434, 29, 751, 12, 2505, 29, 2060, 12, 1844, 29, 719, 9, 272, 871, 2186, 26, 267, 746, 26162, 14, 13716, 1726, 819, 347, 769, 63, 5410, 63, 21234, 8, 277, 304, 272, 408, 1767, 282, 769, 402, 1551, 6426, 18772, 1041, 339, 6771, 83, 275, 942, 272, 6771, 63, 264, 275, 295, 14, 2014, 8, 82, 3212, 83, 7896, 68, 11, 4537, 28149, 2862, 83, 11, 6697, 531, 272, 6771, 63, 478, 275, 291, 14, 1065, 480, 5410, 446, 478, 401, 11971, 29, 549, 26332, 548, 937, 272, 367, 6771, 315, 6771, 63, 478, 26, 267, 6771, 63, 1431, 275, 6771, 63, 264, 14, 1431, 8, 5096, 9, 267, 340, 6771, 63, 1431, 26, 881, 6771, 83, 14, 740, 8, 5096, 63, 1431, 14, 923, 8, 17, 430, 339, 372, 6771, 83, 819, 347, 1255, 63, 5410, 8, 277, 12, 2088, 12, 6771, 63, 354, 12, 2653, 29, 403, 304, 272, 408, 6713, 590, 5341, 282, 1414, 315, 282, 6426, 2351, 14, 982, 2653, 365, 13075, 12, 6426, 911, 506, 17864, 436, 16204, 1551, 14, 2541, 3033, 26, 267, 2088, 26, 1414, 1059, 370, 506, 7934, 14, 267, 6771, 63, 354, 26, 6426, 2351, 1159, 2838, 536, 14, 267, 2653, 26, 5696, 6451, 900, 1041, 339, 6771, 83, 275, 291, 14, 513, 63, 5410, 63, 21234, 342, 339, 327, 51, 766, 2575, 3495, 1, 272, 3495, 275, 1263, 779, 83, 14, 2460, 8, 5096, 63, 354, 9, 367, 308, 315, 6771, 83, 566, 272, 340, 3495, 26, 489, 372, 756, 339, 943, 14, 1757, 480, 18543, 316, 6426, 26, 469, 16, 93, 737, 469, 17, 5469, 908, 8, 5096, 63, 354, 12, 291, 14, 1102, 430, 339, 327, 51, 12531, 14930, 272, 2088, 275, 2088, 14, 1913, 4582, 84, 60, 78, 8700, 531, 272, 31648, 63, 1760, 275, 3087, 272, 367, 1004, 315, 2088, 14, 7644, 837, 489, 31648, 63, 1760, 847, 1004, 14, 1913, 342, 435, 28045, 339, 2088, 275, 31648, 63, 1760, 339, 327, 7084, 1553, 943, 314, 11465, 3769, 1255, 272, 359, 793, 14, 1757, 8, 67, 9, 367, 286, 315, 2088, 14, 1294, 480, 27, 11323, 339, 340, 2653, 26, 489, 18590, 63, 1760, 275, 3087, 489, 367, 1004, 315, 2088, 14, 1294, 480, 27, 2349, 267, 340, 822, 8, 604, 9, 690, 378, 26, 881, 18590, 63, 1760, 847, 298, 2593, 1553, 4653, 29, 25, 469, 16, 93, 469, 17, 12084, 3680, 908, 8, 2593, 12, 1004, 9, 489, 2088, 275, 18590, 63, 1760, 339, 327, 1123, 372, 1233, 8579, 370, 1924, 1414, 272, 2088, 275, 2088, 14, 1814, 480, 17259, 28036, 22030, 27, 6099, 339, 327, 15991, 314, 1414, 543, 282, 20387, 5558, 370, 11441, 436, 4215, 314, 6426, 2351, 1551, 272, 5218, 63, 1579, 275, 298, 346, 342, 3638, 286, 28617, 31, 27, 11343, 2672, 67, 27, 340, 3474, 2672, 67, 1137, 378, 1622, 11566, 2066, 6426, 446, 51, 469, 16, 93, 446, 56, 1315, 24370, 1873, 1022, 82, 27, 340, 3474, 2672, 67, 508, 27750, 1622, 11566, 2066, 6426, 446, 51, 469, 16, 93, 446, 56, 2351, 354, 469, 16, 17063, 26687, 27, 587, 6426, 446, 51, 469, 16, 93, 446, 56, 2351, 354, 469, 16, 17063, 705, 27, 5883, 27, 4458, 27, 5883, 27, 3586, 1674, 908, 8, 5096, 63, 354, 9, 339, 2088, 275, 298, 5410, 446, 51, 469, 16, 93, 446, 68, 446, 44, 446, 77, 2672, 29085, 446, 67, 5041, 18, 12084, 469, 17, 6834, 3212, 267, 1275, 908, 8, 5096, 63, 354, 12, 2088, 12, 5218, 63, 1579, 9, 339, 15985, 275, 291, 14, 5510, 14, 362, 63, 5545, 1252, 1490, 63, 1730, 342, 272, 15985, 14, 1628, 63, 1531, 8, 1760, 9, 339, 870, 2088, 339, 372, 715, 819, 347, 3618, 63, 509, 63, 5410, 8, 277, 12, 6771, 63, 354, 12, 9435, 63, 5553, 29, 19, 304, 272, 408, 24996, 5133, 282, 6426, 6771, 365, 4829, 503, 5431, 548, 14, 339, 3033, 26, 489, 6771, 63, 354, 26, 2838, 370, 506, 10023, 367, 14, 489, 9435, 63, 5553, 26, 900, 370, 9435, 315, 13007, 5920, 14, 272, 1803, 26, 489, 1211, 469, 267, 18590, 548, 26, 2549, 15, 3910, 267, 9158, 26, 2549, 15, 3910, 267, 9266, 20878, 26, 1125, 1233, 489, 789, 624, 339, 754, 275, 469, 489, 298, 26687, 548, 582, 756, 12, 489, 298, 8669, 582, 756, 12, 489, 298, 281, 20878, 582, 756, 272, 789, 339, 327, 2747, 4618, 272, 9435, 8, 4532, 63, 5553, 9, 339, 1830, 715, 26, 489, 19708, 275, 756, 489, 367, 6771, 315, 291, 14, 513, 63, 5410, 63, 21234, 837, 267, 340, 6771, 508, 6771, 63, 354, 26, 881, 19708, 275, 715, 881, 2059, 398, 340, 6771, 508, 6771, 63, 354, 435, 3905, 26687, 582, 881, 327, 9616, 18590, 734, 881, 754, 905, 26687, 548, 937, 275, 715, 881, 372, 754, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
marctc/django
tests/utils_tests/test_crypto.py
447
4581
from __future__ import unicode_literals import binascii import hashlib import unittest from django.utils.crypto import constant_time_compare, pbkdf2 class TestUtilsCryptoMisc(unittest.TestCase): def test_constant_time_compare(self): # It's hard to test for constant time, just test the result. self.assertTrue(constant_time_compare(b'spam', b'spam')) self.assertFalse(constant_time_compare(b'spam', b'eggs')) self.assertTrue(constant_time_compare('spam', 'spam')) self.assertFalse(constant_time_compare('spam', 'eggs')) class TestUtilsCryptoPBKDF2(unittest.TestCase): # http://tools.ietf.org/html/draft-josefsson-pbkdf2-test-vectors-06 rfc_vectors = [ { "args": { "password": "password", "salt": "salt", "iterations": 1, "dklen": 20, "digest": hashlib.sha1, }, "result": "0c60c80f961f0e71f3a9b524af6012062fe037a6", }, { "args": { "password": "password", "salt": "salt", "iterations": 2, "dklen": 20, "digest": hashlib.sha1, }, "result": "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957", }, { "args": { "password": "password", "salt": "salt", "iterations": 4096, "dklen": 20, "digest": hashlib.sha1, }, "result": "4b007901b765489abead49d926f721d065a429c1", }, # # this takes way too long :( # { # "args": { # "password": "password", # "salt": "salt", # "iterations": 16777216, # "dklen": 20, # "digest": hashlib.sha1, # }, # "result": "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984", # }, { "args": { "password": "passwordPASSWORDpassword", "salt": "saltSALTsaltSALTsaltSALTsaltSALTsalt", "iterations": 4096, "dklen": 25, "digest": hashlib.sha1, }, "result": "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038", }, { "args": { "password": "pass\0word", "salt": "sa\0lt", "iterations": 4096, "dklen": 16, "digest": hashlib.sha1, }, "result": "56fa6aa75548099dcc37d7f03425e0c3", }, ] regression_vectors = [ { "args": { "password": "password", "salt": "salt", "iterations": 1, "dklen": 20, "digest": hashlib.sha256, }, "result": "120fb6cffcf8b32c43e7225256c4f837a86548c9", }, { "args": { "password": "password", "salt": "salt", "iterations": 1, "dklen": 20, "digest": hashlib.sha512, }, "result": "867f70cf1ade02cff3752599a3a53dc4af34c7a6", }, { "args": { "password": "password", "salt": "salt", "iterations": 1000, "dklen": 0, "digest": hashlib.sha512, }, "result": ("afe6c5530785b6cc6b1c6453384731bd5ee432ee" "549fd42fb6695779ad8a1c5bf59de69c48f774ef" "c4007d5298f9033c0241d5ab69305e7b64eceeb8d" "834cfec"), }, # Check leading zeros are not stripped (#17481) { "args": { "password": b'\xba', "salt": "salt", "iterations": 1, "dklen": 20, "digest": hashlib.sha1, }, "result": '0053d3b91a7f1e54effebd6d68771e8a6e0b2c5b', }, ] def test_public_vectors(self): for vector in self.rfc_vectors: result = pbkdf2(**vector['args']) self.assertEqual(binascii.hexlify(result).decode('ascii'), vector['result']) def test_regression_vectors(self): for vector in self.regression_vectors: result = pbkdf2(**vector['args']) self.assertEqual(binascii.hexlify(result).decode('ascii'), vector['result'])
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 14755, 199, 646, 8337, 199, 646, 2882, 199, 199, 504, 1639, 14, 1208, 14, 10316, 492, 4413, 63, 521, 63, 5785, 12, 10446, 28996, 18, 421, 199, 533, 1379, 7535, 17134, 29926, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4083, 63, 521, 63, 5785, 8, 277, 304, 267, 327, 2779, 1159, 7508, 370, 511, 367, 4413, 900, 12, 2951, 511, 314, 754, 14, 267, 291, 14, 1815, 8, 4083, 63, 521, 63, 5785, 8, 66, 1159, 28024, 297, 330, 1159, 28024, 1333, 267, 291, 14, 3334, 8, 4083, 63, 521, 63, 5785, 8, 66, 1159, 28024, 297, 330, 7, 14488, 1333, 267, 291, 14, 1815, 8, 4083, 63, 521, 63, 5785, 360, 8283, 297, 283, 8283, 1333, 267, 291, 14, 3334, 8, 4083, 63, 521, 63, 5785, 360, 8283, 297, 283, 14488, 1333, 421, 199, 533, 1379, 7535, 17134, 13167, 43, 3888, 18, 8, 2796, 14, 1746, 304, 339, 327, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 7185, 13, 743, 261, 70, 385, 265, 13, 3317, 28996, 18, 13, 396, 13, 12280, 13, 1690, 272, 18158, 63, 12280, 275, 359, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 413, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 16, 67, 2259, 67, 1257, 70, 24031, 70, 16, 69, 3172, 70, 19, 65, 25, 66, 26419, 2756, 24539, 1165, 2789, 771, 18325, 65, 22, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 499, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 4489, 22, 67, 10752, 3833, 2819, 68, 22, 70, 24, 30013, 17, 379, 2942, 7984, 17, 68, 2953, 70, 16, 68, 24, 271, 1407, 1641, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 17125, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 20, 66, 31108, 614, 66, 2114, 1477, 1407, 7570, 350, 1887, 68, 27642, 70, 23, 2025, 68, 21254, 65, 14372, 67, 17, 401, 267, 1660, 267, 327, 327, 642, 6181, 4340, 4634, 1846, 520, 8, 267, 327, 469, 267, 327, 258, 298, 589, 582, 469, 267, 327, 260, 298, 2060, 582, 298, 2060, 401, 267, 327, 260, 298, 12597, 582, 298, 12597, 401, 267, 327, 260, 298, 13570, 582, 3193, 1138, 2819, 975, 12, 267, 327, 260, 298, 6341, 552, 582, 3388, 12, 267, 327, 260, 298, 5671, 582, 8337, 14, 4835, 17, 12, 267, 327, 258, 1660, 267, 327, 258, 298, 1099, 582, 298, 1024, 771, 19, 68, 2976, 2866, 20, 983, 20, 69, 20, 69, 1020, 2322, 66, 19, 68, 22, 2470, 7842, 24, 67, 1479, 1082, 69, 29703, 401, 267, 327, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 9032, 2060, 401, 355, 298, 12597, 582, 298, 12597, 51, 19600, 12597, 51, 19600, 12597, 51, 19600, 12597, 51, 19600, 12597, 401, 355, 298, 13570, 582, 17125, 12, 355, 298, 6341, 552, 582, 5661, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 19, 68, 18, 69, 825, 20, 771, 2953, 67, 14866, 66, 1257, 67, 24, 68, 2658, 19243, 67, 16, 69, 1602, 65, 24, 66, 16319, 65, 31124, 2177, 18, 70, 1780, 14273, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 1529, 60, 16, 1027, 401, 355, 298, 12597, 582, 298, 2231, 60, 16, 4116, 401, 355, 298, 13570, 582, 17125, 12, 355, 298, 6341, 552, 582, 3193, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 1367, 667, 22, 2158, 12315, 21853, 1020, 68, 2055, 1401, 68, 23, 70, 21756, 821, 69, 16, 67, 19, 401, 267, 1660, 272, 1622, 339, 10864, 63, 12280, 275, 359, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 413, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 3912, 12, 288, 1660, 288, 298, 1099, 582, 298, 6708, 4675, 22, 28667, 2177, 24, 66, 708, 67, 2824, 69, 2819, 821, 3912, 67, 20, 70, 24, 1401, 65, 1184, 17054, 67, 25, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 413, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 7736, 12, 288, 1660, 288, 298, 1099, 582, 298, 14927, 70, 2760, 2177, 17, 9587, 996, 28667, 9946, 821, 1020, 65, 19, 65, 2481, 3833, 20, 2756, 1082, 67, 23, 65, 22, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 5198, 12, 355, 298, 6341, 552, 582, 378, 12, 355, 298, 5671, 582, 8337, 14, 4835, 7736, 12, 288, 1660, 288, 298, 1099, 582, 1689, 6504, 22, 67, 1229, 1216, 19312, 66, 22, 2055, 22, 66, 17, 67, 13067, 1153, 15883, 2192, 3691, 21, 1024, 10657, 1024, 2, 2432, 298, 15419, 2592, 2260, 4675, 1272, 2720, 14580, 350, 24, 65, 17, 67, 21, 4361, 1427, 271, 1876, 67, 2006, 70, 15464, 2829, 2, 2432, 298, 67, 5303, 23, 68, 21, 12877, 70, 2710, 1153, 67, 996, 2953, 68, 21, 371, 1876, 11565, 69, 23, 66, 772, 69, 301, 2871, 24, 68, 2, 2432, 298, 31230, 67, 27848, 1288, 267, 1660, 267, 327, 2670, 9186, 10136, 787, 440, 14489, 15196, 1196, 24923, 9, 267, 469 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 14755, 199, 646, 8337, 199, 646, 2882, 199, 199, 504, 1639, 14, 1208, 14, 10316, 492, 4413, 63, 521, 63, 5785, 12, 10446, 28996, 18, 421, 199, 533, 1379, 7535, 17134, 29926, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4083, 63, 521, 63, 5785, 8, 277, 304, 267, 327, 2779, 1159, 7508, 370, 511, 367, 4413, 900, 12, 2951, 511, 314, 754, 14, 267, 291, 14, 1815, 8, 4083, 63, 521, 63, 5785, 8, 66, 1159, 28024, 297, 330, 1159, 28024, 1333, 267, 291, 14, 3334, 8, 4083, 63, 521, 63, 5785, 8, 66, 1159, 28024, 297, 330, 7, 14488, 1333, 267, 291, 14, 1815, 8, 4083, 63, 521, 63, 5785, 360, 8283, 297, 283, 8283, 1333, 267, 291, 14, 3334, 8, 4083, 63, 521, 63, 5785, 360, 8283, 297, 283, 14488, 1333, 421, 199, 533, 1379, 7535, 17134, 13167, 43, 3888, 18, 8, 2796, 14, 1746, 304, 339, 327, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 7185, 13, 743, 261, 70, 385, 265, 13, 3317, 28996, 18, 13, 396, 13, 12280, 13, 1690, 272, 18158, 63, 12280, 275, 359, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 413, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 16, 67, 2259, 67, 1257, 70, 24031, 70, 16, 69, 3172, 70, 19, 65, 25, 66, 26419, 2756, 24539, 1165, 2789, 771, 18325, 65, 22, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 499, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 4489, 22, 67, 10752, 3833, 2819, 68, 22, 70, 24, 30013, 17, 379, 2942, 7984, 17, 68, 2953, 70, 16, 68, 24, 271, 1407, 1641, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 17125, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 20, 66, 31108, 614, 66, 2114, 1477, 1407, 7570, 350, 1887, 68, 27642, 70, 23, 2025, 68, 21254, 65, 14372, 67, 17, 401, 267, 1660, 267, 327, 327, 642, 6181, 4340, 4634, 1846, 520, 8, 267, 327, 469, 267, 327, 258, 298, 589, 582, 469, 267, 327, 260, 298, 2060, 582, 298, 2060, 401, 267, 327, 260, 298, 12597, 582, 298, 12597, 401, 267, 327, 260, 298, 13570, 582, 3193, 1138, 2819, 975, 12, 267, 327, 260, 298, 6341, 552, 582, 3388, 12, 267, 327, 260, 298, 5671, 582, 8337, 14, 4835, 17, 12, 267, 327, 258, 1660, 267, 327, 258, 298, 1099, 582, 298, 1024, 771, 19, 68, 2976, 2866, 20, 983, 20, 69, 20, 69, 1020, 2322, 66, 19, 68, 22, 2470, 7842, 24, 67, 1479, 1082, 69, 29703, 401, 267, 327, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 9032, 2060, 401, 355, 298, 12597, 582, 298, 12597, 51, 19600, 12597, 51, 19600, 12597, 51, 19600, 12597, 51, 19600, 12597, 401, 355, 298, 13570, 582, 17125, 12, 355, 298, 6341, 552, 582, 5661, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 19, 68, 18, 69, 825, 20, 771, 2953, 67, 14866, 66, 1257, 67, 24, 68, 2658, 19243, 67, 16, 69, 1602, 65, 24, 66, 16319, 65, 31124, 2177, 18, 70, 1780, 14273, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 1529, 60, 16, 1027, 401, 355, 298, 12597, 582, 298, 2231, 60, 16, 4116, 401, 355, 298, 13570, 582, 17125, 12, 355, 298, 6341, 552, 582, 3193, 12, 355, 298, 5671, 582, 8337, 14, 4835, 17, 12, 288, 1660, 288, 298, 1099, 582, 298, 1367, 667, 22, 2158, 12315, 21853, 1020, 68, 2055, 1401, 68, 23, 70, 21756, 821, 69, 16, 67, 19, 401, 267, 1660, 272, 1622, 339, 10864, 63, 12280, 275, 359, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 413, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 3912, 12, 288, 1660, 288, 298, 1099, 582, 298, 6708, 4675, 22, 28667, 2177, 24, 66, 708, 67, 2824, 69, 2819, 821, 3912, 67, 20, 70, 24, 1401, 65, 1184, 17054, 67, 25, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 413, 12, 355, 298, 6341, 552, 582, 3388, 12, 355, 298, 5671, 582, 8337, 14, 4835, 7736, 12, 288, 1660, 288, 298, 1099, 582, 298, 14927, 70, 2760, 2177, 17, 9587, 996, 28667, 9946, 821, 1020, 65, 19, 65, 2481, 3833, 20, 2756, 1082, 67, 23, 65, 22, 401, 267, 1660, 267, 469, 288, 298, 589, 582, 469, 355, 298, 2060, 582, 298, 2060, 401, 355, 298, 12597, 582, 298, 12597, 401, 355, 298, 13570, 582, 5198, 12, 355, 298, 6341, 552, 582, 378, 12, 355, 298, 5671, 582, 8337, 14, 4835, 7736, 12, 288, 1660, 288, 298, 1099, 582, 1689, 6504, 22, 67, 1229, 1216, 19312, 66, 22, 2055, 22, 66, 17, 67, 13067, 1153, 15883, 2192, 3691, 21, 1024, 10657, 1024, 2, 2432, 298, 15419, 2592, 2260, 4675, 1272, 2720, 14580, 350, 24, 65, 17, 67, 21, 4361, 1427, 271, 1876, 67, 2006, 70, 15464, 2829, 2, 2432, 298, 67, 5303, 23, 68, 21, 12877, 70, 2710, 1153, 67, 996, 2953, 68, 21, 371, 1876, 11565, 69, 23, 66, 772, 69, 301, 2871, 24, 68, 2, 2432, 298, 31230, 67, 27848, 1288, 267, 1660, 267, 327, 2670, 9186, 10136, 787, 440, 14489, 15196, 1196, 24923, 9, 267, 469, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ChawalitK/odoo
doc/_extensions/odoo/switcher.py
262
1500
from docutils import nodes, utils from docutils.parsers.rst import Directive from pygments.lexers import get_lexer_by_name def setup(app): app.add_directive('switcher', SwitcherDirective) app.add_directive('case', CaseDirective) class SwitcherDirective(Directive): has_content = True def run(self): self.assert_has_content() body = nodes.compound('\n'.join(self.content), classes=['tabs']) self.state.nested_parse(self.content, self.content_offset, body) titles = [] for child in body.children: if isinstance(child, nodes.literal_block): titles.append(get_lexer_by_name(child['language']).name) else: assert child['names'], ("A switcher case must be either a "\ "code block or a compound with a name") titles.append(' '.join(child['names'])) tabs = nodes.bullet_list('', *[ nodes.list_item('', nodes.Text(title)) for title in titles ]) node = nodes.compound('', tabs, body, classes=['content-switcher']) return [node] class CaseDirective(Directive): required_arguments = 1 final_argument_whitespace = True has_content = True def run(self): self.assert_has_content() node = nodes.compound('\n'.join(self.content), names=[self.arguments[0]]) self.state.nested_parse(self.content, self.content_offset, node) return [node]
gpl-3.0
[ 504, 18382, 492, 3380, 12, 3778, 199, 504, 18382, 14, 11531, 14, 8332, 492, 3757, 8374, 199, 199, 504, 13277, 14, 12245, 492, 664, 63, 11729, 63, 991, 63, 354, 199, 199, 318, 3272, 8, 571, 304, 272, 1145, 14, 525, 63, 15047, 360, 5656, 281, 297, 17711, 281, 29489, 9, 272, 1145, 14, 525, 63, 15047, 360, 2546, 297, 12425, 29489, 9, 199, 199, 533, 17711, 281, 29489, 8, 29489, 304, 272, 965, 63, 1317, 275, 715, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 479, 63, 1989, 63, 1317, 342, 398, 2396, 275, 3380, 14, 15278, 2258, 78, 1370, 904, 8, 277, 14, 1317, 395, 3992, 2968, 8741, 1105, 267, 291, 14, 929, 14, 6376, 63, 1122, 8, 277, 14, 1317, 12, 291, 14, 1317, 63, 2743, 12, 2396, 9, 398, 16194, 275, 942, 267, 367, 1982, 315, 2396, 14, 3223, 26, 288, 340, 1228, 8, 1739, 12, 3380, 14, 8939, 63, 1457, 304, 355, 16194, 14, 740, 8, 362, 63, 11729, 63, 991, 63, 354, 8, 1739, 459, 3671, 13227, 354, 9, 288, 587, 26, 355, 702, 1982, 459, 1247, 995, 1689, 33, 6258, 281, 1930, 1471, 506, 1902, 282, 1867, 3147, 298, 600, 1853, 503, 282, 16487, 543, 282, 536, 531, 355, 16194, 14, 740, 360, 1987, 904, 8, 1739, 459, 1247, 5156, 267, 12187, 275, 3380, 14, 20520, 63, 513, 8594, 627, 59, 288, 3380, 14, 513, 63, 1053, 8594, 3380, 14, 1872, 8, 1213, 430, 288, 367, 2538, 315, 16194, 267, 4794, 267, 1031, 275, 3380, 14, 15278, 8594, 12187, 12, 2396, 12, 3992, 2968, 1317, 13, 5656, 281, 1105, 267, 372, 359, 932, 61, 199, 199, 533, 12425, 29489, 8, 29489, 304, 272, 1415, 63, 4958, 275, 413, 272, 4242, 63, 2094, 63, 8506, 275, 715, 272, 965, 63, 1317, 275, 715, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 479, 63, 1989, 63, 1317, 342, 398, 1031, 275, 3380, 14, 15278, 2258, 78, 1370, 904, 8, 277, 14, 1317, 395, 1561, 1524, 277, 14, 4958, 59, 16, 3934, 267, 291, 14, 929, 14, 6376, 63, 1122, 8, 277, 14, 1317, 12, 291, 14, 1317, 63, 2743, 12, 1031, 9, 267, 372, 359, 932, 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 ]
[ 18382, 492, 3380, 12, 3778, 199, 504, 18382, 14, 11531, 14, 8332, 492, 3757, 8374, 199, 199, 504, 13277, 14, 12245, 492, 664, 63, 11729, 63, 991, 63, 354, 199, 199, 318, 3272, 8, 571, 304, 272, 1145, 14, 525, 63, 15047, 360, 5656, 281, 297, 17711, 281, 29489, 9, 272, 1145, 14, 525, 63, 15047, 360, 2546, 297, 12425, 29489, 9, 199, 199, 533, 17711, 281, 29489, 8, 29489, 304, 272, 965, 63, 1317, 275, 715, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 479, 63, 1989, 63, 1317, 342, 398, 2396, 275, 3380, 14, 15278, 2258, 78, 1370, 904, 8, 277, 14, 1317, 395, 3992, 2968, 8741, 1105, 267, 291, 14, 929, 14, 6376, 63, 1122, 8, 277, 14, 1317, 12, 291, 14, 1317, 63, 2743, 12, 2396, 9, 398, 16194, 275, 942, 267, 367, 1982, 315, 2396, 14, 3223, 26, 288, 340, 1228, 8, 1739, 12, 3380, 14, 8939, 63, 1457, 304, 355, 16194, 14, 740, 8, 362, 63, 11729, 63, 991, 63, 354, 8, 1739, 459, 3671, 13227, 354, 9, 288, 587, 26, 355, 702, 1982, 459, 1247, 995, 1689, 33, 6258, 281, 1930, 1471, 506, 1902, 282, 1867, 3147, 298, 600, 1853, 503, 282, 16487, 543, 282, 536, 531, 355, 16194, 14, 740, 360, 1987, 904, 8, 1739, 459, 1247, 5156, 267, 12187, 275, 3380, 14, 20520, 63, 513, 8594, 627, 59, 288, 3380, 14, 513, 63, 1053, 8594, 3380, 14, 1872, 8, 1213, 430, 288, 367, 2538, 315, 16194, 267, 4794, 267, 1031, 275, 3380, 14, 15278, 8594, 12187, 12, 2396, 12, 3992, 2968, 1317, 13, 5656, 281, 1105, 267, 372, 359, 932, 61, 199, 199, 533, 12425, 29489, 8, 29489, 304, 272, 1415, 63, 4958, 275, 413, 272, 4242, 63, 2094, 63, 8506, 275, 715, 272, 965, 63, 1317, 275, 715, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 479, 63, 1989, 63, 1317, 342, 398, 1031, 275, 3380, 14, 15278, 2258, 78, 1370, 904, 8, 277, 14, 1317, 395, 1561, 1524, 277, 14, 4958, 59, 16, 3934, 267, 291, 14, 929, 14, 6376, 63, 1122, 8, 277, 14, 1317, 12, 291, 14, 1317, 63, 2743, 12, 1031, 9, 267, 372, 359, 932, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dsajkl/123
scripts/metrics/publish.py
69
1310
""" Publish Build Stats. """ import os import subprocess from dogapi import dog_http_api from coverage_metrics import CoverageMetrics class PublishStats(object): """ Publish stats to DataDog. """ def __init__(self, api_key): dog_http_api.api_key = api_key @staticmethod def report_metrics(metrics): """ Send metrics to DataDog. Arguments: metrics (dict): data to publish """ for key, value in metrics.iteritems(): print u"Sending {} ==> {}%".format(key, value) dog_http_api.metric(key, value) def main(api_key): """ Send Stats for everything to DataDog. """ dir_path = os.path.dirname(os.path.relpath(__file__)) unit_reports_cmd = ['find', 'reports', '-name', '"coverage.xml"'] unit_report_paths = subprocess.check_output(unit_reports_cmd) cov_metrics = CoverageMetrics(os.path.join(dir_path, 'unit_test_groups.json'), unit_report_paths) coverage_metrics = cov_metrics.coverage_metrics() # Publish Coverage Stats to DataDog PublishStats(api_key).report_metrics(coverage_metrics) if __name__ == "__main__": API_KEY = os.environ.get('DATADOG_API_KEY') if API_KEY: main(API_KEY) else: print 'SKIP: Publish Stats to Datadog'
agpl-3.0
[ 624, 199, 13956, 6516, 29062, 14, 199, 624, 199, 199, 646, 747, 199, 646, 3873, 199, 504, 23454, 1246, 492, 23454, 63, 1014, 63, 1246, 199, 504, 11745, 63, 6759, 492, 1849, 3652, 17213, 421, 199, 533, 19952, 8257, 8, 785, 304, 272, 408, 272, 19952, 5020, 370, 3918, 36, 974, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2986, 63, 498, 304, 267, 23454, 63, 1014, 63, 1246, 14, 1246, 63, 498, 275, 2986, 63, 498, 339, 768, 4639, 272, 347, 3622, 63, 6759, 8, 6759, 304, 267, 408, 267, 10217, 7186, 370, 3918, 36, 974, 14, 398, 7628, 26, 288, 7186, 334, 807, 304, 666, 370, 2780, 398, 408, 267, 367, 790, 12, 574, 315, 7186, 14, 4611, 837, 288, 870, 399, 2, 27219, 1052, 25375, 1052, 5, 1674, 908, 8, 498, 12, 574, 9, 288, 23454, 63, 1014, 63, 1246, 14, 5165, 8, 498, 12, 574, 9, 421, 199, 318, 2446, 8, 1246, 63, 498, 304, 272, 408, 272, 10217, 29062, 367, 8137, 370, 3918, 36, 974, 14, 272, 408, 272, 2935, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 12405, 3460, 493, 8964, 339, 4137, 63, 15629, 63, 1760, 275, 788, 1623, 297, 283, 15629, 297, 2475, 354, 297, 5522, 10828, 14, 1652, 2, 418, 272, 4137, 63, 3070, 63, 3771, 275, 3873, 14, 1074, 63, 1199, 8, 3248, 63, 15629, 63, 1760, 9, 339, 13786, 63, 6759, 275, 1849, 3652, 17213, 8, 736, 14, 515, 14, 904, 8, 694, 63, 515, 12, 283, 3248, 63, 396, 63, 2634, 14, 1001, 659, 4137, 63, 3070, 63, 3771, 9, 272, 11745, 63, 6759, 275, 13786, 63, 6759, 14, 10828, 63, 6759, 342, 339, 327, 19952, 1849, 3652, 29062, 370, 3918, 36, 974, 272, 19952, 8257, 8, 1246, 63, 498, 680, 3070, 63, 6759, 8, 10828, 63, 6759, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 3261, 63, 3078, 275, 747, 14, 2314, 14, 362, 360, 6521, 1554, 14008, 63, 3735, 63, 3078, 358, 272, 340, 3261, 63, 3078, 26, 267, 2446, 8, 3735, 63, 3078, 9, 272, 587, 26, 267, 870, 283, 13525, 26, 19952, 29062, 370, 577, 292, 30821, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 13956, 6516, 29062, 14, 199, 624, 199, 199, 646, 747, 199, 646, 3873, 199, 504, 23454, 1246, 492, 23454, 63, 1014, 63, 1246, 199, 504, 11745, 63, 6759, 492, 1849, 3652, 17213, 421, 199, 533, 19952, 8257, 8, 785, 304, 272, 408, 272, 19952, 5020, 370, 3918, 36, 974, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2986, 63, 498, 304, 267, 23454, 63, 1014, 63, 1246, 14, 1246, 63, 498, 275, 2986, 63, 498, 339, 768, 4639, 272, 347, 3622, 63, 6759, 8, 6759, 304, 267, 408, 267, 10217, 7186, 370, 3918, 36, 974, 14, 398, 7628, 26, 288, 7186, 334, 807, 304, 666, 370, 2780, 398, 408, 267, 367, 790, 12, 574, 315, 7186, 14, 4611, 837, 288, 870, 399, 2, 27219, 1052, 25375, 1052, 5, 1674, 908, 8, 498, 12, 574, 9, 288, 23454, 63, 1014, 63, 1246, 14, 5165, 8, 498, 12, 574, 9, 421, 199, 318, 2446, 8, 1246, 63, 498, 304, 272, 408, 272, 10217, 29062, 367, 8137, 370, 3918, 36, 974, 14, 272, 408, 272, 2935, 63, 515, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 12405, 3460, 493, 8964, 339, 4137, 63, 15629, 63, 1760, 275, 788, 1623, 297, 283, 15629, 297, 2475, 354, 297, 5522, 10828, 14, 1652, 2, 418, 272, 4137, 63, 3070, 63, 3771, 275, 3873, 14, 1074, 63, 1199, 8, 3248, 63, 15629, 63, 1760, 9, 339, 13786, 63, 6759, 275, 1849, 3652, 17213, 8, 736, 14, 515, 14, 904, 8, 694, 63, 515, 12, 283, 3248, 63, 396, 63, 2634, 14, 1001, 659, 4137, 63, 3070, 63, 3771, 9, 272, 11745, 63, 6759, 275, 13786, 63, 6759, 14, 10828, 63, 6759, 342, 339, 327, 19952, 1849, 3652, 29062, 370, 3918, 36, 974, 272, 19952, 8257, 8, 1246, 63, 498, 680, 3070, 63, 6759, 8, 10828, 63, 6759, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 3261, 63, 3078, 275, 747, 14, 2314, 14, 362, 360, 6521, 1554, 14008, 63, 3735, 63, 3078, 358, 272, 340, 3261, 63, 3078, 26, 267, 2446, 8, 3735, 63, 3078, 9, 272, 587, 26, 267, 870, 283, 13525, 26, 19952, 29062, 370, 577, 292, 30821, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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